1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

66
src/STEPControl/STEPControl.cdl Executable file
View File

@@ -0,0 +1,66 @@
-- File: STEPControl.cdl
-- Created: Tue Apr 9 10:33:36 1996
-- Author: Christian CAILLET
-- <cky@paris1>
---Copyright: Matra Datavision 1996
package STEPControl
---Purpose : This package provides external access and control for STEP,
-- especially to deal with Shapes
uses
Standard,
gp,
TColStd,
TCollection,
Interface,
Transfer,
IFSelect,
XSControl,
TopoDS,
TopTools,
StepBasic,
StepData,
StepGeom,
StepShape,
StepRepr,
STEPConstruct,
TransferBRep,
StepToTopoDS, -- Non-manifold topology: STEP -> TopoDS (ssv; 13.11.2010)
MoniTool -- Non-manifold topology: TopoDS -> STEP (ssv; 13.11.2010)
is
enumeration StepModelType is
AsIs,
ManifoldSolidBrep,
BrepWithVoids,
FacetedBrep,
FacetedBrepAndBrepWithVoids,
ShellBasedSurfaceModel,
GeometricCurveSet,
Hybrid
end StepModelType;
---Purpose: Gives you the choice of translation mode for an Open
-- CASCADE shape that is being translated to STEP.
-- - STEPControl_AsIs translates an Open CASCADE shape to its
-- highest possible STEP representation.
-- - STEPControl_ManifoldSolidBrep translates an Open CASCADE shape
-- to a STEP manifold_solid_brep or brep_with_voids entity.
-- - STEPControl_FacetedBrep translates an Open CASCADE shape
-- into a STEP faceted_brep entity.
-- - STEPControl_ShellBasedSurfaceModel translates an Open CASCADE shape
-- into a STEP shell_based_surface_model entity.
-- - STEPControl_GeometricCurveSet
-- translates an Open CASCADE shape into a STEP geometric_curve_set entity.
class Controller;
class Reader;
class Writer;
class ActorRead;
class ActorWrite;
end STEPControl;

View File

