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

1
src/STEPConstruct/EXTERNLIB Executable file
View File

@@ -0,0 +1 @@
CSF_wsock32

1
src/STEPConstruct/FILES Executable file
View File

@@ -0,0 +1 @@
EXTERNLIB

View File

@@ -0,0 +1,103 @@
-- File: STEPConstruct.cdl
-- Created: Wed Nov 17 14:13:03 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
package STEPConstruct
---Purpose: Defines tools for creation and investigation STEP constructs
-- used for representing various kinds of data, such as product and
-- assembly structure, unit contexts, associated information
-- The creation of these structures is made according to currently
-- active schema (AP203 or AP214 CD2 or DIS)
-- This is taken from parameter write.step.schema
uses
gp,
Quantity,
TCollection,
TColStd,
TopTools,
TopLoc,
TopoDS,
Interface,
Transfer,
XSControl,
StepData,
StepBasic,
StepGeom,
StepRepr,
StepShape,
StepVisual,
StepAP203,
StepAP214
is
class Tool;
---Purpose: Basic class providing general features
class UnitContext;
---Purpose: Create and investigate context of units and uncertanties
class Part;
---Purpose: Create and investigate data associated with parts (product etc.)
class Assembly;
---Purpose: Create and check assembly data structures
class Styles;
---Purpose: Create and investigate STEP constructs for styles (mostly colors)
class ValidationProps;
---Purpose: Create and investigate STEP constructs for validation properties
class ExternRefs;
---Purpose: Work with references to external documents
class AP203Context;
---Purpose: maintains context specific to AP203
class ContextTool;
---Purpose: Maintains global context tool for writing
--- skl 15.01.2004
class DataMapOfAsciiStringTransient instantiates
DataMap from TCollection (AsciiString from TCollection,
Transient from Standard,
AsciiString from TCollection);
class PointHasher;
class DataMapOfPointTransient instantiates
DataMap from TCollection (Pnt from gp,
Transient,
PointHasher from STEPConstruct);
FindEntity (FinderProcess: FinderProcess from Transfer; Shape: Shape from TopoDS)
returns RepresentationItem from StepRepr;
---Purpose: Returns STEP entity of the (sub)type of RepresentationItem
-- which is a result of the tranalation of the Shape, or Null if
-- no result is recorded
FindEntity (FinderProcess: FinderProcess from Transfer; Shape: Shape from TopoDS;
Loc: out Location from TopLoc)
returns RepresentationItem from StepRepr;
---Purpose: The same as above, but in the case if item not found, repeats
-- search on the same shape without location. The Loc corresponds to the
-- location with which result is found (either location of the Shape,
-- or Null)
FindShape (TransientProcess: TransientProcess from Transfer; item: RepresentationItem from StepRepr)
returns Shape from TopoDS;
---Purpose: Returns Shape resulting from given STEP entity (Null if not mapped)
FindCDSR (ComponentBinder: Binder from Transfer;
AssemblySDR: ShapeDefinitionRepresentation from StepShape;
ComponentCDSR: out ContextDependentShapeRepresentation from StepShape)
returns Boolean from Standard;
---Purpose: Find CDSR correcponding to the component in the specified assembly
end STEPConstruct;

View File

@@ -0,0 +1,137 @@
// File: STEPConstruct.cxx
// Created: Tue Jan 11 09:37:57 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <STEPConstruct.ixx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <StepBasic_ProductDefinition.hxx>
#include <StepBasic_ProductDefinitionRelationship.hxx>
#include <StepRepr_PropertyDefinition.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#ifdef DEBUG
void DumpBinder (const Handle(Transfer_Binder) &binder)
{
Handle(Transfer_Binder) bbb = binder;
while ( ! bbb.IsNull() ) {
Handle(Transfer_SimpleBinderOfTransient) bx =
Handle(Transfer_SimpleBinderOfTransient)::DownCast ( bbb );
if ( ! bx.IsNull() ) {
cout << "--> " << bx->ResultTypeName() << " " << *(void**)&bx->Result() << endl;
}
else cout << "--> ???" << endl;
bbb = bbb->NextResult();
}
cout << endl;
}
#endif
//=======================================================================
//function : FindEntity
//purpose :
//=======================================================================
Handle(StepRepr_RepresentationItem) STEPConstruct::FindEntity (const Handle(Transfer_FinderProcess) &FinderProcess,
const TopoDS_Shape &Shape)
{
Handle(StepRepr_RepresentationItem) item;
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess, Shape );
FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item);
#ifdef DEB
if ( item.IsNull() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem not found" << endl;
else cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found: " << item->DynamicType()->Name() << endl;
#endif
return item;
}
//=======================================================================
//function : FindEntity
//purpose :
//=======================================================================
Handle(StepRepr_RepresentationItem) STEPConstruct::FindEntity (const Handle(Transfer_FinderProcess) &FinderProcess,
const TopoDS_Shape &Shape,
TopLoc_Location &Loc)
{
Handle(StepRepr_RepresentationItem) item;
Loc = Shape.Location();
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess, Shape );
if ( ! FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item) &&
! Loc.IsIdentity() ) {
Loc.Identity();
TopoDS_Shape S = Shape;
S.Location (Loc);
mapper = TransferBRep::ShapeMapper ( FinderProcess, S );
FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item);
}
#ifdef DEB
if ( item.IsNull() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem not found" << endl;
else if ( Loc != Shape.Location() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found for shape without location: " << item->DynamicType()->Name() << endl;
else cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found: " << item->DynamicType()->Name() << endl;
#endif
return item;
}
//=======================================================================
//function : FindShape
//purpose :
//=======================================================================
TopoDS_Shape STEPConstruct::FindShape (const Handle(Transfer_TransientProcess) &TransientProcess,
const Handle(StepRepr_RepresentationItem) &item)
{
TopoDS_Shape S;
Handle(Transfer_Binder) binder = TransientProcess->Find(item);
if ( ! binder.IsNull() && binder->HasResult() ) {
S = TransferBRep::ShapeResult ( TransientProcess, binder );
}
return S;
}
//=======================================================================
//function : FindCDSR
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct::FindCDSR
(const Handle(Transfer_Binder)& ComponentBinder,
const Handle(StepShape_ShapeDefinitionRepresentation)& AssemblySDR,
Handle(StepShape_ContextDependentShapeRepresentation)& ComponentCDSR)
{
Standard_Boolean result = Standard_False;
Handle(StepRepr_PropertyDefinition) PropD = AssemblySDR->Definition().PropertyDefinition();
if (!PropD.IsNull()) {
Handle(StepBasic_ProductDefinition) AssemblyPD = PropD->Definition().ProductDefinition();
if (!AssemblyPD.IsNull()) {
Handle(Transfer_Binder) binder = ComponentBinder;
Handle(Transfer_SimpleBinderOfTransient) trb;
Handle(StepRepr_ProductDefinitionShape) PDS;
Handle(StepBasic_ProductDefinitionRelationship) NAUO;
Handle(StepBasic_ProductDefinition) ComponentPD;
while (!binder.IsNull() && !result) {
trb = Handle(Transfer_SimpleBinderOfTransient)::DownCast(binder);
if (!trb.IsNull()) {
ComponentCDSR = Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(trb->Result());
if (!ComponentCDSR.IsNull()) {
PDS = ComponentCDSR->RepresentedProductRelation();
if (!PDS.IsNull()) {
NAUO = PDS->Definition().ProductDefinitionRelationship();
if (!NAUO.IsNull()) {
ComponentPD = NAUO->RelatingProductDefinition();
result = (ComponentPD == AssemblyPD);
}
}
}
}
binder = binder->NextResult();
}
}
}
return result;
}

View File

@@ -0,0 +1,180 @@
-- File: STEPConstruct_AP203Context.cdl
-- Created: Thu Nov 18 19:46:52 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class AP203Context from STEPConstruct
---Purpose: Maintains context specific for AP203 (required data and
-- management information such as persons, dates, approvals etc.)
-- It contains static entities (which can be shared), default
-- values for person and organisation, and also provides
-- tool for creating management entities around specific part (SDR).
uses
Approval from StepBasic,
DateAndTime from StepBasic,
PersonAndOrganization from StepBasic,
SecurityClassificationLevel from StepBasic,
PersonAndOrganizationRole from StepBasic,
DateTimeRole from StepBasic,
ApprovalRole from StepBasic,
CcDesignPersonAndOrganizationAssignment from StepAP203,
CcDesignSecurityClassification from StepAP203,
CcDesignDateAndTimeAssignment from StepAP203,
CcDesignApproval from StepAP203,
ApprovalPersonOrganization from StepBasic,
ApprovalDateTime from StepBasic,
ShapeDefinitionRepresentation from StepShape,
NextAssemblyUsageOccurrence from StepRepr,
ProductCategoryRelationship from StepBasic,
Part from STEPConstruct
is
Create returns AP203Context from STEPConstruct;
---Purpose: Creates tool and fills constant fields
--- Entities shared by others by default
DefaultApproval (me: in out) returns Approval from StepBasic;
---Purpose: Returns default approval entity which
-- is used when no other data are available
SetDefaultApproval (me: in out; app: Approval from StepBasic);
---Purpose: Sets default approval
DefaultDateAndTime (me: in out) returns DateAndTime from StepBasic;
---Purpose: Returns default date_and_time entity which
-- is used when no other data are available
SetDefaultDateAndTime (me: in out; dt: DateAndTime from StepBasic);
---Purpose: Sets default date_and_time entity
DefaultPersonAndOrganization (me: in out) returns PersonAndOrganization from StepBasic;
---Purpose: Returns default person_and_organization entity which
-- is used when no other data are available
SetDefaultPersonAndOrganization (me: in out; po: PersonAndOrganization from StepBasic);
---Purpose: Sets default person_and_organization entity
DefaultSecurityClassificationLevel (me: in out) returns SecurityClassificationLevel from StepBasic;
---Purpose: Returns default security_classification_level entity which
-- is used when no other data are available
SetDefaultSecurityClassificationLevel (me: in out; sc: SecurityClassificationLevel from StepBasic);
---Purpose: Sets default security_classification_level
RoleCreator (me) returns PersonAndOrganizationRole from StepBasic;
RoleDesignOwner (me) returns PersonAndOrganizationRole from StepBasic;
RoleDesignSupplier (me) returns PersonAndOrganizationRole from StepBasic;
RoleClassificationOfficer (me) returns PersonAndOrganizationRole from StepBasic;
RoleCreationDate (me) returns DateTimeRole from StepBasic;
RoleClassificationDate (me) returns DateTimeRole from StepBasic;
RoleApprover (me) returns ApprovalRole from StepBasic;
---Purpose: Return predefined PersonAndOrganizationRole and DateTimeRole
-- entities named 'creator', 'design owner', 'design supplier',
-- 'classification officer', 'creation date', 'classification date',
-- 'approver'
--- Entities instantiated for each part
Init (me: in out; sdr: ShapeDefinitionRepresentation from StepShape);
---Purpose: Takes SDR (part) which brings all standard data around part
-- (common for AP203 and AP214) and creates all the additional
-- entities required for AP203
Init (me: in out; SDRTool: Part from STEPConstruct);
---Purpose: Takes tool which describes standard data around part
-- (common for AP203 and AP214) and creates all the additional
-- entities required for AP203
--
-- The created entities can be obtained by calls to methods
-- GetCreator(), GetDesignOwner(), GetDesignSupplier(),
-- GetClassificationOfficer(), GetSecurity(), GetCreationDate(),
-- GetClassificationDate(), GetApproval(),
-- GetApprover(), GetApprovalDateTime(),
-- GetProductCategoryRelationship()
Init (me: in out; nauo: NextAssemblyUsageOccurrence from StepRepr);
---Purpose: Takes NAUO which describes assembly link to component
-- and creates the security_classification entity associated to
-- it as required by the AP203
--
-- Instantiated (or existing previously) entities concerned
-- can be obtained by calls to methods
-- GetClassificationOfficer(), GetSecurity(),
-- GetClassificationDate(), GetApproval(),
-- GetApprover(), GetApprovalDateTime()
-- Init (me: in out; SDRTool: Part from STEPConstruct;
-- Model: InterfaceModel from Interface);
---Purpose: Takes tool which describes standard data around part
-- (common for AP203 and AP214) and takes from model (or creates
-- if missing) all the additional entities required by AP203
GetCreator (me) returns CcDesignPersonAndOrganizationAssignment from StepAP203;
GetDesignOwner (me) returns CcDesignPersonAndOrganizationAssignment from StepAP203;
GetDesignSupplier (me) returns CcDesignPersonAndOrganizationAssignment from StepAP203;
GetClassificationOfficer (me) returns CcDesignPersonAndOrganizationAssignment from StepAP203;
GetSecurity (me) returns CcDesignSecurityClassification from StepAP203;
GetCreationDate (me) returns CcDesignDateAndTimeAssignment from StepAP203;
GetClassificationDate (me) returns CcDesignDateAndTimeAssignment from StepAP203;
GetApproval (me) returns CcDesignApproval from StepAP203;
GetApprover (me) returns ApprovalPersonOrganization from StepBasic;
GetApprovalDateTime (me) returns ApprovalDateTime from StepBasic;
GetProductCategoryRelationship (me) returns ProductCategoryRelationship from StepBasic;
---Purpose: Return entities (roots) instantiated for the part by method Init
--- Advanced (rather internal) methods
Clear (me: in out);
---Purpose: Clears all fields describing entities specific to each part
InitRoles (me: in out);
---Purpose: Initializes constant fields (shared entities)
InitPart (me: in out; SDRTool: Part from STEPConstruct) is private;
---Purpose: Initializes all missing data which are required for part
InitAssembly (me: in out; nauo: NextAssemblyUsageOccurrence from StepRepr);
---Purpose: Initializes all missing data which are required for assembly
InitSecurityRequisites (me: in out);
---Purpose: Initializes ClassificationOfficer and ClassificationDate
-- entities according to Security entity
InitApprovalRequisites (me: in out);
---Purpose: Initializes Approver and ApprovalDateTime
-- entities according to Approval entity
fields
-- default values (to be replaced by some meaningful externally)
defApproval : Approval from StepBasic;
defDateAndTime : DateAndTime from StepBasic;
defPersonAndOrganization : PersonAndOrganization from StepBasic;
defSecurityClassificationLevel: SecurityClassificationLevel from StepBasic;
-- predefined roles
roleCreator : PersonAndOrganizationRole from StepBasic;
roleDesignOwner : PersonAndOrganizationRole from StepBasic;
roleDesignSupplier : PersonAndOrganizationRole from StepBasic;
roleClassificationOfficer: PersonAndOrganizationRole from StepBasic;
roleCreationDate : DateTimeRole from StepBasic;
roleClassificationDate : DateTimeRole from StepBasic;
roleApprover : ApprovalRole from StepBasic;
-- entities created for each part (roots)
myCreator : CcDesignPersonAndOrganizationAssignment from StepAP203;
myDesignOwner : CcDesignPersonAndOrganizationAssignment from StepAP203;
myDesignSupplier : CcDesignPersonAndOrganizationAssignment from StepAP203;
myClassificationOfficer : CcDesignPersonAndOrganizationAssignment from StepAP203;
mySecurity : CcDesignSecurityClassification from StepAP203;
myCreationDate : CcDesignDateAndTimeAssignment from StepAP203;
myClassificationDate : CcDesignDateAndTimeAssignment from StepAP203;
myApproval : CcDesignApproval from StepAP203;
myApprover : ApprovalPersonOrganization from StepBasic;
myApprovalDateTime : ApprovalDateTime from StepBasic;
myProductCategoryRelationship: ProductCategoryRelationship from StepBasic;
end AP203Context;

View File

@@ -0,0 +1,674 @@
// File: STEPConstruct_AP203Context.cxx
// Created: Fri Nov 19 11:13:38 1999
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <STEPConstruct_AP203Context.ixx>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef WNT
# include <winsock2.h>
#endif
#if defined(HAVE_TIME_H) || defined(WNT)
# include <time.h>
#endif
#include <stdio.h>
#include <OSD_Process.hxx>
#include <Quantity_Date.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Interface_HArray1OfHAsciiString.hxx>
#include <StepBasic_CalendarDate.hxx>
#include <StepBasic_LocalTime.hxx>
#include <StepBasic_ApprovalStatus.hxx>
#include <StepBasic_CoordinatedUniversalTimeOffset.hxx>
#include <StepBasic_AheadOrBehind.hxx>
#include <StepBasic_Person.hxx>
#include <StepBasic_Organization.hxx>
#include <StepBasic_SecurityClassification.hxx>
#include <StepAP203_HArray1OfPersonOrganizationItem.hxx>
#include <StepAP203_HArray1OfClassifiedItem.hxx>
#include <StepAP203_HArray1OfDateTimeItem.hxx>
#include <StepAP203_HArray1OfApprovedItem.hxx>
#include <StepBasic_ProductCategory.hxx>
//=======================================================================
//function : STEPConstruct_AP203Context
//purpose :
//=======================================================================
STEPConstruct_AP203Context::STEPConstruct_AP203Context ()
{
InitRoles();
}
//=======================================================================
//function : DefaultApproval
//purpose :
//=======================================================================
Handle(StepBasic_Approval) STEPConstruct_AP203Context::DefaultApproval ()
{
if ( defApproval.IsNull() ) {
Handle(StepBasic_ApprovalStatus) aStatus = new StepBasic_ApprovalStatus;
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ("not_yet_approved");
aStatus->Init ( aName );
Handle(TCollection_HAsciiString) aLevel = new TCollection_HAsciiString ("");
defApproval = new StepBasic_Approval;
defApproval->Init ( aStatus, aLevel );
}
return defApproval;
}
//=======================================================================
//function : SetDefaultApproval
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::SetDefaultApproval (const Handle(StepBasic_Approval) &app)
{
defApproval = app;
}
//=======================================================================
//function : DefaultDateAndTime
//purpose :
//=======================================================================
Handle(StepBasic_DateAndTime) STEPConstruct_AP203Context::DefaultDateAndTime ()
{
if ( defDateAndTime.IsNull() ) {
OSD_Process sys;
Quantity_Date date = sys.SystemDate ();
Handle(StepBasic_CalendarDate) aDate = new StepBasic_CalendarDate;
aDate->Init ( date.Year(), date.Day(), date.Month() );
Handle(StepBasic_CoordinatedUniversalTimeOffset) zone =
new StepBasic_CoordinatedUniversalTimeOffset;
Standard_Integer shift = Standard_Integer(timezone);
Standard_Integer shifth = abs ( shift ) / 3600;
Standard_Integer shiftm = ( abs ( shift ) - shifth * 3600 ) / 60;
StepBasic_AheadOrBehind sense = ( shift >0 ? StepBasic_aobBehind :
shift <0 ? StepBasic_aobAhead :
StepBasic_aobExact );
zone->Init ( shifth, ( shiftm != 0 ), shiftm, sense );
Handle(StepBasic_LocalTime) aTime = new StepBasic_LocalTime;
aTime->Init ( date.Hour(), Standard_True, date.Minute(), Standard_False, 0., zone );
defDateAndTime = new StepBasic_DateAndTime;
defDateAndTime->Init ( aDate, aTime );
}
return defDateAndTime;
}
//=======================================================================
//function : SetDefaultDateAndTime
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::SetDefaultDateAndTime (const Handle(StepBasic_DateAndTime) &dt)
{
defDateAndTime = dt;
}
//=======================================================================
//function : DefaultPersonAndOrganization
//purpose :
//=======================================================================
Handle(StepBasic_PersonAndOrganization) STEPConstruct_AP203Context::DefaultPersonAndOrganization ()
{
if ( defPersonAndOrganization.IsNull() ) {
// get IP address as a unique id of organization
#ifdef WNT // adapted for NT which lacks gethostent()
char hostname[1024];
hostname[0] = '\0';
gethostname ( hostname, 1020 );
hostname[1020] = '\0';
struct hostent *he = gethostbyname ( hostname );
#else // adapted for Sun2.5, which lacks definition of gethostname()
struct hostent *he = gethostent();
while ( he && he->h_name && (unsigned char)he->h_addr_list[0][0] == 127 )
he = gethostent();
#endif
Handle(TCollection_HAsciiString) orgId = new TCollection_HAsciiString ( "" );
if ( he && he->h_addr_list && he->h_length >0 ) {
char str[100];
unsigned i1 = (unsigned char)he->h_addr_list[0][0];
unsigned i2 = (unsigned char)he->h_addr_list[0][1];
unsigned i3 = (unsigned char)he->h_addr_list[0][2];
sprintf ( str, "IP%03u.%03u.%03u.000", i1, i2, i3 );
orgId->AssignCat ( str );
}
// create organization
Handle(StepBasic_Organization) aOrg = new StepBasic_Organization;
Handle(TCollection_HAsciiString) oName = new TCollection_HAsciiString ( "Unspecified" );
Handle(TCollection_HAsciiString) oDescr = new TCollection_HAsciiString ( "" );
aOrg->Init ( Standard_True, orgId, oName, oDescr );
// construct person`s name
OSD_Process sys;
Standard_CString usr = sys.UserName().ToCString();
#ifndef WNT
if ( usr ) {
struct passwd *pwd = getpwnam ( usr );
if ( pwd ) usr = pwd->pw_gecos;
}
else usr = "Unknown";
#endif
TCollection_AsciiString user ( usr );
Handle(TCollection_HAsciiString) fname = new TCollection_HAsciiString ("");
Handle(TCollection_HAsciiString) lname = new TCollection_HAsciiString ("");
Handle(Interface_HArray1OfHAsciiString) mname;
TColStd_SequenceOfAsciiString names;
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for ( i=1; ; i++ ) {
TCollection_AsciiString token = user.Token ( " \t", i );
if ( ! token.Length() ) break;
names.Append ( token );
}
if ( names.Length() >0 ) fname->AssignCat ( names.Value(1).ToCString() );
if ( names.Length() >1 ) lname->AssignCat ( names.Value(names.Length()).ToCString() );
if ( names.Length() >2 ) {
mname = new Interface_HArray1OfHAsciiString ( 1, names.Length()-2 );
for ( i=2; i < names.Length(); i++ )
mname->SetValue ( i-1, new TCollection_HAsciiString ( names.Value(i) ) );
}
// create a person
Handle(StepBasic_Person) aPerson = new StepBasic_Person;
Handle(TCollection_HAsciiString) uid = new TCollection_HAsciiString ( orgId );
uid->AssignCat ( "," );
uid->AssignCat ( TCollection_AsciiString ( sys.UserId() ).ToCString() );
Handle(Interface_HArray1OfHAsciiString) suffix, prefix;
aPerson->Init ( uid, Standard_True, lname, Standard_True, fname, ( ! mname.IsNull() ),
mname, Standard_False, suffix, Standard_False, prefix );
defPersonAndOrganization = new StepBasic_PersonAndOrganization;
defPersonAndOrganization->Init ( aPerson, aOrg );
}
return defPersonAndOrganization;
}
//=======================================================================
//function : SetDefaultPersonAndOrganization
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::SetDefaultPersonAndOrganization (const Handle(StepBasic_PersonAndOrganization) &po)
{
defPersonAndOrganization = po;
}
//=======================================================================
//function : DefaultSecurityClassificationLevel
//purpose :
//=======================================================================
Handle(StepBasic_SecurityClassificationLevel) STEPConstruct_AP203Context::DefaultSecurityClassificationLevel ()
{
if ( defSecurityClassificationLevel.IsNull() ) {
defSecurityClassificationLevel = new StepBasic_SecurityClassificationLevel;
Handle(TCollection_HAsciiString) levName = new TCollection_HAsciiString ( "unclassified" );
defSecurityClassificationLevel->Init ( levName );
}
return defSecurityClassificationLevel;
}
//=======================================================================
//function : SetDefaultSecurityClassificationLevel
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::SetDefaultSecurityClassificationLevel (const Handle(StepBasic_SecurityClassificationLevel) &scl)
{
defSecurityClassificationLevel = scl;
}
//=======================================================================
//function : RoleCreator
//purpose :
//=======================================================================
Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleCreator () const
{
return roleCreator;
}
//=======================================================================
//function : RoleDesignOwner
//purpose :
//=======================================================================
Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleDesignOwner () const
{
return roleDesignOwner;
}
//=======================================================================
//function : RoleDesignSupplier
//purpose :
//=======================================================================
Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleDesignSupplier () const
{
return roleDesignSupplier;
}
//=======================================================================
//function : RoleClassificationOfficer
//purpose :
//=======================================================================
Handle(StepBasic_PersonAndOrganizationRole) STEPConstruct_AP203Context::RoleClassificationOfficer () const
{
return roleClassificationOfficer;
}
//=======================================================================
//function : RoleCreationDate
//purpose :
//=======================================================================
Handle(StepBasic_DateTimeRole) STEPConstruct_AP203Context::RoleCreationDate () const
{
return roleCreationDate;
}
//=======================================================================
//function : RoleClassificationDate
//purpose :
//=======================================================================
Handle(StepBasic_DateTimeRole) STEPConstruct_AP203Context::RoleClassificationDate () const
{
return roleClassificationDate;
}
//=======================================================================
//function : RoleApprover
//purpose :
//=======================================================================
Handle(StepBasic_ApprovalRole) STEPConstruct_AP203Context::RoleApprover () const
{
return roleApprover;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::Init (const Handle(StepShape_ShapeDefinitionRepresentation) &sdr)
{
Clear();
STEPConstruct_Part SDRTool;
SDRTool.ReadSDR ( sdr );
InitPart ( SDRTool );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::Init (const STEPConstruct_Part &SDRTool)
{
Clear();
InitPart ( SDRTool );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
//void STEPConstruct_AP203Context::Init (const STEPConstruct_Part &SDRTool, const Handle(Interface_Model) &Model) {}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::Init (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO)
{
Clear();
InitAssembly ( NAUO );
}
//=======================================================================
//function : GetCreator
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetCreator () const
{
return myCreator;
}
//=======================================================================
//function : GetDesignOwner
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetDesignOwner () const
{
return myDesignOwner;
}
//=======================================================================
//function : GetDesignSupplier
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetDesignSupplier () const
{
return myDesignSupplier;
}
//=======================================================================
//function : GetClassificationOfficer
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) STEPConstruct_AP203Context::GetClassificationOfficer () const
{
return myClassificationOfficer;
}
//=======================================================================
//function : GetSecurity
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignSecurityClassification) STEPConstruct_AP203Context::GetSecurity () const
{
return mySecurity;
}
//=======================================================================
//function : GetCreationDate
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignDateAndTimeAssignment) STEPConstruct_AP203Context::GetCreationDate () const
{
return myCreationDate;
}
//=======================================================================
//function : GetClassificationDate
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignDateAndTimeAssignment) STEPConstruct_AP203Context::GetClassificationDate () const
{
return myClassificationDate;
}
//=======================================================================
//function : GetApproval
//purpose :
//=======================================================================
Handle(StepAP203_CcDesignApproval) STEPConstruct_AP203Context::GetApproval () const
{
return myApproval;
}
//=======================================================================
//function : GetApprover
//purpose :
//=======================================================================
Handle(StepBasic_ApprovalPersonOrganization) STEPConstruct_AP203Context::GetApprover () const
{
return myApprover;
}
//=======================================================================
//function : GetApprovalDateTime
//purpose :
//=======================================================================
Handle(StepBasic_ApprovalDateTime) STEPConstruct_AP203Context::GetApprovalDateTime () const
{
return myApprovalDateTime;
}
//=======================================================================
//function : GetProductCategoryRelationship
//purpose :
//=======================================================================
Handle(StepBasic_ProductCategoryRelationship) STEPConstruct_AP203Context::GetProductCategoryRelationship () const
{
return myProductCategoryRelationship;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::Clear ()
{
myCreator.Nullify();
myDesignOwner.Nullify();
myDesignSupplier.Nullify();
myClassificationOfficer.Nullify();
mySecurity.Nullify();
myCreationDate.Nullify();
myClassificationDate.Nullify();
myApproval.Nullify();
// myApprover.Nullify();
// myApprovalDateTime.Nullify();
myProductCategoryRelationship.Nullify();
}
//=======================================================================
//function : InitRoles
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::InitRoles ()
{
roleCreator = new StepBasic_PersonAndOrganizationRole;
roleDesignOwner = new StepBasic_PersonAndOrganizationRole;
roleDesignSupplier = new StepBasic_PersonAndOrganizationRole;
roleClassificationOfficer = new StepBasic_PersonAndOrganizationRole;
roleCreationDate = new StepBasic_DateTimeRole;
roleClassificationDate = new StepBasic_DateTimeRole;
roleApprover = new StepBasic_ApprovalRole;
roleCreator->Init ( new TCollection_HAsciiString ( "creator" ) );
roleDesignOwner->Init ( new TCollection_HAsciiString ( "design_owner" ) );
roleDesignSupplier->Init ( new TCollection_HAsciiString ( "design_supplier" ) );
roleClassificationOfficer->Init ( new TCollection_HAsciiString ( "classification_officer" ) );
roleCreationDate->Init ( new TCollection_HAsciiString ( "creation_date" ) );
roleClassificationDate->Init ( new TCollection_HAsciiString ( "classification_date" ) );
roleApprover->Init ( new TCollection_HAsciiString ( "approver" ) );
}
//=======================================================================
//function : InitPart
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::InitPart (const STEPConstruct_Part &SDRTool)
{
if ( myCreator.IsNull() ) {
myCreator = new StepAP203_CcDesignPersonAndOrganizationAssignment;
Handle(StepAP203_HArray1OfPersonOrganizationItem) items =
new StepAP203_HArray1OfPersonOrganizationItem (1, 2);
items->ChangeValue(1).SetValue ( SDRTool.PDF() );
items->ChangeValue(2).SetValue ( SDRTool.PD() );
myCreator->Init ( DefaultPersonAndOrganization(), RoleCreator(), items );
}
if ( myDesignOwner.IsNull() ) {
myDesignOwner = new StepAP203_CcDesignPersonAndOrganizationAssignment;
Handle(StepAP203_HArray1OfPersonOrganizationItem) items =
new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
items->ChangeValue(1).SetValue ( SDRTool.Product() );
myDesignOwner->Init ( DefaultPersonAndOrganization(), RoleDesignOwner(), items );
}
if ( myDesignSupplier.IsNull() ) {
myDesignSupplier = new StepAP203_CcDesignPersonAndOrganizationAssignment;
Handle(StepAP203_HArray1OfPersonOrganizationItem) items =
new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
items->ChangeValue(1).SetValue ( SDRTool.PDF() );
myDesignSupplier->Init ( DefaultPersonAndOrganization(), RoleDesignSupplier(), items );
}
if ( myCreationDate.IsNull() ) {
myCreationDate = new StepAP203_CcDesignDateAndTimeAssignment;
Handle(StepAP203_HArray1OfDateTimeItem) items =
new StepAP203_HArray1OfDateTimeItem (1, 1);
items->ChangeValue(1).SetValue ( SDRTool.PD() );
myCreationDate->Init ( DefaultDateAndTime(), RoleCreationDate(), items );
}
if ( mySecurity.IsNull() ) {
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ( "" );
Handle(TCollection_HAsciiString) aPurpose = new TCollection_HAsciiString ( "" );
Handle(StepBasic_SecurityClassification) sc = new StepBasic_SecurityClassification;
sc->Init ( aName, aPurpose, DefaultSecurityClassificationLevel() );
mySecurity = new StepAP203_CcDesignSecurityClassification;
Handle(StepAP203_HArray1OfClassifiedItem) items =
new StepAP203_HArray1OfClassifiedItem (1, 1);
items->ChangeValue(1).SetValue ( SDRTool.PDF() );
mySecurity->Init ( sc, items );
}
InitSecurityRequisites();
if ( myApproval.IsNull() ) {
myApproval = new StepAP203_CcDesignApproval;
Handle(StepAP203_HArray1OfApprovedItem) items =
new StepAP203_HArray1OfApprovedItem (1, 3);
items->ChangeValue(1).SetValue ( SDRTool.PDF() );
items->ChangeValue(2).SetValue ( SDRTool.PD() );
items->ChangeValue(3).SetValue ( mySecurity->AssignedSecurityClassification() );
myApproval->Init ( DefaultApproval(), items );
}
InitApprovalRequisites();
if ( myProductCategoryRelationship.IsNull() ) {
Handle(StepBasic_ProductCategory) PC = new StepBasic_ProductCategory;
Handle(TCollection_HAsciiString) PCName = new TCollection_HAsciiString ( "part" );
PC->Init ( PCName, Standard_False, 0 );
myProductCategoryRelationship = new StepBasic_ProductCategoryRelationship;
Handle(TCollection_HAsciiString) PCRName = new TCollection_HAsciiString ( "" );
Handle(TCollection_HAsciiString) PCRDescr = new TCollection_HAsciiString ( "" );
myProductCategoryRelationship->Init ( PCRName, Standard_True, PCRDescr, PC, SDRTool.PRPC() );
}
}
//=======================================================================
//function : InitAssembly
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::InitAssembly (const Handle(StepRepr_NextAssemblyUsageOccurrence) &NAUO)
{
if ( mySecurity.IsNull() ) {
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString ( "" );
Handle(TCollection_HAsciiString) aPurpose = new TCollection_HAsciiString ( "" );
Handle(StepBasic_SecurityClassification) sc = new StepBasic_SecurityClassification;
sc->Init ( aName, aPurpose, DefaultSecurityClassificationLevel() );
mySecurity = new StepAP203_CcDesignSecurityClassification;
Handle(StepAP203_HArray1OfClassifiedItem) items =
new StepAP203_HArray1OfClassifiedItem (1, 1);
items->ChangeValue(1).SetValue ( NAUO );
mySecurity->Init ( sc, items );
}
InitSecurityRequisites();
if ( myApproval.IsNull() ) {
myApproval = new StepAP203_CcDesignApproval;
Handle(StepAP203_HArray1OfApprovedItem) items =
new StepAP203_HArray1OfApprovedItem (1, 1);
items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
myApproval->Init ( DefaultApproval(), items );
}
InitApprovalRequisites();
}
//=======================================================================
//function : InitSecurityRequisites
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::InitSecurityRequisites ()
{
if ( myClassificationOfficer.IsNull() ||
myClassificationOfficer->Items()->Value(1).Value() != mySecurity->AssignedSecurityClassification() ) {
myClassificationOfficer = new StepAP203_CcDesignPersonAndOrganizationAssignment;
Handle(StepAP203_HArray1OfPersonOrganizationItem) items =
new StepAP203_HArray1OfPersonOrganizationItem (1, 1);
items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
myClassificationOfficer->Init ( DefaultPersonAndOrganization(), RoleClassificationOfficer(), items );
}
if ( myClassificationDate.IsNull() ||
myClassificationDate->Items()->Value(1).Value() != mySecurity->AssignedSecurityClassification() ) {
myClassificationDate = new StepAP203_CcDesignDateAndTimeAssignment;
Handle(StepAP203_HArray1OfDateTimeItem) items =
new StepAP203_HArray1OfDateTimeItem (1, 1);
items->ChangeValue(1).SetValue ( mySecurity->AssignedSecurityClassification() );
myClassificationDate->Init ( DefaultDateAndTime(), RoleClassificationDate(), items );
}
}
//=======================================================================
//function : InitApprovalRequisites
//purpose :
//=======================================================================
void STEPConstruct_AP203Context::InitApprovalRequisites ()
{
if ( myApprover.IsNull() ||
myApprover->AuthorizedApproval() != myApproval->AssignedApproval() ) {
myApprover = new StepBasic_ApprovalPersonOrganization;
StepBasic_PersonOrganizationSelect po;
po.SetValue ( DefaultPersonAndOrganization() );
myApprover->Init ( po, myApproval->AssignedApproval(), RoleApprover() );
}
if ( myApprovalDateTime.IsNull() ||
myApprovalDateTime->DatedApproval() != myApproval->AssignedApproval() ) {
myApprovalDateTime = new StepBasic_ApprovalDateTime;
StepBasic_DateTimeSelect dt;
dt.SetValue ( DefaultDateAndTime() );
myApprovalDateTime->Init ( dt, myApproval->AssignedApproval() );
}
}

View File

@@ -0,0 +1,71 @@
-- File: STEPConstruct_Assembly.cdl
-- Created: Tue Jul 7 09:13:40 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class Assembly from STEPConstruct
---Purpose : This operator creates an item of an assembly, from its
-- basic data : a ShapeRepresentation, a Location ...
--
-- Three ways of coding such item from a ShapeRepresentation :
-- - do nothing : i.e. informations for assembly are ignored
-- - create a MappedItem
-- - create a RepresentationRelationship (WithTransformation)
uses
Trsf from gp,
InterfaceModel from Interface,
Axis2Placement3d from StepGeom,
ShapeRepresentation from StepShape,
ShapeDefinitionRepresentation from StepShape,
NextAssemblyUsageOccurrence from StepRepr,
ContextDependentShapeRepresentation from StepShape
is
Create returns Assembly from STEPConstruct;
Init (me: in out; aSR, SDR0: ShapeDefinitionRepresentation from StepShape;
Ax0, Loc : Axis2Placement3d from StepGeom);
---Purpose : Initialises with starting values
-- Ax0 : origin axis (typically, standard XYZ)
-- Loc : location to which place the item
-- MakeMappedItem (me: in out);
---Purpose : Makes a MappedItem
-- Resulting Value is returned by ItemValue
MakeRelationship (me: in out);
---Purpose : Make a (ShapeRepresentationRelationship,...WithTransformation)
-- Resulting Value is returned by ItemValue
ItemValue (me) returns Transient;
---Purpose : Returns the Value
-- If no Make... has been called, returns the starting SR
ItemLocation (me) returns Axis2Placement3d from StepGeom;
---Purpose : Returns the location of the item, computed from starting aLoc
GetNAUO (me) returns NextAssemblyUsageOccurrence from StepRepr;
---Purpose: Returns NAUO object describing the assembly link
CheckSRRReversesNAUO (myclass; Model: InterfaceModel from Interface;
CDSR : ContextDependentShapeRepresentation from StepShape)
returns Boolean;
---Purpose: Checks whether SRR's definition of assembly and component contradicts
-- with NAUO definition or not, according to model schema (AP214 or AP203)
--
fields
thesdr : ShapeDefinitionRepresentation from StepShape;
thesdr0: ShapeDefinitionRepresentation from StepShape;
thesr : ShapeRepresentation from StepShape;
thesr0 : ShapeRepresentation from StepShape;
theval : Transient;
theloc : Axis2Placement3d from StepGeom;
theax0 : Axis2Placement3d from StepGeom;
end Assembly;

View File

@@ -0,0 +1,231 @@
//:k8 abv 06.01.99: TR10: writing unique names for NAUOs
// :j4 16.03.99 gka S4134
// abv 18.11.99 renamed from StepPDR_MakeItem
#include <STEPConstruct_Assembly.ixx>
#include <TCollection_HAsciiString.hxx>
// ProductDefinition (pour Relationship)
#include <StepBasic_ProductDefinition.hxx>
#include <StepBasic_DesignContext.hxx>
#include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
#include <StepBasic_Product.hxx>
#include <StepBasic_HArray1OfProductContext.hxx>
#include <StepBasic_MechanicalContext.hxx>
#include <StepBasic_ApplicationContext.hxx>
// ContextDependentShapeRepresentation qui contient la Relationship
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepRepr_CharacterizedDefinition.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
// Relationship
#include <StepRepr_ShapeRepresentationRelationshipWithTransformation.hxx>
#include <StepRepr_HArray1OfRepresentationItem.hxx>
#include <StepRepr_RepresentationContext.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepRepr_ItemDefinedTransformation.hxx>
#include <StepRepr_Transformation.hxx>
//=======================================================================
//function : STEPConstruct_Assembly
//purpose :
//=======================================================================
STEPConstruct_Assembly::STEPConstruct_Assembly ()
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void STEPConstruct_Assembly::Init (const Handle(StepShape_ShapeDefinitionRepresentation)& aSDR,
const Handle(StepShape_ShapeDefinitionRepresentation)& SDR0,
const Handle(StepGeom_Axis2Placement3d)& Ax0,
const Handle(StepGeom_Axis2Placement3d)& AxLoc)
{
thesdr = aSDR;
thesdr0 = SDR0;
thesr = Handle(StepShape_ShapeRepresentation)::DownCast(aSDR->UsedRepresentation());
thesr0 = Handle(StepShape_ShapeRepresentation)::DownCast(SDR0->UsedRepresentation());
theval.Nullify();
theax0 = Ax0;
theloc = AxLoc;
}
//=======================================================================
//function : MakeMappedItem
//purpose :
//=======================================================================
//void STEPConstruct_Assembly::MakeMappedItem ()
//{
// not yet implemented
//}
//=======================================================================
//function : MakeRelationship
//purpose :
//=======================================================================
void STEPConstruct_Assembly::MakeRelationship ()
{
// get PDs for assembly (sdr0) and component (sdr)
Handle(StepBasic_ProductDefinition) PDED =
thesdr->Definition().PropertyDefinition()->Definition().ProductDefinition();
Handle(StepBasic_ProductDefinition) PDING =
thesdr0->Definition().PropertyDefinition()->Definition().ProductDefinition();
// create NAUO
//:k8 abv 06 Jan 99: TR10: writing unique names for NAUOs !!!!!
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
new StepRepr_NextAssemblyUsageOccurrence;
static Standard_Integer id = 0;
Handle(TCollection_HAsciiString) ocid = new TCollection_HAsciiString(++id);
Handle(TCollection_HAsciiString) ocname = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) ocdesc = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) refdes; // reste nulle
NAUO->Init (ocid,ocname,Standard_True,ocdesc,PDING,PDED,Standard_False,refdes);
// create PDS for link CDSR->PDS->NAUO
Handle(StepRepr_ProductDefinitionShape) PDS =
new StepRepr_ProductDefinitionShape;
Handle(TCollection_HAsciiString) pdsname = new TCollection_HAsciiString("Placement");
Handle(TCollection_HAsciiString) pdsdesc = new TCollection_HAsciiString("Placement of an item");
StepRepr_CharacterizedDefinition CD;
CD.SetValue(NAUO);
PDS->Init (pdsname,Standard_True,pdsdesc,CD);
// create transformation
Handle(StepRepr_ItemDefinedTransformation) ItemDef =
new StepRepr_ItemDefinedTransformation;
Handle(TCollection_HAsciiString) idname = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) idescr = new TCollection_HAsciiString("");
ItemDef->Init (idname,idescr,theax0,theloc);
// create SRRWT
Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation) SRRWT =
new StepRepr_ShapeRepresentationRelationshipWithTransformation;
Handle(TCollection_HAsciiString) stname = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) stescr = new TCollection_HAsciiString("");
StepRepr_Transformation StepTrans;
StepTrans.SetValue (ItemDef);
SRRWT->Init (stname,stescr,thesr,thesr0,StepTrans);
// create CDSR (final result, root)
Handle(StepShape_ContextDependentShapeRepresentation) CDSR =
new StepShape_ContextDependentShapeRepresentation;
CDSR->Init (SRRWT,PDS);
theval = CDSR;
}
//=======================================================================
//function : ItemValue
//purpose :
//=======================================================================
Handle(Standard_Transient) STEPConstruct_Assembly::ItemValue () const
{
if (theval.IsNull()) return thesr;
return theval;
}
//=======================================================================
//function : ItemLocation
//purpose :
//=======================================================================
Handle(StepGeom_Axis2Placement3d) STEPConstruct_Assembly::ItemLocation () const
{
return theloc;
}
//=======================================================================
//function : GetNAUO
//purpose :
//=======================================================================
Handle(StepRepr_NextAssemblyUsageOccurrence) STEPConstruct_Assembly::GetNAUO () const
{
Handle(StepShape_ContextDependentShapeRepresentation) CDSR =
Handle(StepShape_ContextDependentShapeRepresentation)::DownCast ( ItemValue() );
if ( ! CDSR.IsNull() ) {
Handle(StepBasic_ProductDefinitionRelationship) PDR =
CDSR->RepresentedProductRelation()->Definition().ProductDefinitionRelationship();
return Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast ( PDR );
}
return 0;
}
//=======================================================================
//function : CheckSRRReversesNAUO
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Assembly::CheckSRRReversesNAUO(const Handle(Interface_InterfaceModel) &Model,
const Handle(StepShape_ContextDependentShapeRepresentation) &CDSR)
{
Handle(StepRepr_NextAssemblyUsageOccurrence) nauo =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast
( CDSR->RepresentedProductRelation()->Definition().ProductDefinitionRelationship() );
if ( nauo.IsNull() ) {
#ifdef DEB
cout << "Warning: No NAUO found in CDSR !" << endl;
#endif
return Standard_False;
}
Handle(StepBasic_ProductDefinition) pd1, pd2;
Handle(StepRepr_Representation) rep1 = CDSR->RepresentationRelation()->Rep1();
Handle(StepRepr_Representation) rep2 = CDSR->RepresentationRelation()->Rep2();
// find SDRs corresponding to Rep1 and Rep2 and remember their PDs
Handle(Standard_Type) tSDR = STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation);
Standard_Integer nb = Model->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) enti = Model->Value(i);
if (enti->DynamicType() == tSDR) {
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(enti);
if ( SDR->UsedRepresentation() == rep1 )
pd1 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
if ( SDR->UsedRepresentation() == rep2 )
pd2 = SDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
}
}
// checks..
if ( pd1 == nauo->RelatedProductDefinition() && // OK
pd2 == nauo->RelatingProductDefinition() ) return Standard_False;
if ( pd2 == nauo->RelatedProductDefinition() && // Reversed
pd1 == nauo->RelatingProductDefinition() ) {
return Standard_True;
}
#ifdef DEB
cout << "Warning: SRR and NAUO are incompatible" << endl;
// cout << "NAUO = " << Model->StringLabel(nauo)->ToCString() <<
// ",\tCDSR = " << Model->StringLabel(CDSR)->ToCString() << endl;
// cout << "Rep1 = " << Model->StringLabel(rep1)->ToCString() <<
// ",\tRep2 = " << Model->StringLabel(rep2)->ToCString() << endl;
// cout << "PD1 = " << Model->StringLabel(pd1)->ToCString() <<
// ",\tPD2 = " << Model->StringLabel(pd2)->ToCString() << endl;
// cout << "Rel1 = " << Model->StringLabel(nauo->RelatingProductDefinition())->ToCString() <<
// ",\tRel2 = " << Model->StringLabel(nauo->RelatedProductDefinition())->ToCString() << endl;
#endif
if ( pd2 == nauo->RelatedProductDefinition() || //:k3 abv 25 Nov 98: rp1sd.stp - bad assemblies
pd1 == nauo->RelatingProductDefinition() ) {
return Standard_True;
}
return Standard_False;
}

