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:
31
src/StepSelect/StepSelect.cdl
Executable file
31
src/StepSelect/StepSelect.cdl
Executable file
@@ -0,0 +1,31 @@
|
||||
-- File: StepSelect.cdl
|
||||
-- Created: Thu Dec 22 11:03:12 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
package StepSelect
|
||||
|
||||
---Purpose : This package defines the library of the tools used for every
|
||||
-- kind of STEP Files, i.e. whatever the considered Protocol.
|
||||
|
||||
uses MMgt, TCollection, TColStd, Message,
|
||||
Interface, IFGraph, IFSelect, StepData
|
||||
|
||||
is
|
||||
|
||||
class StepType;
|
||||
|
||||
deferred class ModelModifier instantiates ModelModifier from IFSelect
|
||||
(StepModel from StepData, Protocol from StepData);
|
||||
deferred class FileModifier instantiates FileModifier from IFSelect
|
||||
(StepWriter from StepData);
|
||||
|
||||
class FloatFormat;
|
||||
|
||||
class WorkLibrary;
|
||||
|
||||
class Activator;
|
||||
|
||||
end StepSelect;
|
27
src/StepSelect/StepSelect_Activator.cdl
Executable file
27
src/StepSelect/StepSelect_Activator.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: StepSelect_Activator.cdl
|
||||
-- Created: Thu Apr 20 18:45:34 1995
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@meteox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class Activator from StepSelect inherits Activator from IFSelect
|
||||
|
||||
---Purpose : Performs Actions specific to StepSelect, i.e. creation of
|
||||
-- Step Selections and Counters, plus dumping specific to Step
|
||||
|
||||
uses CString, SessionPilot, ReturnStatus
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable Activator from StepSelect;
|
||||
|
||||
|
||||
Do (me : mutable; number : Integer; pilot : mutable SessionPilot)
|
||||
returns ReturnStatus;
|
||||
---Purpose : Executes a Command Line for StepSelect
|
||||
|
||||
Help (me; number : Integer) returns CString;
|
||||
---Purpose : Sends a short help message for StepSelect commands
|
||||
|
||||
end Activator;
|
132
src/StepSelect/StepSelect_Activator.cxx
Executable file
132
src/StepSelect/StepSelect_Activator.cxx
Executable file
@@ -0,0 +1,132 @@
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <StepSelect_Activator.ixx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
#include <IFSelect_WorkSession.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <StepData_UndefinedEntity.hxx>
|
||||
#include <StepData_Simple.hxx>
|
||||
#include <StepData_Plex.hxx>
|
||||
|
||||
#include <StepSelect_FloatFormat.hxx>
|
||||
|
||||
|
||||
static int initActivator = 0;
|
||||
|
||||
|
||||
StepSelect_Activator::StepSelect_Activator ()
|
||||
{
|
||||
if (initActivator) return; initActivator = 1;
|
||||
// Add ( 0,"load");
|
||||
// Add ( 0,"loadstep"); // homonyme
|
||||
// Add ( 1,"entity");
|
||||
// Add ( 2,"liststep");
|
||||
|
||||
// AddSet (10,"steptype");
|
||||
|
||||
Add ( 1,"stepschema");
|
||||
AddSet (40,"floatformat");
|
||||
}
|
||||
|
||||
|
||||
IFSelect_ReturnStatus StepSelect_Activator::Do
|
||||
(const Standard_Integer number,
|
||||
const Handle(IFSelect_SessionPilot)& pilot)
|
||||
{
|
||||
Standard_Integer argc = pilot->NbWords();
|
||||
const Standard_CString arg1 = pilot->Word(1).ToCString();
|
||||
const Standard_CString arg2 = pilot->Word(2).ToCString();
|
||||
// const Standard_CString arg3 = pilot->Word(3).ToCString();
|
||||
|
||||
switch (number) {
|
||||
|
||||
case 1 : { // **** StepSchema
|
||||
if (argc < 2) {
|
||||
cout<<"Identify an entity"<<endl;
|
||||
return IFSelect_RetError;
|
||||
}
|
||||
Standard_Integer num = pilot->Number(arg1);
|
||||
if (num <= 0) {
|
||||
cout<<"Not an entity : "<<arg2<<endl;
|
||||
return IFSelect_RetError;
|
||||
}
|
||||
Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
|
||||
DeclareAndCast(StepData_UndefinedEntity,und,ent);
|
||||
if (!und.IsNull()) {
|
||||
cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
|
||||
return IFSelect_RetVoid;
|
||||
}
|
||||
DeclareAndCast(StepData_Simple,sim,ent);
|
||||
if (!sim.IsNull()) {
|
||||
cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
|
||||
cout<<"Simple Type : "<<sim->StepType()<<endl;
|
||||
return IFSelect_RetVoid;
|
||||
}
|
||||
DeclareAndCast(StepData_Plex,plx,ent);
|
||||
if (!plx.IsNull()) {
|
||||
cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
|
||||
cout<<"Complex Type"<<endl;
|
||||
}
|
||||
// reste Early Binding
|
||||
cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
|
||||
cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
|
||||
return IFSelect_RetVoid;
|
||||
}
|
||||
|
||||
case 40 : { // **** FloatFormat
|
||||
char prem = ' ';
|
||||
if (argc < 2) prem = '?';
|
||||
else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
|
||||
else prem = arg1[0];
|
||||
Standard_Boolean zerosup=Standard_False;
|
||||
Standard_Integer digits = 0;
|
||||
if (prem == 'N' || prem == 'n') zerosup = Standard_False;
|
||||
else if (prem == 'Z' || prem == 'z') zerosup = Standard_True;
|
||||
else if (prem >= 48 && prem <= 57) digits = atoi(arg1);
|
||||
else {
|
||||
cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
|
||||
<< "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n"
|
||||
<<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n"
|
||||
<<" %mainformat : format principal type printf, ex,: %E\n"
|
||||
<<" + optionnel : format secondaire (flottants autour de 1.) :\n"
|
||||
<<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n"
|
||||
<<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n"
|
||||
<<flush;
|
||||
return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
|
||||
}
|
||||
Standard_Real Rmin=0., Rmax=0.;
|
||||
if (argc > 4) {
|
||||
Rmin = atof(pilot->Word(4).ToCString());
|
||||
Rmax = atof(pilot->Word(5).ToCString());
|
||||
if (Rmin <= 0 || Rmax <= 0) { cout<<"intervalle : donner reels > 0"<<endl; return IFSelect_RetError; }
|
||||
}
|
||||
Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
|
||||
if (argc == 2) fm->SetDefault(digits);
|
||||
else {
|
||||
fm->SetZeroSuppress(zerosup);
|
||||
fm->SetFormat (arg2);
|
||||
if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString());
|
||||
else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax);
|
||||
else fm->SetFormatForRange("");
|
||||
}
|
||||
return pilot->RecordItem(fm);
|
||||
}
|
||||
|
||||
default : break;
|
||||
}
|
||||
return IFSelect_RetVoid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Standard_CString StepSelect_Activator::Help
|
||||
(const Standard_Integer number) const
|
||||
{
|
||||
switch (number) {
|
||||
|
||||
case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";
|
||||
default : break;
|
||||
}
|
||||
return "";
|
||||
}
|
83
src/StepSelect/StepSelect_FloatFormat.cdl
Executable file
83
src/StepSelect/StepSelect_FloatFormat.cdl
Executable file
@@ -0,0 +1,83 @@
|
||||
-- File: StepSelect_FloatFormat.cdl
|
||||
-- Created: Wed Jun 1 16:04:47 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@bravox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class FloatFormat from StepSelect inherits FileModifier from StepSelect
|
||||
|
||||
---Purpose : This class gives control out format for floatting values :
|
||||
-- ZeroSuppress or no, Main Format, Format in Range (for values
|
||||
-- around 1.), as StepWriter allows to manage it.
|
||||
-- Formats are given under C-printf form
|
||||
|
||||
uses CString, AsciiString from TCollection, HSequenceOfInteger from TColStd,
|
||||
CheckIterator, StepWriter , ContextWrite
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable FloatFormat;
|
||||
---Purpose : Creates a new FloatFormat, with standard options :
|
||||
-- ZeroSuppress, Main Format = %E,
|
||||
-- Format between 0.001 and 1000. = %f
|
||||
|
||||
SetDefault (me : mutable; digits : Integer = 0);
|
||||
---Purpose : Sets FloatFormat to default value (see Create) but if <digits>
|
||||
-- is given positive, it commands Formats (main and range) to
|
||||
-- ensure <digits> significant digits to be displayed
|
||||
|
||||
SetZeroSuppress (me : mutable; mode : Boolean);
|
||||
---Purpose : Sets ZeroSuppress mode to a new value
|
||||
|
||||
SetFormat (me : mutable; format : CString = "%E");
|
||||
---Purpose : Sets Main Format to a new value
|
||||
-- Remark : SetFormat, SetZeroSuppress and SetFormatForRange are
|
||||
-- independant
|
||||
|
||||
SetFormatForRange (me : mutable; format : CString = "%f";
|
||||
Rmin : Real = 0.1; Rmax : Real = 1000.0);
|
||||
---Purpose : Sets Format for Range to a new value with its range of
|
||||
-- application.
|
||||
-- To cancel it, give format as "" (empty string)
|
||||
-- Remark that if the condition (0. < Rmin < Rmax) is not
|
||||
-- verified, this secondary format will be ignored.
|
||||
-- Moreover, this secondary format is intended to be used in a
|
||||
-- range around 1.
|
||||
|
||||
|
||||
Format (me; zerosup : out Boolean;
|
||||
mainform : out AsciiString from TCollection;
|
||||
hasrange : out Boolean;
|
||||
forminrange : out AsciiString from TCollection;
|
||||
rangemin, rangemax : out Real);
|
||||
---Purpose : Returns all recorded parameters :
|
||||
-- zerosup : ZeroSuppress status
|
||||
-- mainform : Main Format (which applies out of the range, or
|
||||
-- for every real if no range is set)
|
||||
-- hasrange : True if a FormatInRange is set, False else
|
||||
-- (following parameters do not apply if it is False)
|
||||
-- forminrange : Secondary Format (it applies inside the range)
|
||||
-- rangemin, rangemax : the range in which the secondary format
|
||||
-- applies
|
||||
|
||||
|
||||
Perform (me; ctx : in out ContextWrite;
|
||||
writer : in out StepWriter);
|
||||
---Purpose : Sets the Floatting Formats of StepWriter to the recorded
|
||||
-- parameters
|
||||
|
||||
Label (me) returns AsciiString from TCollection;
|
||||
---Purpose : Returns specific Label : for instance,
|
||||
-- "Float Format [ZeroSuppress] %E [, in range R1-R2 %f]"
|
||||
|
||||
fields
|
||||
|
||||
thezerosup : Boolean;
|
||||
themainform : AsciiString from TCollection;
|
||||
theformrange : AsciiString from TCollection;
|
||||
therangemin : Real;
|
||||
therangemax : Real;
|
||||
|
||||
end FloatFormat;
|
||||
|
81
src/StepSelect/StepSelect_FloatFormat.cxx
Executable file
81
src/StepSelect/StepSelect_FloatFormat.cxx
Executable file
@@ -0,0 +1,81 @@
|
||||
#include <StepSelect_FloatFormat.ixx>
|
||||
#include <Interface_FloatWriter.hxx>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
StepSelect_FloatFormat::StepSelect_FloatFormat ()
|
||||
: thezerosup (Standard_True) , themainform ("%E") ,
|
||||
theformrange ("%f") , therangemin (0.1) , therangemax (1000.)
|
||||
{ }
|
||||
|
||||
void StepSelect_FloatFormat::SetDefault (const Standard_Integer digits)
|
||||
{
|
||||
themainform.Clear();
|
||||
theformrange.Clear();
|
||||
if (digits <= 0) {
|
||||
themainform.AssignCat ("%E");
|
||||
theformrange.AssignCat ("%f");
|
||||
} else {
|
||||
char format[20];
|
||||
char pourcent = '%'; char point = '.';
|
||||
sprintf(format, "%c%d%c%dE",pourcent,digits+2,point,digits);
|
||||
themainform.AssignCat (format);
|
||||
sprintf(format, "%c%d%c%df",pourcent,digits+2,point,digits);
|
||||
theformrange.AssignCat (format);
|
||||
}
|
||||
therangemin = 0.1; therangemax = 1000.;
|
||||
thezerosup = Standard_True;
|
||||
}
|
||||
|
||||
void StepSelect_FloatFormat::SetZeroSuppress (const Standard_Boolean mode)
|
||||
{ thezerosup = mode; }
|
||||
|
||||
void StepSelect_FloatFormat::SetFormat (const Standard_CString format)
|
||||
{ themainform.Clear(); themainform.AssignCat(format); }
|
||||
|
||||
|
||||
void StepSelect_FloatFormat::SetFormatForRange
|
||||
(const Standard_CString form, const Standard_Real R1, const Standard_Real R2)
|
||||
{
|
||||
theformrange.Clear(); theformrange.AssignCat(form);
|
||||
therangemin = R1; therangemax = R2;
|
||||
}
|
||||
|
||||
void StepSelect_FloatFormat::Format
|
||||
(Standard_Boolean& zerosup, TCollection_AsciiString& mainform,
|
||||
Standard_Boolean& hasrange, TCollection_AsciiString& formrange,
|
||||
Standard_Real& rangemin, Standard_Real& rangemax) const
|
||||
{
|
||||
zerosup = thezerosup;
|
||||
mainform = themainform;
|
||||
hasrange = (theformrange.Length() > 0);
|
||||
formrange = theformrange;
|
||||
rangemin = therangemin;
|
||||
rangemax = therangemax;
|
||||
}
|
||||
|
||||
|
||||
void StepSelect_FloatFormat::Perform
|
||||
(IFSelect_ContextWrite& ctx,
|
||||
StepData_StepWriter& writer) const
|
||||
{
|
||||
writer.FloatWriter().SetFormat (themainform.ToCString());
|
||||
writer.FloatWriter().SetZeroSuppress (thezerosup);
|
||||
if (theformrange.Length() > 0) writer.FloatWriter().SetFormatForRange
|
||||
(theformrange.ToCString(), therangemin, therangemax);
|
||||
}
|
||||
|
||||
TCollection_AsciiString StepSelect_FloatFormat::Label () const
|
||||
{
|
||||
TCollection_AsciiString lab("Float Format ");
|
||||
if (thezerosup) lab.AssignCat(" ZeroSuppress");
|
||||
lab.AssignCat (themainform);
|
||||
if (theformrange.Length() > 0) {
|
||||
char mess[30];
|
||||
sprintf(mess,", in range %f %f %s",
|
||||
therangemin,therangemax,theformrange.ToCString());
|
||||
lab.AssignCat(mess);
|
||||
}
|
||||
return lab;
|
||||
}
|
48
src/StepSelect/StepSelect_StepType.cdl
Executable file
48
src/StepSelect/StepSelect_StepType.cdl
Executable file
@@ -0,0 +1,48 @@
|
||||
-- File: StepSelect_StepType.cdl
|
||||
-- Created: Thu Dec 22 09:38:35 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class StepType from StepSelect inherits Signature from IFSelect
|
||||
|
||||
---Purpose : StepType is a Signature specific to Step definitions : it
|
||||
-- considers the type as defined in STEP Schemas, the same which
|
||||
-- is used in files.
|
||||
-- For a Complex Type, if its definition is known, StepType
|
||||
-- produces the list of basic types, separated by commas, the
|
||||
-- whole between brackets : "(TYPE1,TYPE2..)".
|
||||
-- If its precise definition is not known (simply it is known as
|
||||
-- Complex, it can be recognised, but the list is produced at
|
||||
-- Write time only), StepType produces : "(..COMPLEX TYPE..)"
|
||||
|
||||
uses CString, Transient, AsciiString from TCollection,
|
||||
Protocol from Interface, InterfaceModel,
|
||||
Protocol from StepData, WriterLib from StepData
|
||||
|
||||
raises InterfaceError
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable StepType;
|
||||
---Purpose : Creates a Signature for Step Type. Protocol is undefined here,
|
||||
-- hence no Signature may yet be produced. The StepType signature
|
||||
-- requires a Protocol before working
|
||||
|
||||
SetProtocol (me : mutable; proto : Protocol from Interface)
|
||||
---Purpose : Sets the StepType signature to work with a Protocol : this
|
||||
-- initialises the library
|
||||
raises InterfaceError;
|
||||
-- Error if the Protocol is not from StepData
|
||||
|
||||
Value (me; ent : any Transient; model : InterfaceModel) returns CString;
|
||||
---Purpose : Returns the Step Type defined from the Protocol (see above).
|
||||
-- If <ent> is not recognised, produces "..NOT FROM SCHEMA <name>.."
|
||||
|
||||
fields
|
||||
|
||||
theproto : Protocol from StepData;
|
||||
thelib : WriterLib from StepData is protected;
|
||||
|
||||
end StepType;
|
72
src/StepSelect/StepSelect_StepType.cxx
Executable file
72
src/StepSelect/StepSelect_StepType.cxx
Executable file
@@ -0,0 +1,72 @@
|
||||
#include <StepSelect_StepType.ixx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
#include <StepData_ReadWriteModule.hxx>
|
||||
#include <StepData_UndefinedEntity.hxx>
|
||||
#include <Interface_InterfaceError.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
|
||||
|
||||
static TCollection_AsciiString lastvalue;
|
||||
|
||||
|
||||
StepSelect_StepType::StepSelect_StepType ()
|
||||
: IFSelect_Signature ("Step Type") { }
|
||||
|
||||
void StepSelect_StepType::SetProtocol
|
||||
(const Handle(Interface_Protocol)& proto)
|
||||
{
|
||||
DeclareAndCast(StepData_Protocol,newproto,proto);
|
||||
if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType");
|
||||
theproto = newproto;
|
||||
thelib.Clear();
|
||||
thelib.AddProtocol (theproto);
|
||||
thename.Clear();
|
||||
thename.AssignCat ("Step Type (Schema ");
|
||||
thename.AssignCat (theproto->SchemaName());
|
||||
thename.AssignCat (")");
|
||||
}
|
||||
|
||||
Standard_CString StepSelect_StepType::Value
|
||||
(const Handle(Standard_Transient)& ent,
|
||||
const Handle(Interface_InterfaceModel)& model) const
|
||||
{
|
||||
lastvalue.Clear();
|
||||
Handle(StepData_ReadWriteModule) module;
|
||||
Standard_Integer CN;
|
||||
Standard_Boolean ok = thelib.Select (ent,module,CN);
|
||||
if (!ok) {
|
||||
lastvalue.AssignCat ("..NOT FROM SCHEMA ");
|
||||
lastvalue.AssignCat (theproto->SchemaName());
|
||||
lastvalue.AssignCat ("..");
|
||||
} else {
|
||||
Standard_Boolean plex = module->IsComplex(CN);
|
||||
if (!plex) lastvalue = module->StepType(CN);
|
||||
else {
|
||||
lastvalue.AssignCat ("(");
|
||||
TColStd_SequenceOfAsciiString list;
|
||||
module->ComplexType (CN,list);
|
||||
Standard_Integer nb = list.Length();
|
||||
if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (i > 1) lastvalue.AssignCat (",");
|
||||
lastvalue.AssignCat (list.Value(i).ToCString());
|
||||
}
|
||||
lastvalue.AssignCat (")");
|
||||
}
|
||||
}
|
||||
if (lastvalue.Length() > 0) return lastvalue.ToCString();
|
||||
|
||||
DeclareAndCast(StepData_UndefinedEntity,und,ent);
|
||||
if (und.IsNull()) return lastvalue.ToCString();
|
||||
if (und->IsComplex()) {
|
||||
lastvalue.AssignCat("(");
|
||||
while (!und.IsNull()) {
|
||||
lastvalue.AssignCat (und->StepType());
|
||||
und = und->Next();
|
||||
if (!und.IsNull()) lastvalue.AssignCat(",");
|
||||
}
|
||||
lastvalue.AssignCat(")");
|
||||
}
|
||||
else return und->StepType();
|
||||
return lastvalue.ToCString();
|
||||
}
|
73
src/StepSelect/StepSelect_WorkLibrary.cdl
Executable file
73
src/StepSelect/StepSelect_WorkLibrary.cdl
Executable file
@@ -0,0 +1,73 @@
|
||||
-- File: StepSelect_WorkLibrary.cdl
|
||||
-- Created: Wed Sep 14 16:59:44 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class WorkLibrary from StepSelect inherits WorkLibrary from IFSelect
|
||||
|
||||
---Purpose : Performs Read and Write a STEP File with a STEP Model
|
||||
-- Following the protocols, Copy may be implemented or not
|
||||
|
||||
uses CString, Transient,
|
||||
CheckIterator, InterfaceModel, Protocol from Interface,
|
||||
Messenger from Message,
|
||||
EntityIterator, CopyTool,
|
||||
ContextWrite
|
||||
|
||||
is
|
||||
|
||||
Create (copymode : Boolean = Standard_True)
|
||||
returns mutable WorkLibrary from StepSelect;
|
||||
---Purpose : Creates a STEP WorkLibrary
|
||||
-- <copymode> precises whether Copy is implemented or not
|
||||
|
||||
SetDumpLabel (me : mutable; mode : Integer);
|
||||
---Purpose : Selects a mode to dump entities
|
||||
-- 0 (D) : prints numbers, then displays table number/label
|
||||
-- 1 : prints labels, then displays table label/number
|
||||
-- 2 : prints labels onky
|
||||
|
||||
ReadFile (me; name : CString;
|
||||
model : out mutable InterfaceModel;
|
||||
protocol : Protocol from Interface)
|
||||
returns Integer;
|
||||
---Purpose : Reads a STEP File and returns a STEP Model (into <mod>),
|
||||
-- or lets <mod> "Null" in case of Error
|
||||
-- Returns 0 if OK, 1 if Read Error, -1 if File not opened
|
||||
|
||||
WriteFile (me; ctx : in out ContextWrite) returns Boolean;
|
||||
---Purpose : Writes a File from a STEP Model
|
||||
-- Returns False (and writes no file) if <ctx> does not bring a
|
||||
-- STEP Model
|
||||
|
||||
CopyModel (me;
|
||||
original : InterfaceModel;
|
||||
newmodel : mutable InterfaceModel;
|
||||
list : EntityIterator;
|
||||
TC : in out CopyTool)
|
||||
returns Boolean is redefined;
|
||||
---Purpose : Performs the copy of entities from an original model to a new
|
||||
-- one. Works according <copymode> :
|
||||
-- if True, standard copy is run
|
||||
-- else nothing is done and returned value is False
|
||||
|
||||
DumpEntity (me;
|
||||
model : InterfaceModel;
|
||||
protocol : Protocol from Interface;
|
||||
entity : Transient;
|
||||
S : Messenger from Message;
|
||||
level : Integer);
|
||||
---Purpose : Dumps an entity under STEP form, i.e. as a part of a Step file
|
||||
-- Works with a StepDumper.
|
||||
-- Level 0 just displays type; level 1 displays the entity itself
|
||||
-- and level 2 displays the entity plus its shared ones (one
|
||||
-- sub-level : immediately shared entities)
|
||||
|
||||
fields
|
||||
|
||||
thecopymode : Boolean;
|
||||
thelabmode : Integer;
|
||||
|
||||
end WorkLibrary;
|
151
src/StepSelect/StepSelect_WorkLibrary.cxx
Executable file
151
src/StepSelect/StepSelect_WorkLibrary.cxx
Executable file
@@ -0,0 +1,151 @@
|
||||
#include <StepSelect_WorkLibrary.ixx>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <StepData_Protocol.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
#include <StepFile_Read.hxx>
|
||||
#include <StepData_StepWriter.hxx>
|
||||
#include <Interface_CheckIterator.hxx>
|
||||
|
||||
#include <StepSelect_FileModifier.hxx>
|
||||
|
||||
#include <StepData_UndefinedEntity.hxx>
|
||||
#include <StepData_StepDumper.hxx>
|
||||
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfInteger.hxx>
|
||||
#include <IFSelect_GeneralModifier.hxx>
|
||||
#include <Interface_ParamType.hxx>
|
||||
#include <Interface_ReportEntity.hxx>
|
||||
#include <Interface_UndefinedContent.hxx>
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_Check.hxx>
|
||||
|
||||
StepSelect_WorkLibrary::StepSelect_WorkLibrary
|
||||
(const Standard_Boolean copymode)
|
||||
: thecopymode (copymode) , thelabmode (0)
|
||||
{
|
||||
SetDumpLevels (1,2);
|
||||
SetDumpHelp (0,"#id + Step Type");
|
||||
SetDumpHelp (1,"Entity as in file");
|
||||
SetDumpHelp (2,"Entity + shareds (level 1) as in file");
|
||||
}
|
||||
// rq : les init sont faits par ailleurs, pas de souci a se faire
|
||||
|
||||
|
||||
void StepSelect_WorkLibrary::SetDumpLabel (const Standard_Integer mode)
|
||||
{
|
||||
thelabmode = mode;
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer StepSelect_WorkLibrary::ReadFile
|
||||
(const Standard_CString name,
|
||||
Handle(Interface_InterfaceModel)& model,
|
||||
const Handle(Interface_Protocol)& protocol) const
|
||||
{
|
||||
long status = 1;
|
||||
DeclareAndCast(StepData_Protocol,stepro,protocol);
|
||||
if (stepro.IsNull()) return 1;
|
||||
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
|
||||
model = stepmodel;
|
||||
StepFile_ReadTrace (0);
|
||||
char *pName=(char *)name;
|
||||
status = StepFile_Read (pName,stepmodel,stepro);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean StepSelect_WorkLibrary::WriteFile
|
||||
(IFSelect_ContextWrite& ctx) const
|
||||
{
|
||||
// Preparation
|
||||
Handle(Message_Messenger) sout = Message::DefaultMessenger();
|
||||
DeclareAndCast(StepData_StepModel,stepmodel,ctx.Model());
|
||||
DeclareAndCast(StepData_Protocol,stepro,ctx.Protocol());
|
||||
if (stepmodel.IsNull() || stepro.IsNull()) return Standard_False;
|
||||
|
||||
ofstream fout;
|
||||
fout.open(ctx.FileName(),ios::out|ios::trunc);
|
||||
|
||||
if (!fout || !fout.rdbuf()->is_open()) {
|
||||
ctx.CCheck(0)->AddFail("Step File could not be created");
|
||||
sout<<" Step File could not be created : " << ctx.FileName() << endl; return 0;
|
||||
}
|
||||
sout << " Step File Name : "<<ctx.FileName();
|
||||
StepData_StepWriter SW(stepmodel);
|
||||
sout<<"("<<stepmodel->NbEntities()<<" ents) ";
|
||||
|
||||
// File Modifiers
|
||||
Standard_Integer nbmod = ctx.NbModifiers();
|
||||
for (Standard_Integer numod = 1; numod <= nbmod; numod ++) {
|
||||
ctx.SetModifier (numod);
|
||||
DeclareAndCast(StepSelect_FileModifier,filemod,ctx.FileModifier());
|
||||
if (!filemod.IsNull()) filemod->Perform(ctx,SW);
|
||||
// (impressions de mise au point)
|
||||
sout << " .. FileMod." << numod << filemod->Label();
|
||||
if (ctx.IsForAll()) sout << " (all model)";
|
||||
else sout << " (" << ctx.NbEntities() << " entities)";
|
||||
// sout << flush;
|
||||
}
|
||||
|
||||
// Envoi
|
||||
SW.SendModel(stepro);
|
||||
Interface_CheckIterator chl = SW.CheckList();
|
||||
for (chl.Start(); chl.More(); chl.Next())
|
||||
ctx.CCheck(chl.Number())->GetMessages(chl.Value());
|
||||
sout<<" Write ";
|
||||
Standard_Boolean isGood = SW.Print(fout);
|
||||
sout<<" Done"<<endl;
|
||||
|
||||
errno = 0;
|
||||
fout.close();
|
||||
isGood = fout.good() && isGood && !errno;
|
||||
if(errno)
|
||||
sout << strerror(errno) << endl;
|
||||
return isGood;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean StepSelect_WorkLibrary::CopyModel
|
||||
(const Handle(Interface_InterfaceModel)& original,
|
||||
const Handle(Interface_InterfaceModel)& newmodel,
|
||||
const Interface_EntityIterator& list,
|
||||
Interface_CopyTool& TC) const
|
||||
{
|
||||
if (thecopymode) return
|
||||
IFSelect_WorkLibrary::CopyModel (original,newmodel,list,TC);
|
||||
return thecopymode;
|
||||
}
|
||||
|
||||
|
||||
void StepSelect_WorkLibrary::DumpEntity
|
||||
(const Handle(Interface_InterfaceModel)& model,
|
||||
const Handle(Interface_Protocol)& protocol,
|
||||
const Handle(Standard_Transient)& entity,
|
||||
const Handle(Message_Messenger)& S, const Standard_Integer level) const
|
||||
{
|
||||
Standard_Integer nument = model->Number(entity);
|
||||
if (nument <= 0 || nument > model->NbEntities()) return;
|
||||
Standard_Boolean iserr = model->IsRedefinedContent(nument);
|
||||
Handle(Standard_Transient) ent, con; ent = entity;
|
||||
S<<" --- (STEP) Entity "; model->Print(entity,S);
|
||||
if (iserr) con = model->ReportEntity(nument)->Content();
|
||||
if (entity.IsNull()) { S<<" Null"<<endl; return; }
|
||||
|
||||
// On attaque le dump : d abord cas de l Erreur
|
||||
S << " Type cdl : " << entity->DynamicType()->Name() << endl;
|
||||
if (iserr)
|
||||
S<<" *** NOT WELL LOADED : CONTENT FROM FILE ***"<<endl;
|
||||
else if (model->IsUnknownEntity(nument))
|
||||
S<<" *** UNKNOWN TYPE ***"<<endl;
|
||||
|
||||
StepData_StepDumper dump(GetCasted(StepData_StepModel,model),
|
||||
GetCasted(StepData_Protocol,protocol),thelabmode);
|
||||
dump.Dump(S,ent,level);
|
||||
}
|
Reference in New Issue
Block a user