@@ -0,0 +1,149 @@
-- File: STEPControl_ActorRead.cdl
-- Created: Wed Dec 21 15:51:21 1994
-- Author: Dieter THIEMANN
-- <dth@paris1>
---Copyright: Matra Datavision 1994
class ActorRead from STEPControl
inherits ActorOfTransientProcess from Transfer
---Purpose : This class performs the transfer of an Entity from
-- AP214 and AP203, either Geometric or Topologic.
--
-- I.E. for each type of Entity, it invokes the appropriate Tool
-- then returns the Binder which contains the Result
uses
TransientProcess from Transfer,
Binder from Transfer,
Trsf from gp,
Axis2Placement3d from StepGeom,
Representation from StepRepr,
RepresentationRelationship from StepRepr,
ProductDefinition from StepBasic,
NextAssemblyUsageOccurrence from StepRepr,
ShapeRepresentation from StepShape,
ContextDependentShapeRepresentation from StepShape,
ShapeRepresentationRelationship from StepRepr,
GeometricRepresentationItem from StepGeom,
MappedItem from StepRepr,
FaceSurface from StepShape,
ShapeBinder from TransferBRep,
NMTool from StepToTopoDS, -- To proceed with non-manifold cases (ssv; 13.11.2010)
Shell from TopoDS,
ListOfShape from TopTools,
Compound from TopoDS,
IndexedDataMapOfShapeListOfShape from TopTools
is
Create returns mutable ActorRead from STEPControl;
Recognize (me : mutable; start : Transient) returns Boolean is redefined;
Transfer (me : mutable; start : Transient;
TP : mutable TransientProcess from Transfer)
returns mutable Binder from Transfer is redefined;
-- calls TransferShape
TransferShape (me : mutable;
start : Transient;
TP : mutable TransientProcess from Transfer;
isManifold : Boolean = Standard_True)
returns mutable Binder from Transfer;
---Private: unit and uncertainty context management
PrepareUnits (me : mutable; rep: Representation from StepRepr;
TP: mutable TransientProcess from Transfer);
---Purpose: set units and tolerances context by given ShapeRepresentation
ResetUnits (me: mutable);
---Purpose: reset units and tolerances context to default
--- (mm, radians, read.precision.val, etc.)
ComputeTransformation (me: mutable; Origin, Target: Axis2Placement3d from StepGeom;
OrigContext, TargContext: Representation from StepRepr;
TP: mutable TransientProcess from Transfer;
Trsf: out Trsf from gp)
returns Boolean;
---Purpose: Computes transformation defined by two axis placements (in MAPPED_ITEM
-- or ITEM_DEFINED_TRANSFORMATION) taking into account their
-- representation contexts (i.e. units, which may be different)
-- Returns True if transformation is computed and is not an identity.
ComputeSRRWT (me: mutable; SRR: RepresentationRelationship from StepRepr;
TP: mutable TransientProcess from Transfer;
Trsf: out Trsf from gp)
returns Boolean;
---Purpose: Computes transformation defined by given
-- REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION
TransferEntity(me: mutable; PD : ProductDefinition from StepBasic;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers product definition entity
TransferEntity(me: mutable; NAUO : NextAssemblyUsageOccurrence from StepRepr;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers next assembly usage occurence entity
TransferEntity(me: mutable; sr : ShapeRepresentation from StepShape;
TP : mutable TransientProcess from Transfer;
isBound : out Boolean ) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers shape representation entity
TransferEntity(me: mutable; CDSR : ContextDependentShapeRepresentation from StepShape;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers context dependent shape representation entity
TransferEntity(me: mutable; und : ShapeRepresentationRelationship from StepRepr;
TP : mutable TransientProcess from Transfer;
nbrep : Integer =0) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers shape representation relationship entity
TransferEntity(me : mutable;
git : GeometricRepresentationItem from StepGeom;
TP : mutable TransientProcess from Transfer;
isManifold : Boolean) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers geometric representation item entity such as ManifoldSolidBRep ,...etc
TransferEntity(me: mutable; mapit : MappedItem from StepRepr;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers mapped item
TransferEntity(me: mutable; fs : FaceSurface from StepShape;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Transfers FaceSurface entity
OldWay(me: mutable; start : Transient;
TP : mutable TransientProcess from Transfer) returns mutable ShapeBinder from TransferBRep is protected;
---Purpose:Tranlates file by old way when CDSR are roots . Acts only if "read.step.product_mode" is equal Off.
closeIDEASShell(me : mutable;
shell : in Shell from TopoDS;
closingShells : in ListOfShape from TopTools)
returns Shell from TopoDS
is private;
computeIDEASClosings(me : mutable;
comp : in Compound from TopoDS;
shellClosingMap : in out IndexedDataMapOfShapeListOfShape from TopTools)
is private;
fields
-- theUnitFactor : Real; -- Conversion unit factor.
-- theVTol : Real; -- Tolerance for Vertices
-- theETol : Real; -- Tolerance for Edges
-- theFTol : Real; -- Tolerance for Faces
myNMTool : NMTool from StepToTopoDS; -- To proceed with non-manifold cases (ssv; 13.11.2010)
myPrecision : Real;
myMaxTol : Real;
mySRContext: Representation from StepRepr; -- context for unuts
end ActorRead;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
-- File: STEPControl_ActorWrite.cdl
-- Created: Tue Jan 31 15:19:16 1995
-- Author: Dieter THIEMANN
-- <dth@paris1>
---Copyright: Matra Datavision 1995
class ActorWrite from STEPControl
inherits ActorOfFinderProcess from Transfer
---Purpose : This class performs the transfer of a Shape from TopoDS
-- to AP203 or AP214 (CD2 or DIS)
uses FinderProcess, TransientProcess, Binder, Finder, StepModel from StepData,
Shape from TopoDS,
StepModelType from STEPControl,
Axis2Placement3d from StepGeom,
ShapeRepresentation from StepShape,
ShapeDefinitionRepresentation from StepShape,
HAsciiString from TCollection,
ContextTool from STEPConstruct,
Part from STEPConstruct,
HSequenceOfShape from TopTools, -- For non-manifold topology processing (ssv; 13.11.2010)
NonManifoldSurfaceShapeRepresentation from StepShape -- For non-manifold topology processing (ssv; 13.11.2010)
is
Create returns mutable ActorWrite from STEPControl;
Recognize (me : mutable; start : Finder) returns Boolean is redefined;
Transfer (me : mutable; start : Finder; FP : mutable FinderProcess)
returns mutable Binder is redefined;
-- enchains : TransferShape , MakeProductData , and manages mode
-- "simple" or in Assembly
TransferSubShape (me : mutable; start : Finder;
SDR : ShapeDefinitionRepresentation from StepShape;
AX1 : out Axis2Placement3d from StepGeom;
FP : mutable FinderProcess;
shapeGroup : HSequenceOfShape from TopTools = NULL;
isManifold : Boolean = Standard_True)
returns mutable Binder;
TransferShape (me : mutable; start : Finder;
SDR : ShapeDefinitionRepresentation from StepShape;
FP : mutable FinderProcess;
shapeGroup : HSequenceOfShape from TopTools = NULL;
isManifold : Boolean = Standard_True)
returns mutable Binder;
TransferCompound (me : mutable; start : Finder;
SDR : ShapeDefinitionRepresentation from StepShape;
FP : mutable FinderProcess)
returns mutable Binder;
-- InitProductData (me: mutable) returns Part from STEPConstruct;
-- MakeProductData (me : mutable;
-- SR : ShapeRepresentation from StepShape;
-- SDRTool : Part from STEPConstruct;
-- model : StepModel from StepData;
-- addPRPC : Boolean)
-- returns mutable Binder;
SetMode (me : mutable; M : StepModelType from STEPControl);
Mode (me) returns StepModelType from STEPControl;
SetGroupMode (me : mutable; mode : Integer);
-- Default is 0 (no group item)
-- 1 for REPRESENTATION_RELATIONSHIP with ITEM_DEFINED_TRANSFORMATION
-- other positive values if needed (not implemented)
GroupMode (me) returns Integer;
SetTolerance (me : mutable; Tol : Real);
-- Tol <= 0 means Unset
IsAssembly (me; S: in out Shape from TopoDS) returns Boolean is virtual;
---Purpose: Customizable method to check whether shape S should
-- be written as assembly or not
-- Default implementation uses flag GroupMode and analyses
-- the shape itself
-- NOTE: this method can modify shape
getNMSSRForGroup (me;
shapeGroup : HSequenceOfShape from TopTools;
FP : mutable FinderProcess;
isNMSSRCreated : in out Boolean)
returns NonManifoldSurfaceShapeRepresentation from StepShape
is private;
---Purpose: Non-manifold shapes are stored in NMSSR group
-- (NON_MANIFOLD_SURFACE_SHAPE_REPRESENTATION).
-- Use this method to get the corresponding NMSSR (or
-- to create a new one if doesn't exist yet)
-- (ssv; 13.11.2010)
fields
mygroup : Integer;
mytoler : Real;
myContext: ContextTool from STEPConstruct;
end ActorWrite;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
-- File: STEPControl_Controller.cdl
-- Created: Mon Feb 20 11:00:58 1995
-- Author: Christian CAILLET
-- <cky@paris1>
---Copyright: Matra Datavision 1995
class Controller from STEPControl inherits Controller from XSControl
---Purpose : defines basic controller for STEP processor
uses
CString,
Protocol from Interface,
InterfaceModel from Interface,
WorkLibrary from IFSelect,
ReturnStatus from IFSelect,
ActorOfTransientProcess from Transfer,
FinderProcess from Transfer,
ActorOfFinderProcess from Transfer,
Shape from TopoDS,
WorkSession from XSControl
is
Create returns mutable Controller from STEPControl;
---Purpose : Initializes the use of STEP Norm (the first time) and
-- returns a Controller
NewModel (me) returns mutable InterfaceModel from Interface;
---Purpose : Creates a new empty Model ready to receive data of the Norm.
-- It is taken from STEP Template Model
ActorRead (me; model : InterfaceModel)
returns mutable ActorOfTransientProcess from Transfer;
---Purpose : Returns a new Actor for Read attached to the pair (norm,appli)
-- It is a PmsToTopoDSAct_Actor
-- Redefined Transfer for Write (using Actor) --
Customise (me: mutable; WS : in out WorkSession from XSControl) is redefined;
TransferWriteShape (me; shape : Shape from TopoDS;
FP : mutable FinderProcess from Transfer;
model : mutable InterfaceModel from Interface;
modetrans : Integer = 0) returns ReturnStatus
is redefined;
---Purpose : Takes one Shape and transfers it to the InterfaceModel
-- (already created by NewModel for instance)
-- <modeshape> is to be interpreted by each kind of XstepAdaptor
-- Returns a status : 0 OK 1 No result 2 Fail -1 bad modeshape
-- -2 bad model (requires a StepModel)
-- modeshape : 1 Facetted BRep, 2 Shell, 3 Manifold Solid
-- for global initialisation
Init (myclass) returns Boolean;
---Purpose : Standard Initialisation. It creates a Controller for STEP
-- and records it to various names, available to select it later
-- Returns True when done, False if could not be done
end Controller;

View File

@@ -0,0 +1,412 @@
//:j4 gka 16.03.99 S4134
// gka 05.04.99 S4136: parameters definitions changed
#include <STEPControl_Controller.ixx>
#include <StepSelect_WorkLibrary.hxx>
#include <IFSelect_Option.hxx>
#include <IFSelect_Profile.hxx>
//#include <StepAP214.hxx>
#include <RWStepAP214.hxx>
#include <Standard_Version.hxx>
#include <StepData_StepModel.hxx>
#include <APIHeaderSection_MakeHeader.hxx>
#include <StepData_FileProtocol.hxx>
#include <HeaderSection.hxx>
#include <RWHeaderSection.hxx>
#include <IFSelect_SignCounter.hxx>
#include <IFSelect_SelectSignature.hxx>
#include <StepSelect_StepType.hxx>
// Pour NewModel et Write : definition de produit (temporaire ...)
#include <STEPControl_ActorRead.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPEdit.hxx>
#include <STEPEdit_EditContext.hxx>
#include <STEPEdit_EditSDR.hxx>
#include <APIHeaderSection_EditHeader.hxx>
#include <IFSelect_EditForm.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Static.hxx>
#include <Interface_Macros.hxx>
#include <IFSelect_SignAncestor.hxx>
#include <STEPSelections_SelectFaces.hxx>
#include <STEPSelections_SelectDerived.hxx>
#include <STEPSelections_SelectGSCurves.hxx>
#include <STEPSelections_SelectInstances.hxx>
#include <STEPSelections_SelectAssembly.hxx>
#include <XSAlgo.hxx>
#include <STEPSelections_SelectForTransfer.hxx>
#include <IFSelect_SelectModelRoots.hxx>
STEPControl_Controller::STEPControl_Controller ()
: XSControl_Controller ("STEP", "step")
{
static Standard_Boolean init = Standard_False;
if (!init) {
RWHeaderSection::Init(); RWStepAP214::Init();
Interface_Static::Init ("step","write.step.product.name",'t',"Open CASCADE STEP translator "OCC_VERSION_STRING);
Interface_Static::Init ("step","write.step.assembly",'e',"");
Interface_Static::Init ("step","write.step.assembly",'&',"enum 0");
Interface_Static::Init ("step","write.step.assembly",'&',"eval Off");
Interface_Static::Init ("step","write.step.assembly",'&',"eval On");
Interface_Static::Init ("step","write.step.assembly",'&',"eval Auto");
Interface_Static::SetCVal("write.step.assembly","Auto");
Interface_Static::Init("step","step.angleunit.mode", 'e',"");
Interface_Static::Init("step","step.angleunit.mode", '&',"enum 0");
Interface_Static::Init("step","step.angleunit.mode", '&',"eval File");
Interface_Static::Init("step","step.angleunit.mode", '&',"eval Rad");
Interface_Static::Init("step","step.angleunit.mode", '&',"eval Deg");
Interface_Static::SetCVal("step.angleunit.mode","File");
Interface_Static::Init("step","write.step.schema", 'e',"");
Interface_Static::Init("step","write.step.schema",'&',"enum 1");
Interface_Static::Init("step","write.step.schema",'&',"eval AP214CD");
Interface_Static::Init("step","write.step.schema",'&',"eval AP214DIS");
Interface_Static::Init("step","write.step.schema",'&',"eval AP203");
Interface_Static::Init("step","write.step.schema",'&',"eval AP214IS");
Interface_Static::SetCVal("write.step.schema","AP214CD");
// Type of Product Definition for reading
// Note: the numbers should be consistent with function FindShapeReprType()
// in STEPControl_ActorRead.cxx
Interface_Static::Init("step","read.step.shape.repr",'e',"");
Interface_Static::Init("step","read.step.shape.repr",'&',"enum 1");
Interface_Static::Init("step","read.step.shape.repr",'&',"eval All"); // 1
Interface_Static::Init("step","read.step.shape.repr",'&',"eval ABSR"); // 2
Interface_Static::Init("step","read.step.shape.repr",'&',"eval MSSR"); // 3
Interface_Static::Init("step","read.step.shape.repr",'&',"eval GBSSR"); // 4
Interface_Static::Init("step","read.step.shape.repr",'&',"eval FBSR"); // 5
Interface_Static::Init("step","read.step.shape.repr",'&',"eval EBWSR"); // 6
Interface_Static::Init("step","read.step.shape.repr",'&',"eval GBWSR"); // 7
Interface_Static::SetCVal("read.step.shape.repr","All");
// Mode for reading shapes attached to main SDR by SRR
// (hybrid model representation in AP203 since 1998)
Interface_Static::Init("step","read.step.shape.relationship",'e',"");
Interface_Static::Init("step","read.step.shape.relationship",'&',"enum 0");
Interface_Static::Init("step","read.step.shape.relationship",'&',"eval OFF");
Interface_Static::Init("step","read.step.shape.relationship",'&',"eval ON");
Interface_Static::SetCVal("read.step.shape.relationship","ON");
// Mode for reading shapes attached to Product by ShapeAspect
// (hybrid model representation in AP203 before 1998)
Interface_Static::Init("step","read.step.shape.aspect",'e',"");
Interface_Static::Init("step","read.step.shape.aspect",'&',"enum 0");
Interface_Static::Init("step","read.step.shape.aspect",'&',"eval OFF");
Interface_Static::Init("step","read.step.shape.aspect",'&',"eval ON");
Interface_Static::SetCVal("read.step.shape.aspect","ON");
// Mode for reading SDR and ShapeRepr if it is necessary
Interface_Static::Init("step","read.step.product.mode",'e',"");
Interface_Static::Init("step","read.step.product.mode",'&',"enum 0");
Interface_Static::Init("step","read.step.product.mode",'&',"eval OFF");
Interface_Static::Init("step","read.step.product.mode",'&',"eval ON");
Interface_Static::SetCVal("read.step.product.mode","ON");
// Order of reading ShapeDefinitionRepresentation in ProductDefinition
Interface_Static::Init("step","read.step.product.context",'e',"");
Interface_Static::Init("step","read.step.product.context",'&',"enum 1");
Interface_Static::Init("step","read.step.product.context",'&',"eval all"); // 1
Interface_Static::Init("step","read.step.product.context",'&',"eval design"); // 2
Interface_Static::Init("step","read.step.product.context",'&',"eval analysis");// 3
Interface_Static::SetCVal("read.step.product.context","all");
// What we try to read in ProductDefinition
Interface_Static::Init("step","read.step.assembly.level",'e',"");
Interface_Static::Init("step","read.step.assembly.level",'&',"enum 1");
Interface_Static::Init("step","read.step.assembly.level",'&',"eval all"); // 1
Interface_Static::Init("step","read.step.assembly.level",'&',"eval assembly"); // 2
Interface_Static::Init("step","read.step.assembly.level",'&',"eval structure");// 3
Interface_Static::Init("step","read.step.assembly.level",'&',"eval shape"); // 4
Interface_Static::SetCVal("read.step.assembly.level","all");
// unit: supposed to be cascade unit (target unit for reading)
Interface_Static::Init("step","write.step.unit", 'e',"");
Interface_Static::Init("step","write.step.unit",'&',"enum 1");
Interface_Static::Init("step","write.step.unit",'&',"eval INCH"); // 1
Interface_Static::Init("step","write.step.unit",'&',"eval MM"); // 2
Interface_Static::Init("step","write.step.unit",'&',"eval ??"); // 3
Interface_Static::Init("step","write.step.unit",'&',"eval FT"); // 4
Interface_Static::Init("step","write.step.unit",'&',"eval MI"); // 5
Interface_Static::Init("step","write.step.unit",'&',"eval M"); // 6
Interface_Static::Init("step","write.step.unit",'&',"eval KM"); // 7
Interface_Static::Init("step","write.step.unit",'&',"eval MIL"); // 8
Interface_Static::Init("step","write.step.unit",'&',"eval UM"); // 9
Interface_Static::Init("step","write.step.unit",'&',"eval CM"); //10
Interface_Static::Init("step","write.step.unit",'&',"eval UIN"); //11
Interface_Static::SetCVal ("write.step.unit","MM");
// Non-manifold topology reading: OFF by default (ssv; 26.11.2010)
Interface_Static::Init ("step","read.step.nonmanifold",'e',"");
Interface_Static::Init ("step","read.step.nonmanifold",'&',"enum 0");
Interface_Static::Init ("step","read.step.nonmanifold",'&',"eval Off");
Interface_Static::Init ("step","read.step.nonmanifold",'&',"eval On");
Interface_Static::SetIVal("read.step.nonmanifold",0);
// Non-manifold topology writing: OFF by default (ssv; 26.11.2010)
Interface_Static::Init ("step","write.step.nonmanifold",'e',"");
Interface_Static::Init ("step","write.step.nonmanifold",'&',"enum 0");
Interface_Static::Init ("step","write.step.nonmanifold",'&',"eval Off");
Interface_Static::Init ("step","write.step.nonmanifold",'&',"eval On");
Interface_Static::SetIVal("write.step.nonmanifold",0);
// I-Deas-like STEP processing: OFF by default (ssv; 22.11.2010)
Interface_Static::Init ("step","read.step.ideas",'e',"");
Interface_Static::Init ("step","read.step.ideas",'&',"enum 0");
Interface_Static::Init ("step","read.step.ideas",'&',"eval Off");
Interface_Static::Init ("step","read.step.ideas",'&',"eval On");
Interface_Static::SetIVal("read.step.ideas",0);
// abv 15.11.00: ShapeProcessing
Interface_Static::Init ("XSTEP","write.step.resource.name",'t',"STEP");
Interface_Static::Init ("XSTEP","read.step.resource.name",'t',"STEP");
Interface_Static::Init ("XSTEP","write.step.sequence",'t',"ToSTEP");
Interface_Static::Init ("XSTEP","read.step.sequence",'t',"FromSTEP");
init = Standard_True;
}
Handle(STEPControl_ActorWrite) ActWrite = new STEPControl_ActorWrite;
ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
theAdaptorWrite = ActWrite;
Handle(StepSelect_WorkLibrary) swl = new StepSelect_WorkLibrary;
swl->SetDumpLabel(1);
theAdaptorLibrary = swl;
theAdaptorProtocol = STEPEdit::Protocol();
// theAdaptorProtocol = StepAP214::Protocol();
theAdaptorRead = new STEPControl_ActorRead; // par ex pour Recognize
SetModeWrite (0,4);
SetModeWriteHelp (0,"As Is");
SetModeWriteHelp (1,"Faceted Brep");
SetModeWriteHelp (2,"Shell Based");
SetModeWriteHelp (3,"Manifold Solid");
SetModeWriteHelp (4,"Wireframe");
TraceStatic ("read.surfacecurve.mode",5);
// --- SELECTIONS, SIGNATURES, COMPTEURS, EDITEURS
DeclareAndCast(IFSelect_Selection,xmr,SessionItem("xst-model-roots"));
if (!xmr.IsNull()) {
Handle(IFSelect_Signature) sty = STEPEdit::SignType();
AddSessionItem (sty,"step-type");
Handle(IFSelect_SignCounter) tys = new IFSelect_SignCounter
(sty,Standard_False,Standard_True);
AddSessionItem (tys,"step-types");
theSignType = sty;
//pdn S4133 18.02.99
Handle(IFSelect_SignAncestor)sta = new IFSelect_SignAncestor();
AddSessionItem (sta,"xst-derived");
Handle(STEPSelections_SelectDerived) stdvar = new STEPSelections_SelectDerived();
stdvar->SetProtocol(STEPEdit::Protocol());
AddSessionItem (stdvar,"step-derived");
Handle(IFSelect_SelectSignature) selsdr = STEPEdit::NewSelectSDR();
selsdr->SetInput (xmr);
AddSessionItem (selsdr,"step-shape-def-repr");
Handle(IFSelect_SelectSignature) selrrs = STEPEdit::NewSelectPlacedItem();
// selrrs->SetInput (xmr); deja prete avec ModelAll
AddSessionItem (selrrs,"step-placed-items");
Handle(IFSelect_SelectSignature) selsr = STEPEdit::NewSelectShapeRepr();
// input deja pret avec ModelAll
AddSessionItem (selsr,"step-shape-repr");
}
//pdn
Handle(STEPSelections_SelectFaces) stfaces = new STEPSelections_SelectFaces;
stfaces->SetInput (xmr);
AddSessionItem (stfaces,"step-faces");
Handle(STEPSelections_SelectInstances) stinst = new STEPSelections_SelectInstances;
AddSessionItem (stinst,"step-instances");
Handle(STEPSelections_SelectGSCurves) stcurves = new STEPSelections_SelectGSCurves;
stcurves->SetInput (xmr);
AddSessionItem (stcurves,"step-GS-curves");
Handle(STEPSelections_SelectAssembly) assembly = new STEPSelections_SelectAssembly;
assembly->SetInput (xmr);
AddSessionItem (assembly,"step-assembly");
Handle(APIHeaderSection_EditHeader) edhead = new APIHeaderSection_EditHeader;
Handle(IFSelect_EditForm) edheadf = new IFSelect_EditForm (edhead,Standard_False,Standard_True,"Step Header");
AddSessionItem (edhead,"step-header-edit");
AddSessionItem (edheadf,"step-header");
Handle(STEPEdit_EditContext) edctx = new STEPEdit_EditContext;
Handle(IFSelect_EditForm) edctxf = new IFSelect_EditForm (edctx,Standard_False,Standard_True,"STEP Product Definition Context");
AddSessionItem (edctx,"step-context-edit");
AddSessionItem (edctxf,"step-context");
Handle(STEPEdit_EditSDR) edsdr = new STEPEdit_EditSDR;
Handle(IFSelect_EditForm) edsdrf = new IFSelect_EditForm (edsdr,Standard_False,Standard_True,"STEP Product Data (SDR)");
AddSessionItem (edsdr,"step-SDR-edit");
AddSessionItem (edsdrf,"step-SDR-data");
// #### PROFILE ####
// ActorRead : on ajoute le cas Shape possible, a part du default
// ainsi, on l a tjrs sous la main
Handle(IFSelect_Option) optacrd = Profile()->Option("tr-read");
optacrd->Add ("shape",theAdaptorRead);
// ActorWrite : on ajoute les cas possibles (NB : shape == default)
// On garde a part les cas shape compound (= shape traitee globale ou en
// assembly), peuvent etre utiles. Tandis que les autres cas sont
// susceptibles d etre remplaces si on fait du Model-Editor
Handle(IFSelect_Option) optacwr = Profile()->Option("tr-write");
Handle(STEPControl_ActorWrite) ActWSh = new STEPControl_ActorWrite;
ActWSh->SetGroupMode(0);
optacwr->Add ("shape",ActWSh);
Handle(STEPControl_ActorWrite) ActWA1 = new STEPControl_ActorWrite;
ActWA1->SetGroupMode(1);
optacwr->Add ("compound",ActWA1);
optacwr->Add ("assembly",ActWA1);
optacwr->Add ("SRWT",ActWA1);
Profile()->AddConf ("Shape");
Profile()->AddSwitch ("Shape","tr-write","shape");
Profile()->AddConf ("Assembly");
Profile()->AddSwitch ("Assembly","tr-write","SRWT");
}
Handle(Interface_InterfaceModel) STEPControl_Controller::NewModel () const
{
return STEPEdit::NewModel();
}
Handle(Transfer_ActorOfTransientProcess) STEPControl_Controller::ActorRead
(const Handle(Interface_InterfaceModel)& ) const
{
return theAdaptorRead;
} // new Cc1ToTopoDSAct_Actor ??
// #### PROVISOIRE ??? ####
IFSelect_ReturnStatus STEPControl_Controller::TransferWriteShape
(const TopoDS_Shape& shape,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modeshape) const
{
if (modeshape < 0 || modeshape > 4) return IFSelect_RetError;
Handle(STEPControl_ActorWrite) ActWrite =
Handle(STEPControl_ActorWrite)::DownCast(theAdaptorWrite);
// A PRESENT ON PASSE PAR LE PROFILE
if (!ActWrite.IsNull())
ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
return XSControl_Controller::TransferWriteShape (shape,FP,model,modeshape);
}
Standard_Boolean STEPControl_Controller::Init ()
{
static Standard_Boolean inic = Standard_False;
if (!inic) {
Handle(STEPControl_Controller) STEPCTL = new STEPControl_Controller;
STEPCTL->AutoRecord(); // avec les noms donnes a la construction
XSAlgo::Init();
inic = Standard_True;
}
return Standard_True;
}
//=======================================================================
//function : Customise
//purpose :
//=======================================================================
void STEPControl_Controller::Customise(Handle(XSControl_WorkSession)& WS)
{
XSControl_Controller::Customise(WS);
Handle(IFSelect_SelectModelRoots) slr;
Handle(Standard_Transient) slr1 = WS->NamedItem("xst-model-roots");
if(!slr1.IsNull())
slr = Handle(IFSelect_SelectModelRoots)::DownCast(slr1);
else {
slr = new IFSelect_SelectModelRoots;
WS->AddNamedItem ("xst-model-roots",slr);
}
Handle(STEPSelections_SelectForTransfer) st1= new STEPSelections_SelectForTransfer;
st1->SetReader (WS->TransferReader());
WS->AddNamedItem ("xst-transferrable-roots",st1);
//DeclareAndCast(IFSelect_Selection,xmr,SessionItem("xst-model-roots"));
if (!slr.IsNull()) {
Handle(IFSelect_Signature) sty = STEPEdit::SignType();
WS->AddNamedItem ("step-type",sty);
Handle(IFSelect_SignCounter) tys = new IFSelect_SignCounter
(sty,Standard_False,Standard_True);
WS->AddNamedItem ("step-types",tys);
theSignType = sty;
//pdn S4133 18.02.99
Handle(IFSelect_SignAncestor)sta = new IFSelect_SignAncestor();
WS->AddNamedItem ("xst-derived",sta);
Handle(STEPSelections_SelectDerived) stdvar = new STEPSelections_SelectDerived();
stdvar->SetProtocol(STEPEdit::Protocol());
WS->AddNamedItem ("step-derived",stdvar);
Handle(IFSelect_SelectSignature) selsdr = STEPEdit::NewSelectSDR();
selsdr->SetInput (slr);
WS->AddNamedItem ("step-shape-def-repr",selsdr);
Handle(IFSelect_SelectSignature) selrrs = STEPEdit::NewSelectPlacedItem();
// selrrs->SetInput (slr); deja prete avec ModelAll
WS->AddNamedItem ("step-placed-items",selrrs);
Handle(IFSelect_SelectSignature) selsr = STEPEdit::NewSelectShapeRepr();
// input deja pret avec ModelAll
WS->AddNamedItem ("step-shape-repr",selsr);
}
//pdn
Handle(STEPSelections_SelectFaces) stfaces = new STEPSelections_SelectFaces;
stfaces->SetInput (slr);
WS->AddNamedItem ("step-faces",stfaces);
Handle(STEPSelections_SelectInstances) stinst = new STEPSelections_SelectInstances;
WS->AddNamedItem ("step-instances",stinst);
Handle(STEPSelections_SelectGSCurves) stcurves = new STEPSelections_SelectGSCurves;
stcurves->SetInput (slr);
WS->AddNamedItem ("step-GS-curves",stcurves);
Handle(STEPSelections_SelectAssembly) assembly = new STEPSelections_SelectAssembly;
assembly->SetInput (slr);
WS->AddNamedItem ("step-assembly",assembly);
Handle(APIHeaderSection_EditHeader) edhead = new APIHeaderSection_EditHeader;
Handle(IFSelect_EditForm) edheadf = new IFSelect_EditForm (edhead,Standard_False,Standard_True,"Step Header");
WS->AddNamedItem ("step-header-edit",edhead);
WS->AddNamedItem ("step-header",edheadf);
Handle(STEPEdit_EditContext) edctx = new STEPEdit_EditContext;
Handle(IFSelect_EditForm) edctxf = new IFSelect_EditForm (edctx,Standard_False,Standard_True,"STEP Product Definition Context");
WS->AddNamedItem ("step-context-edit",edctx);
WS->AddNamedItem ("step-context",edctxf);
Handle(STEPEdit_EditSDR) edsdr = new STEPEdit_EditSDR;
Handle(IFSelect_EditForm) edsdrf = new IFSelect_EditForm (edsdr,Standard_False,Standard_True,"STEP Product Data (SDR)");
WS->AddNamedItem ("step-SDR-edit",edsdr);
WS->AddNamedItem ("step-SDR-data",edsdrf);
}

View File

@@ -0,0 +1,77 @@
-- File: STEPControl_Reader.cdl
-- Created: Mon Jul 8 15:29:41 1996
-- Author: Christian CAILLET
-- <cky@paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Reader from STEPControl inherits Reader from XSControl
---Purpose : Reads STEP files, checks them and translates their contents
-- into Open CASCADE models. The STEP data can be that of
-- a whole model or that of a specific list of entities in the model.
-- As in XSControl_Reader, you specify the list using a selection.
-- For the translation of iges files it is possible to use next sequence:
-- To change translation parameters
-- class Interface_Static should be used before beginning of
-- translation (see STEP Parameters and General Parameters)
-- Creation of reader - STEPControl_Reader reader;
-- To load s file in a model use method reader.ReadFile("filename.stp")
-- To print load results reader.PrintCheckLoad(failsonly,mode)
-- where mode is equal to the value of enumeration IFSelect_PrintCount
-- For definition number of candidates :
-- Standard_Integer nbroots = reader. NbRootsForTransfer();
-- To transfer entities from a model the following methods can be used:
-- for the whole model - reader.TransferRoots();
-- to transfer a list of entities: reader.TransferList(list);
-- to transfer one entity Handle(Standard_Transient)
-- ent = reader.RootForTransfer(num);
-- reader.TransferEntity(ent), or
-- reader.TransferOneRoot(num), or
-- reader.TransferOne(num), or
-- reader.TransferRoot(num)
-- To obtain the result the following method can be used:
-- reader.NbShapes() and reader.Shape(num); or reader.OneShape();
-- To print the results of transfer use method:
-- reader.PrintCheckTransfer(failwarn,mode);
-- where printfail is equal to the value of enumeration
-- IFSelect_PrintFail, mode see above; or reader.PrintStatsTransfer();
-- Gets correspondence between a STEP entity and a result
-- shape obtained from it.
-- Handle(XSControl_WorkSession)
-- WS = reader.WS();
-- if ( WS->TransferReader()->HasResult(ent) )
-- TopoDS_Shape shape = WS->TransferReader()->ShapeResult(ent);
uses
CString, OStream, Transient, SequenceOfTransient from TColStd,
StepModel from StepData, WorkSession from XSControl,
ReturnStatus from IFSelect, PrintCount from IFSelect,
Shape from TopoDS, SequenceOfShape from TopTools
is
Create returns Reader;
---Purpose : Creates a reader object with an empty STEP model.
Create (WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True) returns Reader;
---Purpose : Creates a Reader for STEP from an already existing Session
-- Clears the session if it was not yet set for STEP
StepModel (me) returns StepModel;
---Purpose : Returns the model as a StepModel.
-- It can then be consulted (header, product)
TransferRoot (me : in out; num : Integer = 1) returns Boolean;
---Purpose : Transfers a root given its rank in the list of candidate roots
-- Default is the first one
-- Returns True if a shape has resulted, false else
-- Same as inherited TransferOneRoot, kept for compatibility
NbRootsForTransfer (me : in out) returns Integer is redefined;
---Purpose : Determines the list of root entities from Model which are candidate for
-- a transfer to a Shape (type of entities is PRODUCT)
end Reader;

View File

@@ -0,0 +1,260 @@
#include <STEPControl_Reader.ixx>
#include <STEPControl_Controller.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_TransferReader.hxx>
#include <Interface_ShareFlags.hxx>
#include <STEPControl_ActorRead.hxx>
#include <StepBasic_ProductDefinition.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_Graph.hxx>
#include <Interface_Static.hxx>
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepBasic_ProductDefinitionContext.hxx>
#include <StepBasic_ApplicationContext.hxx>
#include <TCollection_AsciiString.hxx>
#include <StepBasic_ProductDefinitionWithAssociatedDocuments.hxx>
#include <StepBasic_DocumentProductEquivalence.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepRepr_PropertyDefinition.hxx>
#include <StepRepr_RepresentationRelationship.hxx>
#include <StepRepr_ShapeAspect.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepRepr_RepresentationMap.hxx>
#include <StepRepr_MappedItem.hxx>
#include <Transfer_TransientProcess.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
//=======================================================================
//function : STEPControl_Reader
//purpose :
//=======================================================================
STEPControl_Reader::STEPControl_Reader ()
{
STEPControl_Controller::Init();
SetNorm ("STEP");
}
//=======================================================================
//function : STEPControl_Reader
//purpose :
//=======================================================================
STEPControl_Reader::STEPControl_Reader
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
STEPControl_Controller::Init();
SetWS (WS,scratch);
SetNorm ("STEP");
}
//=======================================================================
//function : StepModel
//purpose :
//=======================================================================
Handle(StepData_StepModel) STEPControl_Reader::StepModel () const
{
return Handle(StepData_StepModel)::DownCast(Model());
}
//=======================================================================
//function : TransferRoot
//purpose :
//=======================================================================
Standard_Boolean STEPControl_Reader::TransferRoot (const Standard_Integer num)
{
return TransferOneRoot (num);
}
//=======================================================================
//function : NbRootsForTransfer
//purpose :
//=======================================================================
Standard_Integer STEPControl_Reader::NbRootsForTransfer()
{
if (therootsta) return theroots.Length();
therootsta = Standard_True;
//theroots.Clear();
Standard_Integer nb = Model()->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = Model()->Value(i);
if(ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinition))) {
// PTV 31.01.2003 TRJ11 exclude Product Definition With Associated Document from roots
if (ent->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments))) {
// check if PDWAD-> PDF <-Document_Product_Equivalence.
Standard_Boolean iSexclude = Standard_False;
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments) PDWAD =
Handle(StepBasic_ProductDefinitionWithAssociatedDocuments)::DownCast(ent);
Interface_EntityIterator PDWADsubs = WS()->Graph().Shareds(PDWAD);
for (PDWADsubs.Start(); PDWADsubs.More(); PDWADsubs.Next()) {
if ( !PDWADsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_ProductDefinitionFormation)))
continue;
Handle(StepBasic_ProductDefinitionFormation) localPDF =
Handle(StepBasic_ProductDefinitionFormation)::DownCast(PDWADsubs.Value());
Interface_EntityIterator PDFsubs = WS()->Graph().Sharings(localPDF);
for( PDFsubs.Start(); PDFsubs.More(); PDFsubs.Next() )
if (PDFsubs.Value()->IsKind(STANDARD_TYPE(StepBasic_DocumentProductEquivalence))) {
iSexclude = Standard_True;
break;
}
if (iSexclude)
break;
}
if (iSexclude) {
#ifdef DEB
cout << "Warning: STEPControl_Reader::NbRootsForTransfer exclude PDWAD from roots" << endl;
#endif
continue;
}
}
Handle(StepBasic_ProductDefinition) PD =
Handle(StepBasic_ProductDefinition)::DownCast(ent);
Standard_Boolean IsRoot = Standard_True;
const Interface_Graph& graph = WS()->Graph();
// determinate roots used NextAssemblyUsageOccurrence
Interface_EntityIterator subs = graph.Sharings(PD);
for(subs.Start(); subs.More(); subs.Next()) {
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value());
if (NAUO.IsNull()) continue;
if (PD==NAUO->RelatedProductDefinition()) IsRoot=Standard_False;
}
// determinate roots used ProductDefinitionContext
if(IsRoot) {
const char *str1 = Interface_Static::CVal("read.step.product.context");
Standard_Integer ICS = Interface_Static::IVal("read.step.product.context");
if(ICS>1) {
subs = graph.Shareds(PD);
for(subs.Start(); subs.More(); subs.Next()) {
Handle(StepBasic_ProductDefinitionContext) PDC =
Handle(StepBasic_ProductDefinitionContext)::DownCast(subs.Value());
if (PDC.IsNull()) continue;
const char *str2 = PDC->LifeCycleStage()->String().ToCString();
const char *str3 = PDC->Name()->String().ToCString();
if( !( strcasecmp(str1,str2)==0 || strcasecmp(str1,str3)==0 ) )
IsRoot=Standard_False;
}
}
}
// determinate roots used ProductDefinitionFormationRelationship
//subs = graph.Shareds(PD);
//for(subs.Start(); subs.More(); subs.Next()) {
// Handle(StepBasic_ProductDefinitionFormation) PDF =
// Handle(StepBasic_ProductDefinitionFormation)::DownCast(subs.Value());
// if (PDF.IsNull()) continue;
// Interface_EntityIterator subs1 = graph.Sharings(PDF);
// for(subs1.Start(); subs1.More(); subs1.Next()) {
// Handle(StepBasic_ProductDefinitionFormationRelationship) PDFR =
// Handle(StepBasic_ProductDefinitionFormationRelationship)::DownCast(subs1.Value());
// if (PDFR.IsNull()) continue;
// if (PDF==PDFR->RelatedProductDefinition()) IsRoot=Standard_False;
// }
//}
if (IsRoot) {
theroots.Append(ent);
WS()->MapReader()->RootsForTransfer()->Append(ent);
}
}
TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode");
if(!aProdMode.IsEqual("ON")) {
if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
Standard_Boolean IsRoot = Standard_True;
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(ent);
Handle(StepRepr_PropertyDefinition) PropDef = SDR->Definition().PropertyDefinition();
if(!PropDef.IsNull()) {
Handle(StepBasic_ProductDefinition) PD = PropDef->Definition().ProductDefinition();
if(!PD.IsNull()) IsRoot = Standard_False;
if(IsRoot) {
Handle(StepRepr_ShapeAspect) SA = PropDef->Definition().ShapeAspect();
if(!SA.IsNull()) {
Handle(StepRepr_ProductDefinitionShape) PDS = SA->OfShape();
PD = PDS->Definition().ProductDefinition();
if(!PD.IsNull()) IsRoot = Standard_False;
}
}
if(IsRoot) {
Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO =
Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(PropDef->Definition().ProductDefinitionRelationship());
if(!NAUO.IsNull()) IsRoot = Standard_False;
}
if(IsRoot) {
Handle(StepShape_ShapeRepresentation) SR =
Handle(StepShape_ShapeRepresentation)::DownCast(SDR->UsedRepresentation());
if(SR.IsNull()) IsRoot = Standard_False;
}
}
if(IsRoot) {
theroots.Append(ent);
WS()->MapReader()->RootsForTransfer()->Append(ent);
}
}
if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) {
Standard_Boolean IsRoot = Standard_True;
Handle(StepShape_ShapeRepresentation) SR =
Handle(StepShape_ShapeRepresentation)::DownCast(ent);
const Interface_Graph& graph = WS()->Graph();
Interface_EntityIterator subs = graph.Sharings(SR);
for(subs.Start(); subs.More() && IsRoot; subs.Next()) {
Handle(StepShape_ShapeDefinitionRepresentation) SDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
if(!SDR.IsNull()) IsRoot = Standard_False;
if(IsRoot) {
Handle(StepRepr_RepresentationRelationship) RR =
Handle(StepRepr_RepresentationRelationship)::DownCast(subs.Value());
if(!RR.IsNull()) {
Handle(StepShape_ShapeRepresentation) SR2 =
Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep1());
if(SR==SR2)
SR2 = Handle(StepShape_ShapeRepresentation)::DownCast(RR->Rep2());
Interface_EntityIterator subs2 = graph.Sharings(SR2);
for(subs2.Start(); subs2.More(); subs2.Next()) {
Handle(StepShape_ShapeDefinitionRepresentation) SDR2 =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs2.Value());
if(!SDR2.IsNull()) IsRoot = Standard_False;
//else {
// if(SR==SRR->Rep2()) IsRoot = Standard_False;
//}
}
}
}
if(IsRoot) {
Handle(StepRepr_RepresentationMap) RM =
Handle(StepRepr_RepresentationMap)::DownCast(subs.Value());
if(!RM.IsNull()) {
Interface_EntityIterator subs2 = graph.Sharings(RM);
for(subs2.Start(); subs2.More(); subs2.Next()) {
Handle(StepRepr_MappedItem) MI = Handle(StepRepr_MappedItem)::DownCast(subs2.Value());
if(!MI.IsNull()) {
Interface_EntityIterator subs3 = graph.Sharings(MI);
for(subs3.Start(); subs3.More(); subs3.Next()) {
Handle(StepShape_ShapeRepresentation) SR2 =
Handle(StepShape_ShapeRepresentation)::DownCast(subs3.Value());
if(!SR2.IsNull()) IsRoot = Standard_False;
}
}
}
}
}
}
if(IsRoot) {
theroots.Append(ent);
WS()->MapReader()->RootsForTransfer()->Append(ent);
}
}
}
}
return theroots.Length();
}