View File

@@ -0,0 +1,126 @@
-- File: STEPConstruct_ContextTool.cdl
-- Created: Tue Sep 14 14:27:48 1993
-- Author: Frederic MAUPAS
-- <fma@sdsun2>
---Copyright: Matra Datavision 1993
class ContextTool from STEPConstruct
---Purpose : Gives access to Product Definition Context (one per Model)
-- Maintains ApplicationProtocolDefinition entity (common for all
-- products)
-- Also maintains context specific for AP203 and provides set of
-- methods to work with various STEP constructs as required
-- by Actor
uses
SequenceOfInteger from TColStd,
HSequenceOfTransient from TColStd,
HAsciiString from TCollection,
StepModel from StepData,
ApplicationProtocolDefinition from StepBasic,
ShapeDefinitionRepresentation from StepShape,
Axis2Placement3d from StepGeom,
AP203Context from STEPConstruct,
Assembly from STEPConstruct,
Part from STEPConstruct
is
Create returns ContextTool from STEPConstruct;
Create (aStepModel : StepModel from StepData) returns ContextTool from STEPConstruct;
---Management of ApplicationProtocolDefinition
SetModel (me : in out; aStepModel : StepModel from StepData);
---Purpose: Initialize ApplicationProtocolDefinition by the first
-- entity of that type found in the model
GetAPD(me : in out) returns ApplicationProtocolDefinition from StepBasic;
---Purpose:
AddAPD(me : in out; enforce : Boolean = Standard_False);
IsAP203 (me) returns Boolean;
---Purpose: Returns True if APD.schema_name is config_control_design
IsAP214 (me) returns Boolean;
---Purpose: Returns True if APD.schema_name is automotive_design
-- AC : Application Context
GetACstatus(me : in out) returns HAsciiString from TCollection;
GetACschemaName(me : in out) returns HAsciiString from TCollection;
GetACyear(me : in out) returns Integer;
-- GetACapplication(me : in out)
-- returns HAsciiString from TCollection; via the SDR
GetACname (me : in out) returns HAsciiString from TCollection;
SetACstatus (me: in out; status: HAsciiString from TCollection);
SetACschemaName(me: in out; schemaName: HAsciiString from TCollection);
SetACyear (me: in out; year: Integer);
-- SetACapplication(me : in out;
-- application : HAsciiString from TCollection);
SetACname (me: in out; name : HAsciiString from TCollection);
-- Other context items
GetDefaultAxis (me: in out) returns Axis2Placement3d from StepGeom;
---Purpose: Returns a default axis placement
AP203Context (me: in out) returns AP203Context from STEPConstruct;
---Purpose: Returns tool which maintains context specific for AP203
---C++: return &
-- Management of assembly level for naming products
Level (me) returns Integer;
---Purpose: Returns current assembly level
NextLevel (me: in out);
PrevLevel (me: in out);
SetLevel (me: in out; lev: Integer );
---Purpose: Changes current assembly level
Index (me) returns Integer;
---Purpose: Returns current index of assembly component on current level
NextIndex (me: in out);
PrevIndex (me: in out);
SetIndex (me: in out; ind: Integer );
---Purpose: Changes current index of assembly component on current level
GetProductName (me) returns HAsciiString from TCollection;
---Purpose: Generates a product name basing on write.step.product.name
-- parameter and current position in the assembly structure
-- Methods for collecting all roots corresponding to some constructs
GetRootsForPart (me: in out; SDRTool: Part from STEPConstruct)
returns HSequenceOfTransient from TColStd;
---Purpose: Produces and returns a full list of root entities required
-- for part identified by SDRTool (including SDR itself)
GetRootsForAssemblyLink (me: in out; assembly: Assembly from STEPConstruct)
returns HSequenceOfTransient from TColStd;
---Purpose: Produces and returns a full list of root entities required
-- for assembly link identified by assembly (including NAUO and CDSR)
fields
myLevel : SequenceOfInteger from TColStd; -- level of assembly for auto naming products
theAPD : ApplicationProtocolDefinition from StepBasic;
theAP203 : AP203Context from STEPConstruct;
myAxis : Axis2Placement3d from StepGeom;
end ContextTool;

View File

@@ -0,0 +1,598 @@
// File: STEPConstruct_ContextTool.cxx
// Created: Mon Sep 20 12:23:40 1993
// Author: Martine LANGLOIS
// <mla@ecolox>
// :j4 16.03.99 gka S4134
// abv 18.11.99 renamed from StepPDR_ContextTool
#include <STEPConstruct_ContextTool.ixx>
#include <StepData_StepModel.hxx>
#include <Interface_Macros.hxx>
#include <StepBasic_ProductDefinition.hxx>
//#include <StepBasic_ProductDefinitionContext.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <StepBasic_Product.hxx>
#include <StepBasic_ProductContext.hxx>
#include <StepBasic_HArray1OfProductContext.hxx>
#include <StepBasic_ApplicationContext.hxx>
#include <StepBasic_ApplicationProtocolDefinition.hxx>
#include <StepRepr_PropertyDefinition.hxx>
#include <StepBasic_HArray1OfProduct.hxx>
#include <StepBasic_ProductType.hxx> //:i3
#include <Interface_Static.hxx> //:j4
#include <GeomToStep_MakeAxis2Placement3d.hxx>
#include "stdio.h"
//=======================================================================
//function : STEPConstruct_ContextTool
//purpose :
//=======================================================================
STEPConstruct_ContextTool::STEPConstruct_ContextTool ()
{
}
//=======================================================================
//function : STEPConstruct_ContextTool
//purpose :
//=======================================================================
STEPConstruct_ContextTool::STEPConstruct_ContextTool (const Handle(StepData_StepModel)& aStepModel)
{
SetModel(aStepModel);
}
//=======================================================================
//function : SetModel
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetModel (const Handle(StepData_StepModel)& aStepModel)
{
theAPD.Nullify(); //thePRPC.Nullify();
Standard_Integer i, nb = aStepModel->NbEntities();
for(i = 1; i<=nb && theAPD.IsNull(); i ++) {
Handle(Standard_Transient) ent = aStepModel->Value(i);
if (ent->IsKind(STANDARD_TYPE(StepBasic_ApplicationProtocolDefinition))) {
if (theAPD.IsNull()) theAPD = GetCasted(StepBasic_ApplicationProtocolDefinition, ent);
}
//if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductRelatedProductCategory))) {
// if (thePRPC.IsNull()) thePRPC = GetCasted(StepBasic_ProductRelatedProductCategory, ent);
//}
}
}
//=======================================================================
//function : GetAPD
//purpose :
//=======================================================================
Handle(StepBasic_ApplicationProtocolDefinition) STEPConstruct_ContextTool::GetAPD()
{
return theAPD;
}
//=======================================================================
//function : AddAPD
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::AddAPD (const Standard_Boolean enforce)
{
Standard_Boolean noapd = theAPD.IsNull();
if (noapd || enforce) theAPD = new StepBasic_ApplicationProtocolDefinition;
switch (Interface_Static::IVal("write.step.schema")) { //j4
default:
case 1:
theAPD->SetApplicationProtocolYear (1997);
theAPD->SetStatus (new TCollection_HAsciiString("committee draft"));
theAPD->SetApplicationInterpretedModelSchemaName
(new TCollection_HAsciiString("automotive_design"));
break;
case 2:
theAPD->SetApplicationProtocolYear (1998);
theAPD->SetStatus (new TCollection_HAsciiString("draft international standard"));
theAPD->SetApplicationInterpretedModelSchemaName
(new TCollection_HAsciiString("automotive_design"));
break;
case 3:
theAPD->SetApplicationProtocolYear (1994);
theAPD->SetStatus (new TCollection_HAsciiString("international standard"));
theAPD->SetApplicationInterpretedModelSchemaName
(new TCollection_HAsciiString("config_control_design"));
break;
case 4: theAPD->SetApplicationProtocolYear (2000);
theAPD->SetStatus (new TCollection_HAsciiString("international standard"));
theAPD->SetApplicationInterpretedModelSchemaName
(new TCollection_HAsciiString("automotive_design"));
break;
}
if (theAPD->Application().IsNull())
theAPD->SetApplication (new StepBasic_ApplicationContext);
Handle(TCollection_HAsciiString) appl;
switch (Interface_Static::IVal("write.step.schema")) { //j4
default:
case 1:
case 2: appl = new TCollection_HAsciiString ( "core data for automotive mechanical design processes" );
break;
case 3: appl = new TCollection_HAsciiString ( "configuration controlled 3D designs of mechanical parts and assemblies" );
break;
}
theAPD->Application()->SetApplication ( appl );
// if (noapd || enforce) aStepModel->AddWithRefs (theAPD);
}
//=======================================================================
//function : IsAP203
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ContextTool::IsAP203 () const
{
if ( theAPD.IsNull() ) return Standard_False;
Handle(TCollection_HAsciiString) schema = theAPD->ApplicationInterpretedModelSchemaName();
if ( schema.IsNull() ) return Standard_False;
TCollection_AsciiString sch = schema->String();
sch.LowerCase();
return sch == "config_control_design";
}
//=======================================================================
//function : IsAP214
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ContextTool::IsAP214 () const
{
if ( theAPD.IsNull() ) return Standard_False;
Handle(TCollection_HAsciiString) schema = theAPD->ApplicationInterpretedModelSchemaName();
if ( schema.IsNull() ) return Standard_False;
TCollection_AsciiString sch = schema->String();
sch.LowerCase();
return sch == "automotive_design";
}
// ================================================================
// Data Section : Basic Product Information (level S1)
// * Get methods
// * Set methods
// ================================================================
//=======================================================================
//function : GetACstatus
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetACstatus()
{
if (GetAPD().IsNull()) return new TCollection_HAsciiString("");
return GetAPD()->Status();
}
//=======================================================================
//function : GetACschemaName
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetACschemaName()
{
if (GetAPD().IsNull()) return new TCollection_HAsciiString("");
return GetAPD()->ApplicationInterpretedModelSchemaName();
}
//=======================================================================
//function : GetACyear
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ContextTool::GetACyear()
{
return (GetAPD().IsNull() ? 1998 :
GetAPD()->ApplicationProtocolYear());
}
/*
//=======================================================================
//function : GetACapplication
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetACapplication()
{
return GetPDC()->Formation()->OfProduct()->FrameOfReferenceValue(1)
->FrameOfReference()->Application();
}
*/
//=======================================================================
//function : GetACname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetACname()
{
if (GetAPD().IsNull()) return new TCollection_HAsciiString("");
if (GetAPD()->Application().IsNull()) return new TCollection_HAsciiString("");
return GetAPD()->Application()->Application();
}
//=======================================================================
//function : SetACstatus
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetACstatus (const Handle(TCollection_HAsciiString)& status)
{
if (GetAPD().IsNull()) return;
GetAPD()->SetStatus(status);
}
//=======================================================================
//function : SetACschemaName
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetACschemaName (const Handle(TCollection_HAsciiString)& schemaName)
{
if (GetAPD().IsNull()) return;
GetAPD()->SetApplicationInterpretedModelSchemaName(schemaName);
}
//=======================================================================
//function : SetACyear
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetACyear (const Standard_Integer year)
{
if (GetAPD().IsNull()) return;
GetAPD()->SetApplicationProtocolYear(year);
}
//=======================================================================
//function : SetACname
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetACname (const Handle(TCollection_HAsciiString)& name)
{
if (GetAPD().IsNull()) return;
if (GetAPD()->Application().IsNull()) GetAPD()->SetApplication
(new StepBasic_ApplicationContext);
GetAPD()->Application()->SetApplication (name);
}
/*
//=======================================================================
//function : SetACapplication
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetACapplication (const Handle(TCollection_HAsciiString)& application)
{
GetPDC()->Formation()->OfProduct()->FrameOfReferenceValue(1)
->FrameOfReference()->SetApplication(application);
}
*/
// --------------------------------
// Product Related Product Category
// --------------------------------
/*
//=======================================================================
//function : GetPRPC
//purpose :
//=======================================================================
Handle(StepBasic_ProductRelatedProductCategory) STEPConstruct_ContextTool::GetPRPC()
{
return thePRPC;
}
//=======================================================================
//function : AddPRPC
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::AddPRPC (const Standard_Boolean enforce)
{
Standard_Boolean noprpc = thePRPC.IsNull();
if (noprpc || enforce) {
//:i3 abv 1 Sep 98: ProSTEP TR9: generate PRODUCT_TYPE (derived) instead of PRPC
switch (Interface_Static::IVal("write.step.schema")) { //j4
default:
case 1:
thePRPC = new StepBasic_ProductType;
thePRPC->SetName (new TCollection_HAsciiString("part"));
break;
case 4:
case 2:
thePRPC = new StepBasic_ProductRelatedProductCategory;
thePRPC->SetName (new TCollection_HAsciiString("part"));
break;
case 3:
thePRPC = new StepBasic_ProductRelatedProductCategory;
thePRPC->SetName (new TCollection_HAsciiString("detail")); // !!!!! or "assembly"
break;
}
thePRPC->UnSetDescription(); //:i3
}
// if (noprpc || enforce) aStepModel->AddWithRefs(thePRPC);
}
//=======================================================================
//function : SetPRPCName
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetPRPCName(const Handle(TCollection_HAsciiString)& aName)
{
GetPRPC()->SetName(aName);
}
//=======================================================================
//function : GetPRPCName
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetPRPCName()
{
if (GetPRPC().IsNull()) return new TCollection_HAsciiString("");
return GetPRPC()->Name();
}
//=======================================================================
//function : SetPRPCDescription
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetPRPCDescription (const Handle(TCollection_HAsciiString)& aDescription)
{
Handle(StepBasic_ProductRelatedProductCategory) aPRPC = GetPRPC();
aPRPC->SetDescription(aDescription);
// aPRPC->HasDescription(Standard_True);
}
//=======================================================================
//function : GetPRPCDescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetPRPCDescription()
{
Handle(StepBasic_ProductRelatedProductCategory) aPRPC = GetPRPC();
if (!aPRPC.IsNull() && aPRPC->HasDescription())
return aPRPC->Description();
else {
return new TCollection_HAsciiString("");
}
}
// ================================================================
//
// Settings from an already done SDR (see SDRtool)
//
// ================================================================
void STEPConstruct_ContextTool::SetSDR (const Handle(StepShape_ShapeDefinitionRepresentation)& sdr)
{
// SDR partage des choses avec le contexte ... On raccroche les wagons
Handle(StepBasic_Product) theProduct =
sdr->Definition()->Definition().ProductDefinition()->Formation()->OfProduct();
Handle(StepBasic_ApplicationContext) theAppli =
theProduct->FrameOfReferenceValue(1)->FrameOfReference();
Handle(StepBasic_HArray1OfProduct) ProdList =
new StepBasic_HArray1OfProduct(1,1);
ProdList->SetValue(1,theProduct);
thePRPC->SetProducts (ProdList);
theAPD->SetApplication (theAppli);
}
*/
//=======================================================================
//function : GetDefaultAxis
//purpose :
//=======================================================================
Handle(StepGeom_Axis2Placement3d) STEPConstruct_ContextTool::GetDefaultAxis ()
{
if ( myAxis.IsNull() ) {
GeomToStep_MakeAxis2Placement3d mkax;
myAxis = mkax.Value();
}
return myAxis;
}
//=======================================================================
//function : AP203Context
//purpose :
//=======================================================================
STEPConstruct_AP203Context &STEPConstruct_ContextTool::AP203Context ()
{
return theAP203;
}
//=======================================================================
//function : Level
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ContextTool::Level () const
{
return myLevel.Length();
}
//=======================================================================
//function : NextLevel
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::NextLevel ()
{
myLevel.Append ( 1 );
}
//=======================================================================
//function : PrevLevel
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::PrevLevel ()
{
if ( myLevel.Length() >0 ) myLevel.Remove ( myLevel.Length() );
}
//=======================================================================
//function : SetLevel
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetLevel (const Standard_Integer lev)
{
if ( lev < myLevel.Length() ) {
while ( lev < myLevel.Length() && myLevel.Length() >0 )
myLevel.Remove ( myLevel.Length() );
}
else {
while ( myLevel.Length() < lev ) myLevel.Append ( 1 );
}
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ContextTool::Index () const
{
return ( myLevel.Length() >0 ? myLevel.Last() : 0 );
}
//=======================================================================
//function : NextIndex
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::NextIndex ()
{
if ( myLevel.Length() >0 )
myLevel.SetValue ( myLevel.Length(), myLevel.Last() + 1 );
}
//=======================================================================
//function : PrevIndex
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::PrevIndex ()
{
if ( myLevel.Length() >0 )
myLevel.SetValue ( myLevel.Length(), myLevel.Last() - 1 );
}
//=======================================================================
//function : SetIndex
//purpose :
//=======================================================================
void STEPConstruct_ContextTool::SetIndex (const Standard_Integer ind)
{
if ( myLevel.Length() >0 )
myLevel.SetValue ( myLevel.Length(), ind );
}
//=======================================================================
//function : GetProductName
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetProductName () const
{
Handle(TCollection_HAsciiString) PdtName;
if (Interface_Static::IsSet("write.step.product.name"))
PdtName = new TCollection_HAsciiString(Interface_Static::CVal("write.step.product.name"));
else PdtName = new TCollection_HAsciiString("Product");
for ( Standard_Integer i=1; i <= myLevel.Length(); i++ ) {
PdtName->AssignCat ((char*)( i >1 ? "." : " " ));
char buf[100];
sprintf ( buf, "%d", myLevel.Value(i) );
PdtName->AssignCat ( buf );
}
return PdtName;
}
//=======================================================================
//function : GetRootsForPart
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForPart (const STEPConstruct_Part &SDRTool)
{
Handle(TColStd_HSequenceOfTransient) seq = new TColStd_HSequenceOfTransient;
seq->Append ( SDRTool.SDRValue() );
// seq->Append ( GetAPD() );
if ( ! SDRTool.PRPC().IsNull() ) seq->Append ( SDRTool.PRPC() );
// for AP203, add required product management data
if ( Interface_Static::IVal("write.step.schema") == 3 ) {
theAP203.Init ( SDRTool );
seq->Append (theAP203.GetProductCategoryRelationship());
seq->Append (theAP203.GetCreator());
seq->Append (theAP203.GetDesignOwner());
seq->Append (theAP203.GetDesignSupplier());
seq->Append (theAP203.GetClassificationOfficer());
seq->Append (theAP203.GetSecurity());
seq->Append (theAP203.GetCreationDate());
seq->Append (theAP203.GetClassificationDate());
seq->Append (theAP203.GetApproval());
seq->Append (theAP203.GetApprover());
seq->Append (theAP203.GetApprovalDateTime());
}
return seq;
}
//=======================================================================
//function : GetRootsForAssemblyLink
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForAssemblyLink (const STEPConstruct_Assembly &assembly)
{
Handle(TColStd_HSequenceOfTransient) seq = new TColStd_HSequenceOfTransient;
seq->Append ( assembly.ItemValue() );
// for AP203, write required product management data
if ( Interface_Static::IVal("write.step.schema") == 3 ) {
theAP203.Init ( assembly.GetNAUO() );
seq->Append (theAP203.GetSecurity());
seq->Append (theAP203.GetClassificationOfficer());
seq->Append (theAP203.GetClassificationDate());
seq->Append (theAP203.GetApproval());
seq->Append (theAP203.GetApprover());
seq->Append (theAP203.GetApprovalDateTime());
}
return seq;
}

View File

@@ -0,0 +1,121 @@
-- File: STEPConstruct_ExternRefs.cdl
-- Created: Fri Sep 29 16:09:49 2000
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class ExternRefs from STEPConstruct inherits Tool from STEPConstruct
---Purpose: Provides a tool for analyzing (reading) and creating (writing)
-- references to external files in STEP
--
-- It maintains a data structure in the form of sequences
-- of relevant STEP entities (roots), allowing either to create
-- them by convenient API, or load from existing model and
-- investigate
uses
HAsciiString from TCollection,
SequenceOfTransient from TColStd,
WorkSession from XSControl,
ProductDefinition from StepBasic,
SequenceOfInteger from TColStd,
CString from Standard,
ProductRelatedProductCategory from StepBasic,
DocumentType from StepBasic,
ApplicationProtocolDefinition from StepBasic,
AppliedDocumentReference from StepAP214,
DocumentFile from StepBasic,
ProductContext from StepBasic,
ProductDefinitionContext from StepBasic
is
Create returns ExternRefs;
---Purpose: Creates an empty tool
Create (WS: WorkSession from XSControl) returns ExternRefs;
---Purpose: Creates a tool and initializes it
Init (me: in out; WS: WorkSession from XSControl) returns Boolean;
---Purpose: Initializes tool; returns True if succeeded
Clear (me: in out);
---Purpose: Clears internal fields (list of defined extern refs)
---Scope: Reading
LoadExternRefs (me: in out) returns Boolean;
---Purpose: Searches current STEP model for external references
-- and loads them to the internal data structures
-- NOTE: does not clear data structures before loading
NbExternRefs (me) returns Integer;
---Purpose: Returns number of defined extern references
FileName (me; num: Integer) returns CString;
---Purpose: Returns filename for numth extern reference
-- Returns Null if FileName is not defined or bad
---C++: return const
ProdDef (me; num: Integer) returns ProductDefinition from StepBasic;
---Purpose: Returns ProductDefinition to which numth extern reference
-- is associated.
-- Returns Null if cannot be detected or if extern reference
-- is not associated to SDR in a proper way.
Format (me; num: Integer) returns HAsciiString from TCollection;
---Purpose: Returns format identification string for the extern document
-- Returns Null handle if format is not defined
---Scope: Writing
AddExternRef (me: in out; filename: CString;
PD: ProductDefinition from StepBasic;
format: CString) returns Integer;
---Purpose: Create a new external reference with specified attributes
-- attached to a given SDR
-- <format> can be Null string, in that case this information
-- is not written. Else, it can be "STEP AP214" or "STEP AP203"
-- Returns index of a new extern ref
addAP214ExterRef (me: in out; ADR : AppliedDocumentReference from StepAP214;
PD: ProductDefinition from StepBasic;
DF : DocumentFile from StepBasic;
filename: CString from Standard )
returns Boolean from Standard is protected;
---Purpose: Create a new additional structure entities and add ncessary references
-- Note: do not refer from ADR to DF directly in AP214 (TRJ11).
checkAP214Shared (me: in out);
---Purpose: Check (create if it is null) all shared entities for the model
WriteExternRefs (me; num: Integer) returns Integer;
---Purpose: Adds all the currently defined external refs to the model
-- Returns number of written extern refs
SetAP214APD (me: in out; APD : ApplicationProtocolDefinition from StepBasic);
---Purpose: Set the ApplicationProtocolDefinition of the PDM schema
GetAP214APD (me: in out) returns ApplicationProtocolDefinition from StepBasic;
---Purpose: Returns the ApplicationProtocolDefinition of the PDM schema
-- NOTE: if not defined then create new APD with new Application Context
fields
myAEIAs : SequenceOfTransient from TColStd; -- StepAP214_AppliedExternalIdentificationAssignment
myRoles : SequenceOfTransient from TColStd; -- StepBasic_RoleAssociation
myFormats: SequenceOfTransient from TColStd; -- StepRepr_PropertyDefinitionRepresentation
myShapes : SequenceOfTransient from TColStd; -- StepBasic_ProductDefinition
myTypes : SequenceOfTransient from TColStd; -- StepBasic_DocumentRepresentationType
myIsAP214: SequenceOfInteger from TColStd;
myReplaceNum : SequenceOfInteger from TColStd;
myDocFiles : SequenceOfTransient from TColStd; -- StepBasic_DocumentFile
mySharedPRPC : ProductRelatedProductCategory from StepBasic; -- shared since AP214
mySharedDocType : DocumentType from StepBasic; -- shared since AP214
mySharedPDC : ProductDefinitionContext from StepBasic; -- shared since AP214
mySharedPC : ProductContext from StepBasic; -- shared since AP214
myAPD : ApplicationProtocolDefinition from StepBasic; -- Application Protocol Definition of PDM schema
end ExternRefs;

View File

@@ -0,0 +1,896 @@
// File: STEPConstruct_ExternRefs.cxx
// Created: Fri Sep 29 16:52:17 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <STEPConstruct_ExternRefs.ixx>
#include <Interface_EntityIterator.hxx>
#include <StepData_SelectNamed.hxx>
#include <StepBasic_RoleAssociation.hxx>
#include <StepBasic_DocumentRepresentationType.hxx>
#include <StepBasic_DocumentRepresentationType.hxx>
#include <StepBasic_DocumentFile.hxx>
#include <StepBasic_ObjectRole.hxx>
#include <StepBasic_SourceItem.hxx>
#include <StepBasic_DocumentType.hxx>
#include <StepBasic_IdentificationRole.hxx>
#include <StepBasic_ExternalSource.hxx>
#include <StepBasic_ExternalSource.hxx>
#include <StepRepr_CharacterizedDefinition.hxx>
#include <StepRepr_PropertyDefinition.hxx>
#include <StepRepr_RepresentationContext.hxx>
#include <StepRepr_DescriptiveRepresentationItem.hxx>
#include <StepRepr_HArray1OfRepresentationItem.hxx>
#include <StepRepr_PropertyDefinitionRepresentation.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepAP214_AppliedDocumentReference.hxx>
#include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
#include <StepAP214_ExternalIdentificationItem.hxx>
#include <StepAP214_HArray1OfExternalIdentificationItem.hxx>
#include <StepAP214_HArray1OfDocumentReferenceItem.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <StepBasic_ProductDefinitionContext.hxx>
#include <StepBasic_ProductDefinitionWithAssociatedDocuments.hxx>
#include <StepBasic_Product.hxx>
#include <StepBasic_HArray1OfDocument.hxx>
#include <StepBasic_HArray1OfProductContext.hxx>
#include <StepBasic_ApplicationContext.hxx>
#include <StepRepr_CharacterizedDefinition.hxx>
#include <StepRepr_RepresentedDefinition.hxx>
#include <TCollection_HAsciiString.hxx>
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepAP203_CcDesignPersonAndOrganizationAssignment.hxx>
#include <StepAP203_HArray1OfPersonOrganizationItem.hxx>
#include <StepAP203_PersonOrganizationItem.hxx>
#include <StepAP203_CcDesignDateAndTimeAssignment.hxx>
#include <StepAP203_HArray1OfDateTimeItem.hxx>
#include <StepAP203_DateTimeItem.hxx>
#include <StepAP203_CcDesignApproval.hxx>
#include <StepAP203_HArray1OfApprovedItem.hxx>
#include <StepAP203_ApprovedItem.hxx>
#include <StepBasic_DocumentProductEquivalence.hxx>
#include <StepBasic_DocumentType.hxx>
#include <StepBasic_HArray1OfProduct.hxx>
#include <StepBasic_Document.hxx>
#include <StepBasic_ProductOrFormationOrDefinition.hxx>
#include <StepBasic_ProductRelatedProductCategory.hxx>
//=======================================================================
//function : STEPConstruct_ExternRefs
//purpose :
//=======================================================================
STEPConstruct_ExternRefs::STEPConstruct_ExternRefs ()
{
}
//=======================================================================
//function : STEPConstruct_ExternRefs
//purpose :
//=======================================================================
STEPConstruct_ExternRefs::STEPConstruct_ExternRefs (const Handle(XSControl_WorkSession) &WS)
: STEPConstruct_Tool ( WS )
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ExternRefs::Init (const Handle(XSControl_WorkSession) &WS)
{
Clear();
return SetWS ( WS );
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void STEPConstruct_ExternRefs::Clear ()
{
myAEIAs.Clear();
myRoles.Clear();
myFormats.Clear();
myShapes.Clear();
myTypes.Clear();
myIsAP214.Clear();
// PTV 30.01.2003 TRJ11
myDocFiles.Clear();
mySharedPRPC.Nullify();
mySharedDocType.Nullify();
mySharedPDC.Nullify();
mySharedPC.Nullify();
myAPD.Nullify();
}
//=======================================================================
//function : LoadExternRefs
//purpose :
//=======================================================================
static Standard_Boolean findPDWADandExcludeExcess (Handle(StepAP214_AppliedDocumentReference)& ADR,
TColStd_SequenceOfTransient& aSeqOfPDWAD,
const Interface_Graph& Graph,
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)& aPDWAD)
{
// WARNING! do not add check for aSeqOfPDWAD.Length() and exit if it < 1,
// because this methods invokes with an empty sequence too to find PDWAD by ADR
Interface_EntityIterator subsADR = Graph.Shareds(ADR);
for ( subsADR.Start(); subsADR.More(); subsADR.Next() ) {
if ( !subsADR.Value()->IsKind (STANDARD_TYPE(StepBasic_Document)) )
continue;
Handle(StepBasic_Document) aDoc = Handle(StepBasic_Document)::DownCast(subsADR.Value());
// looking for Document Product Equivalence
Interface_EntityIterator subsD = Graph.Sharings(aDoc);
for ( subsD.Start(); subsD.More(); subsD.Next() ) {
if ( !subsD.Value()->IsKind (STANDARD_TYPE(StepBasic_DocumentProductEquivalence)) )
continue;
Handle(StepBasic_DocumentProductEquivalence) aDPE =
Handle(StepBasic_DocumentProductEquivalence)::DownCast(subsD.Value());
// take PDF and search the same PDF by PDWAD chain
Interface_EntityIterator subsDPE = Graph.Shareds(aDPE);
for ( subsDPE.Start(); subsDPE.More(); subsDPE.Next() ) {
if ( !subsDPE.Value()->IsKind (STANDARD_TYPE(StepBasic_ProductDefinitionFormation)) )
continue;
Handle(StepBasic_ProductDefinitionFormation) aPDF =
Handle(StepBasic_ProductDefinitionFormation)::DownCast(subsDPE.Value());
Interface_EntityIterator subs = Graph.Sharings(aPDF);
for ( subs.Start(); subs.More(); subs.Next() ) {
if ( !subs.Value()->IsKind (STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments)) )
continue;
aPDWAD = Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(subs.Value());
}
// now searching for PDWAD that refer to the same PDF
for (Standard_Integer pdwadi = 1; pdwadi <= aSeqOfPDWAD.Length(); pdwadi++) {
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aCurPDWAD =
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(aSeqOfPDWAD(pdwadi));
if ( !aCurPDWAD.IsNull() && aPDWAD == aCurPDWAD ) {
// found the same Product Definition Formation
aSeqOfPDWAD.Remove( pdwadi );
return Standard_True;
}
}
} // end of looking for PDF by ADR chain
} // end of looking for DPE
} // end iterations on Shareds(ADR)
return Standard_False;
}
Standard_Boolean STEPConstruct_ExternRefs::LoadExternRefs ()
{
// iterate on entities in the model and find AEIAs
// or PDWADs (for AP203)
Handle(Interface_InterfaceModel) model = Model();
Handle(Standard_Type) tADR = STANDARD_TYPE(StepAP214_AppliedDocumentReference);
Handle(Standard_Type) tPDWAD = STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments);
Standard_Integer nb = model->NbEntities();
// PTV 28.01.2003 CAX-IF TRJ11, file ext_ref_master.stp
// search all ADR and PDWAD and exclude excess PDWADs
TColStd_SequenceOfTransient aSeqOfADR, aSeqOfPDWAD;
for (Standard_Integer ient = 1; ient <= nb; ient ++) {
Handle(Standard_Transient) enti = model->Value(ient);
if ( enti->DynamicType() == tPDWAD )
aSeqOfPDWAD.Append( enti );
else if ( enti->DynamicType() == tADR )
aSeqOfADR.Append( enti );
}
Standard_Integer IsAP214 = 0;
// run on sequence aSeqOfADR of ADR and remove excess PDWAD from aSeqOfPDWAD
for (Standard_Integer adri = 1; adri <= aSeqOfADR.Length(); adri++) {
Handle(StepAP214_AppliedDocumentReference) ADR =
Handle(StepAP214_AppliedDocumentReference)::DownCast(aSeqOfADR.Value(adri));
// looking for Product Definition Formation and exlude excess PDWAD from aSeqOfPDWAD
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD;
findPDWADandExcludeExcess( ADR, aSeqOfPDWAD, Graph(), aPDWAD );
// now add all necessary information as original implementation.
IsAP214 = 1;
Handle(StepBasic_RoleAssociation) Role;
Handle(StepBasic_ProductDefinition) Shape;
Handle(StepRepr_PropertyDefinitionRepresentation) Format;
Handle(StepBasic_DocumentRepresentationType) Type;
// AppliedDocumentReference with RoleAssociation...
Interface_EntityIterator subs4 = Graph().Sharings(ADR);
for (subs4.Start(); subs4.More(); subs4.Next()) {
if ( subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_RoleAssociation) ) )
Role = Handle(StepBasic_RoleAssociation)::DownCast(subs4.Value());
}
subs4 = Graph().Shareds(ADR);
for (subs4.Start(); subs4.More(); subs4.Next()) {
if ( subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_ProductDefinition) ) )
Shape = Handle(StepBasic_ProductDefinition)::DownCast(subs4.Value());
}
// search for Document file
Handle(StepBasic_DocumentFile) DocFile;
if ( aPDWAD.IsNull() ) { // shoudnot be begin from TRJ11
// #ifdef DEB
// cout << "Warning: Cannot find PDWAD corresponding to ADR to search Document File. " << endl;
// cout << "Info: Looking for Document File direct from ARD" << endl;
// #endif
// lookinf from ADR
subs4 = Graph().Shareds(ADR);
} else
// looking from PDWAD
subs4 = Graph().Shareds(aPDWAD);
for (subs4.Start(); subs4.More(); subs4.Next()) {
if ( !subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_DocumentFile) ) )
continue;
DocFile = Handle(StepBasic_DocumentFile)::DownCast(subs4.Value());
if ( DocFile.IsNull() )
continue;
// for each DocumentFile, find associated with it data:
Interface_EntityIterator subs = Graph().Sharings(DocFile);
for (subs.Start(); subs.More(); subs.Next()) {
Handle(Standard_Transient) sub = subs.Value();
// FORMAT - ???????
//
// PDRs of a shape and of a file format
if ( sub->IsKind ( STANDARD_TYPE(StepRepr_PropertyDefinition) ) ) {
Handle(StepRepr_PropertyDefinition) PD = Handle(StepRepr_PropertyDefinition)::DownCast(sub);
Interface_EntityIterator subs2 = Graph().Sharings(PD);
for (subs2.Start(); subs2.More(); subs2.Next()) {
Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast(subs2.Value());
if ( PDR.IsNull() ) continue;
if ( PDR->UsedRepresentation()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation)) )
Format = PDR;
}
}
// DocumentRepresentationType
if ( sub->IsKind ( STANDARD_TYPE(StepBasic_DocumentRepresentationType) ) ) {
Type = Handle(StepBasic_DocumentRepresentationType)::DownCast(sub);
}
if ( !Type.IsNull() && !Format.IsNull() )
break;
}
if ( !Type.IsNull() && !Format.IsNull() )
break;
}
if ( DocFile.IsNull() )
continue;
myAEIAs.Append ( ADR );
myRoles.Append ( Role );
myFormats.Append ( Format );
myShapes.Append ( Shape );
myTypes.Append ( Type );
myIsAP214.Append ( IsAP214 );
myDocFiles.Append( DocFile );
} // end iterations on aSeqOfADR
// now iterates on sequence aSeqOfPDWAD of Product Definition With Associated Documents
for (Standard_Integer pdwadi = 1; pdwadi <= aSeqOfPDWAD.Length(); pdwadi++) {
IsAP214 = 0;
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD =
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(aSeqOfPDWAD(pdwadi));
myShapes.Append(aPDWAD);
myIsAP214.Append ( IsAP214 );
Handle(StepAP214_AppliedExternalIdentificationAssignment) AEIA;
Handle(StepBasic_RoleAssociation) Role;
Handle(StepRepr_PropertyDefinitionRepresentation) Format;
Handle(StepBasic_DocumentRepresentationType) Type;
Handle(StepBasic_DocumentFile) DocFile;
myAEIAs.Append ( AEIA );
myRoles.Append ( Role );
myFormats.Append ( Format );
myTypes.Append ( Type );
myDocFiles.Append( DocFile );
}
return myShapes.Length() >0;
}
//=======================================================================
//function : NbExternRefs
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ExternRefs::NbExternRefs () const
{
return myShapes.Length();
}
//=======================================================================
//function : FileName
//purpose :
//=======================================================================
const Standard_CString STEPConstruct_ExternRefs::FileName (const Standard_Integer num) const
{
Handle(StepBasic_DocumentFile) DocFile;
Handle(StepAP214_AppliedExternalIdentificationAssignment) AEIA;
Standard_CString aCStringFileName = 0;
if ( myDocFiles.Length() >= num && !myDocFiles.Value(num).IsNull() )
DocFile = Handle(StepBasic_DocumentFile)::DownCast(myDocFiles.Value( num ));
else if (myIsAP214(num)==1)
{
Handle(StepAP214_AppliedDocumentReference) ADR =
Handle(StepAP214_AppliedDocumentReference)::DownCast ( myAEIAs(num) );
// PTV 28.01.2003 CAX-IF TRJ11, file ext_ref_master.stp
// serach document file name by long chain ADR->D<-DPE->PDF<-PDWAD->DF
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD;
// create an empty aSeqOfPDWAD
TColStd_SequenceOfTransient aSeqOfPDWAD;
// we do not need to exclude, just find PDWAD
findPDWADandExcludeExcess( ADR, aSeqOfPDWAD, Graph(), aPDWAD );
// search for Document file
Interface_EntityIterator subs4;
if ( aPDWAD.IsNull() ) { // shoudnot be begin from TRJ11
// #ifdef DEB
// cout << "Warning: Cannot find PDWAD corresponding to ADR to search Document File. " << endl;
// cout << "Info: Looking for DocumentFile direct from ARD" << endl;
// #endif
// lookinf from ADR
subs4 = Graph().Shareds(ADR);
} else
// looking from PDWAD
subs4 = Graph().Shareds(aPDWAD);
for (subs4.Start(); subs4.More(); subs4.Next()) {
if ( !subs4.Value()->IsKind ( STANDARD_TYPE(StepBasic_DocumentFile) ) )
continue;
DocFile = Handle(StepBasic_DocumentFile)::DownCast(subs4.Value());
if ( DocFile.IsNull() ) continue;
}
}
else {
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) aPDWAD =
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(myShapes(num));
if ( aPDWAD.IsNull() || aPDWAD->DocIds().IsNull() )
return "";
Standard_Integer i;
for ( i=1; i <= aPDWAD->NbDocIds(); i++ ) {
Handle(StepBasic_Document) Doc = aPDWAD->DocIdsValue(i);
Handle(TCollection_HAsciiString) aFilename = Doc->Name();
if (!aFilename.IsNull() && !aFilename->IsEmpty()) return aFilename->ToCString();
}
return "";
}
// take name from AEIA and from DF
if(!DocFile.IsNull()) {
Interface_EntityIterator subs3 = Graph().Sharings(DocFile);
for (subs3.Start(); subs3.More(); subs3.Next()) {
if (subs3.Value()->IsKind(STANDARD_TYPE(StepAP214_AppliedExternalIdentificationAssignment))) {
AEIA = Handle(StepAP214_AppliedExternalIdentificationAssignment)::DownCast(subs3.Value());
if (!AEIA.IsNull())
break;
}
}
}
if(!AEIA.IsNull()) {
Handle(TCollection_HAsciiString) aFilename;
aFilename = AEIA->AssignedId();
if (!aFilename.IsNull() && !aFilename->IsEmpty()) {
aCStringFileName = aFilename->ToCString();
// ptv 29.01.2003 file trj4_xr1-tc-214.stp entity #71 have id "#71"
if ( aCStringFileName && aCStringFileName[0] == '#')
aCStringFileName = 0;
}
if ( ! aCStringFileName || ! aCStringFileName[0] ) {
// try to take name from external source
Handle(StepBasic_ExternalSource) theSource = AEIA->Source();
if (!theSource.IsNull()) {
StepBasic_SourceItem theSourceId = theSource->SourceId();
if (!theSourceId.IsNull()) {
Handle(StepData_SelectNamed) theFileName;
theFileName = Handle(StepData_SelectNamed)::DownCast (theSourceId.Value());
if (theFileName.IsNull() || theFileName->Kind()!=6 ) {
// nothing to do, hope could take name later.
}
else
aCStringFileName = theFileName->String();
}
}
}
}
if ( ! aCStringFileName || ! aCStringFileName[0] ) {
// try to find name direct from DocFile
if ( !DocFile.IsNull() ) {
Handle(TCollection_HAsciiString) aFilename = DocFile->Id();
if (!aFilename.IsNull() && !aFilename->IsEmpty())
aCStringFileName = aFilename->ToCString();
if ( ! aCStringFileName || ! aCStringFileName[0] ) {
aFilename = DocFile->Name();
if (!aFilename.IsNull() && !aFilename->IsEmpty())
aCStringFileName = aFilename->ToCString();
}
if ( ! aCStringFileName || ! aCStringFileName[0] ) {
return "";
}
else
return aCStringFileName;
}
}
return aCStringFileName;
}
//=======================================================================
//function : ProdDef
//purpose :
//=======================================================================
Handle(StepBasic_ProductDefinition) STEPConstruct_ExternRefs::ProdDef (const Standard_Integer num) const
{
return Handle(StepBasic_ProductDefinition)::DownCast( myShapes(num) );
}
//=======================================================================
//function : Format
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_ExternRefs::Format (const Standard_Integer num) const
{
Handle(TCollection_HAsciiString) Format;
if (myIsAP214(num)==0) return Format;
Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( myFormats(num) );
if (PDR.IsNull()) return Format;
Handle(StepRepr_Representation) rep = PDR->UsedRepresentation();
for ( Standard_Integer i=1; i <= rep->NbItems(); i++ ) {
if ( rep->ItemsValue(i)->IsKind ( STANDARD_TYPE(StepRepr_DescriptiveRepresentationItem) ) ) {
Handle(StepRepr_DescriptiveRepresentationItem) DRI =
Handle(StepRepr_DescriptiveRepresentationItem)::DownCast ( rep->ItemsValue(i) );
Format = DRI->Description();
break;
}
}
return Format;
}
//=======================================================================
//function : AddExternRef
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ExternRefs::AddExternRef (const Standard_CString filename,
const Handle(StepBasic_ProductDefinition) &PD,
const Standard_CString format)
{
Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) fmt = new TCollection_HAsciiString(format);
Handle(TCollection_HAsciiString) tmp = new TCollection_HAsciiString("203");
Standard_Integer np = fmt->Location(tmp,1,fmt->Length());
// if( !(fmt==tmp) ) {
if( !(np>0) ) {
// create core entity DocumentFile
Handle(StepBasic_DocumentType) DT = new StepBasic_DocumentType;
DT->Init(EmptyString);
Handle(TCollection_HAsciiString) DFid = new TCollection_HAsciiString(filename);
// PTV 30.01.2003 TRJ11 - copy external filename as is
// DFid->AssignCat ( " file id" );
Handle(StepBasic_DocumentFile) DF = new StepBasic_DocumentFile;
DF->Init(DFid, EmptyString, Standard_False, EmptyString, DT, EmptyString, Standard_False, EmptyString);
// create AppliedExternalIdentificationAssignment et al
Handle(StepBasic_IdentificationRole) IR = new StepBasic_IdentificationRole;
// PTV 30.01.2003 TRJ11
// - set the ("external document id and location", $) without unmeaning description
Handle(TCollection_HAsciiString) aName =
new TCollection_HAsciiString("external document id and location");
IR->SetName( aName );
// Handle(TCollection_HAsciiString) aIRdescr = new TCollection_HAsciiString("source system");
// IR->Init(aName, Standard_True, aIRdescr);
Handle(StepData_SelectNamed) SDS = new StepData_SelectNamed;
SDS->SetString ( filename );
SDS->SetName("IDENTIFIER");
StepBasic_SourceItem SID;
SID.SetValue(SDS);
Handle(StepBasic_ExternalSource) ES = new StepBasic_ExternalSource;
ES->Init(SID);
StepAP214_ExternalIdentificationItem Item;
Item.SetValue(DF);
Handle(StepAP214_HArray1OfExternalIdentificationItem) Items =
new StepAP214_HArray1OfExternalIdentificationItem(1,1);
Items->SetValue(1, Item);
Handle(StepAP214_AppliedExternalIdentificationAssignment) ExtIdent =
new StepAP214_AppliedExternalIdentificationAssignment;
// ExtIdent->Init(EmptyString, IR, ES, Items);
// PTV 30.01.2003 TRJ11 - store filename in AEIA
Handle(TCollection_HAsciiString) aFName = new TCollection_HAsciiString(filename);
ExtIdent->Init(aFName, IR, ES, Items);
// create DocumentRepresentationType
Handle(TCollection_HAsciiString) Dig = new TCollection_HAsciiString("digital");
Handle(StepBasic_DocumentRepresentationType) Type = new StepBasic_DocumentRepresentationType;
Type->Init(Dig, DF);
// create AppliedDocumentReference,
Handle(StepAP214_AppliedDocumentReference) ADR = new StepAP214_AppliedDocumentReference;
// PTV 30.01.2003 TRJ11 - create additional entities for AP214
addAP214ExterRef( ADR, PD, DF, filename );
// create RoleAssociation etc.
Handle(StepBasic_ObjectRole) OR = new StepBasic_ObjectRole;
Handle(TCollection_HAsciiString) mandatory = new TCollection_HAsciiString("mandatory");
OR->Init(mandatory, Standard_False, EmptyString);
StepBasic_RoleSelect RS;
RS.SetValue(ADR);
Handle(StepBasic_RoleAssociation) Role = new StepBasic_RoleAssociation;
Role->Init(OR, RS);
// create PDR for association with SR
StepRepr_CharacterizedDefinition CD;
CD.SetValue(DF);
Handle(TCollection_HAsciiString) PDname = new TCollection_HAsciiString("external definition");
Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
PropD->Init(PDname, Standard_True, EmptyString, CD);
StepRepr_RepresentedDefinition RD;
RD.SetValue(PropD);
// Handle(StepRepr_PropertyDefinitionRepresentation) PDRshape = new StepRepr_PropertyDefinitionRepresentation;
// PDRshape->Init ( RD, SDR->UsedRepresentation() );
// create PDR for definition of document format (if defined)
Handle(StepRepr_PropertyDefinitionRepresentation) PDRformat;
if ( format && format[0] ) {
Handle(TCollection_HAsciiString) RCftype = new TCollection_HAsciiString ( "document parameters" );
Handle(StepRepr_RepresentationContext) RCf = new StepRepr_RepresentationContext;
RCf->Init ( EmptyString, RCftype );
Handle(TCollection_HAsciiString) DRIname = new TCollection_HAsciiString ( "data format" );
Handle(TCollection_HAsciiString) DRIdscr = new TCollection_HAsciiString ( format );
Handle(StepRepr_DescriptiveRepresentationItem) DRI = new StepRepr_DescriptiveRepresentationItem;
DRI->Init ( DRIname, DRIdscr );
Handle(StepRepr_HArray1OfRepresentationItem) fItems = new StepRepr_HArray1OfRepresentationItem(1,1);
fItems->SetValue ( 1, DRI );
Handle(TCollection_HAsciiString) SRfname = new TCollection_HAsciiString ( "document format" );
Handle(StepRepr_Representation) SRformat = new StepRepr_Representation;
SRformat->Init(SRfname, fItems, RCf);
StepRepr_CharacterizedDefinition CDf;
CDf.SetValue(DF);
Handle(TCollection_HAsciiString) PDfname = new TCollection_HAsciiString("document property");
Handle(StepRepr_PropertyDefinition) PDf = new StepRepr_PropertyDefinition;
PDf->Init(PDfname, Standard_True, EmptyString, CDf);
StepRepr_RepresentedDefinition RDf;
RDf.SetValue(PDf);
PDRformat = new StepRepr_PropertyDefinitionRepresentation;
PDRformat->Init ( RDf, SRformat );
}
// add all the created root entities to sequences
myAEIAs.Append ( ExtIdent ); //StepAP214_AppliedExternalIdentificationAssignment
myRoles.Append ( Role ); //StepBasic_RoleAssociation
myFormats.Append ( PDRformat ); //StepRepr_PropertyDefinitionRepresentation
// myShapes.Append ( PDRshape ); //StepRepr_PropertyDefinitionRepresentation
myShapes.Append ( PD ); //StepBasic_ProductDefinition
myTypes.Append ( Type ); //StepBasic_DocumentRepresentationType
}
else { // format=="AP203"
// StepRepr_RepresentedDefinition aRD = SDR->Definition();
// Handle(StepRepr_PropertyDefinition) aPD = aRD.PropertyDefinition();
// StepRepr_CharacterizedDefinition aCD = aPD->Definition();
// Handle(StepBasic_ProductDefinition) aProdDef = aCD.ProductDefinition();
Handle(StepBasic_ProductDefinitionFormation) ProdDefForm = PD->Formation();
Handle(StepBasic_ProductDefinitionContext) ProdDefCont = PD->FrameOfReference();
// create document
Handle(TCollection_HAsciiString) fname = new TCollection_HAsciiString(filename);
Handle(StepBasic_DocumentType) aDocType = new StepBasic_DocumentType;
Handle(TCollection_HAsciiString) aDT = new TCollection_HAsciiString("cad_filename");
aDocType->Init(aDT);
Handle(StepBasic_Document) aDoc = new StepBasic_Document;
Handle(TCollection_HAsciiString) aDescription =
new TCollection_HAsciiString("CAD Model associated to the part");
aDoc->Init(EmptyString,fname,Standard_True,aDescription,aDocType);
Handle(StepBasic_HArray1OfDocument) aDocIds = new StepBasic_HArray1OfDocument(1,1);
aDocIds->SetValue(1,aDoc);
// create ProductDefinitionWithAssociatedDocuments
aDescription = PD->Description();
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
new StepBasic_ProductDefinitionWithAssociatedDocuments;
PDWAD->Init(EmptyString,aDescription,ProdDefForm,ProdDefCont,aDocIds);
//Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
// Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(PD);
// searh in graph for replace
// Standard_Integer numProdDef;
// Interface_EntityIterator subs = Graph().Shareds(SDR);
// for (subs.Start(); subs.More(); subs.Next()) {
// Handle(Standard_Transient) sub = subs.Value();
Interface_EntityIterator subs = Graph().Sharings(PD);
for (subs.Start(); subs.More(); subs.Next()) {
Handle(Standard_Transient) sub = subs.Value();
if (!sub->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape))) continue;
Handle(StepRepr_ProductDefinitionShape) ProdDefSh =
Handle(StepRepr_ProductDefinitionShape)::DownCast ( sub );
if(ProdDefSh.IsNull()) continue;
StepRepr_CharacterizedDefinition CDf;
CDf.SetValue(PDWAD);
ProdDefSh->SetDefinition(CDf);
}
// Interface_EntityIterator subs1 = Graph().Shareds(ProdDefSh);
// for (subs1.Start(); subs1.More(); subs1.Next()) {
// Handle(Standard_Transient) sub1 = subs1.Value();
// if (!sub1->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) continue;
// Handle(StepBasic_ProductDefinition) ProdDef =
// Handle(StepBasic_ProductDefinition)::DownCast ( sub1 );
// numProdDef = Model()->Number(ProdDef);
Standard_Integer numProdDef = Model()->Number(PD);
// Interface_EntityIterator subs2 = Graph().Sharings(ProdDef);
Interface_EntityIterator subs2 = Graph().Sharings(PD);
for (subs2.Start(); subs2.More(); subs2.Next()) {
Handle(Standard_Transient) sub2 = subs2.Value();
if (sub2->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) {
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast ( sub2 );
NAUO->SetRelatedProductDefinition(PDWAD);
}
if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignPersonAndOrganizationAssignment))) {
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment) CDPAOA =
Handle(StepAP203_CcDesignPersonAndOrganizationAssignment)::DownCast ( sub2 );
Handle(StepAP203_HArray1OfPersonOrganizationItem) HAPOI = CDPAOA->Items();
for(Standard_Integer i=1; i<=HAPOI->Length(); i++) {
StepAP203_PersonOrganizationItem POI = HAPOI->Value(i);
Handle(StepBasic_ProductDefinition) PDtmp = POI.ProductDefinition();
Standard_Integer numPDtmp = Model()->Number(PDtmp);
if(numProdDef==numPDtmp) {
POI.SetValue(PDWAD);
HAPOI->SetValue(i,POI);
}
}
}
if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignDateAndTimeAssignment))) {
Handle(StepAP203_CcDesignDateAndTimeAssignment) CDDATA =
Handle(StepAP203_CcDesignDateAndTimeAssignment)::DownCast ( sub2 );
Handle(StepAP203_HArray1OfDateTimeItem) HADTI = CDDATA->Items();
for(Standard_Integer i=1; i<=HADTI->Length(); i++) {
StepAP203_DateTimeItem DTI = HADTI->Value(i);
Handle(StepBasic_ProductDefinition) PDtmp = DTI.ProductDefinition();
Standard_Integer numPDtmp = Model()->Number(PDtmp);
if(numProdDef==numPDtmp) {
DTI.SetValue(PDWAD);
HADTI->SetValue(i,DTI);
}
}
}
if (sub2->IsKind(STANDARD_TYPE(StepAP203_CcDesignApproval))) {
Handle(StepAP203_CcDesignApproval) CDA =
Handle(StepAP203_CcDesignApproval)::DownCast ( sub2 );
Handle(StepAP203_HArray1OfApprovedItem) HAAI = CDA->Items();
for(Standard_Integer i=1; i<=HAAI->Length(); i++) {
StepAP203_ApprovedItem AI = HAAI->Value(i);
Handle(StepBasic_ProductDefinition) PDtmp = AI.ProductDefinition();
Standard_Integer numPDtmp = Model()->Number(PDtmp);
if(numProdDef==numPDtmp) {
AI.SetValue(PDWAD);
HAAI->SetValue(i,AI);
}
}
}
}
// }
//
// StepRepr_CharacterizedDefinition ChartDef;
// ChartDef.SetValue(PDWAD);
// ProdDefSh->SetDefinition(ChartDef);
// }
myAEIAs.Append ( PDWAD );
myReplaceNum.Append(numProdDef);
myRoles.Append ( aDoc );
myTypes.Append ( aDocType );
}
return myAEIAs.Length();
}
//=======================================================================
//function : WriteExternRefs
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_ExternRefs::WriteExternRefs (const Standard_Integer num) const
{
if(num==3) {
for ( Standard_Integer i=1; i <= myAEIAs.Length(); i++ ) {
Model()->ReplaceEntity(myReplaceNum(i),myAEIAs(i));
if ( ! myRoles(i).IsNull() )
Model()->AddWithRefs ( myRoles(i) );
if ( ! myTypes(i).IsNull() )
Model()->AddWithRefs ( myTypes(i) );
}
}
else {
for ( Standard_Integer i=1; i <= myAEIAs.Length(); i++ ) {
Model()->AddWithRefs ( myAEIAs(i) );
if ( ! myRoles(i).IsNull() )
Model()->AddWithRefs ( myRoles(i) );
if ( ! myFormats(i).IsNull() )
Model()->AddWithRefs ( myFormats(i) );
if ( ! myShapes(i).IsNull() )
Model()->AddWithRefs ( myShapes(i) );
if ( ! myTypes(i).IsNull() )
Model()->AddWithRefs ( myTypes(i) );
}
}
// PTV 30.01.2003 TRJ11
if ( !myAPD.IsNull() )
Model()->AddWithRefs( myAPD );
if ( !mySharedPRPC.IsNull() )
Model()->AddWithRefs( mySharedPRPC );
return myAEIAs.Length();
}
//=======================================================================
//function : addAP214ExterRef
//purpose : PTV 30.01.2003 TRJ11
//=======================================================================
Standard_Boolean STEPConstruct_ExternRefs::addAP214ExterRef (const Handle(StepAP214_AppliedDocumentReference)& ADR,
const Handle(StepBasic_ProductDefinition)& PD,
const Handle(StepBasic_DocumentFile)& DF,
const Standard_CString filename )
{
Handle(StepAP214_HArray1OfDocumentReferenceItem) DRIs = new StepAP214_HArray1OfDocumentReferenceItem(1,1);
StepAP214_DocumentReferenceItem aDRI;
aDRI.SetValue(PD);
DRIs->SetValue(1, aDRI);
Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
// create/get created shared entities:
// DocumentType, ProductDefinitionContext, ProductRelatedProductCategory, ProductContext
checkAP214Shared();
// create document
Handle(StepBasic_Document) aDocument = new StepBasic_Document;
aDocument->Init( EmptyString, EmptyString, Standard_False, EmptyString, mySharedDocType );
ADR->Init(aDocument, EmptyString, DRIs);
// create new product
Handle(StepBasic_Product) Product = new StepBasic_Product;
Handle(StepBasic_HArray1OfProduct) HProducts = mySharedPRPC->Products();
Standard_Integer nbProducts = 0;
if (!HProducts.IsNull())
nbProducts = HProducts->Length();
Standard_Integer intProdId = 20001 + nbProducts;
Handle(TCollection_HAsciiString) ProductID = new TCollection_HAsciiString( intProdId );
Handle(TCollection_HAsciiString) ProductName = new TCollection_HAsciiString(filename);
ProductName->AssignCat( "-Doc" );
Handle(StepBasic_HArray1OfProductContext) aHProdContext = new StepBasic_HArray1OfProductContext(1, 1);
aHProdContext->SetValue( 1, mySharedPC );
Product->Init( ProductID, ProductName, EmptyString, aHProdContext );
// create new product definition formation
Handle(StepBasic_ProductDefinitionFormation) PDF = new StepBasic_ProductDefinitionFormation;
// name id taked from exapmle Standard_ExtString_ref_master.stp
Handle(TCollection_HAsciiString) PDF_ID = new TCollection_HAsciiString("1");
PDF->Init( PDF_ID, EmptyString, Product );
Handle(StepBasic_DocumentProductEquivalence) DPE = new StepBasic_DocumentProductEquivalence;
Handle(TCollection_HAsciiString) DPEname = new TCollection_HAsciiString("equivalence");
StepBasic_ProductOrFormationOrDefinition aPOFOD;
aPOFOD.SetValue( PDF );
DPE->Init( DPEname, Standard_False, EmptyString, aDocument, aPOFOD );
// add to the model with references
Model()->AddWithRefs( DPE );
// add products to shared PRPC
Handle(StepBasic_HArray1OfProduct) newHProducts = new StepBasic_HArray1OfProduct(1, nbProducts + 1);
for (Standard_Integer pi = 1; pi <= nbProducts; pi++)
newHProducts->SetValue( pi, HProducts->Value( pi ) );
newHProducts->SetValue( nbProducts + 1, Product );
// set the hArray to the PRPC
mySharedPRPC->SetProducts( newHProducts );
// create new PDWAD
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
new StepBasic_ProductDefinitionWithAssociatedDocuments;
Handle(StepBasic_HArray1OfDocument) aDocIds = new StepBasic_HArray1OfDocument(1,1);
aDocIds->SetValue( 1, DF );
Handle(TCollection_HAsciiString) PDWAD_ID = new TCollection_HAsciiString("1");
PDWAD->Init( PDWAD_ID, EmptyString, PDF, mySharedPDC, aDocIds );
// add to the model with references
Model()->AddWithRefs( PDWAD );
return Standard_True;
}
//=======================================================================
//function : SetAP214APD
//purpose :
//=======================================================================
void STEPConstruct_ExternRefs::SetAP214APD (const Handle(StepBasic_ApplicationProtocolDefinition)& APD)
{
myAPD = APD;
}
//=======================================================================
//function : GetAP214APD
//purpose :
//=======================================================================
Handle(StepBasic_ApplicationProtocolDefinition) STEPConstruct_ExternRefs::GetAP214APD()
{
if (myAPD.IsNull()) {
// create new APD with new Application Context
myAPD = new StepBasic_ApplicationProtocolDefinition;
// examples of the values taken from ext_ref_master.stp
Handle(TCollection_HAsciiString) status =
new TCollection_HAsciiString("version 1.1");
Handle(TCollection_HAsciiString) appSchemaName =
new TCollection_HAsciiString("pdm_schema");
Standard_Integer intProtocolYear = 1999;
Handle(StepBasic_ApplicationContext) aApplication = new StepBasic_ApplicationContext;
Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
aApplication->Init( EmptyString );
myAPD->Init( status, appSchemaName, intProtocolYear, aApplication );
}
return myAPD;
}
void STEPConstruct_ExternRefs::checkAP214Shared ()
{
Handle(TCollection_HAsciiString) EmptyString = new TCollection_HAsciiString("");
if ( mySharedPRPC.IsNull() ) {
// create new ProductRelatedProductCategory for all extern files.
Handle(TCollection_HAsciiString) PRPCname = new TCollection_HAsciiString("document");
mySharedPRPC = new StepBasic_ProductRelatedProductCategory;
mySharedPRPC->Init( PRPCname, Standard_False, EmptyString );
}
if ( mySharedDocType.IsNull() ) {
// create new shared Document Type
mySharedDocType = new StepBasic_DocumentType;
Handle(TCollection_HAsciiString) prod_dat_type =
new TCollection_HAsciiString("configuration controlled document version");
mySharedDocType->Init( prod_dat_type );
}
if ( mySharedPDC.IsNull() ) {
// create new shared Product Definition Context
mySharedPDC = new StepBasic_ProductDefinitionContext;
Handle(TCollection_HAsciiString) aPDCname =
new TCollection_HAsciiString("digital document definition");
Handle(StepBasic_ApplicationContext) anAppContext = GetAP214APD()->Application();
mySharedPDC->Init( aPDCname, anAppContext, EmptyString );
}
if ( mySharedPC.IsNull() ) {
// create new shared ProductContext
mySharedPC = new StepBasic_ProductContext;
Handle(StepBasic_ApplicationContext) anAppContext = GetAP214APD()->Application();
mySharedPC->Init( EmptyString, anAppContext, EmptyString );
}
}