View File

@@ -0,0 +1,102 @@
-- File: STEPControl_Writer.cdl
-- Created: Mon Jul 8 16:13:44 1996
-- Author: Christian CAILLET
-- <cky@anion.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Writer from STEPControl
---Purpose : This class creates and writes
-- STEP files from Open CASCADE models. A STEP file can be
-- written to an existing STEP file or to a new one.
-- Translation can be performed in one or several operations. Each
-- translation operation outputs a distinct root entity in the STEP file.
uses
CString,
StepModel from StepData, WorkSession from XSControl,
ReturnStatus from IFSelect,
Shape from TopoDS,
StepModelType from STEPControl
is
Create returns Writer;
---Purpose : Creates a Writer from scratch
Create (WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True) returns Writer;
---Purpose : Creates a Writer from an already existing Session
-- If <scratch> is True (D), clears already recorded data
SetTolerance (me : in out; Tol : Real);
---Purpose : Sets a length-measure value that
-- will be written to uncertainty-measure-with-unit
-- when the next shape is translated.
UnsetTolerance (me : in out);
---Purpose : Unsets the tolerance formerly forced by SetTolerance
SetWS (me : in out; WS : mutable WorkSession from XSControl;
scratch : Boolean = Standard_True);
---Purpose : Sets a specific session to <me>
WS (me) returns WorkSession from XSControl;
---Purpose : Returns the session used in <me>
Model (me : in out; newone : Boolean = Standard_False) returns StepModel;
---Purpose : Returns the produced model. Produces a new one if not yet done
-- or if <newone> is True
-- This method allows for instance to edit product or header
-- data before writing.
Transfer (me : in out; sh : Shape from TopoDS;
mode : StepModelType from STEPControl;
compgraph : Boolean = Standard_True)
returns ReturnStatus;
---Purpose : Translates shape sh to a STEP
-- entity. mode defines the STEP entity type to be output:
-- - STEPControlStd_AsIs translates a shape to its highest possible
-- STEP representation.
-- - STEPControlStd_ManifoldSolidBrep translates a shape to a STEP
-- manifold_solid_brep or brep_with_voids entity.
-- - STEPControlStd_FacetedBrep translates a shape into a STEP
-- faceted_brep entity.
-- - STEPControlStd_ShellBasedSurfaceModel translates a shape into a STEP
-- shell_based_surface_model entity.
-- - STEPControlStd_GeometricCurveSet translates a shape into a STEP
-- geometric_curve_set entity.
Write (me : in out; filename : CString) returns ReturnStatus;
---Purpose : Writes a STEP model in the file identified by filename.
PrintStatsTransfer (me; what : Integer; mode : Integer = 0);
---Purpose : Displays the statistics for the
-- last translation. what defines the kind of statistics that are displayed:
-- - 0 gives general statistics (number of translated roots,
-- number of warnings, number of fail messages),
-- - 1 gives root results,
-- - 2 gives statistics for all checked entities,
-- - 3 gives the list of translated entities,
-- - 4 gives warning and fail messages,
-- - 5 gives fail messages only.
-- mode is used according to the use of what. If what is 0, mode is
-- ignored. If what is 1, 2 or 3, mode defines the following:
-- - 0 lists the numbers of STEP entities in a STEP model,
-- - 1 gives the number, identifier, type and result type for each
-- STEP entity and/or its status (fail, warning, etc.),
-- - 2 gives maximum information for each STEP entity (i.e. checks),
-- - 3 gives the number of entities by the type of a STEP entity,
-- - 4 gives the number of of STEP entities per result type and/or status,
-- - 5 gives the number of pairs (STEP or result type and status),
-- - 6 gives the number of pairs (STEP or result type and status)
-- AND the list of entity numbers in the STEP model.
fields
thesession : WorkSession from XSControl;
end Writer;