View File

@@ -0,0 +1,98 @@
-- File: STEPConstruct_Part.cdl
-- Created: Wed Aug 4 09:42:53 1993
-- Author: Herve LEGRAND
-- <hl@ecolox>
---Copyright: Matra Datavision 1993
class Part from STEPConstruct
---Purpose: Provides tools for creating STEP structures associated
-- with part (SDR), such as PRODUCT, PDF etc., as requied
-- by current schema
-- Also allows to investigate and modify this data
uses
HAsciiString from TCollection,
ShapeRepresentation from StepShape,
ShapeDefinitionRepresentation from StepShape,
ApplicationContext from StepBasic,
ProductContext from StepBasic,
ApplicationContext from StepBasic,
ProductDefinitionContext from StepBasic,
Product from StepBasic,
ProductDefinitionFormation from StepBasic,
ProductDefinition from StepBasic,
ProductDefinitionShape from StepRepr,
ProductRelatedProductCategory from StepBasic
is
Create returns Part;
MakeSDR (me : in out; aShape: ShapeRepresentation from StepShape;
aName : HAsciiString from TCollection;
AC : ApplicationContext from StepBasic);
ReadSDR (me : in out; aShape: ShapeDefinitionRepresentation from StepShape);
IsDone (me) returns Boolean;
SDRValue (me) returns ShapeDefinitionRepresentation from StepShape;
---Purpose: Returns SDR or Null if not done
SRValue (me) returns ShapeRepresentation from StepShape;
---Purpose: Returns SDR->UsedRepresentation() or Null if not done
PC (me) returns ProductContext from StepBasic;
PCname (me) returns HAsciiString from TCollection;
PCdisciplineType (me) returns HAsciiString from TCollection;
SetPCname (me: in out; name : HAsciiString from TCollection);
SetPCdisciplineType(me: in out; label : HAsciiString from TCollection);
AC (me) returns ApplicationContext from StepBasic;
ACapplication (me) returns HAsciiString from TCollection;
SetACapplication (me: in out; text : HAsciiString from TCollection);
PDC (me) returns ProductDefinitionContext from StepBasic;
PDCname (me) returns HAsciiString from TCollection;
PDCstage (me) returns HAsciiString from TCollection;
SetPDCname (me: in out; label : HAsciiString from TCollection);
SetPDCstage (me: in out; label : HAsciiString from TCollection);
Product (me) returns Product from StepBasic;
Pid (me) returns HAsciiString from TCollection;
Pname (me) returns HAsciiString from TCollection;
Pdescription (me) returns HAsciiString from TCollection;
SetPid (me: in out; id : HAsciiString from TCollection);
SetPname (me: in out; label : HAsciiString from TCollection);
SetPdescription (me: in out; text : HAsciiString from TCollection);
PDF (me) returns ProductDefinitionFormation from StepBasic;
PDFid (me) returns HAsciiString from TCollection;
PDFdescription (me) returns HAsciiString from TCollection;
SetPDFid (me: in out; id : HAsciiString from TCollection);
SetPDFdescription (me: in out; text : HAsciiString from TCollection);
PD (me) returns ProductDefinition from StepBasic;
PDdescription (me) returns HAsciiString from TCollection;
SetPDdescription (me: in out; text : HAsciiString from TCollection);
PDS (me) returns ProductDefinitionShape from StepRepr;
PDSname (me) returns HAsciiString from TCollection;
PDSdescription (me) returns HAsciiString from TCollection;
SetPDSname (me: in out; label : HAsciiString from TCollection);
SetPDSdescription (me: in out; text : HAsciiString from TCollection);
PRPC (me) returns ProductRelatedProductCategory from StepBasic;
PRPCname (me) returns HAsciiString from TCollection;
PRPCdescription (me) returns HAsciiString from TCollection;
SetPRPCname (me: in out; label : HAsciiString from TCollection);
SetPRPCdescription (me: in out; text : HAsciiString from TCollection);
fields
myDone: Boolean;
mySDR : ShapeDefinitionRepresentation from StepShape;
myPRPC: ProductRelatedProductCategory from StepBasic;
end Part;

View File

@@ -0,0 +1,684 @@
//:k8 abv 6 Jan 99: unique names for PRODUCT_DEFINITION_FORMATIONs
//:k9 abv 6 Jan 99: TR10: eliminating duplicated APPLICATION_CONTEXT entities
//:j4 gka 16.03.99 S4134
// abv 20.11.99 renamed from StepPDR_SDRtool
#include <STEPConstruct_Part.ixx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Static.hxx>
#include <StepBasic_ProductDefinition.hxx>
#include <StepBasic_ProductDefinitionContext.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <StepBasic_ProductDefinitionFormationWithSpecifiedSource.hxx>
#include <StepBasic_Product.hxx>
#include <StepBasic_DesignContext.hxx>
#include <StepBasic_ProductContext.hxx>
#include <StepBasic_MechanicalContext.hxx>
#include <StepBasic_HArray1OfProductContext.hxx>
#include <StepBasic_ApplicationContext.hxx>
#include <StepBasic_ProductType.hxx>
#include <StepBasic_HArray1OfProduct.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
// ------------------------------
// Modification a faire :
// ApplicationProtocolDefinition status
// ApplicationProtocolDefinition year
// ApplicationProtocolDefinition schema_name
// ces information ne sont plus accessibles en parcourant le graphe a partir
// du ShapeDefinitionRepresentation.
// Elles se trouvent dans Cc1 au niveau d`une entite racine !
// ------------------------------
//=======================================================================
//function : STEPConstruct_Part
//purpose :
//=======================================================================
STEPConstruct_Part::STEPConstruct_Part()
{
myDone = Standard_False;
}
//=======================================================================
//function : MakeSDR
//purpose :
//=======================================================================
void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR,
const Handle(TCollection_HAsciiString)& aName,
const Handle(StepBasic_ApplicationContext)& AC)
{
// get current schema
Standard_Integer schema = Interface_Static::IVal("write.step.schema");
// create PC
Handle(StepBasic_ProductContext) PC;
switch (schema) {
default :
case 1: PC = new StepBasic_MechanicalContext;
break;
case 4:
case 2: PC = new StepBasic_ProductContext;
break;
case 3: PC = new StepBasic_MechanicalContext;
break;
}
Handle(TCollection_HAsciiString) PCname = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) PCdisciplineType =
new TCollection_HAsciiString("mechanical");
PC->Init(PCname, AC, PCdisciplineType);
// create product
Handle(StepBasic_Product) P = new StepBasic_Product;
Handle(StepBasic_HArray1OfProductContext) PCs = new StepBasic_HArray1OfProductContext(1,1);
PCs->SetValue(1,PC);
Handle(TCollection_HAsciiString) Pdescription = new TCollection_HAsciiString("");
P->Init(aName, aName, Pdescription, PCs);
// create PDF
Handle(StepBasic_ProductDefinitionFormation) PDF;
switch (schema) {
default:
case 1:
case 2: PDF = new StepBasic_ProductDefinitionFormation;
break;
case 3: PDF = new StepBasic_ProductDefinitionFormationWithSpecifiedSource;
Handle(StepBasic_ProductDefinitionFormationWithSpecifiedSource)::DownCast(PDF)->
SetMakeOrBuy(StepBasic_sNotKnown);
break;
}
Handle(TCollection_HAsciiString) PDFName = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) PDFdescription = new TCollection_HAsciiString("");
PDF->Init(PDFName, PDFdescription, P);
// create PDC, depending on current schema
Handle(StepBasic_ProductDefinitionContext) PDC;
Handle(TCollection_HAsciiString) PDCname;
switch (schema) {
default:
case 1:
case 2: PDC = new StepBasic_ProductDefinitionContext;
PDCname = new TCollection_HAsciiString ("part definition");
break;
case 3: PDC = new StepBasic_DesignContext;
PDCname = new TCollection_HAsciiString("");
break;
}
Handle(TCollection_HAsciiString) PDClifeCycleStage = new TCollection_HAsciiString("design");
PDC->Init(PDCname, AC, PDClifeCycleStage);
// create PD
Handle(StepBasic_ProductDefinition) PD = new StepBasic_ProductDefinition;
Handle(TCollection_HAsciiString) PDId = new TCollection_HAsciiString("design");
Handle(TCollection_HAsciiString) PDdescription = new TCollection_HAsciiString("");
PD->Init(PDId, PDdescription, PDF, PDC);
// create PDS
Handle(StepRepr_ProductDefinitionShape) PDS = new StepRepr_ProductDefinitionShape;
Handle(TCollection_HAsciiString) PDSname = new TCollection_HAsciiString("");
Handle(TCollection_HAsciiString) PDSdescription = new TCollection_HAsciiString("");
StepRepr_CharacterizedDefinition CD;
CD.SetValue(PD);
PDS->Init(PDSname, Standard_True, PDSdescription, CD);
// finally, create SDR
mySDR = new StepShape_ShapeDefinitionRepresentation;
StepRepr_RepresentedDefinition RD;
RD.SetValue ( PDS );
mySDR->Init(RD, SR);
// and an associated PRPC
Handle(TCollection_HAsciiString) PRPCName;
switch (Interface_Static::IVal("write.step.schema")) {
default:
case 1:
myPRPC = new StepBasic_ProductType;
PRPCName = new TCollection_HAsciiString("part") ;
break;
case 4:
case 2:
myPRPC = new StepBasic_ProductRelatedProductCategory;
PRPCName = new TCollection_HAsciiString("part");
break;
case 3:
myPRPC = new StepBasic_ProductRelatedProductCategory;
PRPCName = new TCollection_HAsciiString("detail"); // !!!!! or "assembly"
break;
}
Handle(StepBasic_HArray1OfProduct) PRPCproducts = new StepBasic_HArray1OfProduct(1,1);
PRPCproducts->SetValue(1,P);
myPRPC->Init ( PRPCName, Standard_False, 0, PRPCproducts );
myDone = Standard_True;
}
//=======================================================================
//function : ReadSDR
//purpose :
//=======================================================================
void STEPConstruct_Part::ReadSDR(const Handle(StepShape_ShapeDefinitionRepresentation)& aShape)
{
mySDR = aShape;
myDone = ( ! mySDR.IsNull() );
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Part::IsDone() const
{
return myDone;
}
//=======================================================================
//function : SDRValue
//purpose :
//=======================================================================
Handle(StepShape_ShapeDefinitionRepresentation) STEPConstruct_Part::SDRValue() const
{
return mySDR;
}
//=======================================================================
//function : SRValue
//purpose :
//=======================================================================
Handle(StepShape_ShapeRepresentation) STEPConstruct_Part::SRValue() const
{
if ( ! myDone ) return 0;
return Handle(StepShape_ShapeRepresentation)::DownCast(mySDR->UsedRepresentation());
}
//=======================================================================
//function : PCname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PCname() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->Name();
}
//=======================================================================
//function : PC
//purpose :
//=======================================================================
Handle(StepBasic_ProductContext) STEPConstruct_Part::PC() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1);
}
//=======================================================================
//function : PCdisciplineType
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PCdisciplineType() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->DisciplineType();
}
//=======================================================================
//function : SetPCname
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPCname(const Handle(TCollection_HAsciiString)& name)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->SetName(name);
}
//=======================================================================
//function : SetPCdisciplineType
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPCdisciplineType(const Handle(TCollection_HAsciiString)& label)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->SetDisciplineType(label);
}
//=======================================================================
//function : AC
//purpose :
//=======================================================================
Handle(StepBasic_ApplicationContext) STEPConstruct_Part::AC() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->FrameOfReference();
}
//=======================================================================
//function : ACapplication
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::ACapplication() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->FrameOfReference()
->Application();
}
//=======================================================================
//function : SetACapplication
//purpose :
//=======================================================================
void STEPConstruct_Part::SetACapplication(const Handle(TCollection_HAsciiString)& text)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->FrameOfReferenceValue(1)
->FrameOfReference()
->SetApplication(text);
}
//=======================================================================
//function : PDC
//purpose :
//=======================================================================
Handle(StepBasic_ProductDefinitionContext) STEPConstruct_Part::PDC() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->FrameOfReference();
}
//=======================================================================
//function : PDCname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDCname() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->FrameOfReference()
->Name();
}
//=======================================================================
//function : PDCstage
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDCstage() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->FrameOfReference()
->LifeCycleStage();
}
//=======================================================================
//function : SetPDCname
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDCname(const Handle(TCollection_HAsciiString)& label)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->FrameOfReference()
->SetName(label);
}
//=======================================================================
//function : SetPDCstage
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDCstage(const Handle(TCollection_HAsciiString)& label)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->FrameOfReference()
->SetLifeCycleStage(label);
}
//=======================================================================
//function : Product
//purpose :
//=======================================================================
Handle(StepBasic_Product) STEPConstruct_Part::Product() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct();
}
//=======================================================================
//function : Pid
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::Pid() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->Id();
}
//=======================================================================
//function : Pname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::Pname() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->Name();
}
//=======================================================================
//function : Pdescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::Pdescription() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->Description();
}
//=======================================================================
//function : SetPid
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPid(const Handle(TCollection_HAsciiString)& id)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->SetId(id);
}
//=======================================================================
//function : SetPname
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPname(const Handle(TCollection_HAsciiString)& label)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->SetName(label);
}
//=======================================================================
//function : SetPdescription
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPdescription(const Handle(TCollection_HAsciiString)& text)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->OfProduct()
->SetDescription(text);
}
//=======================================================================
//function : PDF
//purpose :
//=======================================================================
Handle(StepBasic_ProductDefinitionFormation) STEPConstruct_Part::PDF() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation();
}
//=======================================================================
//function : PDFid
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDFid() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->Id();
}
//=======================================================================
//function : PDFdescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDFdescription() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->Description();
}
//=======================================================================
//function : SetPDFid
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDFid(const Handle(TCollection_HAsciiString)& id)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->SetId(id);
}
//=======================================================================
//function : SetPDFdescription
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDFdescription(const Handle(TCollection_HAsciiString)& text)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Formation()
->SetDescription(text);
}
//=======================================================================
//function : PDS
//purpose :
//=======================================================================
Handle(StepRepr_ProductDefinitionShape) STEPConstruct_Part::PDS() const
{
return Handle(StepRepr_ProductDefinitionShape)::DownCast ( mySDR->Definition().PropertyDefinition() );
}
//=======================================================================
//function : PDSname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDSname() const
{
return mySDR->Definition().PropertyDefinition()->Name();
}
//=======================================================================
//function : PDSdescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDSdescription() const
{
return mySDR->Definition().PropertyDefinition()->Description();
}
//=======================================================================
//function : SetPDSname
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDSname(const Handle(TCollection_HAsciiString)& label)
{
mySDR->Definition().PropertyDefinition()->SetName(label);
}
//=======================================================================
//function : SetPDSdescription
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPDSdescription(const Handle(TCollection_HAsciiString)& text)
{
mySDR->Definition().PropertyDefinition()->SetDescription(text);
}
//=======================================================================
//function : PD
//purpose :
//=======================================================================
Handle(StepBasic_ProductDefinition) STEPConstruct_Part::PD() const
{
return mySDR->Definition().PropertyDefinition()->Definition().ProductDefinition();
}
//=======================================================================
//function : PDdescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PDdescription() const
{
return mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->Description();
}
//=======================================================================
//function : SetPDdescription
//purpose :
//=======================================================================
// a modifier
void STEPConstruct_Part::SetPDdescription(const Handle(TCollection_HAsciiString) &text)
{
mySDR->Definition().PropertyDefinition()
->Definition().ProductDefinition()
->SetDescription(text);
}
//=======================================================================
//function : PRPC
//purpose :
//=======================================================================
Handle(StepBasic_ProductRelatedProductCategory) STEPConstruct_Part::PRPC () const
{
return myPRPC;
}
//=======================================================================
//function : PRPCname
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PRPCname () const
{
return myPRPC->Name();
}
//=======================================================================
//function : PRPCdescription
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) STEPConstruct_Part::PRPCdescription () const
{
return myPRPC->Description();
}
//=======================================================================
//function : SetPRPCname
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPRPCname (const Handle(TCollection_HAsciiString) &text)
{
myPRPC->SetName ( text );
}
//=======================================================================
//function : SetPRPCdescription
//purpose :
//=======================================================================
void STEPConstruct_Part::SetPRPCdescription (const Handle(TCollection_HAsciiString) &text)
{
myPRPC->SetDescription ( text );
}

View File

@@ -0,0 +1,31 @@
-- File: STEPConstruct_PointHasher.cdl
-- Created: Wed Jan 15 13:40:33 2003
-- Author: data exchange team
-- <det@friendox>
---Copyright: Matra Datavision 2003
class PointHasher from STEPConstruct
---Purpose:
uses
Pnt from gp
is
HashCode(myclass; Point : Pnt from gp;
Upper : Integer)
returns Integer;
---Purpose: Returns a HasCode value for the Key <K> in the
-- range 0..Upper.
---C++: inline
IsEqual(myclass; Point1,Point2 : Pnt from gp)
returns Boolean;
---Purpose: Returns True when the two keys are the same. Two
-- same keys must have the same hashcode, the
-- contrary is not necessary.
end PointHasher;

View File

@@ -0,0 +1,14 @@
#include <STEPConstruct_PointHasher.ixx>
//=======================================================================
//function : IsEqual
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_PointHasher::IsEqual(const gp_Pnt& point1,
const gp_Pnt& point2)
{
if(Abs(point1.X()-point2.X()) > Epsilon(point1.X())) return Standard_False;
if(Abs(point1.Y()-point2.Y()) > Epsilon(point1.Y())) return Standard_False;
if(Abs(point1.Z()-point2.Z()) > Epsilon(point1.Z())) return Standard_False;
return Standard_True;
}

View File

@@ -0,0 +1,20 @@
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
inline Standard_Integer STEPConstruct_PointHasher::HashCode
(const gp_Pnt& point, const Standard_Integer Upper)
{
union
{
Standard_Real R[3];
Standard_Integer I[6];
} U;
point.Coord(U.R[0],U.R[1],U.R[2]);
return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
// return ::HashCode((U.I[0]>>4)+(U.I[1]>>3)+(U.I[2]>>2)+(U.I[3]>>1)+(U.I[4]>>4)+(U.I[5]>>3),Upper);
}

View File

@@ -0,0 +1,173 @@
-- File: STEPConstruct_Styles.cdl
-- Created: Fri Sep 10 18:30:23 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class Styles from STEPConstruct inherits Tool from STEPConstruct
---Purpose: Provides a mechanism for reading and writing shape styles
-- (such as color) to and from the STEP file
-- This tool maintains a list of styles, either taking them
-- from STEP model (reading), or filling it by calls to
-- AddStyle or directly (writing).
-- Some methods deal with general structures of styles and
-- presentations in STEP, but there are methods which deal
-- with particular implementation of colors (as described in RP)
uses
WorkSession from XSControl,
InterfaceModel from Interface,
HGraph from Interface,
FinderProcess from Transfer,
TransientProcess from Transfer,
Shape from TopoDS,
SequenceOfTransient from TColStd,
HSequenceOfTransient from TColStd,
MapOfShape from TopTools,
RepresentationItem from StepRepr,
RepresentationContext from StepRepr,
PresentationStyleAssignment from StepVisual,
StyledItem from StepVisual,
Colour from StepVisual,
Color from Quantity,
IndexedDataMapOfTransientTransient from TColStd,
MechanicalDesignGeometricPresentationRepresentation from StepVisual,
ContextDependentShapeRepresentation from StepShape,
ProductDefinitionShape from StepRepr,
DataMapOfAsciiStringTransient from STEPConstruct,
DataMapOfPointTransient from STEPConstruct
is
Create returns Styles;
---Purpose: Creates an empty tool
Create (WS: WorkSession from XSControl) returns Styles;
---Purpose: Creates a tool and initializes it
Init (me: in out; WS: WorkSession from XSControl) returns Boolean;
---Purpose: Initializes tool; returns True if succeeded
--Basic methods: general work with styles
NbStyles (me) returns Integer;
---Purpose: Returns number of defined styles
Style (me; i: Integer) returns StyledItem from StepVisual;
---Purpose: Returns style with given index
ClearStyles (me: in out);
---Purpose: Clears all defined styles and PSA sequence
AddStyle (me: in out; style: StyledItem from StepVisual);
---Purpose: Adds a style to a sequence
AddStyle (me: in out; item: RepresentationItem from StepRepr;
PSA: PresentationStyleAssignment from StepVisual;
Override: StyledItem from StepVisual)
returns StyledItem from StepVisual;
---Purpose: Create a style linking giving PSA to the item, and add it to the
-- sequence of stored styles. If Override is not Null, then
-- the resulting style will be of the subtype OverridingStyledItem.
AddStyle (me: in out; Shape: Shape from TopoDS;
PSA: PresentationStyleAssignment from StepVisual;
Override: StyledItem from StepVisual)
returns StyledItem from StepVisual;
---Purpose: Create a style linking giving PSA to the Shape, and add it to the
-- sequence of stored styles. If Override is not Null, then
-- the resulting style will be of the subtype OverridingStyledItem.
-- The Sape is used to find corresponding STEP entity by call to
-- STEPConstruct::FindEntity(), then previous method is called.
CreateMDGPR (me: in out; Context: RepresentationContext from StepRepr;
MDGPR :in out MechanicalDesignGeometricPresentationRepresentation from StepVisual)
returns Boolean;
---Purpose: Create MDGPR, fill it with all the styles previously defined,
-- and add it to the model
CreateNAUOSRD (me: in out; Context: RepresentationContext from StepRepr;
CDSR : ContextDependentShapeRepresentation from StepShape;
initPDS : ProductDefinitionShape from StepRepr)
returns Boolean;
---Purpose: Create MDGPR, fill it with all the styles previously defined,
-- and add it to the model
-- IMPORTANT: <initPDS> must be null when use for NAUO colors
-- <initPDS> initialised only for SHUO case.
FindContext (me; Shape: Shape from TopoDS)
returns RepresentationContext from StepRepr;
---Purpose: Searches the STEP model for the RepresentationContext in which
-- given shape is defined. This context (if found) can be used
-- then in call to CreateMDGPR()
LoadStyles (me: in out) returns Boolean;
---Purpose: Searches the STEP model for the MDGPR or DM entities
-- (which bring styles) and fills sequence of styles
LoadInvisStyles (me; InvSyles : in out HSequenceOfTransient from TColStd)
returns Boolean;
---Purpose: Searches the STEP model for the INISIBILITY enteties
-- (which bring styles) and fills out sequence of styles
--Specialized methods: work with colors
MakeColorPSA (me; item: RepresentationItem from StepRepr;
SurfCol: Colour from StepVisual;
CurveCol: Colour from StepVisual;
isForNAUO : Boolean from Standard = Standard_False)
returns PresentationStyleAssignment from StepVisual;
---Purpose: Create a PresentationStyleAssignment entity which defines
-- two colors (for filling surfaces and curves)
-- if isForNAUO true then returns PresentationStyleByContext
GetColorPSA (me: in out; item: RepresentationItem from StepRepr;
Col: Colour from StepVisual)
returns PresentationStyleAssignment from StepVisual;
---Purpose: Returns a PresentationStyleAssignment entity which defines
-- surface and curve colors as Col. This PSA is either created
-- or taken from internal map where all PSAs created by this
-- method are remembered.
GetColors (me; style: StyledItem from StepVisual;
SurfCol : out Colour from StepVisual;
BoundCol: out Colour from StepVisual;
CurveCol: out Colour from StepVisual;
IsComponent: in out Boolean from Standard)
returns Boolean;
---Purpose: Extract color definitions from the style entity
-- For each type of color supported, result can be either
-- NULL if it is not defined by that style, or last
-- definition (if they are 1 or more)
--Auxiliary methods: conversions between STEP and CASCADE color definitions
EncodeColor (myclass; Col: Color from Quantity) returns Colour from StepVisual;
---Purpose: Create STEP color entity by given Quantity_Color
-- The analysis is performed for whether the color corresponds to
-- one of standard colors predefined in STEP. In that case,
-- PredefinedColour entity is created instead of RGBColour
EncodeColor (myclass; Col: Color from Quantity;
DPDCs : in out DataMapOfAsciiStringTransient from STEPConstruct;
ColRGBs : in out DataMapOfPointTransient from STEPConstruct)
returns Colour from StepVisual;
---Purpose: Create STEP color entity by given Quantity_Color
-- The analysis is performed for whether the color corresponds to
-- one of standard colors predefined in STEP. In that case,
-- PredefinedColour entity is created instead of RGBColour
DecodeColor (myclass; Colour: Colour from StepVisual;
Col : out Color from Quantity)
returns Boolean;
---Purpose: Decodes STEP color and fills the Quantity_Color.
-- Returns True if OK or False if color is not recognized
fields
myMapOfStyles : IndexedDataMapOfTransientTransient from TColStd;
myStyles : SequenceOfTransient from TColStd;
myPSA : SequenceOfTransient from TColStd;
end Styles;

View File