View File

@@ -0,0 +1,158 @@
#include <STEPControl_Writer.ixx>
#include <STEPControl_Controller.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <XSControl_TransferWriter.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Macros.hxx>
#include <Message_ProgressIndicator.hxx>
#include <TopExp_Explorer.hxx>
#include <Transfer_FinderProcess.hxx>
//=======================================================================
//function : STEPControl_Writer
//purpose :
//=======================================================================
STEPControl_Writer::STEPControl_Writer ()
{
STEPControl_Controller::Init();
SetWS (new XSControl_WorkSession);
}
//=======================================================================
//function : STEPControl_Writer
//purpose :
//=======================================================================
STEPControl_Writer::STEPControl_Writer
(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch)
{
STEPControl_Controller::Init();
SetWS (WS,scratch);
}
//=======================================================================
//function : SetWS
//purpose :
//=======================================================================
void STEPControl_Writer::SetWS(const Handle(XSControl_WorkSession)& WS,
const Standard_Boolean scratch)
{
thesession = WS;
thesession->SelectNorm("STEP");
thesession->InitTransferReader(0);
Handle(StepData_StepModel) model = Model (scratch);
}
//=======================================================================
//function : WS
//purpose :
//=======================================================================
Handle(XSControl_WorkSession) STEPControl_Writer::WS () const
{
return thesession;
}
//=======================================================================
//function : Model
//purpose :
//=======================================================================
Handle(StepData_StepModel) STEPControl_Writer::Model
(const Standard_Boolean newone)
{
DeclareAndCast(StepData_StepModel,model,thesession->Model());
if (newone || model.IsNull())
model = GetCasted(StepData_StepModel,thesession->NewModel());
return model;
}
//=======================================================================
//function : SetTolerance
//purpose :
//=======================================================================
void STEPControl_Writer::SetTolerance (const Standard_Real Tol)
{
DeclareAndCast(STEPControl_ActorWrite,act,WS()->NormAdaptor()->ActorWrite());
if (!act.IsNull()) act->SetTolerance (Tol);
}
//=======================================================================
//function : UnsetTolerance
//purpose :
//=======================================================================
void STEPControl_Writer::UnsetTolerance ()
{
SetTolerance (-1.);
}
//=======================================================================
//function : Transfer
//purpose :
//=======================================================================
IFSelect_ReturnStatus STEPControl_Writer::Transfer
(const TopoDS_Shape& sh, const STEPControl_StepModelType mode,
const Standard_Boolean compgraph)
{
Standard_Integer mws = -1;
switch (mode) {
case STEPControl_AsIs : mws = 0; break;
case STEPControl_FacetedBrep : mws = 1; break;
case STEPControl_ShellBasedSurfaceModel : mws = 2; break;
case STEPControl_ManifoldSolidBrep : mws = 3; break;
case STEPControl_GeometricCurveSet : mws = 4; break;
default : break;
}
if (mws < 0) return IFSelect_RetError; // cas non reconnu
thesession->SetModeWriteShape (mws);
// for progress indicator.
Handle(Message_ProgressIndicator) progress =
WS()->TransferWriter()->FinderProcess()->GetProgress();
if ( ! progress.IsNull() ) {
Standard_Integer nbfaces=0;
for( TopExp_Explorer exp(sh, TopAbs_FACE); exp.More(); exp.Next()) nbfaces++;
progress->SetScale ( "Face", 0, nbfaces, 1 );
progress->Show();
}
return thesession->TransferWriteShape(sh,compgraph);
}
//=======================================================================
//function : Write
//purpose :
//=======================================================================
IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString filename)
{
return thesession->SendAll(filename);
}
//=======================================================================
//function : PrintStatsTransfer
//purpose :
//=======================================================================
void STEPControl_Writer::PrintStatsTransfer
(const Standard_Integer what, const Standard_Integer mode) const
{
thesession->TransferWriter()->PrintStats (what,mode);
}