@@ -0,0 +1,708 @@
// File: STEPConstruct_Styles.cxx
// Created: Fri Sep 10 18:46:26 1999
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <STEPConstruct_Styles.ixx>
#include <STEPConstruct.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TopoDS_Iterator.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_TransferWriter.hxx>
#include <Interface_Graph.hxx>
#include <Interface_Static.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_EntityIterator.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <TransferBRep.hxx>
#include <Transfer_Binder.hxx>
#include <APIHeaderSection_MakeHeader.hxx>
#include <StepRepr_RepresentationItem.hxx>
#include <StepRepr_RepresentationContext.hxx>
#include <StepRepr_HArray1OfRepresentationItem.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepVisual_ColourRgb.hxx>
#include <StepVisual_FillAreaStyleColour.hxx>
#include <StepVisual_FillStyleSelect.hxx>
#include <StepVisual_HArray1OfFillStyleSelect.hxx>
#include <StepVisual_FillAreaStyle.hxx>
#include <StepVisual_SurfaceStyleFillArea.hxx>
#include <StepVisual_SurfaceStyleElementSelect.hxx>
#include <StepVisual_HArray1OfSurfaceStyleElementSelect.hxx>
#include <StepVisual_SurfaceSideStyle.hxx>
#include <StepVisual_SurfaceStyleUsage.hxx>
#include <StepVisual_PresentationStyleSelect.hxx>
#include <StepVisual_HArray1OfPresentationStyleSelect.hxx>
#include <StepVisual_PresentationStyleAssignment.hxx>
#include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
#include <StepVisual_OverRidingStyledItem.hxx>
#include <StepVisual_StyledItem.hxx>
#include <StepVisual_MechanicalDesignGeometricPresentationRepresentation.hxx>
#include <StepVisual_PreDefinedColour.hxx>
#include <StepVisual_PreDefinedItem.hxx>
#include <StepVisual_CurveStyle.hxx>
#include <StepVisual_DraughtingPreDefinedCurveFont.hxx>
#include <StepVisual_SurfaceStyleBoundary.hxx>
#include <StepVisual_DraughtingPreDefinedColour.hxx>
#include <StepBasic_MeasureValueMember.hxx>
#include <StepVisual_DraughtingModel.hxx>
#include <StepVisual_PresentationStyleByContext.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <StepRepr_ShapeRepresentationRelationship.hxx>
#include <StepRepr_RepresentationRelationshipWithTransformation.hxx>
#include <StepRepr_Transformation.hxx>
#include <StepRepr_ItemDefinedTransformation.hxx>
#include <StepVisual_Invisibility.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <StepVisual_InvisibleItem.hxx>
#include <gp_Pnt.hxx>
//=======================================================================
//function : STEPConstruct_Styles
//purpose :
//=======================================================================
STEPConstruct_Styles::STEPConstruct_Styles ()
{
}
//=======================================================================
//function : STEPConstruct_Styles
//purpose :
//=======================================================================
STEPConstruct_Styles::STEPConstruct_Styles (const Handle(XSControl_WorkSession) &WS)
: STEPConstruct_Tool ( WS )
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::Init (const Handle(XSControl_WorkSession) &WS)
{
myMapOfStyles.Clear();
myStyles.Clear();
myPSA.Clear();
return SetWS ( WS );
}
//=======================================================================
//function : NbStyles
//purpose :
//=======================================================================
Standard_Integer STEPConstruct_Styles::NbStyles () const
{
return myStyles.Length();
}
//=======================================================================
//function : Style
//purpose :
//=======================================================================
Handle(StepVisual_StyledItem) STEPConstruct_Styles::Style (const Standard_Integer i) const
{
return Handle(StepVisual_StyledItem)::DownCast ( myStyles.Value(i) );
}
//=======================================================================
//function : ClearStyles
//purpose :
//=======================================================================
void STEPConstruct_Styles::ClearStyles ()
{
myStyles.Clear();
myPSA.Clear();
}
//=======================================================================
//function : AddStyle
//purpose :
//=======================================================================
void STEPConstruct_Styles::AddStyle (const Handle(StepVisual_StyledItem) &style)
{
myStyles.Append ( style );
}
//=======================================================================
//function : AddStyle
//purpose :
//=======================================================================
Handle(StepVisual_StyledItem) STEPConstruct_Styles::AddStyle (const Handle(StepRepr_RepresentationItem) &item,
const Handle(StepVisual_PresentationStyleAssignment) &PSA,
const Handle(StepVisual_StyledItem) &Override)
{
Handle(StepVisual_StyledItem) Style;
Handle(StepVisual_HArray1OfPresentationStyleAssignment) Styles =
new StepVisual_HArray1OfPresentationStyleAssignment ( 1, 1 );
Styles->SetValue ( 1, PSA );
if ( Override.IsNull() ) {
Handle(TCollection_HAsciiString) StyName = new TCollection_HAsciiString ( "color" );
Style = new StepVisual_StyledItem;
Style->Init ( StyName, Styles, item );
}
else {
Handle(TCollection_HAsciiString) StyName = new TCollection_HAsciiString ( "overriding color" );
Handle(StepVisual_OverRidingStyledItem) OStyle = new StepVisual_OverRidingStyledItem;
OStyle->Init ( StyName, Styles, item, Override );
Style = OStyle;
}
myStyles.Append ( Style );
// for future using
myPSA.Append( PSA );
return Style;
}
//=======================================================================
//function : AddStyle
//purpose :
//=======================================================================
Handle(StepVisual_StyledItem) STEPConstruct_Styles::AddStyle (const TopoDS_Shape &Shape,
const Handle(StepVisual_PresentationStyleAssignment) &PSA,
const Handle(StepVisual_StyledItem) &Override)
{
Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity ( FinderProcess(), Shape );
Handle(StepVisual_StyledItem) Style;
if ( ! item.IsNull() ) Style = AddStyle ( item, PSA, Override );
return Style;
}
//=======================================================================
//function : CreateMDGPR
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::CreateMDGPR (const Handle(StepRepr_RepresentationContext) &Context,
Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& Repr)
{
if ( myStyles.Length() <1 ) return Standard_False;
// create MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION
Handle(StepRepr_HArray1OfRepresentationItem) elems =
new StepRepr_HArray1OfRepresentationItem ( 1, myStyles.Length() );
for ( Standard_Integer i=1; i <= myStyles.Length(); i++ )
elems->SetValue ( i, Handle(StepRepr_RepresentationItem)::DownCast ( myStyles.Value(i) ) );
// create new MDGPR
Repr = new StepVisual_MechanicalDesignGeometricPresentationRepresentation;
Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" );
Repr->Init ( ReprName, elems, Context );
// record Repr in order to have it written to the file
// Model()->AddWithRefs ( Repr ); add into the model upper
// for AP203, add subschema name
if ( Interface_Static::IVal("write.step.schema") ==3 ) {
APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) );
Handle(TCollection_HAsciiString) subSchema =
new TCollection_HAsciiString ( "SHAPE_APPEARANCE_LAYER_MIM" );
mkHdr.AddSchemaIdentifier ( subSchema );
}
return Standard_True;
}
//=======================================================================
//function : CreateNAUOSRD
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::CreateNAUOSRD (const Handle(StepRepr_RepresentationContext) &Context,
const Handle(StepShape_ContextDependentShapeRepresentation)& CDSR,
const Handle(StepRepr_ProductDefinitionShape)& initPDS)
{
Handle(StepShape_ShapeDefinitionRepresentation) aSDR =
new StepShape_ShapeDefinitionRepresentation;
Handle(StepShape_ShapeRepresentation) aSR =
new StepShape_ShapeRepresentation;
Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" );
// element for axis 2 placement
Handle(StepRepr_HArray1OfRepresentationItem) elems =
new StepRepr_HArray1OfRepresentationItem ( 1, 1 );
// get PDS
Handle(StepRepr_ProductDefinitionShape) aPDS;
if ( initPDS.IsNull() )
aPDS = CDSR->RepresentedProductRelation();
else
aPDS = initPDS; // for SHUO
Handle(StepRepr_ShapeRepresentationRelationship) aRepRelationShip = CDSR->RepresentationRelation();
Handle(StepRepr_RepresentationRelationshipWithTransformation) aRRwTRSF =
Handle(StepRepr_RepresentationRelationshipWithTransformation)::DownCast(aRepRelationShip);
StepRepr_Transformation SetReprTRSF;
if (!aRRwTRSF.IsNull())
SetReprTRSF = aRRwTRSF->TransformationOperator();
else
return Standard_False;
// take Item defined transformation
Handle(StepRepr_ItemDefinedTransformation) anItDT = SetReprTRSF.ItemDefinedTransformation();
elems->SetValue( 1, anItDT->TransformItem2() );
// init Shape representation.
aSR->Init ( ReprName, elems, Context );
// register reference between PresentationStyleByContext and ShapeRepresentation
for (Standard_Integer psbci = 1; psbci <= myPSA.Length(); psbci++) {
Handle(StepVisual_PresentationStyleByContext) PSA =
Handle(StepVisual_PresentationStyleByContext)::DownCast(myPSA.Value(psbci));
if (PSA.IsNull())
continue;
// register the reference
StepVisual_StyleContextSelect aStyleCntxSlct;
aStyleCntxSlct.SetValue( aSR );
PSA->SetStyleContext( aStyleCntxSlct );
}
StepRepr_RepresentedDefinition aPDSselect;
aPDSselect.SetValue(aPDS);
aSDR->Init( aPDSselect, aSR );
Model()->AddWithRefs ( aSDR );
return Standard_True;
}
//=======================================================================
//function : FindContext
//purpose :
//=======================================================================
Handle(StepRepr_RepresentationContext) STEPConstruct_Styles::FindContext (const TopoDS_Shape &Shape) const
{
// find context of items
Handle(StepRepr_RepresentationContext) Context;
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess(), Shape );
Handle(StepShape_ShapeRepresentation) sr;
if ( FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepShape_ShapeRepresentation), sr) ) {
#ifdef DEB
// cout << "Context of " << Shape.TShape()->DynamicType()->Name() << ": SR found: " << sr->DynamicType()->Name() << endl;
#endif
Context = sr->ContextOfItems();
}
else {
Handle(StepGeom_GeometricRepresentationItem) item;
if ( FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepGeom_GeometricRepresentationItem), item) ) {
#ifdef DEB
// cout << "Context of " << Shape.TShape()->DynamicType()->Name() << ": GeomRepItem found: " << item->DynamicType()->Name() << endl;
#endif
Interface_EntityIterator subs = Graph().Sharings(item);
for (subs.Start(); Context.IsNull() && subs.More(); subs.Next()) {
#ifdef DEB
// cout << "Parsing back refs: found " << subs.Value()->DynamicType()->Name() << endl;
#endif
if ( ! subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation)) ) continue;
sr = Handle(StepShape_ShapeRepresentation)::DownCast ( subs.Value() );
Context = sr->ContextOfItems();
}
}
}
#ifdef DEB
if ( Context.IsNull() ) {
cout << Shape.TShape()->DynamicType()->Name() << ": Cannot find context" << endl;
}
#endif
return Context;
}
//=======================================================================
//function : LoadStyles
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::LoadStyles ()
{
myStyles.Clear();
myPSA.Clear();
// find all MDGPRs and DMs and collect all defined styles in myStyles
Handle(Interface_InterfaceModel) model = Model();
Standard_Integer nb = model->NbEntities();
Handle(Standard_Type) tMDGPR = STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation);
Handle(Standard_Type) tDM = STANDARD_TYPE(StepVisual_DraughtingModel);
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) enti = model->Value(i);
if ( enti->DynamicType() != tMDGPR && enti->DynamicType() != tDM ) continue;
Handle(StepRepr_Representation) container = Handle(StepRepr_Representation)::DownCast ( enti );
Standard_Integer nbi = container->NbItems();
for ( Standard_Integer j=1; j <= nbi; j++ ) {
Handle(StepVisual_StyledItem) style =
Handle(StepVisual_StyledItem)::DownCast ( container->ItemsValue(j) );
if ( style.IsNull() ) continue;
myStyles.Append ( style );
}
}
return myStyles.Length() >0;
}
//=======================================================================
//function : LoadInvisStyles
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::LoadInvisStyles (Handle(TColStd_HSequenceOfTransient)& theInvStyles) const
{
Handle(Interface_InterfaceModel) model = Model();
Standard_Integer nb = model->NbEntities();
Handle(Standard_Type) tInvisibility = STANDARD_TYPE(StepVisual_Invisibility);
// serach for invisibility
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) enti = model->Value(i);
if ( enti->DynamicType() != tInvisibility )
continue;
// search for styled items
Handle(StepVisual_Invisibility) container = Handle(StepVisual_Invisibility)::DownCast ( enti );
Standard_Integer nbi = container->NbInvisibleItems();
for ( Standard_Integer j=1; j <= nbi; j++ ) {
StepVisual_InvisibleItem anInvItem = container->InvisibleItemsValue(j);
Handle(StepVisual_StyledItem) style = anInvItem.StyledItem();
if ( style.IsNull() )
continue;
// collect the invisible styled items
if ( theInvStyles.IsNull() )
theInvStyles = new TColStd_HSequenceOfTransient;
theInvStyles->Append( style );
}
}
return ( !theInvStyles.IsNull() && (theInvStyles->Length() > 0) );
}
//=======================================================================
//function : MakeColorPSA
//purpose :
//=======================================================================
Handle(StepVisual_PresentationStyleAssignment) STEPConstruct_Styles::MakeColorPSA (const Handle(StepRepr_RepresentationItem) &/*item*/,
const Handle(StepVisual_Colour) &SurfCol,
const Handle(StepVisual_Colour) &CurveCol,
const Standard_Boolean isForNAUO) const
{
Handle(StepVisual_PresentationStyleAssignment) PSA;
TColStd_SequenceOfTransient items;
// surface color
if ( ! SurfCol.IsNull() ) {
Handle(TCollection_HAsciiString) FASCName = new TCollection_HAsciiString ( "" );
Handle(StepVisual_FillAreaStyleColour) FASC = new StepVisual_FillAreaStyleColour;
FASC->Init ( FASCName, SurfCol );
StepVisual_FillStyleSelect FSS;
FSS.SetValue ( FASC );
Handle(StepVisual_HArray1OfFillStyleSelect) FASSs = new StepVisual_HArray1OfFillStyleSelect ( 1, 1 );
FASSs->SetValue ( 1, FSS );
Handle(TCollection_HAsciiString) FASName = new TCollection_HAsciiString ( "" );
Handle(StepVisual_FillAreaStyle) FAS = new StepVisual_FillAreaStyle;
FAS->Init ( FASName, FASSs );
Handle(StepVisual_SurfaceStyleFillArea) SSFA = new StepVisual_SurfaceStyleFillArea;
SSFA->Init ( FAS );
StepVisual_SurfaceStyleElementSelect SES;
SES.SetValue ( SSFA );
Handle(StepVisual_HArray1OfSurfaceStyleElementSelect) SSESs =
new StepVisual_HArray1OfSurfaceStyleElementSelect ( 1, 1 );
SSESs->SetValue ( 1, SES );
Handle(TCollection_HAsciiString) SSSName = new TCollection_HAsciiString ( "" );
Handle(StepVisual_SurfaceSideStyle) SSS = new StepVisual_SurfaceSideStyle;
SSS->Init ( SSSName, SSESs );
Handle(StepVisual_SurfaceStyleUsage) SSU = new StepVisual_SurfaceStyleUsage;
SSU->Init ( StepVisual_ssBoth, SSS );
items.Append ( SSU );
}
// curve color
if ( ! CurveCol.IsNull() ) {
Handle(TCollection_HAsciiString) fontName = new TCollection_HAsciiString("continuous");
Handle(StepVisual_DraughtingPreDefinedCurveFont) SDPDCF = new StepVisual_DraughtingPreDefinedCurveFont;
SDPDCF->Init(fontName);
Handle(StepBasic_MeasureValueMember) Val = new StepBasic_MeasureValueMember;
Val->SetReal ( 0.1 );
Val->SetName ( "POSITIVE_LENGTH_MEASURE");
StepVisual_CurveStyleFontSelect SCSFS;
SCSFS.SetValue(SDPDCF);
StepBasic_SizeSelect SSSelect;
SSSelect.SetValue(Val);
Handle(TCollection_HAsciiString) SCSName = new TCollection_HAsciiString ( "" );
Handle(StepVisual_CurveStyle) SCS = new StepVisual_CurveStyle;
SCS->Init(SCSName,SCSFS,SSSelect,CurveCol);
items.Append ( SCS );
}
if ( items.Length() <1 ) {
#ifdef DEB
cout << "Error: no color is supplied" << endl;
#endif
return PSA;
}
// general part
Handle(StepVisual_HArray1OfPresentationStyleSelect) PSSs =
new StepVisual_HArray1OfPresentationStyleSelect ( 1, items.Length() );
for ( Standard_Integer i=1; i <= items.Length(); i++ ) {
StepVisual_PresentationStyleSelect PSS;
PSS.SetValue ( items.Value(i) );
PSSs->SetValue ( i, PSS );
}
if (!isForNAUO)
PSA = new StepVisual_PresentationStyleAssignment;
else
PSA = new StepVisual_PresentationStyleByContext;
PSA->Init ( PSSs );
return PSA;
}
//=======================================================================
//function : GetColorPSA
//purpose :
//=======================================================================
Handle(StepVisual_PresentationStyleAssignment) STEPConstruct_Styles::GetColorPSA (const Handle(StepRepr_RepresentationItem) &item,
const Handle(StepVisual_Colour) &Col)
{
// if this color already was processed, just use the same PSA, else create new and add it to map
Handle(StepVisual_PresentationStyleAssignment) PSA;
if ( myMapOfStyles.Contains(Col) ) {
PSA = Handle(StepVisual_PresentationStyleAssignment)::
DownCast(myMapOfStyles.FindFromKey(Col));
}
else {
PSA = MakeColorPSA ( item, Col, Col );
myMapOfStyles.Add(Col,PSA);
}
return PSA;
}
//=======================================================================
//function : GetColors
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::GetColors (const Handle(StepVisual_StyledItem) &style,
Handle(StepVisual_Colour) &SurfCol,
Handle(StepVisual_Colour) &BoundCol,
Handle(StepVisual_Colour) &CurveCol,
Standard_Boolean& IsComponent) const
{
SurfCol.Nullify();
BoundCol.Nullify();
CurveCol.Nullify();
// parse on styles
for(Standard_Integer j=1; j<=style->NbStyles(); j++ ) {
Handle(StepVisual_PresentationStyleAssignment) PSA = style->StylesValue ( j );
if(PSA.IsNull()) continue;
IsComponent = Standard_True;
for(Standard_Integer k=1; k<=PSA->NbStyles(); k++ ) {
StepVisual_PresentationStyleSelect PSS = PSA->StylesValue(k);
// try surface_style_usage
Handle(StepVisual_SurfaceStyleUsage) SSU = PSS.SurfaceStyleUsage();
if( !SSU.IsNull() ) {
Handle(StepVisual_SurfaceSideStyle) SSS = SSU->Style();
for(Standard_Integer l=1; l<=SSS->NbStyles(); l++ ) {
StepVisual_SurfaceStyleElementSelect SSES = SSS->StylesValue(l);
// try fill color
Handle(StepVisual_SurfaceStyleFillArea) SSFA = SSES.SurfaceStyleFillArea();
if ( !SSFA.IsNull() ) {
Handle(StepVisual_FillAreaStyle) FAS = SSFA->FillArea();
for ( Standard_Integer m=1; m <= FAS->NbFillStyles(); m++ ) {
StepVisual_FillStyleSelect FSS = FAS->FillStylesValue ( m );
Handle(StepVisual_FillAreaStyleColour) FASC = FSS.FillAreaStyleColour();
if ( SurfCol.IsNull() || SSU->Side() != StepVisual_ssNegative ) //abv 30 Mar 00: trj3_s1-pe.stp
SurfCol = FASC->FillColour();
}
continue;
}
// try boundary color
Handle(StepVisual_SurfaceStyleBoundary) SSB = SSES.SurfaceStyleBoundary();
if(!SSB.IsNull()) {
Handle(StepVisual_CurveStyle) CS = SSB->StyleOfBoundary();
if ( ! CS.IsNull() ) BoundCol = CS->CurveColour();
continue;
}
}
continue;
}
// try curve_style
Handle(StepVisual_CurveStyle) CS = PSS.CurveStyle();
if ( ! CS.IsNull() ) CurveCol = CS->CurveColour();
}
}
return ! SurfCol.IsNull() || ! BoundCol.IsNull() || ! CurveCol.IsNull();
}
//=======================================================================
//function : EncodeColor
//purpose :
//=======================================================================
Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor(const Quantity_Color &C)
{
// detect if color corresponds to one of pre-defined colors
Standard_CString cName = 0;
if ( C == Quantity_Color(Quantity_NOC_GREEN) ) cName = "green";
else if ( C == Quantity_Color(Quantity_NOC_RED) ) cName = "red";
else if ( C == Quantity_Color(Quantity_NOC_BLUE1) ) cName = "blue";
else if ( C == Quantity_Color(Quantity_NOC_YELLOW) ) cName = "yellow";
else if ( C == Quantity_Color(Quantity_NOC_MAGENTA1) ) cName = "magenta";
else if ( C == Quantity_Color(Quantity_NOC_CYAN1) ) cName = "cyan";
else if ( C == Quantity_Color(Quantity_NOC_BLACK) ) cName = "black";
else if ( C == Quantity_Color(Quantity_NOC_WHITE) ) cName = "white";
if ( cName ) {
Handle(StepVisual_DraughtingPreDefinedColour) ColPr = new StepVisual_DraughtingPreDefinedColour;
Handle(StepVisual_PreDefinedItem) preDef = new StepVisual_PreDefinedItem;
preDef->Init(new TCollection_HAsciiString(cName));
ColPr->SetPreDefinedItem(preDef);
return ColPr;
}
else {
Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
Handle(StepVisual_ColourRgb) ColRGB = new StepVisual_ColourRgb;
ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
return ColRGB;
}
}
//=======================================================================
//function : EncodeColor
//purpose :
//=======================================================================
Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor
(const Quantity_Color &C,
STEPConstruct_DataMapOfAsciiStringTransient &DPDCs,
STEPConstruct_DataMapOfPointTransient &ColRGBs)
{
// detect if color corresponds to one of pre-defined colors
Standard_CString cName = 0;
if ( C == Quantity_Color(Quantity_NOC_GREEN) ) cName = "green";
else if ( C == Quantity_Color(Quantity_NOC_RED) ) cName = "red";
else if ( C == Quantity_Color(Quantity_NOC_BLUE1) ) cName = "blue";
else if ( C == Quantity_Color(Quantity_NOC_YELLOW) ) cName = "yellow";
else if ( C == Quantity_Color(Quantity_NOC_MAGENTA1) ) cName = "magenta";
else if ( C == Quantity_Color(Quantity_NOC_CYAN1) ) cName = "cyan";
else if ( C == Quantity_Color(Quantity_NOC_BLACK) ) cName = "black";
else if ( C == Quantity_Color(Quantity_NOC_WHITE) ) cName = "white";
if ( cName ) {
Handle(StepVisual_DraughtingPreDefinedColour) ColPr;
TCollection_AsciiString aName(cName);
if(DPDCs.IsBound(aName)) {
ColPr = Handle(StepVisual_DraughtingPreDefinedColour)::DownCast(DPDCs.Find(aName));
if(!ColPr.IsNull()) return ColPr;
}
ColPr = new StepVisual_DraughtingPreDefinedColour;
Handle(StepVisual_PreDefinedItem) preDef = new StepVisual_PreDefinedItem;
preDef->Init(new TCollection_HAsciiString(cName));
ColPr->SetPreDefinedItem(preDef);
DPDCs.Bind(aName,ColPr);
return ColPr;
}
else {
Handle(StepVisual_ColourRgb) ColRGB;
gp_Pnt P(C.Red(),C.Green(),C.Blue());
if(ColRGBs.IsBound(P)) {
ColRGB = Handle(StepVisual_ColourRgb)::DownCast(ColRGBs.Find(P));
if(!ColRGB.IsNull()) return ColRGB;
}
Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
ColRGB = new StepVisual_ColourRgb;
ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
ColRGBs.Bind(P,ColRGB);
return ColRGB;
}
}
//=======================================================================
//function : DecodeColor
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Styles::DecodeColor (const Handle(StepVisual_Colour) &Colour, Quantity_Color &Col)
{
if ( Colour->IsKind (STANDARD_TYPE(StepVisual_ColourRgb)) ) {
Handle(StepVisual_ColourRgb) rgb = Handle(StepVisual_ColourRgb)::DownCast ( Colour );
if( rgb->Red()>1. || rgb->Green()>1. || rgb->Blue()>1. ) {
Standard_Real norm = rgb->Red();
if(norm<rgb->Green()) norm = rgb->Green();
if(norm<rgb->Blue()) norm = rgb->Blue();
Col.SetValues(rgb->Red()/norm, rgb->Green()/norm,
rgb->Blue()/norm, Quantity_TOC_RGB);
}
else
Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_RGB);
return Standard_True;
}
else if ( Colour->IsKind (STANDARD_TYPE(StepVisual_PreDefinedColour)) ) {
Handle(StepVisual_PreDefinedColour) pdc =
Handle(StepVisual_PreDefinedColour)::DownCast ( Colour );
Handle(StepVisual_PreDefinedItem) pdi = pdc->GetPreDefinedItem();
const TCollection_AsciiString name = pdi->Name()->String();
if ( name.IsEqual ( "red" ) ) Col.SetValues ( Quantity_NOC_RED );
else if ( name.IsEqual ( "green" ) ) Col.SetValues ( Quantity_NOC_GREEN );
else if ( name.IsEqual ( "blue" ) ) Col.SetValues ( Quantity_NOC_BLUE1 );
else if ( name.IsEqual ( "yellow" ) ) Col.SetValues ( Quantity_NOC_YELLOW );
else if ( name.IsEqual ( "magenta" ) ) Col.SetValues ( Quantity_NOC_MAGENTA1 );
else if ( name.IsEqual ( "cyan" ) ) Col.SetValues ( Quantity_NOC_CYAN1 );
else if ( name.IsEqual ( "black" ) ) Col.SetValues ( Quantity_NOC_BLACK );
else if ( name.IsEqual ( "white" ) ) Col.SetValues ( Quantity_NOC_WHITE );
else {
#ifdef DEB
cout << "Error: color name \"" << name << "\" is not recognized" << endl;
#endif
return Standard_False;
}
return Standard_True;
}
return Standard_False;
}

View File

@@ -0,0 +1,74 @@
-- File: STEPConstruct_Tool.cdl
-- Created: Fri Sep 29 16:11:39 2000
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class Tool from STEPConstruct
---Purpose: Provides basic functionalities for tools which are intended
-- for encoding/decoding specific STEP constructs
--
-- It is initialized by WorkSession and allows easy access to
-- its fields and internal data such as Model, TP and FP
--
-- NOTE: Call to method Graph() with True (or for a first time,
-- if you have updated the model since last computation of model)
-- can take a time, so it is recommended to avoid creation of
-- this (and derived) tool multiple times
uses
WorkSession from XSControl,
InterfaceModel from Interface,
Graph from Interface,
HGraph from Interface,
FinderProcess from Transfer,
TransientProcess from Transfer
is
Create returns Tool;
---Purpose: Creates an empty tool
Create (WS: WorkSession from XSControl) returns Tool;
---Purpose: Creates a tool and loads it with worksession
SetWS (me: in out; WS: WorkSession from XSControl)
returns Boolean is protected;
---Purpose: Load worksession; returns True if succeeded
-- Returns False if either FinderProcess of TransientProcess
-- cannot be obtained or are Null
WS (me) returns WorkSession from XSControl;
---Purpose: Returns currently loaded WorkSession
---C++: return const &
---C++: inline
Model (me) returns InterfaceModel from Interface;
---Purpose: Returns current model (Null if not loaded)
---C++: inline
Graph (me; recompute: Boolean = Standard_False) returns Graph from Interface;
---Purpose: Returns current graph (recomputing if necessary)
---C++: return const &
---C++: inline
TransientProcess (me) returns TransientProcess from Transfer;
---Purpose: Returns TransientProcess (reading; Null if not loaded)
---C++: return const &
---C++: inline
FinderProcess (me) returns FinderProcess from Transfer;
---Purpose: Returns FinderProcess (writing; Null if not loaded)
---C++: return const &
---C++: inline
fields
myWS : WorkSession from XSControl;
myFinderProcess: FinderProcess from Transfer;
myTransientProcess: TransientProcess from Transfer;
myHGraph : HGraph from Interface; -- for optimization (no recomutings)
end Tool;

View File

@@ -0,0 +1,54 @@
// File: STEPConstruct_Tool.cxx
// Created: Fri Sep 29 16:18:16 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <STEPConstruct_Tool.ixx>
#include <XSControl_TransferReader.hxx>
#include <XSControl_TransferWriter.hxx>
//=======================================================================
//function : STEPConstruct_Tool
//purpose :
//=======================================================================
STEPConstruct_Tool::STEPConstruct_Tool ()
{
}
//=======================================================================
//function : STEPConstruct_Tool
//purpose :
//=======================================================================
STEPConstruct_Tool::STEPConstruct_Tool (const Handle(XSControl_WorkSession) &WS)
{
SetWS ( WS );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_Tool::SetWS (const Handle(XSControl_WorkSession) &WS)
{
myWS.Nullify();
myTransientProcess.Nullify();
myFinderProcess.Nullify();
if ( WS.IsNull() ) return Standard_False;
myWS = WS;
myHGraph = myWS->HGraph();
// collect data on reading process
Handle(XSControl_TransferReader) TR = WS->TransferReader();
if ( ! TR.IsNull() ) myTransientProcess = TR->TransientProcess();
// collect data on writing process
Handle(XSControl_TransferWriter) TW = myWS->TransferWriter();
if ( ! TW.IsNull() ) myFinderProcess = TW->FinderProcess();
return ! myTransientProcess.IsNull() && ! myFinderProcess.IsNull();
}

View File

@@ -0,0 +1,62 @@
// File: STEPConstruct_Tool.lxx
// Created: Fri Sep 29 16:26:28 2000
// Author: data exchange team
// <det@doomox>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Graph.hxx>
#include <Interface_HGraph.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_FinderProcess.hxx>
#include <XSControl_WorkSession.hxx>
//=======================================================================
//function : WS
//purpose :
//=======================================================================
inline const Handle(XSControl_WorkSession) &STEPConstruct_Tool::WS() const
{
return myWS;
}
//=======================================================================
//function : Model
//purpose :
//=======================================================================
inline Handle(Interface_InterfaceModel) STEPConstruct_Tool::Model() const
{
return myWS->Model();
}
//=======================================================================
//function : Graph
//purpose :
//=======================================================================
inline const Interface_Graph &STEPConstruct_Tool::Graph (const Standard_Boolean recompute) const
{
// Note: myWS->Graph() recomputes graph each time!
return recompute ? myWS->Graph() : myHGraph->Graph();
}
//=======================================================================
//function : TransientProcess
//purpose :
//=======================================================================
inline const Handle(Transfer_TransientProcess) &STEPConstruct_Tool::TransientProcess() const
{
return myTransientProcess;
}
//=======================================================================
//function : FinderProcess
//purpose :
//=======================================================================
inline const Handle(Transfer_FinderProcess) &STEPConstruct_Tool::FinderProcess() const
{
return myFinderProcess;
}

View File

@@ -0,0 +1,119 @@
-- File: STEPConstruct_UnitContext.cdl
-- Created: Thu Jan 18 15:16:52 1996
-- Author: Frederic MAUPAS
-- <fma@pronox>
---Copyright: Matra Datavision 1996
class UnitContext from STEPConstruct
---Purpose: Tool for creation (encoding) and decoding (for writing and reading
-- accordingly) context defining units and tolerances (uncerntanties)
uses
SiUnit from StepBasic,
SiPrefix from StepBasic,
NamedUnit from StepBasic,
GlobalUnitAssignedContext from StepRepr,
GlobalUncertaintyAssignedContext from StepRepr,
GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx from StepGeom
is
Create returns UnitContext;
---Purpose: Creates empty tool
Init (me: in out; Tol3d: Real);
---Purpose: Creates new context (units are MM and radians,
-- uncertainty equal to Tol3d)
IsDone (me) returns Boolean;
---Purpose: Returns True if Init was called successfully
Value (me) returns GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx from StepGeom;
---Purpose: Returns context (or Null if not done)
ComputeFactors(me: in out; aContext: GlobalUnitAssignedContext from StepRepr)
returns Integer;
---Purpose: Computes the length, plane angle and solid angle conversion
-- factor . Returns a status, 0 if OK
ComputeFactors(me: in out; aUnit: NamedUnit from StepBasic)
returns Integer;
ComputeTolerance(me: in out; aContext: GlobalUncertaintyAssignedContext from StepRepr)
returns Integer;
---Purpose : Computes the uncertainty value (for length)
LengthFactor(me) returns Real;
---Purpose: Returns the lengthFactor
PlaneAngleFactor(me) returns Real;
---Purpose: Returns the planeAngleFactor
SolidAngleFactor(me) returns Real;
---Purpose: Returns the solidAngleFactor
Uncertainty(me) returns Real;
---Purpose: Returns the Uncertainty value (for length)
-- It has been converted with LengthFactor
AreaFactor(me) returns Real;
---Purpose: Returns the areaFactor
VolumeFactor(me) returns Real;
---Purpose: Returns the volumeFactor
HasUncertainty(me) returns Boolean;
---Purpose: Tells if a Uncertainty (for length) is recorded
LengthDone(me) returns Boolean;
---Purpose: Returns true if ComputeFactors has calculated
-- a LengthFactor
PlaneAngleDone(me) returns Boolean;
---Purpose: Returns true if ComputeFactors has calculated
-- a PlaneAngleFactor
SolidAngleDone(me) returns Boolean;
---Purpose: Returns true if ComputeFactors has calculated
-- a SolidAngleFactor
AreaDone(me) returns Boolean;
---Purpose: Returns true if areaFactor is computed
VolumeDone(me) returns Boolean;
---Purpose: Returns true if volumeFactor is computed
SiUnitNameFactor(me; aSiUnit : SiUnit from StepBasic; val : out Real)
returns Boolean is private;
---Purpose: Fills numerical equivalent of SiUnitName (in SI value)
-- Returns False if name SiUnit Name not recognized
StatusMessage (me; status :Integer) returns CString;
---Purpose: Returns a message for a given status (0 - empty)
-- This message can then be added as warning for transfer
ConvertSiPrefix (myclass; aPrefix: SiPrefix from StepBasic) returns Real;
---Purpose: Convert SI prefix defined by enumertaion to corresponding
-- real factor (e.g. 1e6 for mega)
fields
-- writing (encoding)
done: Boolean;
GRC : GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx from StepGeom;
-- reading (decoding)
lengthFactor : Real;
planeAngleFactor : Real;
solidAngleFactor : Real;
theUncertainty : Real;
areaFactor : Real;
volumeFactor : Real;
areaDone : Boolean;
volumeDone : Boolean;
lengthDone : Boolean;
planeAngleDone : Boolean;
solidAngleDone : Boolean;
hasUncertainty : Boolean;
end UnitContext;

View File

@@ -0,0 +1,583 @@
// File: StepPDR_MakeUnitAndToleranceContext.cxx
// Created: Thu Jan 18 15:26:08 1996
// Author: Frederic MAUPAS
// <fma@pronox>
//abv 17.11.99: renamed from StepPDR_MakeUnitAndToleranceContext and merged with STEPControl_Unit
//abv 30.02.00: ability to write file in units other than MM
#include <STEPConstruct_UnitContext.ixx>
#include <TCollection_HAsciiString.hxx>
#include <StepBasic_SiUnit.hxx>
#include <StepBasic_SiPrefix.hxx>
#include <StepBasic_NamedUnit.hxx>
#include <StepBasic_LengthUnit.hxx>
#include <StepBasic_PlaneAngleUnit.hxx>
#include <StepBasic_SolidAngleUnit.hxx>
#include <StepBasic_SiUnitAndLengthUnit.hxx>
#include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
#include <StepBasic_SiUnitAndSolidAngleUnit.hxx>
#include <StepBasic_SiUnitAndAreaUnit.hxx>
#include <StepBasic_SiUnitAndVolumeUnit.hxx>
#include <StepBasic_UncertaintyMeasureWithUnit.hxx>
#include <StepBasic_DimensionalExponents.hxx>
#include <StepBasic_MeasureValueMember.hxx>
#include <StepBasic_MeasureWithUnit.hxx>
#include <StepBasic_LengthMeasureWithUnit.hxx>
#include <StepBasic_PlaneAngleMeasureWithUnit.hxx>
#include <StepBasic_SolidAngleMeasureWithUnit.hxx>
#include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
#include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
#include <StepBasic_ConversionBasedUnitAndSolidAngleUnit.hxx>
#include <StepBasic_ConversionBasedUnitAndAreaUnit.hxx>
#include <StepBasic_ConversionBasedUnitAndVolumeUnit.hxx>
#include <StepBasic_HArray1OfNamedUnit.hxx>
#include <StepBasic_HArray1OfUncertaintyMeasureWithUnit.hxx>
#include <UnitsMethods.hxx>
#include <Interface_Static.hxx>
//=======================================================================
//function : STEPConstruct_UnitContext
//purpose :
//=======================================================================
STEPConstruct_UnitContext::STEPConstruct_UnitContext() : done(Standard_False)
{
lengthDone = planeAngleDone = solidAngleDone = hasUncertainty =
areaDone = volumeDone = Standard_False;
//pdn file r_47-sd.stp initalize field.
theUncertainty = RealLast();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d)
{
done = Standard_True;
GRC = new StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx;
Handle(TCollection_HAsciiString) contextID =
new TCollection_HAsciiString("Context #1"); // ?????
Handle(TCollection_HAsciiString) contextType =
new TCollection_HAsciiString("3D Context with UNIT and UNCERTAINTY");
// Units : LengthUnit and PlaneAngleUnit (no SolidAngleUnit appliable)
Handle(StepBasic_NamedUnit) lengthUnit;
Standard_CString uName = 0;
Standard_Boolean hasPref = Standard_True;
StepBasic_SiPrefix siPref = StepBasic_spMilli;
switch ( Interface_Static::IVal ( "write.step.unit" ) ) {
case 1 : uName = "INCH"; break;
default :
case 2 : break;
case 4 : uName = "FOOT"; break;
case 5 : uName = "MILE"; break;
case 6 : hasPref = Standard_False; break;
case 7 : siPref = StepBasic_spKilo; break;
case 8 : uName = "MIL"; break;
case 9 : siPref = StepBasic_spMicro; break;
case 10 : siPref = StepBasic_spCenti; break;
case 11 : uName = "MICROINCH"; break;
}
Handle(StepBasic_SiUnitAndLengthUnit) siUnit =
new StepBasic_SiUnitAndLengthUnit;
siUnit->Init(hasPref,siPref,StepBasic_sunMetre);
if ( uName ) { // for non-metric units, create conversion_based_unit
Handle(StepBasic_MeasureValueMember) val = new StepBasic_MeasureValueMember;
val->SetName("LENGTH_UNIT");
val->SetReal ( UnitsMethods::GetLengthFactorValue ( Interface_Static::IVal ( "write.step.unit" ) ) );
Handle(StepBasic_LengthMeasureWithUnit) measure = new StepBasic_LengthMeasureWithUnit;
StepBasic_Unit Unit;
Unit.SetValue ( siUnit );
measure->Init ( val, Unit );
Handle(StepBasic_DimensionalExponents) theDimExp = new StepBasic_DimensionalExponents;
theDimExp->Init ( 1., 0., 0., 0., 0., 0., 0. );
Handle(TCollection_HAsciiString) convName = new TCollection_HAsciiString ( uName );
Handle(StepBasic_ConversionBasedUnitAndLengthUnit) convUnit =
new StepBasic_ConversionBasedUnitAndLengthUnit;
convUnit->Init ( theDimExp, convName, measure );
lengthUnit = convUnit;
}
else lengthUnit = siUnit;
Handle(StepBasic_SiUnitAndPlaneAngleUnit) radianUnit =
new StepBasic_SiUnitAndPlaneAngleUnit;
radianUnit ->Init(Standard_False,
StepBasic_spMilli, // the unit is radian, no prefix
StepBasic_sunRadian);
Handle(StepBasic_HArray1OfNamedUnit) units =
new StepBasic_HArray1OfNamedUnit(1, 3);
Handle(StepBasic_SiUnitAndSolidAngleUnit) sradUnit =
new StepBasic_SiUnitAndSolidAngleUnit;
sradUnit ->Init(Standard_False,
StepBasic_spMilli, // the unit is steradian, no prefix
StepBasic_sunSteradian);
units->SetValue(1, lengthUnit);
units->SetValue(2, radianUnit);
units->SetValue(3, sradUnit);
// Uncertainty : 3D confusion Tolerance
Handle(StepBasic_HArray1OfUncertaintyMeasureWithUnit) Tols =
new StepBasic_HArray1OfUncertaintyMeasureWithUnit(1,1);
Handle(StepBasic_UncertaintyMeasureWithUnit) theTol3d =
new StepBasic_UncertaintyMeasureWithUnit;
Handle(TCollection_HAsciiString) TolName =
new TCollection_HAsciiString("distance_accuracy_value");
Handle(TCollection_HAsciiString) TolDesc =
new TCollection_HAsciiString("confusion accuracy");
Handle(StepBasic_MeasureValueMember) mvs = new StepBasic_MeasureValueMember;
mvs->SetName("LENGTH_MEASURE");
mvs->SetReal ( Tol3d / UnitsMethods::LengthFactor() );
StepBasic_Unit Unit;
Unit.SetValue ( lengthUnit );
theTol3d->Init(mvs, Unit, TolName, TolDesc);
Tols->SetValue(1, theTol3d);
GRC->Init(contextID, contextType, 3, units, Tols);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_UnitContext::IsDone() const
{
return done;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) STEPConstruct_UnitContext::Value() const
{
return GRC;
}
// ==========================================================================
// Method : ConvertSiPrefix
// Purpose : Computes SiPrefix conversion
// ==========================================================================
Standard_Real STEPConstruct_UnitContext::ConvertSiPrefix (const StepBasic_SiPrefix aPrefix)
{
switch(aPrefix)
{
case StepBasic_spExa: return 1.E+18;
case StepBasic_spPeta: return 1.E+15;
case StepBasic_spTera: return 1.E+12;
case StepBasic_spGiga: return 1.E+9;
case StepBasic_spMega: return 1.E+6;
case StepBasic_spKilo: return 1.E+3;
case StepBasic_spHecto: return 1.E+2;
case StepBasic_spDeca: return 1.E+1;
case StepBasic_spDeci: return 1.E-1;
case StepBasic_spCenti: return 1.E-2;
case StepBasic_spMilli: return 1.E-3;
case StepBasic_spMicro: return 1.E-6;
case StepBasic_spNano: return 1.E-9;
case StepBasic_spPico: return 1.E-12;
case StepBasic_spFemto: return 1.E-15;
case StepBasic_spAtto: return 1.E-18;
default:
break;
}
return 1.;
}
// ==========================================================================
// Method : STEPConstruct_UnitContext::SiUnitNameFactor
// Purpose :
// ==========================================================================
Standard_Boolean STEPConstruct_UnitContext::SiUnitNameFactor(const Handle(StepBasic_SiUnit)& aSiUnit,
Standard_Real& theSIUNFactor) const
{
theSIUNFactor = 1.;
switch ( aSiUnit->Name() )
{
case StepBasic_sunMetre:
case StepBasic_sunRadian:
case StepBasic_sunSteradian:
return Standard_True;
default:
// cout << "Unknown SiUnitName : " << aSiUnit->Name() << endl;
return Standard_False;
}
}
// ==========================================================================
// Method : STEPConstruct_UnitContext::ComputeFactors
// Purpose :
// ==========================================================================
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr_GlobalUnitAssignedContext)& aContext)
{
Standard_Integer status = 0;
// Initialise the default value
// status : 0 if OK, else 1 2 3
lengthFactor = solidAngleFactor = 1.;
planeAngleFactor = PI/180.;
// Standard_Real theLExp = 1.;
// Standard_Real thePAExp = 0.;
// Standard_Real theSAExp = 0.;
lengthDone = planeAngleDone = solidAngleDone = Standard_False;
if (aContext.IsNull()) {
#ifdef DEB
cout<<" -- STEPConstruct_UnitContext:ComputeFactor, Context undefined -> default"<<endl;
#endif
return 1;
}
// Start Computation
Handle(StepBasic_HArray1OfNamedUnit) theUnits = aContext->Units();
Standard_Integer nbU = aContext->NbUnits();
for (Standard_Integer i = 1; i <= nbU; i++) {
Handle(StepBasic_NamedUnit) theNamedUnit = aContext->UnitsValue(i);
status = ComputeFactors(theNamedUnit);
#ifdef DEB
if(status == -1)
cout << " -- STEPConstruct_UnitContext:ComputeFactor: Unit item no." << i << " is not recognized" << endl;
#endif
}
return status;
}
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasic_NamedUnit)& aUnit)
{
//:f3 abv 8 Apr 98: ProSTEP TR8 tr8_as_sd_sw: the case of unrecognized entity
if ( aUnit.IsNull() )
return -1;
Standard_Integer status = 0;
Standard_Real theFactor= 0.;
Standard_Real theSIUNF = 0.;
Standard_Real parameter= 0.;
Standard_Boolean parameterDone = Standard_False;
if(aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnit))) {
Handle(StepBasic_ConversionBasedUnit) theCBU =
Handle(StepBasic_ConversionBasedUnit)::DownCast(aUnit);
// Handle(StepBasic_DimensionalExponents) theDimExp = theCBU->Dimensions();
Handle(StepBasic_MeasureWithUnit) theMWU;
if(!theCBU.IsNull()) {
theMWU = theCBU->ConversionFactor();
// sln 8.10.2001: the case of unrecognized entity
if(theMWU.IsNull())
return -1;
//if (!theMWU->IsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit))) { gka
// return 2;
//}
Handle(StepBasic_NamedUnit) theTargetUnit = theMWU->UnitComponent().NamedUnit();
//StepBasic_Unit theTargetUnit = theMWU->UnitComponent();
Standard_Real theSIPFactor = 1.;
//:f5 abv 24 Apr 98: ProSTEP TR8 tr8_bv1_tc: INCHES
//gka Handle(StepBasic_SiUnitAndLengthUnit) theSUALU =
// Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(theTargetUnit);
// Handle(StepBasic_SiUnit) theSIU;
// if ( ! theSUALU.IsNull() ) theSIU = Handle(StepBasic_SiUnit)::DownCast(theSUALU);
Handle(StepBasic_SiUnit) theSIU = //f5
Handle(StepBasic_SiUnit)::DownCast(theTargetUnit);//f5
if (!theSIU.IsNull()) {
if (theSIU->HasPrefix()) {
// Treat the prefix
StepBasic_SiPrefix aPrefix = theSIU->Prefix();
theSIPFactor = ConvertSiPrefix(aPrefix);
}
// Treat the SiUnitName
if (!SiUnitNameFactor(theSIU,theSIUNF)) status = 11; // et continue
//cout << "The SiUnitNameFactor is :";
//cout << theSIUNF << endl;
}
else {
// cout << "Recursive algo required - Aborted" << endl;
return 3;
}
Standard_Real theMVAL = theMWU->ValueComponent();
theFactor = theSIPFactor * theMVAL; // * theSIUNF * pow(10.,theLExp)
}
parameter = theFactor;
if(!parameterDone) {
parameterDone = Standard_True;
}
else {
status = 14;
#ifdef DEB
cout << "Error in the file : parameter double defined" << endl;
#endif
}
}
else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
Handle(StepBasic_SiUnit) theSIU = Handle(StepBasic_SiUnit)::DownCast(aUnit);
Standard_Real theSIPFactor = 1.;
if (theSIU->HasPrefix()) {
// Treat the prefix
StepBasic_SiPrefix aPrefix = theSIU->Prefix();
theSIPFactor = ConvertSiPrefix(aPrefix);
}
// Treat the SiUnitName
if (!SiUnitNameFactor(theSIU,theSIUNF)) status = 11;
// final computation for lengthFactor
theFactor = theSIPFactor * theSIUNF;
parameter = theFactor;
if (!parameterDone) {
parameterDone = Standard_True;
}
else {
status = 14;
#ifdef DEB
cout << "Error in the file : parameter double defined" << endl;
#endif
}
}
// Defining a type of unit
if(!parameterDone) {
#ifdef DEB
cout << "Unit Type not implemented" << endl;
#endif
return 0;
}
if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
#ifdef METER
lengthFactor = parameter;
#else
lengthFactor = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
#endif
if(!lengthDone)
lengthDone = Standard_True;
else {
status = 14;
#ifdef DEB
cout << "Error in the file : LengthFactor double defined" << endl;
#endif
}
} // end of LengthUnit
else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit))||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
planeAngleFactor = parameter;
planeAngleDone = Standard_True;
} // end of PlaneAngleUnit
else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndSolidAngleUnit))||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndSolidAngleUnit))) {
solidAngleFactor = parameter;
solidAngleDone = Standard_True;
} // end of SolidAngleUnit
else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndAreaUnit)) ||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndAreaUnit))) {
Standard_Real af;
#ifdef METER
af = parameter;
#else
af = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
#endif
areaDone = Standard_True;
areaFactor = pow(af,2);
}
else if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndVolumeUnit)) ||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndVolumeUnit))) {
Standard_Real af;
#ifdef METER
af = parameter;
#else
af = parameter * 1000. / UnitsMethods::GetCasCadeLengthUnit();
#endif
volumeDone = Standard_True;
volumeFactor = pow(af,3);
}
return status;
}
// ==========================================================================
// Method : STEPConstruct_UnitContext::ComputeTolerance
// Purpose :
// ==========================================================================
Standard_Integer STEPConstruct_UnitContext::ComputeTolerance
(const Handle(StepRepr_GlobalUncertaintyAssignedContext)& aContext)
{
Standard_Integer status = 0;
// Decode the Uncertainty information (geometric accuracy)
hasUncertainty = Standard_False;
Standard_Integer nbUncertainty = 0;
if (!aContext.IsNull()) nbUncertainty = aContext->NbUncertainty();
else return 40;
for (Standard_Integer un = 1 ; un <= nbUncertainty ; un ++) {
Handle(StepBasic_UncertaintyMeasureWithUnit) aUMWU = aContext->UncertaintyValue(un);
if (aUMWU.IsNull()) {
#ifdef DEB
cout<<"BAD Uncertainty Measure with Units, n0."<<un<<endl;
#endif
continue;
}
// Decode the associated Unit
Handle(StepBasic_SiUnitAndLengthUnit) aUnit =
Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aUMWU->UnitComponent().NamedUnit());
if (!aUnit.IsNull()) {
// Extract Uncertainty value
Standard_Real LengthUncertainty = aUMWU->ValueComponent();
// Update it according to the Length Unit Factor
//pdn r_47-sd.stp to choose minimal uncertainty
if(theUncertainty > LengthUncertainty) theUncertainty = LengthUncertainty;
hasUncertainty = Standard_True;
} else {
Handle(StepBasic_ConversionBasedUnitAndLengthUnit) aCBULU =
Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(aUMWU->UnitComponent().NamedUnit());
if (!aCBULU.IsNull()) {
// Extract Uncertainty value
Standard_Real LengthUncertainty = aUMWU->ValueComponent();
// Update it according to the Length Unit Factor
//pdn r_47-sd.stp to choose minimal uncertainty
if(theUncertainty > LengthUncertainty) theUncertainty = LengthUncertainty; // *lengthFactor; fait par appelant
hasUncertainty = Standard_True;
}
}
}
#ifdef DEBUG
if (hasUncertainty) cout << "UNCERTAINTY read as " << theUncertainty << endl;
#endif
return status;
}
// ==========================================================================
// Method : STEPConstruct_UnitContext::LengthFactor
// Purpose :
// ==========================================================================
Standard_Real STEPConstruct_UnitContext::LengthFactor() const
{ return lengthFactor; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::PlaneAngleFactor
// Purpose :
// ==========================================================================
Standard_Real STEPConstruct_UnitContext::PlaneAngleFactor() const
{ return planeAngleFactor; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::SolidAngleFactor
// Purpose :
// ==========================================================================
Standard_Real STEPConstruct_UnitContext::SolidAngleFactor() const
{ return solidAngleFactor; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::Uncertainty
// Purpose :
// ==========================================================================
Standard_Real STEPConstruct_UnitContext::Uncertainty () const
{ return theUncertainty; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::HasUncertainty
// Purpose :
// ==========================================================================
Standard_Boolean STEPConstruct_UnitContext::HasUncertainty () const
{ return hasUncertainty; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::LengthDone
// Purpose :
// ==========================================================================
Standard_Boolean STEPConstruct_UnitContext::LengthDone() const
{ return lengthDone; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::PlaneAngleDone
// Purpose :
// ==========================================================================
Standard_Boolean STEPConstruct_UnitContext::PlaneAngleDone() const
{ return planeAngleDone; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::SolidAngleDone
// Purpose :
// ==========================================================================
Standard_Boolean STEPConstruct_UnitContext::SolidAngleDone() const
{ return solidAngleDone; }
// ==========================================================================
// Method : STEPConstruct_UnitContext::StatusMessage
// Purpose :
// ==========================================================================
Standard_CString STEPConstruct_UnitContext::StatusMessage (const Standard_Integer status) const
{
switch (status) {
case 0 : return "";
case 1 : return "No GlobalUnitAssignedContext, default taken";
case 2 : return "No LengthMeasureWithUnit, default taken";
case 3 : return "No SiUnit for LengthMeasure undefined, default taken";
case 4 : return "No PlaneAngleMeasureWithUnit, default taken";
case 5 : return "No SiUnit for PlaneAngleMeasure undefined, default taken";
case 6 : return "No SolidAngleMeasureWithUnit, default taken";
case 7 : return "No SiUnit for SolidAngleMeasure undefined, default taken";
case 11 : return "Length Unit not recognized, default taken";
case 12 : return "Plane Angle Unit not recognized, default taken";
case 13 : return "Solid Angle Unit not recognized, default taken";
case 14 : return "At least one unit is twice defined";
case 40 : return "Bad GlobalUncertaintyAssignedContext, default unit taken";
default : break;
}
return "Badly defined units, default taken";
}
Standard_Real STEPConstruct_UnitContext::AreaFactor() const
{
return areaFactor;
}
Standard_Real STEPConstruct_UnitContext::VolumeFactor() const
{
return volumeFactor;
}
Standard_Boolean STEPConstruct_UnitContext::AreaDone() const
{
return areaDone;
}
Standard_Boolean STEPConstruct_UnitContext::VolumeDone() const
{
return volumeDone;
}

View File

@@ -0,0 +1,141 @@
-- File: STEPConstruct_ValidationProps.cdl
-- Created: Wed Sep 8 16:39:51 1999
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ValidationProps from STEPConstruct inherits Tool from STEPConstruct
---Purpose: This class provides tools for access (write and read)
-- the validation properties on shapes in the STEP file.
-- These are surface area, solid volume and centroid.
uses
WorkSession from XSControl,
InterfaceModel from Interface,
HGraph from Interface,
FinderProcess from Transfer,
TransientProcess from Transfer,
RepresentationItem from StepRepr,
Pnt from gp,
Shape from TopoDS,
MapOfShape from TopTools,
SequenceOfTransient from TColStd,
Unit from StepBasic,
CharacterizedDefinition from StepRepr,
RepresentationContext from StepRepr,
--ShapeDefinitionRepresentation from StepShape,
--ContextDependentShapeRepresentation from StepShape,
ProductDefinition from StepBasic,
NextAssemblyUsageOccurrence from StepRepr,
PropertyDefinition from StepRepr,
RepresentationContext from StepRepr
is
Create returns ValidationProps;
---Purpose: Creates an empty tool
Create (WS: WorkSession from XSControl) returns ValidationProps;
---Purpose: Creates a tool and loads it with worksession
Init (me: in out; WS: WorkSession from XSControl) returns Boolean;
---Purpose: Load worksession; returns True if succeeded
AddProp (me: in out; Shape: Shape from TopoDS;
Prop: RepresentationItem from StepRepr;
Descr: CString;
instance: Boolean = Standard_False)
returns Boolean;
---Purpose: General method for adding (writing) a validation property
-- for shape which should be already mapped on writing itself.
-- It uses FindTarget() to find target STEP entity
-- resulting from given shape, and associated context
-- Returns True if success, False in case of fail
AddProp (me: in out; target: CharacterizedDefinition from StepRepr;
Context: RepresentationContext from StepRepr;
Prop: RepresentationItem from StepRepr;
Descr: CString)
returns Boolean;
---Purpose: General method for adding (writing) a validation property
-- for shape which should be already mapped on writing itself.
-- It takes target and Context entities which correspond to shape
-- Returns True if success, False in case of fail
AddArea (me: in out; Shape: Shape from TopoDS; Area: Real)
returns Boolean;
---Purpose: Adds surface area property for given shape (already mapped).
-- Returns True if success, False in case of fail
AddVolume (me: in out; Shape: Shape from TopoDS; Vol: Real)
returns Boolean;
---Purpose: Adds volume property for given shape (already mapped).
-- Returns True if success, False in case of fail
AddCentroid (me: in out; Shape: Shape from TopoDS; Pnt: Pnt from gp;
instance: Boolean = Standard_False)
returns Boolean;
---Purpose: Adds centroid property for given shape (already mapped).
-- Returns True if success, False in case of fail
-- If instance is True, then centroid is assigned to
-- an instance of component in assembly
FindTarget (me: in out; S: Shape from TopoDS;
target: out CharacterizedDefinition from StepRepr;
Context: out RepresentationContext from StepRepr;
instance: Boolean = Standard_False)
returns Boolean;
---Purpose: Finds target STEP entity to which validation props should
-- be assigned, and corresponding context, starting from shape
-- Returns True if success, False in case of fail
LoadProps (me; seq: out SequenceOfTransient from TColStd) returns Boolean;
---Purpose: Searches for entities of the type PropertyDefinitionRepresentation
-- in the model and fills the sequence by them
GetPropNAUO (me; PD: PropertyDefinition from StepRepr)
returns NextAssemblyUsageOccurrence from StepRepr;
---Purpose: Returns CDSR associated with given PpD or NULL if not found
-- (when, try GetPropSDR)
GetPropPD (me; PD: PropertyDefinition from StepRepr)
returns ProductDefinition from StepBasic;
---Purpose: Returns SDR associated with given PpD or NULL if not found
-- (when, try GetPropCDSR)
GetPropShape (me; ProdDef: ProductDefinition from StepBasic)
returns Shape from TopoDS;
---Purpose: Returns Shape associated with given SDR or Null Shape
-- if not found
GetPropShape (me; PD: PropertyDefinition from StepRepr)
returns Shape from TopoDS;
---Purpose: Returns Shape associated with given PpD or Null Shape
-- if not found
GetPropReal (me; item: RepresentationItem from StepRepr;
Val: out Real; isArea: out Boolean)
returns Boolean;
---Purpose: Returns value of Real-Valued property (Area or Volume)
-- If Property is neither Area nor Volume, returns False
-- Else returns True and isArea indicates whether property
-- is area or volume
GetPropPnt (me; item: RepresentationItem from StepRepr;
Context: RepresentationContext from StepRepr;
Pnt: out Pnt from gp)
returns Boolean;
---Purpose: Returns value of Centriod property (or False if it is not)
SetAssemblyShape (me: in out; shape: Shape from TopoDS);
---Purpose: Sets current assembly shape SDR (for FindCDSR calls)
fields
areaUnit, volUnit: Unit from StepBasic; -- units for sharing on writing
myAssemblyPD: ProductDefinition from StepBasic;
end ValidationProps;

View File

@@ -0,0 +1,729 @@
// File: STEPConstruct_ValidationProps.cxx
// Created: Thu Sep 9 09:25:31 1999
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <STEPConstruct_ValidationProps.ixx>
#include <STEPConstruct_UnitContext.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <Interface_EntityIterator.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_TransferReader.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Iterator.hxx>
#include <TCollection_HAsciiString.hxx>
#include <APIHeaderSection_MakeHeader.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
#include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
#include <StepRepr_ShapeAspect.hxx>
#include <StepRepr_CharacterizedDefinition.hxx>
#include <StepRepr_PropertyDefinition.hxx>
#include <StepRepr_HArray1OfRepresentationItem.hxx>
#include <StepRepr_MeasureRepresentationItem.hxx>
#include <StepRepr_GlobalUnitAssignedContext.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <StepBasic_MeasureValueMember.hxx>
#include <StepBasic_SiUnitAndLengthUnit.hxx>
#include <StepBasic_DerivedUnitElement.hxx>
#include <StepBasic_HArray1OfDerivedUnitElement.hxx>
#include <StepBasic_DerivedUnit.hxx>
#include <StepBasic_MeasureWithUnit.hxx>
#include <StepBasic_Unit.hxx>
#include <StepBasic_SiUnitAndAreaUnit.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
#include <StepRepr_ShapeRepresentationRelationship.hxx>
#include <STEPConstruct.hxx>
//=======================================================================
//function : STEPConstruct_ValidationProps
//purpose :
//=======================================================================
STEPConstruct_ValidationProps::STEPConstruct_ValidationProps ()
{
}
//=======================================================================
//function : STEPConstruct_ValidationProps
//purpose :
//=======================================================================
STEPConstruct_ValidationProps::STEPConstruct_ValidationProps (const Handle(XSControl_WorkSession) &WS)
: STEPConstruct_Tool(WS)
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::Init (const Handle(XSControl_WorkSession) &WS)
{
return SetWS ( WS );
}
//=======================================================================
//function : TransientResult CORRECTED
//purpose :
//=======================================================================
static Handle(Transfer_SimpleBinderOfTransient) TransientResult (const Handle(Standard_Transient)& res)
{
Handle(Transfer_SimpleBinderOfTransient) binder;
if (res.IsNull()) return binder;
binder = new Transfer_SimpleBinderOfTransient;
binder->SetResult (res);
return binder;
}
//=======================================================================
//function : FindTarget
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::FindTarget (const TopoDS_Shape &Shape,
StepRepr_CharacterizedDefinition &target,
Handle(StepRepr_RepresentationContext) &Context,
const Standard_Boolean instance)
{
// find the target STEP entity corresponding to a shape
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess(), Shape );
Handle(Transfer_Binder) binder = FinderProcess()->Find ( mapper );
#ifdef DEB
// cout << "\n>========------" << endl;
// cout << "Binders for " << Shape.TShape()->DynamicType()->Name() << " " << *(void**)&Shape.TShape() << ", Loc = " << *(void**)&Shape.Location() << endl;
// cout << "mapper = " << *(void**)&mapper << ", binder = " << *(void**)&binder << endl;
// DumpBinder ( binder );
#endif
// if requested, try to find instance of assembly
if ( instance ) {
/*
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
Standard_Boolean found = myAssemblyPD.IsNull()?
FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence), NAUO) :
STEPConstruct::FindNAUO (binder,myAssemblyPD,NAUO);
if ( found ) {
//skl find CDSR using NAUO:
Handle(StepShape_ContextDependentShapeRepresentation) CDSR
Interface_EntityIterator subs1 = graph.Sharings(NAUO);
for (subs1.Start(); subs1.More(); subs1.Next()) {
Handle(StepRepr_ProductDefinitionShape) PDS =
Handle(StepRepr_ProductDefinitionShape)::DownCast(subs1.Value());
if(PDS.IsNull()) continue;
//IsPDS=Standard_True;
Interface_EntityIterator subs2 = graph.Sharings(PDS);
for (subs2.Start(); CDSR.IsNull() && subs2.More(); subs2.Next()) {
CDSR = Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(subs2.Value());
}
}
if(!CDSR.IsNull()) {
target.SetValue ( CDSR->RepresentedProductRelation() );
Context = CDSR->RepresentationRelation()->Rep2()->ContextOfItems();
}
#ifdef DEB
else cout << "INSTANCE: CDRS from NAUO NOT found" << endl;
#endif
}
#ifdef DEB
else cout << "INSTANCE: NAUO NOT found" << endl;
#endif
*/
}
// for Compounds, search for SDR
else if ( Shape.ShapeType() == TopAbs_COMPOUND ) {
Handle(StepBasic_ProductDefinition) ProdDef;
if ( FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepBasic_ProductDefinition), ProdDef) ) {
Handle(StepRepr_ProductDefinitionShape) PDS;
Interface_EntityIterator subs1 = Graph().Sharings(ProdDef);
for (subs1.Start(); PDS.IsNull() && subs1.More(); subs1.Next()) {
PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(subs1.Value());
}
target.SetValue ( PDS );
#ifdef DEB
// cout << "COMPOUND: SDR found: " << sdr->DynamicType()->Name() << endl;
#endif
}
else {
#ifdef DEB
cout << "COMPOUND: ProdDef NOT found" << endl;
#endif
Handle(StepShape_ShapeRepresentation) SR;
if(FinderProcess()->FindTypedTransient(mapper,STANDARD_TYPE(StepShape_ShapeRepresentation),SR)) {
Handle(StepRepr_ProductDefinitionShape) PDS;
Interface_EntityIterator subs1 = Graph().Sharings(SR);
for (subs1.Start(); PDS.IsNull() && subs1.More(); subs1.Next()) {
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs1.Value());
if(SDR.IsNull()) continue;
PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(SDR->Definition().PropertyDefinition());
}
if(PDS.IsNull()) {
subs1 = Graph().Sharings(SR);
for (subs1.Start(); PDS.IsNull() && subs1.More(); subs1.Next()) {
Handle(StepRepr_RepresentationRelationship) RR =
Handle(StepRepr_RepresentationRelationship)::DownCast(subs1.Value());
if(RR.IsNull()) continue;
Handle(StepShape_ShapeRepresentation) SR1;
if(RR->Rep1()==SR)
SR1 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
else SR1 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
if(!SR1.IsNull()) {
Interface_EntityIterator subs2 = Graph().Sharings(SR1);
for (subs2.Start(); PDS.IsNull() && subs2.More(); subs2.Next()) {
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
if(SDR.IsNull()) continue;
PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(SDR->Definition().PropertyDefinition());
}
}
}
}
if(!PDS.IsNull()) {
target.SetValue(PDS);
Context = SR->ContextOfItems();
}
}
}
}
// for others, search for GEOMETRIC_REPRESENTATION_ITEM
else {
Handle(StepGeom_GeometricRepresentationItem) item;
if ( FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepGeom_GeometricRepresentationItem), item) ) {
#ifdef DEB
// cout << Shape.TShape()->DynamicType()->Name() << ": GeomRepItem found: " << item->DynamicType()->Name() << endl;
#endif
// find PDS (GRI <- SR <- SDR -> PDS)
Handle(StepRepr_ProductDefinitionShape) PDS;
Interface_EntityIterator subs = Graph().Sharings(item);
for (subs.Start(); PDS.IsNull() && subs.More(); subs.Next()) {
#ifdef DEB
// cout << "Parsing back refs: found " << subs.Value()->DynamicType()->Name() << endl;
#endif
if ( ! subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation)) ) continue;
Handle(StepShape_ShapeRepresentation) sr =
Handle(StepShape_ShapeRepresentation)::DownCast ( subs.Value() );
Context = sr->ContextOfItems();
Interface_EntityIterator sub2 = Graph().Sharings(subs.Value());
for (sub2.Start(); sub2.More(); sub2.Next()) {
if ( ! sub2.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)) ) continue;
Handle(StepShape_ShapeDefinitionRepresentation) sdr =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(sub2.Value());
PDS = Handle(StepRepr_ProductDefinitionShape)::DownCast ( sdr->Definition().PropertyDefinition() );
}
}
if ( ! PDS.IsNull() ) {
// find SHAPE_ASPECT or create it with all associated info if not yet exists
Handle(StepRepr_ShapeAspect) aspect;
Handle(Transfer_Binder) bbb = binder;
while ( ! bbb.IsNull() ) {
Handle(Transfer_SimpleBinderOfTransient) bx =
Handle(Transfer_SimpleBinderOfTransient)::DownCast ( bbb );
if ( ! bx.IsNull() ) {
Handle(StepRepr_ShapeAspect) asp =
Handle(StepRepr_ShapeAspect)::DownCast ( bx->Result() );
if ( ! asp.IsNull() && asp->OfShape() == PDS ) {
aspect = asp;
break;
}
}
bbb = bbb->NextResult();
}
if ( aspect.IsNull() ) {
// if ( ! FinderProcess()->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_ShapeAspect), aspect ) ||
// aspect->OfShape() != PDS )
#ifdef DEB
cout << Shape.TShape()->DynamicType()->Name() << ": SHAPE_ASPECT NOT found, creating" << endl;
#endif
// create aspect and all related data
Handle(TCollection_HAsciiString) AspectName = new TCollection_HAsciiString ( "" );
Handle(TCollection_HAsciiString) AspectDescr = new TCollection_HAsciiString ( "" );
aspect = new StepRepr_ShapeAspect;
aspect->Init ( AspectName, AspectDescr, PDS, StepData_LFalse );
StepRepr_CharacterizedDefinition SA;
SA.SetValue ( aspect );
Handle(TCollection_HAsciiString) PropDefName =
new TCollection_HAsciiString ( "shape with specific properties" );
Handle(TCollection_HAsciiString) PropDefDescr = new TCollection_HAsciiString ( "properties for subshape" );
Handle(StepRepr_PropertyDefinition) propdef = new StepRepr_PropertyDefinition;
propdef->Init ( PropDefName, Standard_True, PropDefDescr, SA );
Handle(TCollection_HAsciiString) SRName = new TCollection_HAsciiString ( "" );
Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation;
Handle(StepRepr_HArray1OfRepresentationItem) SRItems = new StepRepr_HArray1OfRepresentationItem ( 1, 1 );
SRItems->SetValue ( 1, item );
SR->Init ( SRName, SRItems, Context );
Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation;
StepRepr_RepresentedDefinition RD;
RD.SetValue ( propdef );
SDR->Init ( RD, SR );
// record SHAPE_ASPECT in the map
binder->AddResult ( TransientResult ( aspect ) );
// add SDR and all the data into model
Model()->AddWithRefs ( SDR );
}
// SHAPE_ASPECT found, but we also need context: FIND IT !!!!
else {
#ifdef DEB
cout << Shape.TShape()->DynamicType()->Name() << ": SHAPE_ASPECT found" << endl;
#endif
Handle(StepRepr_ProductDefinitionShape) aPDS = aspect->OfShape();
Interface_EntityIterator asubs = Graph().Sharings(aPDS);
for (asubs.Start(); Context.IsNull() && asubs.More(); asubs.Next()) {
if ( ! asubs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)) ) continue;
Handle(StepShape_ShapeDefinitionRepresentation) sdr =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(asubs.Value());
Context = sdr->UsedRepresentation()->ContextOfItems();
}
}
if ( ! aspect.IsNull() ) target.SetValue ( aspect );
}
#ifdef DEB
else cout << Shape.TShape()->DynamicType()->Name() << ": PDS NOT found, fail to create SHAPE_ASPECT" << endl;
#endif
}
#ifdef DEB
else cout << Shape.TShape()->DynamicType()->Name() << ": GeomRepItem NOT found" << endl;
#endif
}
// if target not found and shape has location, try the same shape without location
return ! target.IsNull();
}
//=======================================================================
//function : AddProp CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::AddProp (const StepRepr_CharacterizedDefinition &target,
const Handle(StepRepr_RepresentationContext) &Context,
const Handle(StepRepr_RepresentationItem) &Prop,
const Standard_CString Descr)
{
// FINALLY, create a structure of 5 entities describing a link between a shape and its property
Handle(TCollection_HAsciiString) PropDefName =
new TCollection_HAsciiString ( "geometric_validation_property" );
Handle(TCollection_HAsciiString) PropDefDescr = new TCollection_HAsciiString ( Descr );
Handle(StepRepr_PropertyDefinition) propdef = new StepRepr_PropertyDefinition;
propdef->Init ( PropDefName, Standard_True, PropDefDescr, target );
Handle(TCollection_HAsciiString) SRName = new TCollection_HAsciiString ( Descr );
Handle(StepRepr_Representation) rep = new StepRepr_Representation;
Handle(StepRepr_HArray1OfRepresentationItem) SRItems = new StepRepr_HArray1OfRepresentationItem ( 1, 1 );
SRItems->SetValue ( 1, Prop );
rep->Init ( SRName, SRItems, Context );
Handle(StepRepr_PropertyDefinitionRepresentation) PrDR = new StepRepr_PropertyDefinitionRepresentation;
StepRepr_RepresentedDefinition RD;
RD.SetValue ( propdef );
PrDR->Init ( RD, rep );
// record SDR in order to have it written to the file
Model()->AddWithRefs ( PrDR );
// for AP203, add subschema name
if ( Interface_Static::IVal("write.step.schema") ==3 ) {
APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) );
Handle(TCollection_HAsciiString) subSchema =
new TCollection_HAsciiString ( "GEOMETRIC_VALIDATION_PROPERTIES_MIM" );
mkHdr.AddSchemaIdentifier ( subSchema );
}
return Standard_True;
}
//=======================================================================
//function : AddProp CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::AddProp (const TopoDS_Shape &Shape,
const Handle(StepRepr_RepresentationItem) &Prop,
const Standard_CString Descr,
const Standard_Boolean instance)
{
StepRepr_CharacterizedDefinition target;
Handle(StepRepr_RepresentationContext) Context;
if ( ! FindTarget ( Shape, target, Context, instance ) ) return Standard_False;
return AddProp ( target, Context, Prop, Descr );
}
//=======================================================================
//function : AddVolume CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::AddVolume (const TopoDS_Shape &Shape,
const Standard_Real Vol)
{
Handle(StepBasic_MeasureValueMember) Val = new StepBasic_MeasureValueMember;
Val->SetReal ( Vol );
//Val->SetName ( "solid volume" );
Val->SetName ( "VOLUME_MEASURE");
// for volume unit, either take existing or create a new
if ( volUnit.DerivedUnit().IsNull() ) {
Handle(StepBasic_SiUnitAndLengthUnit) MM = new StepBasic_SiUnitAndLengthUnit;
MM->Init ( Standard_True, StepBasic_spMilli, StepBasic_sunMetre );
Handle(StepBasic_DerivedUnitElement) DUE = new StepBasic_DerivedUnitElement;
DUE->Init ( MM, 3. );
Handle(StepBasic_HArray1OfDerivedUnitElement) DUElems =
new StepBasic_HArray1OfDerivedUnitElement ( 1, 1 );
DUElems->SetValue ( 1, DUE );
Handle(StepBasic_DerivedUnit) DU = new StepBasic_DerivedUnit;
DU->Init ( DUElems );
volUnit.SetValue ( DU );
}
Handle(TCollection_HAsciiString) MRIName = new TCollection_HAsciiString ( "volume measure" );
Handle(StepRepr_MeasureRepresentationItem) MRI = new StepRepr_MeasureRepresentationItem;
MRI->Init ( MRIName, Val, volUnit );
return AddProp ( Shape, MRI, "volume" );
}
//=======================================================================
//function : AddArea CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::AddArea (const TopoDS_Shape &Shape,
const Standard_Real Area)
{
Handle(StepBasic_MeasureValueMember) Val = new StepBasic_MeasureValueMember;
Val->SetReal ( Area );
//Val->SetName ( "surface area" );
Val->SetName ( "AREA_MEASURE" );
// for area unit, either take existing or create a new
if ( areaUnit.DerivedUnit().IsNull() ) {
Handle(StepBasic_SiUnitAndLengthUnit) MM = new StepBasic_SiUnitAndLengthUnit;
MM->Init ( Standard_True, StepBasic_spMilli, StepBasic_sunMetre );
Handle(StepBasic_DerivedUnitElement) DUE = new StepBasic_DerivedUnitElement;
DUE->Init ( MM, 2. );
Handle(StepBasic_HArray1OfDerivedUnitElement) DUElems =
new StepBasic_HArray1OfDerivedUnitElement ( 1, 1 );
DUElems->SetValue ( 1, DUE );
Handle(StepBasic_DerivedUnit) DU = new StepBasic_DerivedUnit;
DU->Init ( DUElems );
areaUnit.SetValue ( DU );
}
Handle(TCollection_HAsciiString) MRIName = new TCollection_HAsciiString ( "surface area measure" );
Handle(StepRepr_MeasureRepresentationItem) MRI = new StepRepr_MeasureRepresentationItem;
MRI->Init ( MRIName, Val, areaUnit );
return AddProp ( Shape, MRI, "surface area" );
}
//=======================================================================
//function : AddCentroid CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::AddCentroid (const TopoDS_Shape &Shape,
const gp_Pnt &Pnt,
const Standard_Boolean instance)
{
Handle(TCollection_HAsciiString) CPName = new TCollection_HAsciiString ( "centre point" );
Handle(StepGeom_CartesianPoint) CP = new StepGeom_CartesianPoint;
CP->Init3D ( CPName, Pnt.X(), Pnt.Y(), Pnt.Z() );
return AddProp ( Shape, CP, "centroid", instance );
}
//=======================================================================
//function : LoadProps CORRECTED
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::LoadProps (TColStd_SequenceOfTransient &seq) const
{
// parse on PropertyDefinitionRepresentations
Standard_Integer nb = Model()->NbEntities();
Handle(Standard_Type) tPDR = STANDARD_TYPE(StepRepr_PropertyDefinitionRepresentation);
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) enti = Model()->Value(i);
if ( ! enti->IsKind (tPDR) ) continue;
Handle(StepRepr_PropertyDefinitionRepresentation) PDR =
Handle(StepRepr_PropertyDefinitionRepresentation)::DownCast ( enti );
// check that PDR is for validation props
Handle(StepRepr_PropertyDefinition) PD = PDR->Definition().PropertyDefinition();
if ( PD.IsNull() || PD->Name().IsNull()
|| PD->Name()->String() != "geometric_validation_property" )
continue;
seq.Append ( PDR );
}
return seq.Length() >0;
}
//=======================================================================
//function : GetPropPD CORRECTED
//purpose :
//=======================================================================
Handle(StepBasic_ProductDefinition) STEPConstruct_ValidationProps::GetPropPD (const Handle(StepRepr_PropertyDefinition) &PD) const
{
StepRepr_CharacterizedDefinition CD = PD->Definition();
// detect target entity of valprop
Handle(StepBasic_ProductDefinition) ProdDef;
Handle(StepRepr_PropertyDefinition) PDS = CD.ProductDefinitionShape();
if ( PDS.IsNull() ) {
Handle(StepRepr_ShapeAspect) SA = CD.ShapeAspect();
if ( SA.IsNull() ) {
#ifdef DEB
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << "Error: Cannot find target entity (SA) for geometric_validation_property ";
Model()->PrintLabel ( PD, sout );
sout << endl;
#endif
return ProdDef;
}
Interface_EntityIterator subs = Graph().Sharings(SA);
for (subs.Start(); subs.More(); subs.Next()) {
PDS = Handle(StepRepr_PropertyDefinition)::DownCast ( subs.Value() );
if ( PDS.IsNull() ) return ProdDef;
Interface_EntityIterator subs1 = Graph().Shareds(PDS);
for (subs1.Start(); ProdDef.IsNull() && subs1.More(); subs1.Next()) {
ProdDef = Handle(StepBasic_ProductDefinition)::DownCast ( subs1.Value() );
}
}
}
else {
Interface_EntityIterator subs = Graph().Shareds(PDS);
for (subs.Start(); ProdDef.IsNull() && subs.More(); subs.Next()) {
ProdDef = Handle(StepBasic_ProductDefinition)::DownCast ( subs.Value() );
}
}
#ifdef DEB
if ( ProdDef.IsNull() ) {
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << "Error: Cannot find target entity (SDR) for geometric_validation_property ";
Model()->PrintLabel ( PD, sout );
sout << endl;
}
#endif
return ProdDef;
}
//=======================================================================
//function : GetPropCDSR CORRECTED
//purpose :
//=======================================================================
Handle(StepRepr_NextAssemblyUsageOccurrence) STEPConstruct_ValidationProps::GetPropNAUO (const Handle(StepRepr_PropertyDefinition) &PD) const
{
StepRepr_CharacterizedDefinition CD = PD->Definition();
// detect target entity of valprop
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
Handle(StepRepr_PropertyDefinition) PDS = CD.ProductDefinitionShape();
if ( PDS.IsNull() ) return NAUO; // not found
Interface_EntityIterator subs = Graph().Shareds(PDS);
for (subs.Start(); NAUO.IsNull() && subs.More(); subs.Next()) {
NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast ( subs.Value() );
}
return NAUO;
}
//=======================================================================
//function : GetPropShape CORRECTED
//purpose :
//=======================================================================
TopoDS_Shape STEPConstruct_ValidationProps::GetPropShape (const Handle(StepBasic_ProductDefinition) &ProdDef) const
{
// find target shape
TopoDS_Shape S;
Handle(Transfer_Binder) binder = TransientProcess()->Find(ProdDef);
if ( ! binder.IsNull() && binder->HasResult() ) {
S = TransferBRep::ShapeResult ( TransientProcess(), binder );
}
//if ( S.IsNull() ) { // for subshape (via shape_aspect)
// Handle(StepRepr_Representation) rep = SDR->UsedRepresentation();
// for ( Standard_Integer j=1; S.IsNull() && j <= rep->NbItems(); j++ ) {
// binder = TransientProcess()->Find(rep->ItemsValue(j));
// if ( ! binder.IsNull() && binder->HasResult() ) {
// S = TransferBRep::ShapeResult ( TransientProcess(), binder );
// }
// }
//}
#ifdef DEB
if ( S.IsNull() ) {
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << "Warning: Entity ";
Model()->PrintLabel ( ProdDef, sout );
sout << " is not mapped to shape" << endl;
}
#endif
return S;
}
//=======================================================================
//function : GetPropShape CORRECTED
//purpose :
//=======================================================================
TopoDS_Shape STEPConstruct_ValidationProps::GetPropShape (const Handle(StepRepr_PropertyDefinition) &PD) const
{
Handle(StepBasic_ProductDefinition) ProdDef = GetPropPD ( PD );
TopoDS_Shape S;
if ( ! ProdDef.IsNull() ) S = GetPropShape ( ProdDef );
return S;
}
//=======================================================================
//function : GetPropReal
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::GetPropReal (const Handle(StepRepr_RepresentationItem) &item,
Standard_Real &Val, Standard_Boolean &isArea) const
{
// decode volume & area
if ( ! item->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem)) )
return Standard_False;
Handle(StepRepr_MeasureRepresentationItem) mri =
Handle(StepRepr_MeasureRepresentationItem)::DownCast ( item );
Handle(StepBasic_MeasureWithUnit) M = mri->Measure();
TCollection_AsciiString Name = M->ValueComponentMember()->Name();
StepBasic_Unit Unit = M->UnitComponent();
Standard_Real scale = 1.;
Handle(StepBasic_DerivedUnit) DU = Unit.DerivedUnit();
if ( ! DU.IsNull() ) {
for(Standard_Integer ind = 1; ind <= DU->NbElements(); ind++) {
Handle(StepBasic_DerivedUnitElement) DUE = DU->ElementsValue(ind);
Standard_Real exp = DUE->Exponent();
Handle(StepBasic_NamedUnit) NU = DUE->Unit();
STEPConstruct_UnitContext unit;
unit.ComputeFactors(NU);
if(unit.LengthDone()) {
Standard_Real lengthFactor = unit.LengthFactor();
scale *= pow(lengthFactor,exp);
}
}
}
else {
Handle(StepBasic_NamedUnit) NU = Unit.NamedUnit();
if(!NU.IsNull()) {
STEPConstruct_UnitContext unit;
unit.ComputeFactors(NU);
if(unit.AreaDone())
scale = unit.AreaFactor();
if(unit.VolumeDone())
scale = unit.VolumeFactor();
}
}
Val = M->ValueComponent() * scale;
if ( Name == "AREA_MEASURE" ) isArea = Standard_True;
else if ( Name == "VOLUME_MEASURE" ) isArea = Standard_False;
else {
#ifdef DEB
cout << "Warning: Measure " << Model()->StringLabel ( M ) << " is neither area not volume" << endl;
#endif
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : GetPropPnt
//purpose :
//=======================================================================
Standard_Boolean STEPConstruct_ValidationProps::GetPropPnt (const Handle(StepRepr_RepresentationItem) &item,
const Handle(StepRepr_RepresentationContext) &Context,
gp_Pnt &Pnt) const
{
// centroid
if ( ! item->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint)) )
return Standard_False;
Handle(StepGeom_CartesianPoint) P = Handle(StepGeom_CartesianPoint)::DownCast ( item );
if ( P.IsNull() || P->NbCoordinates() != 3 ) {
#ifdef DEB
cout << "Warning: Point " << Model()->StringLabel ( P ) << " is not valid for centroid" << endl;
#endif
return Standard_False;;
}
gp_Pnt pos ( P->CoordinatesValue(1), P->CoordinatesValue(2), P->CoordinatesValue(3) );
// scale according to units
if ( ! Context.IsNull() ) {
Handle(StepRepr_GlobalUnitAssignedContext) theGUAC;
if (Context->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext))) {
DeclareAndCast(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext, theGRCAGAUC,Context);
theGUAC = theGRCAGAUC->GlobalUnitAssignedContext();
}
else if (Context->IsKind(STANDARD_TYPE(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx))) {
DeclareAndCast(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx,
theGRCAGAUC,Context);
theGUAC = theGRCAGAUC->GlobalUnitAssignedContext();
}
if ( ! theGUAC.IsNull() ) {
STEPConstruct_UnitContext UnitTool;
UnitTool.ComputeFactors(theGUAC);
gp_Pnt zero(0,0,0);
pos.Scale ( zero, UnitTool.LengthFactor() );
}
}
Pnt = pos;
return Standard_True;
}
//=======================================================================
//function : SetAssemblyShape CORRECTED
//purpose :
//=======================================================================
void STEPConstruct_ValidationProps::SetAssemblyShape (const TopoDS_Shape& shape)
{
Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper(FinderProcess(),shape);
FinderProcess()->FindTypedTransient(mapper,STANDARD_TYPE(StepBasic_ProductDefinition),myAssemblyPD);
}