From: dpasukhi Date: Fri, 27 Jan 2023 23:26:45 +0000 (+0000) Subject: starting of hell X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=2b5410a946c5c84c0ef5cb0594f39d0182ffabcb;p=occt.git starting of hell --- diff --git a/dox/user_guides/iges/iges.md b/dox/user_guides/iges/iges.md index 1db3f4dec8..c78e025ba6 100644 --- a/dox/user_guides/iges/iges.md +++ b/dox/user_guides/iges/iges.md @@ -62,7 +62,7 @@ Administrative data, in the Global Section of the IGES file (such as the file n Before performing any other operation, you have to load the file using the syntax below. ~~~~{.cpp} IGESControl_Reader reader; -IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”); +XSControl_ReturnStatus stat = reader.ReadFile(“filename.igs”); ~~~~ The loading operation only loads the IGES file into computer memory; it does not translate it. @@ -1125,7 +1125,7 @@ Allows writing the prepared model to a file with name *filename.igs*. Before performing any other operation, you must load an IGES file with: ~~~~{.cpp} IGESCAFControl_Reader reader(XSDRAW::Session(), Standard_False); -IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”); +XSControl_ReturnStatus stat = reader.ReadFile(“filename.igs”); ~~~~ Loading the file only memorizes, but does not translate the data. @@ -1183,7 +1183,7 @@ aWriter.SetNameMode(mode); You can perform the translation of a document by calling the function: ~~~~{.cpp} -IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc); +XSControl_ReturnStatus aRetSt = aWriter.Transfer(doc); ~~~~ where "doc" is a variable which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*. @@ -1191,11 +1191,11 @@ where "doc" is a variable which contains a handle to the input document for tran Write an IGES file with: ~~~~{.cpp} -IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.igs"); +XSControl_ReturnStatus statw = aWriter.WriteFile("filename.igs"); ~~~~ or ~~~~{.cpp} -IFSelect_ReturnStatus statw = writer.WriteFile (S); +XSControl_ReturnStatus statw = writer.WriteFile (S); ~~~~ where S is OStream. diff --git a/dox/user_guides/step/step.md b/dox/user_guides/step/step.md index f8f47da396..d8b89d70c5 100644 --- a/dox/user_guides/step/step.md +++ b/dox/user_guides/step/step.md @@ -123,7 +123,7 @@ For further information see 2.4 Mapping STEP entities to Open CASCADE Technology Before performing any other operation you have to load the file with: ~~~~{.cpp} STEPControl_Reader reader; -IFSelect_ReturnStatus stat = reader.ReadFile("filename.stp"); +XSControl_ReturnStatus stat = reader.ReadFile("filename.stp"); ~~~~ Loading the file only memorizes the data, it does not translate it. @@ -1067,13 +1067,13 @@ If *TopoDS_Compound* contains any other types besides the ones mentioned in the In case if an OCCT shape cannot be translated according to its mode the result of translation is void. ~~~~{.cpp} STEP214Control_StepModelTope mode = STEP214Control_ManifoldSolidBrep; -IFSelect_ReturnStatus stat = writer.Transfer(shape,mode); +XSControl_ReturnStatus stat = writer.Transfer(shape,mode); ~~~~ @subsubsection occt_step_3_3_4 Writing the STEP file Write the STEP file with: ~~~~{.cpp} -IFSelect_ReturnStatus stat = writer.Write("filename.stp"); +XSControl_ReturnStatus stat = writer.Write("filename.stp"); ~~~~ to give the file name. @@ -1514,7 +1514,7 @@ In addition to the translation of shapes implemented in basic translator, it pro Before performing any other operation, you must load a STEP file with: ~~~~{.cpp} STEPCAFControl_Reader reader(XSDRAW::Session(), Standard_False); -IFSelect_ReturnStatus stat = reader.ReadFile("filename.stp"); +XSControl_ReturnStatus stat = reader.ReadFile("filename.stp"); ~~~~ Loading the file only memorizes the data, it does not translate it. @@ -1678,7 +1678,7 @@ aWriter.SetNameMode(mode); You can perform the translation of document by calling the function: ~~~~{.cpp} -IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc); +XSControl_ReturnStatus aRetSt = aWriter.Transfer(doc); ~~~~ where *doc* is a variable, which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*. @@ -1686,11 +1686,11 @@ where *doc* is a variable, which contains a handle to the input document for tr Write a STEP file with: ~~~~{.cpp} -IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.stp"); +XSControl_ReturnStatus statw = aWriter.WriteFile("filename.stp"); ~~~~ or ~~~~{.cpp} -IFSelect_ReturnStatus statw = writer.WriteFile (S); +XSControl_ReturnStatus statw = writer.WriteFile (S); ~~~~ where *S* is *OStream*. diff --git a/dox/user_guides/xde/xde.md b/dox/user_guides/xde/xde.md index 72056a2e63..226953527b 100644 --- a/dox/user_guides/xde/xde.md +++ b/dox/user_guides/xde/xde.md @@ -1240,8 +1240,8 @@ To read a STEP file by itself, use: ~~~~{.cpp} const char* theFilename = ...; STEPCAFControl_Reader aReader; -IFSelect_ReturnStatus aReadStat = aReader.ReadFile (theFilename); -if (aReadStat != IFSelect_RetDone) { .. reader/parser error .. } +XSControl_ReturnStatus aReadStat = aReader.ReadFile (theFilename); +if (aReadStat != XSControl_RetDone) { .. reader/parser error .. } // the various ways of reading a file are available here too: // to read it by the reader, to take it from a WorkSession ... Handle(TDocStd_Document) aDoc = ...; @@ -1278,8 +1278,8 @@ if (!aWriter.Transfer (aDoc, aMode)) // writing the File const char* theFilename = ...; -IFSelect_ReturnStatus aStat = aWriter.Write (theFilename); -if (aStat != IFSelect_RetDone) { .. writing failed .. } +XSControl_ReturnStatus aStat = aWriter.Write (theFilename); +if (aStat != XSControl_RetDone) { .. writing failed .. } ~~~~ @subsection occt_xde_2_11_3 Reading an IGES File diff --git a/src/APIHeaderSection/APIHeaderSection_EditHeader.cxx b/src/APIHeaderSection/APIHeaderSection_EditHeader.cxx deleted file mode 100644 index 2bc59031ef..0000000000 --- a/src/APIHeaderSection/APIHeaderSection_EditHeader.cxx +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(APIHeaderSection_EditHeader,IFSelect_Editor) - -static Standard_Boolean IsTimeStamp - (const Handle(TCollection_HAsciiString)& val) -{ - if (val.IsNull()) return Standard_False; - if (val->Length() != 19) return Standard_False; -// On y va - char dizmois = val->Value(6); - char dizjour = val->Value(9); - char dizheur = val->Value(12); - for (Standard_Integer i = 1; i <= 19; i ++) - { - char uncar = val->Value(i); - switch (i) { - case 1 : if (uncar != '1' && uncar != '2') return Standard_False; - break; - case 2 : - case 3 : - case 4 : if (uncar < '0' || uncar > '9') return Standard_False; - break; - case 5 : if (uncar != '-') return Standard_False; - Standard_FALLTHROUGH - case 6 : if (uncar != '0' && uncar != '1') return Standard_False; - break; - case 7 : if (uncar < '0' || uncar > '9') return Standard_False; - if (dizmois == '1' && (uncar < '0' || uncar > '2')) return Standard_False; - break; - case 8 : if (uncar != '-') return Standard_False; - Standard_FALLTHROUGH - case 9 : if (uncar < '0' || uncar > '3') return Standard_False; - break; - case 10 : if (uncar < '0' || uncar > '9') return Standard_False; - if (dizjour == '3' && (uncar != '0' && uncar != '1')) return Standard_False; - break; - case 11 : if (uncar != 'T') return Standard_False; - Standard_FALLTHROUGH - case 12 : if (uncar < '0' || uncar > '2') return Standard_False; - break; - case 13 : if (uncar < '0' || uncar > '9') return Standard_False; - if (dizheur == '2' && (uncar < '0' || uncar > '3')) return Standard_False; - break; - case 14 : if (uncar != ':') return Standard_False; - Standard_FALLTHROUGH - case 15 : if (uncar < '0' || uncar > '5') return Standard_False; - break; - case 16 : if (uncar < '0' || uncar > '9') return Standard_False; - break; - case 17 : if (uncar != ':') return Standard_False; - Standard_FALLTHROUGH - case 18 : if (uncar < '0' || uncar > '5') return Standard_False; - break; - case 19 : if (uncar < '0' || uncar > '9') return Standard_False; - break; - default : - break; - } - } - return Standard_True; -} - - - APIHeaderSection_EditHeader::APIHeaderSection_EditHeader () - : IFSelect_Editor (10) -{ -// Definition - Handle(Interface_TypedValue) fn_name = new Interface_TypedValue("fn_name"); - SetValue (1,fn_name,"name"); - Handle(Interface_TypedValue) fn_time = new Interface_TypedValue("fn_time_stamp"); - fn_time->SetSatisfies (IsTimeStamp,"IsTimeStamp"); - SetValue (2,fn_time,"time"); - Handle(Interface_TypedValue) fn_author = new Interface_TypedValue("fn_author"); - SetValue (3,fn_author,"author"); // 1 seul (1er de liste) - Handle(Interface_TypedValue) fn_org = new Interface_TypedValue("fn_organization"); - SetValue (4,fn_org,"org"); // 1 seul (1er de liste) - Handle(Interface_TypedValue) fn_preproc = new Interface_TypedValue("fn_preprocessor_version"); - SetValue (5,fn_preproc,"preproc"); - Handle(Interface_TypedValue) fn_orig = new Interface_TypedValue("fn_originating_system"); - SetValue (6,fn_orig,"orig"); - Handle(Interface_TypedValue) fn_autorize = new Interface_TypedValue("fn_authorization"); - SetValue (7,fn_autorize,"autorize"); - - Handle(Interface_TypedValue) fs_schema = new Interface_TypedValue("fs_schema_identifiers"); - SetValue (8,fs_schema,"schema"); // 1 seul (1er de liste) - - Handle(Interface_TypedValue) fd_descr = new Interface_TypedValue("fd_description"); - SetValue (9,fd_descr,"descr"); // 1 seul (1er de liste) - - Handle(Interface_TypedValue) fd_level = new Interface_TypedValue("fd_implementation_level"); - SetValue (10,fd_level,"level"); - -} - - TCollection_AsciiString APIHeaderSection_EditHeader::Label () const - { return TCollection_AsciiString ("Step Header"); } - - Standard_Boolean APIHeaderSection_EditHeader::Recognize - (const Handle(IFSelect_EditForm)& /*form*/) const -{ return Standard_True; } // ?? - - Handle(TCollection_HAsciiString) APIHeaderSection_EditHeader::StringValue - (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const -{ -// Default Values - return TypedValue(num)->HStringValue(); -} - - Standard_Boolean APIHeaderSection_EditHeader::Load - (const Handle(IFSelect_EditForm)& form, - const Handle(Standard_Transient)& /*ent*/, - const Handle(Interface_InterfaceModel)& model) const -{ - Handle(StepData_StepModel) modl = - Handle(StepData_StepModel)::DownCast(model); - if (modl.IsNull()) return Standard_False; - - APIHeaderSection_MakeHeader mkh (modl); - - form->LoadValue (1 ,mkh.Name ()); - form->LoadValue (2 ,mkh.TimeStamp ()); - form->LoadValue (3 ,mkh.AuthorValue (1)); - form->LoadValue (4 ,mkh.OrganizationValue (1)); - form->LoadValue (5 ,mkh.PreprocessorVersion ()); - form->LoadValue (6 ,mkh.OriginatingSystem ()); - form->LoadValue (7 ,mkh.Authorisation ()); - - form->LoadValue (8 ,mkh.SchemaIdentifiersValue (1)); - - form->LoadValue (9 ,mkh.DescriptionValue (1)); - form->LoadValue (10,mkh.ImplementationLevel ()); - - return Standard_True; -} - - Standard_Boolean APIHeaderSection_EditHeader::Apply - (const Handle(IFSelect_EditForm)& form, - const Handle(Standard_Transient)& /*ent*/, - const Handle(Interface_InterfaceModel)& model) const -{ - Handle(StepData_StepModel) modl = - Handle(StepData_StepModel)::DownCast(model); - if (modl.IsNull()) return Standard_False; - - APIHeaderSection_MakeHeader mkh (modl); - - if (form->IsModified(1)) mkh.SetName (form->EditedValue(1)); - if (form->IsModified(2)) mkh.SetTimeStamp (form->EditedValue(2)); - if (form->IsModified(3)) mkh.SetAuthorValue (1,form->EditedValue(3)); - if (form->IsModified(4)) mkh.SetOrganizationValue (1,form->EditedValue(4)); - if (form->IsModified(5)) mkh.SetPreprocessorVersion (form->EditedValue(5)); - if (form->IsModified(6)) mkh.SetOriginatingSystem (form->EditedValue(6)); - if (form->IsModified(7)) mkh.SetAuthorisation (form->EditedValue(7)); - - if (form->IsModified(8)) mkh.SetSchemaIdentifiersValue (1,form->EditedValue(8)); - - if (form->IsModified(9)) mkh.SetDescriptionValue (1,form->EditedValue(9)); - if (form->IsModified(10)) mkh.SetImplementationLevel (form->EditedValue(10)); - - mkh.Apply( Handle(StepData_StepModel)::DownCast(model) ); - - return Standard_True; -} diff --git a/src/APIHeaderSection/APIHeaderSection_EditHeader.hxx b/src/APIHeaderSection/APIHeaderSection_EditHeader.hxx deleted file mode 100644 index 749528cb48..0000000000 --- a/src/APIHeaderSection/APIHeaderSection_EditHeader.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Created on: 1998-07-08 -// Created by: Christian CAILLET -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _APIHeaderSection_EditHeader_HeaderFile -#define _APIHeaderSection_EditHeader_HeaderFile - -#include - -#include -#include -class TCollection_AsciiString; -class IFSelect_EditForm; -class TCollection_HAsciiString; -class Standard_Transient; -class Interface_InterfaceModel; - - -class APIHeaderSection_EditHeader; -DEFINE_STANDARD_HANDLE(APIHeaderSection_EditHeader, IFSelect_Editor) - - -class APIHeaderSection_EditHeader : public IFSelect_Editor -{ - -public: - - - Standard_EXPORT APIHeaderSection_EditHeader(); - - Standard_EXPORT TCollection_AsciiString Label() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Boolean Recognize (const Handle(IFSelect_EditForm)& form) const Standard_OVERRIDE; - - Standard_EXPORT Handle(TCollection_HAsciiString) StringValue (const Handle(IFSelect_EditForm)& form, const Standard_Integer num) const Standard_OVERRIDE; - - Standard_EXPORT Standard_Boolean Apply (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE; - - Standard_EXPORT Standard_Boolean Load (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE; - - - - - DEFINE_STANDARD_RTTIEXT(APIHeaderSection_EditHeader,IFSelect_Editor) - -protected: - - - - -private: - - - - -}; - - - - - - - -#endif // _APIHeaderSection_EditHeader_HeaderFile diff --git a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx b/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx deleted file mode 100644 index 9f90004ff9..0000000000 --- a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// Created on: 1993-08-12 -// Created by: Frederic MAUPAS -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//#58 rln 28.12.98 STEP header fields (NOTE: more parameterization is necessary) -//pdn 11.01.99 including for compilation on NT - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -// This is a generic header for any STEP sheme -static Handle(TCollection_HAsciiString) nulstr; -static Handle(Interface_HArray1OfHAsciiString) nularr; - -APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader - (const Handle(StepData_StepModel)& model) -{ - done = Standard_True; - if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileName))) { - fn = GetCasted(HeaderSection_FileName, - model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileName))); - } - else done = Standard_False; - if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileSchema))) { - fs = GetCasted(HeaderSection_FileSchema, - model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))); - } - else done = Standard_False; - if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileDescription))) { - fd = GetCasted(HeaderSection_FileDescription, - model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))); - } - else done = Standard_False; -} - -APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader - (const Standard_Integer shapetype) -{ - switch(shapetype) { - case 1 : Init ("Open CASCADE Facetted BRep Model"); break; - case 2 : Init ("Open CASCADE Face Based Surface Model"); break; - case 3 : Init ("Open CASCADE Shell Based Surface Model"); break; - case 4 : Init ("Open CASCADE Manifold Solid Brep Model"); break; - default: Init ("Open CASCADE Shape Model"); break; - } -} - -void APIHeaderSection_MakeHeader::Init (const Standard_CString nameval) -{ - done = Standard_True; - - // - File Name - char timestamp[50]; - - if (fn.IsNull()) fn = new HeaderSection_FileName; - Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(nameval); - fn->SetName(name); - Interface_MSG::TDate (timestamp,0,0,0,0,0,1,"C:%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d"); // actually - Handle(TCollection_HAsciiString) tst = - new TCollection_HAsciiString(timestamp); - fn->SetTimeStamp(tst); - Handle(Interface_HArray1OfHAsciiString) authors = - new Interface_HArray1OfHAsciiString(1,1); - Handle(TCollection_HAsciiString) a1 = - new TCollection_HAsciiString("Author"); - authors->SetValue(1,a1); - fn->SetAuthor(authors); - Handle(Interface_HArray1OfHAsciiString) org = - new Interface_HArray1OfHAsciiString(1,1); - Handle(TCollection_HAsciiString) org1 = - new TCollection_HAsciiString("Open CASCADE"); - org->SetValue(1,org1); - fn->SetOrganization(org); - - char procver[80]; - sprintf (procver, XSTEP_PROCESSOR_VERSION, "STEP"); - Handle(TCollection_HAsciiString) pv = new TCollection_HAsciiString (procver); - //Handle(TCollection_HAsciiString) pv = - //new TCollection_HAsciiString(XSTEP_VERSION); - fn->SetPreprocessorVersion(pv); - - Handle(TCollection_HAsciiString) sys = - new TCollection_HAsciiString(XSTEP_SYSTEM_VERSION);//#58 rln - fn->SetOriginatingSystem(sys); - Handle(TCollection_HAsciiString) auth = - new TCollection_HAsciiString("Unknown"); - fn->SetAuthorisation(auth); - - // - File Description - - if (fd.IsNull()) fd = new HeaderSection_FileDescription; - Handle(Interface_HArray1OfHAsciiString) descr = - new Interface_HArray1OfHAsciiString(1,1); - Handle(TCollection_HAsciiString) descr1 = - new TCollection_HAsciiString("Open CASCADE Model"); - descr->SetValue(1,descr1); - fd->SetDescription(descr); - Handle(TCollection_HAsciiString) il = - new TCollection_HAsciiString("2;1"); - fd->SetImplementationLevel(il); - - // - File Schema - - if (fs.IsNull()) fs = new HeaderSection_FileSchema; - Handle(Interface_HArray1OfHAsciiString) schid = - new Interface_HArray1OfHAsciiString(1,1); - Handle(TCollection_HAsciiString) schid1 = - new TCollection_HAsciiString(""); - schid->SetValue(1,schid1); - fs->SetSchemaIdentifiers(schid); - -} - -Standard_Boolean APIHeaderSection_MakeHeader::IsDone() const -{ - return done; -} - -void APIHeaderSection_MakeHeader::Apply - (const Handle(StepData_StepModel)& model) const -{ - Interface_EntityIterator header = model->Header(); - if (HasFd() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileDescription))) - header.AddItem(fd); - if (HasFn() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileName))) - header.AddItem(fn); - if (HasFs() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileSchema))) { - -// Schema defined? If not take it from the protocole - Handle(TCollection_HAsciiString) sch; - Handle(Interface_HArray1OfHAsciiString) schid = fs->SchemaIdentifiers(); - if (!schid.IsNull()) sch = schid->Value(1); - else { - schid = new Interface_HArray1OfHAsciiString(1,1); - fs->SetSchemaIdentifiers(schid); - } - if (!sch.IsNull()) { if (sch->Length() < 2) sch.Nullify(); } // not defined - if (sch.IsNull()) { - Handle(StepData_Protocol) stepro = Handle(StepData_Protocol)::DownCast - ( model->Protocol()); - if (!stepro.IsNull()) sch = new TCollection_HAsciiString - (stepro->SchemaName()); - if (!sch.IsNull()) schid->SetValue (1,sch); - } - header.AddItem(fs); - } - model->ClearHeader(); - for (header.Start(); header.More(); header.Next()) - model->AddHeaderEntity(header.Value()); -} - - -// ======== -// FileName -// ======== - -Handle(StepData_StepModel) APIHeaderSection_MakeHeader::NewModel - (const Handle(Interface_Protocol)& protocol) const -{ - Handle(StepData_StepModel) stepmodel = new StepData_StepModel; - stepmodel->SetProtocol (protocol); - - // - Make Header information - - Apply(stepmodel); - return stepmodel; -} - -// ######## Individual Queries / Actions ######## - -// ======== -// FileName -// ======== - -Standard_Boolean APIHeaderSection_MakeHeader::HasFn() const -{ return (!fn.IsNull()); } - -Handle(HeaderSection_FileName) APIHeaderSection_MakeHeader::FnValue() const -{ - return fn; -} - -/* -void APIHeaderSection_MakeHeader::SetNameFromShapeType(const Standard_Integer shapetype) -{ - Handle(TCollection_HAsciiString) name; - switch(shapetype) - { - case 1: // face_based_surface_model - name = new TCollection_HAsciiString - ("Euclid Face Based Surface Model"); - break; - case 2: // manifold_solid_brep - name = new TCollection_HAsciiString - ("Euclid Manifold Solid Brep Model"); - break; - case 3: // facetted_brep - name = new TCollection_HAsciiString - ("Euclid Facetted Brep Model"); - break; - default : // others ? - name = new TCollection_HAsciiString - ("Euclid Shape Model"); - break; - } - SetName(aName); -} -*/ - -void APIHeaderSection_MakeHeader::SetName(const Handle(TCollection_HAsciiString)& aName) -{ - if (!fn.IsNull()) fn->SetName(aName); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::Name() const -{ - return (fn.IsNull() ? nulstr : fn->Name()); -} - -void APIHeaderSection_MakeHeader::SetTimeStamp(const Handle(TCollection_HAsciiString)& aTimeStamp) -{ - if (!fn.IsNull()) fn->SetTimeStamp(aTimeStamp); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::TimeStamp() const -{ - return (fn.IsNull() ? nulstr : fn->TimeStamp()); -} - -void APIHeaderSection_MakeHeader::SetAuthor(const Handle(Interface_HArray1OfHAsciiString)& aAuthor) -{ - if (!fn.IsNull()) fn->SetAuthor(aAuthor); -} - -void APIHeaderSection_MakeHeader::SetAuthorValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aAuthor) -{ - if (fn.IsNull()) return; - Handle(Interface_HArray1OfHAsciiString) li = fn->Author(); - if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aAuthor); -} - -Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Author() const -{ - return (fn.IsNull() ? nularr : fn->Author()); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::AuthorValue(const Standard_Integer num) const -{ - return (fn.IsNull() ? nulstr : fn->AuthorValue(num)); -} - -Standard_Integer APIHeaderSection_MakeHeader::NbAuthor () const -{ - return (fn.IsNull() ? 0 : fn->NbAuthor()); -} - -void APIHeaderSection_MakeHeader::SetOrganization(const Handle(Interface_HArray1OfHAsciiString)& aOrganization) -{ - if (!fn.IsNull()) fn->SetOrganization(aOrganization); -} - -void APIHeaderSection_MakeHeader::SetOrganizationValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aOrgan) -{ - if (fn.IsNull()) return; - Handle(Interface_HArray1OfHAsciiString) li = fn->Organization(); - if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aOrgan); -} - -Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Organization() const -{ - return (fn.IsNull() ? nularr : fn->Organization()); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::OrganizationValue(const Standard_Integer num) const -{ - return (fn.IsNull() ? nulstr : fn->OrganizationValue(num)); -} - -Standard_Integer APIHeaderSection_MakeHeader::NbOrganization () const -{ - return (fn.IsNull() ? 0 : fn->NbOrganization()); -} - -void APIHeaderSection_MakeHeader::SetPreprocessorVersion(const Handle(TCollection_HAsciiString)& aPreprocessorVersion) -{ - if (!fn.IsNull()) fn->SetPreprocessorVersion(aPreprocessorVersion); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::PreprocessorVersion() const -{ - return (fn.IsNull() ? nulstr : fn->PreprocessorVersion()); -} - -void APIHeaderSection_MakeHeader::SetOriginatingSystem(const Handle(TCollection_HAsciiString)& aOriginatingSystem) -{ - if (!fn.IsNull()) fn->SetOriginatingSystem(aOriginatingSystem); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::OriginatingSystem() const -{ - return (fn.IsNull() ? nulstr : fn->OriginatingSystem()); -} - -void APIHeaderSection_MakeHeader::SetAuthorisation(const Handle(TCollection_HAsciiString)& aAuthorisation) -{ - if (!fn.IsNull()) fn->SetAuthorisation(aAuthorisation); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::Authorisation() const -{ - return (fn.IsNull() ? nulstr : fn->Authorisation()); -} - -// =========== -// File Schema -// =========== - -Standard_Boolean APIHeaderSection_MakeHeader::HasFs() const -{ return (!fs.IsNull()); } - -Handle(HeaderSection_FileSchema) APIHeaderSection_MakeHeader::FsValue() const -{ - return fs; -} - -void APIHeaderSection_MakeHeader::SetSchemaIdentifiers(const Handle(Interface_HArray1OfHAsciiString)& aSchemaIdentifiers) -{ - if (!fs.IsNull()) fs->SetSchemaIdentifiers(aSchemaIdentifiers); -} - -void APIHeaderSection_MakeHeader::SetSchemaIdentifiersValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aSchem) -{ - if (fs.IsNull()) return; - Handle(Interface_HArray1OfHAsciiString) li = fs->SchemaIdentifiers(); - if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aSchem); -} - -Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::SchemaIdentifiers() const -{ - return (fs.IsNull() ? nularr : fs->SchemaIdentifiers()); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::SchemaIdentifiersValue(const Standard_Integer num) const -{ - return (fs.IsNull() ? nulstr : fs->SchemaIdentifiersValue(num)); -} - -Standard_Integer APIHeaderSection_MakeHeader::NbSchemaIdentifiers () const -{ - return (fs.IsNull() ? 0 : fs->NbSchemaIdentifiers()); -} - -//======================================================================= -//function : AddSchemaIdentifier -//purpose : -//======================================================================= - -void APIHeaderSection_MakeHeader::AddSchemaIdentifier(const Handle(TCollection_HAsciiString)& aSchem) -{ - if ( fs.IsNull() ) fs = new HeaderSection_FileSchema; - Handle(Interface_HArray1OfHAsciiString) idents = fs->SchemaIdentifiers(); - - // check that requested subschema is already in the list - Standard_Integer i; - for ( i=1; ! idents.IsNull() && i <= idents->Length(); i++ ) { - if ( aSchem->IsSameString ( idents->Value(i) ) ) return; - } - - // add a subshema - Handle(Interface_HArray1OfHAsciiString) ids = - new Interface_HArray1OfHAsciiString ( 1, ( idents.IsNull() ? 1 : idents->Length() + 1 ) ); - for ( i=1; ! idents.IsNull() && i <= idents->Length(); i++ ) { - ids->SetValue ( i, idents->Value(i) ); - } - ids->SetValue ( i, aSchem ); - - fs->SetSchemaIdentifiers ( ids ); -} - -// ================ -// File Description -// ================ - -Standard_Boolean APIHeaderSection_MakeHeader::HasFd() const -{ return (!fd.IsNull()); } - -Handle(HeaderSection_FileDescription) APIHeaderSection_MakeHeader::FdValue() const -{ - return fd; -} - -void APIHeaderSection_MakeHeader::SetDescription(const Handle(Interface_HArray1OfHAsciiString)& aDescription) -{ - if (!fs.IsNull()) fd->SetDescription(aDescription); -} - -void APIHeaderSection_MakeHeader::SetDescriptionValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aDescr) -{ - if (fd.IsNull()) return; - Handle(Interface_HArray1OfHAsciiString) li = fd->Description(); - if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aDescr); -} - -Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Description() const -{ - return (fd.IsNull() ? nularr : fd->Description()); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::DescriptionValue(const Standard_Integer num) const -{ - return (fd.IsNull() ? nulstr : fd->DescriptionValue(num)); -} - -Standard_Integer APIHeaderSection_MakeHeader::NbDescription () const -{ - return (fd.IsNull() ? 0 : fd->NbDescription()); -} - -void APIHeaderSection_MakeHeader::SetImplementationLevel(const Handle(TCollection_HAsciiString)& aImplementationLevel) -{ - if (!fd.IsNull()) fd->SetImplementationLevel(aImplementationLevel); -} - -Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::ImplementationLevel() const -{ - return (fd.IsNull() ? nulstr : fd->ImplementationLevel()); -} diff --git a/src/APIHeaderSection/APIHeaderSection_MakeHeader.hxx b/src/APIHeaderSection/APIHeaderSection_MakeHeader.hxx deleted file mode 100644 index 9415693b65..0000000000 --- a/src/APIHeaderSection/APIHeaderSection_MakeHeader.hxx +++ /dev/null @@ -1,202 +0,0 @@ -// Created on: 1993-08-12 -// Created by: Frederic MAUPAS -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _APIHeaderSection_MakeHeader_HeaderFile -#define _APIHeaderSection_MakeHeader_HeaderFile - -#include -#include -#include - -#include -#include -#include -class HeaderSection_FileName; -class HeaderSection_FileSchema; -class HeaderSection_FileDescription; -class StepData_StepModel; -class Interface_Protocol; -class TCollection_HAsciiString; - - -//! This class allows to consult and prepare/edit data stored in -//! a Step Model Header -class APIHeaderSection_MakeHeader -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! Prepares a new MakeHeader from scratch - Standard_EXPORT APIHeaderSection_MakeHeader(const Standard_Integer shapetype = 0); - - //! Prepares a MakeHeader from the content of a StepModel - //! See IsDone to know if the Header is well defined - Standard_EXPORT APIHeaderSection_MakeHeader(const Handle(StepData_StepModel)& model); - - //! Cancels the former definition and gives a FileName - //! To be used when a Model has no well defined Header - Standard_EXPORT void Init (const Standard_CString nameval); - - //! Returns True if all data have been defined (see also - //! HasFn, HasFs, HasFd) - Standard_EXPORT Standard_Boolean IsDone() const; - - //! Creates an empty header for a new - //! STEP model and allows the header fields to be completed. - Standard_EXPORT void Apply (const Handle(StepData_StepModel)& model) const; - - //! Builds a Header, creates a new StepModel, then applies the - //! Header to the StepModel - //! The Schema Name is taken from the Protocol (if it inherits - //! from StepData, else it is left in blanks) - Standard_EXPORT Handle(StepData_StepModel) NewModel (const Handle(Interface_Protocol)& protocol) const; - - //! Checks whether there is a - //! file_name entity. Returns True if there is one. - Standard_EXPORT Standard_Boolean HasFn() const; - - //! Returns the file_name entity. - //! Returns an empty entity if the file_name entity is not initialized. - Standard_EXPORT Handle(HeaderSection_FileName) FnValue() const; - - Standard_EXPORT void SetName (const Handle(TCollection_HAsciiString)& aName); - - //! Returns the name attribute for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) Name() const; - - Standard_EXPORT void SetTimeStamp (const Handle(TCollection_HAsciiString)& aTimeStamp); - - //! Returns the value of the time_stamp attribute for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) TimeStamp() const; - - Standard_EXPORT void SetAuthor (const Handle(Interface_HArray1OfHAsciiString)& aAuthor); - - Standard_EXPORT void SetAuthorValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& aAuthor); - - Standard_EXPORT Handle(Interface_HArray1OfHAsciiString) Author() const; - - //! Returns the value of the name attribute for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) AuthorValue (const Standard_Integer num) const; - - //! Returns the number of values for the author attribute in the file_name entity. - Standard_EXPORT Standard_Integer NbAuthor() const; - - Standard_EXPORT void SetOrganization (const Handle(Interface_HArray1OfHAsciiString)& aOrganization); - - Standard_EXPORT void SetOrganizationValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& aOrganization); - - Standard_EXPORT Handle(Interface_HArray1OfHAsciiString) Organization() const; - - //! Returns the value of attribute - //! organization for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) OrganizationValue (const Standard_Integer num) const; - - //! Returns the number of values for - //! the organization attribute in the file_name entity. - Standard_EXPORT Standard_Integer NbOrganization() const; - - Standard_EXPORT void SetPreprocessorVersion (const Handle(TCollection_HAsciiString)& aPreprocessorVersion); - - //! Returns the name of the preprocessor_version for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) PreprocessorVersion() const; - - Standard_EXPORT void SetOriginatingSystem (const Handle(TCollection_HAsciiString)& aOriginatingSystem); - - Standard_EXPORT Handle(TCollection_HAsciiString) OriginatingSystem() const; - - Standard_EXPORT void SetAuthorisation (const Handle(TCollection_HAsciiString)& aAuthorisation); - - //! Returns the value of the authorization attribute for the file_name entity. - Standard_EXPORT Handle(TCollection_HAsciiString) Authorisation() const; - - //! Checks whether there is a file_schema entity. Returns True if there is one. - Standard_EXPORT Standard_Boolean HasFs() const; - - //! Returns the file_schema entity. Returns an empty entity if the file_schema entity is not initialized. - Standard_EXPORT Handle(HeaderSection_FileSchema) FsValue() const; - - Standard_EXPORT void SetSchemaIdentifiers (const Handle(Interface_HArray1OfHAsciiString)& aSchemaIdentifiers); - - Standard_EXPORT void SetSchemaIdentifiersValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& aSchemaIdentifier); - - Standard_EXPORT Handle(Interface_HArray1OfHAsciiString) SchemaIdentifiers() const; - - //! Returns the value of the schema_identifier attribute for the file_schema entity. - Standard_EXPORT Handle(TCollection_HAsciiString) SchemaIdentifiersValue (const Standard_Integer num) const; - - //! Returns the number of values for the schema_identifier attribute in the file_schema entity. - Standard_EXPORT Standard_Integer NbSchemaIdentifiers() const; - - //! Add a subname of schema (if not yet in the list) - Standard_EXPORT void AddSchemaIdentifier (const Handle(TCollection_HAsciiString)& aSchemaIdentifier); - - //! Checks whether there is a file_description entity. Returns True if there is one. - Standard_EXPORT Standard_Boolean HasFd() const; - - //! Returns the file_description - //! entity. Returns an empty entity if the file_description entity is not initialized. - Standard_EXPORT Handle(HeaderSection_FileDescription) FdValue() const; - - Standard_EXPORT void SetDescription (const Handle(Interface_HArray1OfHAsciiString)& aDescription); - - Standard_EXPORT void SetDescriptionValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& aDescription); - - Standard_EXPORT Handle(Interface_HArray1OfHAsciiString) Description() const; - - //! Returns the value of the - //! description attribute for the file_description entity. - Standard_EXPORT Handle(TCollection_HAsciiString) DescriptionValue (const Standard_Integer num) const; - - //! Returns the number of values for - //! the file_description entity in the STEP file header. - Standard_EXPORT Standard_Integer NbDescription() const; - - Standard_EXPORT void SetImplementationLevel (const Handle(TCollection_HAsciiString)& aImplementationLevel); - - //! Returns the value of the - //! implementation_level attribute for the file_description entity. - Standard_EXPORT Handle(TCollection_HAsciiString) ImplementationLevel() const; - - - - -protected: - - - - - -private: - - - - Standard_Boolean done; - Handle(HeaderSection_FileName) fn; - Handle(HeaderSection_FileSchema) fs; - Handle(HeaderSection_FileDescription) fd; - - -}; - - - - - - - -#endif // _APIHeaderSection_MakeHeader_HeaderFile diff --git a/src/APIHeaderSection/FILES b/src/APIHeaderSection/FILES deleted file mode 100644 index 41bf0dd0ec..0000000000 --- a/src/APIHeaderSection/FILES +++ /dev/null @@ -1,4 +0,0 @@ -APIHeaderSection_EditHeader.cxx -APIHeaderSection_EditHeader.hxx -APIHeaderSection_MakeHeader.cxx -APIHeaderSection_MakeHeader.hxx diff --git a/src/DE/DE_DataModel.cxx b/src/DE/DE_DataModel.cxx new file mode 100644 index 0000000000..184743ce32 --- /dev/null +++ b/src/DE/DE_DataModel.cxx @@ -0,0 +1,1037 @@ +// Copyright (c) 1999-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +//szv#4 S4163 +//svv#1 11.01.00 : porting on DEC +//svv#2 21.02.00 : porting on SIL +//smh#14 17.03.2000 : FRA62479 Clearing of gtool. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(Interface_InterfaceModel, Standard_Transient) + +// Un Modele d`Interface est un ensemble ferme d`Entites d`interface : chacune +// est dans un seul modele a la fois; elle y a un numero (Number) qui permet de +// verifier qu`une entite est bien dans un seul modele, de definir des Map tres +// performantes, de fournir un identifieur numerique +// Il est a meme d`etre utilise dans des traitements de Graphe +// STATICS : les TEMPLATES +static NCollection_DataMap atemp; + +static const Handle(Standard_Type)& typerep() +{ + static Handle(Standard_Type) tr = STANDARD_TYPE(Interface_ReportEntity); + return tr; +} + + +static const Handle(Interface_Check)& nulch() +{ + static Handle(Interface_Check) anulch = new Interface_Check; + return anulch; +} + + +//======================================================================= +//function : Interface_InterfaceModel +//purpose : +//======================================================================= + +Interface_InterfaceModel::Interface_InterfaceModel () + : haschecksem (Standard_False), isdispatch (Standard_False) +{ + thecheckstx = new Interface_Check; + thechecksem = new Interface_Check; +} + + +//======================================================================= +//function : Destroy +//purpose : +//======================================================================= + +void Interface_InterfaceModel::Destroy () // on fait un mimumum +{ +// Moins que Clear que, lui, est adapte a chaque norme + ClearEntities(); + thecheckstx->Clear(); + thechecksem->Clear(); + thecategory.Nullify(); +} + + +//======================================================================= +//function : SetProtocol +//purpose : +//======================================================================= + +void Interface_InterfaceModel::SetProtocol(const Handle(Interface_Protocol)& proto) +{ + thegtool = new Interface_GTool(proto); +} + + +//======================================================================= +//function : Protocol +//purpose : +//======================================================================= + +Handle(Interface_Protocol) Interface_InterfaceModel::Protocol () const +{ + Handle(Interface_Protocol) proto; + if (!thegtool.IsNull()) return thegtool->Protocol(); + return proto; +} + + +//======================================================================= +//function : SetGTool +//purpose : +//======================================================================= + +void Interface_InterfaceModel::SetGTool(const Handle(Interface_GTool)& gtool) +{ + thegtool = gtool; +} + + +//======================================================================= +//function : GTool +//purpose : +//======================================================================= + +Handle(Interface_GTool) Interface_InterfaceModel::GTool () const +{ + return thegtool; +} + + +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + +void Interface_InterfaceModel::Clear () +{ + ClearEntities(); + thecheckstx->Clear(); + thechecksem->Clear(); + ClearHeader(); + ClearLabels(); + thecategory.Nullify(); +} + + +//======================================================================= +//function : DispatchStatus +//purpose : +//======================================================================= + +Standard_Boolean& Interface_InterfaceModel::DispatchStatus () +{ + return isdispatch; +} + + +//======================================================================= +//function : ClearEntities +//purpose : +//======================================================================= + +void Interface_InterfaceModel::ClearEntities () +{ + thereports.Clear(); + therepch.Clear(); + haschecksem = Standard_False; + + if (!thegtool.IsNull()) { +// WhenDeleteCase is not applicable +/* Handle(Interface_GeneralModule) module; Standard_Integer CN; + Standard_Integer nb = NbEntities(); + for (Standard_Integer i = 1; i <= nb ; i ++) { + Handle(Standard_Transient) anent = Value(i); + if (thegtool->Select (anent,module,CN)) + module->WhenDeleteCase (CN,anent,isdispatch); + }*/ + thegtool->ClearEntities(); //smh#14 FRA62479 + } + isdispatch = Standard_False; + theentities.Clear(); +} + + +// .... ACCES AUX ENTITES .... + + +//======================================================================= +//function : NbEntities +//purpose : +//======================================================================= + +Standard_Integer Interface_InterfaceModel::NbEntities () const +{ + return theentities.Extent(); +} + + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::Contains + (const Handle(Standard_Transient)& anentity) const +{ + if (theentities.Contains(anentity)) return Standard_True; + Handle(Interface_ReportEntity) rep = + Handle(Interface_ReportEntity)::DownCast(anentity); + if (!rep.IsNull()) return Contains(rep->Concerned()); + return Standard_False; +} + + +//======================================================================= +//function : Number +//purpose : +//======================================================================= + +Standard_Integer Interface_InterfaceModel::Number + (const Handle(Standard_Transient)& anentity) const +{ + if (anentity.IsNull()) return 0; + Standard_Integer num = theentities.FindIndex(anentity); + if (num > 0) return num; + if (anentity->IsKind(typerep())) { + Handle(Interface_ReportEntity) rep = + Handle(Interface_ReportEntity)::DownCast(anentity); + if (!rep.IsNull()) return Number(rep->Concerned()); + } + return 0; +} + +/* +Standard_Integer Interface_InterfaceModel::DENumber + (const Handle(Standard_Transient)& anentity) const +{ + if (anentity.IsNull()) return 0; + Standard_Integer num = theentities.FindIndex(anentity); + if (num > 0) return (2*num-1); + if (anentity->IsKind(typerep())) { + Handle(Interface_ReportEntity) rep = + Handle(Interface_ReportEntity)::DownCast(anentity); + if (!rep.IsNull()) return (Number(rep->Concerned())*2-1); + } + return 0; +} +*/ + +// .. Acces Speciaux (Report, etc...) .. + + +//======================================================================= +//function : Value +//purpose : +//======================================================================= + +const Handle(Standard_Transient)& Interface_InterfaceModel::Value + (const Standard_Integer num) const +{ + return theentities.FindKey(num); +} + + +//======================================================================= +//function : NbTypes +//purpose : +//======================================================================= + +Standard_Integer Interface_InterfaceModel::NbTypes + (const Handle(Standard_Transient)& ent) const +{ + if (Protocol().IsNull()) return 1; + return Protocol()->NbTypes(ent); +} + + +//======================================================================= +//function : Type +//purpose : +//======================================================================= + +Handle(Standard_Type) Interface_InterfaceModel::Type + (const Handle(Standard_Transient)& ent, const Standard_Integer nt) const +{ + if (Protocol().IsNull()) return ent->DynamicType(); + return Protocol()->Type(ent,nt); +} + + +//======================================================================= +//function : TypeName +//purpose : +//======================================================================= + +Standard_CString Interface_InterfaceModel::TypeName + (const Handle(Standard_Transient)& ent, const Standard_Boolean complet) const +{ + if (!thegtool.IsNull()) return thegtool->SignValue (ent,this); + Standard_CString tn = ent->DynamicType()->Name(); + if (complet) return tn; + return Interface_InterfaceModel::ClassName(tn); +} + + +//======================================================================= +//function : ClassName +//purpose : +//======================================================================= + +Standard_CString Interface_InterfaceModel::ClassName(const Standard_CString typnam) +{ + return Interface_SignType::ClassName (typnam); +} + + +//======================================================================= +//function : EntityState +//purpose : +//======================================================================= + +Interface_DataState Interface_InterfaceModel::EntityState + (const Standard_Integer num) const +{ + Handle(Interface_ReportEntity) rep; + if (!thereports.IsBound(num)) { + if (!therepch.IsBound(num)) return Interface_StateOK; + rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num)); + if (rep->IsError()) return Interface_DataFail; + return Interface_DataWarning; + } + rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num)); + if (rep.IsNull()) return Interface_StateUnknown; + if (rep->IsUnknown()) return Interface_StateUnknown; + if (rep->HasNewContent()) return Interface_StateUnloaded; + if (rep->IsError()) return Interface_LoadFail; + + if (!therepch.IsBound(num)) return Interface_LoadWarning; + rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num)); + if (rep->IsError()) return Interface_DataFail; + return Interface_DataWarning; +} + + +//======================================================================= +//function : IsReportEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::IsReportEntity + (const Standard_Integer num, const Standard_Boolean semantic) const +{ + return (semantic ? therepch.IsBound(num) : thereports.IsBound(num)); +} + + +//======================================================================= +//function : ReportEntity +//purpose : +//======================================================================= + +Handle(Interface_ReportEntity) Interface_InterfaceModel::ReportEntity + (const Standard_Integer num, const Standard_Boolean semantic) const +{ + Handle(Interface_ReportEntity) rep; + if (!IsReportEntity(num,semantic)) return rep; + if (semantic) rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num)); + else rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num)); + return rep; +} + + +//======================================================================= +//function : IsErrorEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::IsErrorEntity + (const Standard_Integer num) const +{ + Handle(Interface_ReportEntity) rep = ReportEntity(num); + if (rep.IsNull()) return Standard_False; + return rep->IsError(); +} + + +//======================================================================= +//function : IsRedefinedContent +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::IsRedefinedContent + (const Standard_Integer num) const +{ + Handle(Interface_ReportEntity) rep = ReportEntity(num); + if (rep.IsNull()) return Standard_False; + return rep->HasNewContent(); +} + + +//======================================================================= +//function : ClearReportEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::ClearReportEntity + (const Standard_Integer num) +{ + if (!thereports.IsBound(num)) return Standard_False; + thereports.UnBind (num); + return Standard_True; +} + + +//======================================================================= +//function : SetReportEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::SetReportEntity + (const Standard_Integer num, const Handle(Interface_ReportEntity)& rep) +{ + Standard_Integer nm = num; + Handle(Standard_Transient) ent; + if (num > 0) { + ent = Value(nm); + if (! (ent == rep->Concerned()) ) throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } else if (num < 0) { + nm = -num; + ent = Value(nm); + if (! (ent == rep->Concerned()) ) throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } else { + ent = rep->Concerned(); + nm = Number (ent); + if (nm == 0) throw Interface_InterfaceMismatch("InterfaceModel : SetReportEntity"); + } + if (!thereports.IsBound(nm)) { + Standard_Integer maxrep = thereports.NbBuckets(); + if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2); + } + if (nm <= 0) return Standard_False; + return thereports.Bind (nm,rep); +} + + +//======================================================================= +//function : AddReportEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::AddReportEntity + (const Handle(Interface_ReportEntity)& rep, const Standard_Boolean semantic) +{ + if (rep.IsNull()) return Standard_False; + Handle(Standard_Transient) ent = rep->Concerned(); + if (ent.IsNull()) return Standard_False; + Standard_Integer num = Number(ent); + if (num == 0) return Standard_False; + if (semantic) return thereports.Bind (num,rep); + else return therepch.Bind (num,rep); +} + + +//======================================================================= +//function : IsUnknownEntity +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::IsUnknownEntity + (const Standard_Integer num) const +{ + Handle(Interface_ReportEntity) rep = ReportEntity(num); + if (rep.IsNull()) return Standard_False; + return rep->IsUnknown(); +} + + +// .... Checks semantiques .... // + + +//======================================================================= +//function : FillSemanticChecks +//purpose : +//======================================================================= + +void Interface_InterfaceModel::FillSemanticChecks + (const Interface_CheckIterator& checks, const Standard_Boolean clear) +{ + if (!checks.Model().IsNull()) { + Handle(Standard_Transient) t1 = checks.Model(); + Handle(Standard_Transient) t2 = this; + if (t2 != t1) return; + } + if (clear) { therepch.Clear(); thechecksem->Clear(); } + Standard_Integer nb = 0; + for (checks.Start(); checks.More(); checks.Next()) nb ++; + therepch.ReSize (therepch.Extent() + nb + 2); + for (checks.Start(); checks.More(); checks.Next()) { + const Handle(Interface_Check) ach = checks.Value(); + Standard_Integer num = checks.Number(); +// global check : ok si MEME MODELE + if (num == 0) thechecksem->GetMessages(ach); + else { + Handle(Standard_Transient) ent = Value(num); + Handle(Interface_ReportEntity) rep = new Interface_ReportEntity(ach,ent); + therepch.Bind (num,rep); + } + } + haschecksem = Standard_True; +} + + +//======================================================================= +//function : HasSemanticChecks +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::HasSemanticChecks () const +{ + return haschecksem; +} + + +//======================================================================= +//function : Check +//purpose : +//======================================================================= + +const Handle(Interface_Check)& Interface_InterfaceModel::Check + (const Standard_Integer num, const Standard_Boolean syntactic) const +{ + if (num == 0) { + if (syntactic) return thecheckstx; + else return thechecksem; + } + if (! (syntactic ? thereports.IsBound(num) : therepch.IsBound(num)) ) + return nulch(); + Handle(Standard_Transient) trep; + if (syntactic) trep = thereports.Find(num); + else trep = therepch.Find(num); + Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast(trep); + if (rep.IsNull()) return nulch(); + return rep->Check(); +} + + +// .... Chargement des donnees du Modele .... // + + +//======================================================================= +//function : Reservate +//purpose : +//======================================================================= + +void Interface_InterfaceModel::Reservate (const Standard_Integer nbent) +{ + if (nbent > theentities.NbBuckets()) theentities.ReSize (nbent); + if (nbent < -thereports.NbBuckets()) thereports.ReSize (-nbent); +} + + +//======================================================================= +//function : AddEntity +//purpose : +//======================================================================= + +void Interface_InterfaceModel::AddEntity(const Handle(Standard_Transient)& anentity) +{ + //Standard_Integer newnum; svv #2 + if (!anentity->IsKind(typerep())) theentities.Add(anentity); +// Report : Ajouter Concerned, mais noter presence Report et sa valeur + else { + Handle(Interface_ReportEntity) rep = + Handle(Interface_ReportEntity)::DownCast(anentity); + AddEntity(rep->Concerned()); + Standard_Integer maxrep = thereports.NbBuckets(); + if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2); + thereports.Bind (Number(rep->Concerned()),rep); + } +} + + +// AddWithRefs itere sur les Entities referencees pour charger une Entite +// au complet, avec tout ce dont elle a besoin + + +//======================================================================= +//function : AddWithRefs +//purpose : +//======================================================================= + +void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent, + const Handle(Interface_Protocol)& proto, + const Standard_Integer level, + const Standard_Boolean listall) +{ + if (anent.IsNull()) return; + if (theentities.FindIndex(anent) != 0) { + if (!listall) return; + } + Interface_GeneralLib lib(proto); + AddWithRefs (anent,lib,level,listall); + if (Protocol().IsNull() && !proto.IsNull()) SetProtocol(proto); +} + + +//======================================================================= +//function : AddWithRefs +//purpose : +//======================================================================= + +void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent, + const Standard_Integer level, + const Standard_Boolean listall) +{ + Handle(Interface_Protocol) proto = Protocol(); + if (proto.IsNull()) throw Interface_InterfaceMismatch("InterfaceModel : AddWithRefs"); + AddWithRefs (anent,proto,level,listall); +} + + +//======================================================================= +//function : AddWithRefs +//purpose : +//======================================================================= + +void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent, + const Interface_GeneralLib& lib, + const Standard_Integer level, + const Standard_Boolean listall) +{ + if (anent.IsNull()) return; + if (theentities.FindIndex(anent) != 0) { + if (!listall) return; + } + else AddEntity(anent); + + Interface_EntityIterator iter; + Handle(Interface_GeneralModule) module; Standard_Integer CN; + if (lib.Select (anent,module,CN)) { + module->FillSharedCase (CN,anent,iter); +// FillShared tout court : supposerait que le modele soit deja pret +// or justement, on est en train de le construire ... + module->ListImpliedCase (CN,anent,iter); + } + Standard_Integer lev1 = level-1; + if (lev1 == 0) return; // level = 0 -> tous niveaux; sinon encore n-1 + for (iter.Start(); iter.More(); iter.Next()) + AddWithRefs(iter.Value(),lib,lev1,listall); +} + + +//======================================================================= +//function : ReplaceEntity +//purpose : +//======================================================================= + +void Interface_InterfaceModel::ReplaceEntity(const Standard_Integer nument, + const Handle(Standard_Transient)& anent) +{ + theentities.Substitute(nument,anent); +} + +// ReverseOrders permet de mieux controler la numeration des Entites : +// Souvent, les fichiers mettent les racines en fin, tandis que AddWithRefs +// les met en tete. + + +//======================================================================= +//function : ReverseOrders +//purpose : +//======================================================================= + +void Interface_InterfaceModel::ReverseOrders (const Standard_Integer after) +{ + Standard_Integer nb = NbEntities(); //Standard_Integer num; svv #2 + if (nb < 2 || after >= nb) return; + TColStd_Array1OfTransient ents(1,nb); + Standard_Integer i; // svv #1 + for (i = 1; i <= nb; i ++) + ents.SetValue (i, theentities.FindKey(i)); +// On va vider la Map, puis la recharger : dans l ordre jusqua after +// en ordre inverse apres + theentities.Clear(); + Reservate (nb); + for (i = 1; i <= after; i ++) theentities.Add (ents(i));// svv #2 + for (i = nb; i > after; i --) theentities.Add (ents(i)); +// Faudra aussi s occuper des Reports + for (i = nb; i > after; i --) { + Standard_Integer i2 = nb+after-i; + Handle(Standard_Transient) rep1,rep2; + if (thereports.IsBound(i)) rep1 = thereports.Find(i); + if (thereports.IsBound(i2)) rep2 = thereports.Find(i2); + if (!rep1.IsNull()) thereports.Bind (i2,rep1); + else thereports.UnBind (i2); + if (!rep2.IsNull()) thereports.Bind (i,rep2); + else thereports.UnBind (i); + } +} + + +//======================================================================= +//function : ChangeOrder +//purpose : +//======================================================================= + +void Interface_InterfaceModel::ChangeOrder(const Standard_Integer oldnum, + const Standard_Integer newnum, + const Standard_Integer cnt) //szv#4:S4163:12Mar99 `count` hid one from this +{ + Standard_Integer nb = NbEntities(); Standard_Integer i; //, num; svv #2 + if (nb < 2 || newnum >= nb || cnt<= 0) return; + TColStd_Array1OfTransient ents(1,nb); + // On va preparer le changement + Standard_Integer minum = (oldnum > newnum ? newnum : oldnum); + Standard_Integer mxnum = (oldnum < newnum ? newnum : oldnum); + Standard_Integer kount = (oldnum > newnum ? cnt : -cnt); + if (cnt <= 0 || cnt > mxnum - minum) throw Interface_InterfaceMismatch("InterfaceModel : ChangeOrder, Overlap"); + for (i = 1; i < minum; i ++) ents.SetValue (i,theentities.FindKey(i)); + for (i = mxnum+cnt; i <= nb; i ++) ents.SetValue (i,theentities.FindKey(i)); + for (i = minum; i < mxnum; i ++) + ents.SetValue( i + kount, theentities.FindKey(i) ); + for (i = oldnum; i < oldnum+cnt; i ++) + ents.SetValue( i + (newnum-oldnum), theentities.FindKey(i) ); + + theentities.Clear(); + Reservate (nb); + for (i = 1; i <= nb; i ++) theentities.Add (ents(i)); // svv #2 + + Standard_Integer difnum = mxnum - minum; + for (i = minum; i < minum+cnt; i ++) { + Handle(Standard_Transient) rep1, rep2; + if (thereports.IsBound(i)) rep1 = thereports.Find(i); + if (thereports.IsBound(i+difnum)) rep1 = thereports.Find(i+difnum); + if (!rep1.IsNull()) thereports.Bind (i+difnum,rep1); + else thereports.UnBind (i+difnum); + if (!rep2.IsNull()) thereports.Bind (i,rep2); + else thereports.UnBind (i); + } +} + + +// GetFromTransfer permet de recuperer un resultat prepare par ailleurs +// Le Modele demarre a zero. Les entites doivent etre libres (cf AddEntity) + + +//======================================================================= +//function : GetFromTransfer +//purpose : +//======================================================================= + +void Interface_InterfaceModel::GetFromTransfer + (const Interface_EntityIterator& aniter) +{ + theentities.Clear(); theentities.ReSize (aniter.NbEntities()); + for (aniter.Start(); aniter.More(); aniter.Next()) { + Handle(Standard_Transient) ent = aniter.Value(); AddEntity(ent); + } +} + + +// .... Interrogations .... // + + +//======================================================================= +//function : SetCategoryNumber +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::SetCategoryNumber + (const Standard_Integer num, const Standard_Integer val) +{ + Standard_Integer i,nb = NbEntities(); + if (num < 1 || num > nb) return Standard_False; + if (thecategory.IsNull()) thecategory = new TCollection_HAsciiString(nb,' '); + else if (thecategory->Length() < nb) { + Handle(TCollection_HAsciiString) c = new TCollection_HAsciiString(nb,' '); + for (i = thecategory->Length(); i > 0; i --) + c->SetValue(i,thecategory->Value(i)); + thecategory = c; + } + Standard_Character cval = (Standard_Character)(val + 32); + thecategory->SetValue(num,cval); + return Standard_True; +} + + +//======================================================================= +//function : CategoryNumber +//purpose : +//======================================================================= + +Standard_Integer Interface_InterfaceModel::CategoryNumber + (const Standard_Integer num) const +{ + if (thecategory.IsNull()) return 0; + if (num < 1 || num > thecategory->Length()) return 0; + Standard_Integer val = thecategory->Value(num); + return val-32; +} + + +//======================================================================= +//function : FillIterator +//purpose : +//======================================================================= + +void Interface_InterfaceModel::FillIterator(Interface_EntityIterator& iter) const +{ + Standard_Integer nb = NbEntities(); + for (Standard_Integer i = 1; i <= nb; i ++) + iter.GetOneItem (theentities.FindKey(i)); +} + + +//======================================================================= +//function : Entities +//purpose : +//======================================================================= + +Interface_EntityIterator Interface_InterfaceModel::Entities () const +{ + Interface_EntityIterator iter; + FillIterator(iter); + return iter; +} + + +//======================================================================= +//function : Reports +//purpose : +//======================================================================= + +Interface_EntityIterator Interface_InterfaceModel::Reports + (const Standard_Boolean semantic) const +{ + Interface_EntityIterator iter; + if (semantic) { + TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (therepch); + for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value()); + } else { + TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports); + for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value()); + } + return iter; +} + + +//======================================================================= +//function : Redefineds +//purpose : +//======================================================================= + +Interface_EntityIterator Interface_InterfaceModel::Redefineds () const +{ + Interface_EntityIterator iter; + TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports); + for (; itmap.More(); itmap.Next()) { + Handle(Interface_ReportEntity) rep = + Handle(Interface_ReportEntity)::DownCast(itmap.Value()); + if (rep.IsNull()) continue; + if (!rep->HasNewContent()) continue; + iter.AddItem (rep); + } + return iter; +} + +//#include +//#include + + +//======================================================================= +//function : GlobalCheck +//purpose : +//======================================================================= + +const Handle(Interface_Check)& Interface_InterfaceModel::GlobalCheck + (const Standard_Boolean syntactic) const +{ + if (syntactic) return thecheckstx; + else return thechecksem; +} + + +//======================================================================= +//function : SetGlobalCheck +//purpose : +//======================================================================= + +void Interface_InterfaceModel::SetGlobalCheck(const Handle(Interface_Check)& ach) +{ + thecheckstx = ach; +} + + +//======================================================================= +//function : VerifyCheck +//purpose : +//======================================================================= + +void Interface_InterfaceModel::VerifyCheck (Handle(Interface_Check)& /*ach*/) const +{ +} + + +//======================================================================= +//function : Print +//purpose : +//======================================================================= + +void Interface_InterfaceModel::Print(const Handle(Standard_Transient)& ent, + Standard_OStream& S, + const Standard_Integer mode) const +{ + if (ent.IsNull()) { S << "NULL" ; return; } + Standard_Integer num = Number(ent); + if (mode <= 0) S <= 0) { + if (num > 0) + PrintToLog(ent,S); +// PrintLabel (ent,S); + else S <<"??"; + } +} + + +//======================================================================= +//function : PrintToLog +//purpose : +//======================================================================= + +void Interface_InterfaceModel::PrintToLog(const Handle(Standard_Transient)& ent, + Standard_OStream& S) const +{ + PrintLabel (ent,S); +} + + +// .... TEMPLATES .... // + + +//======================================================================= +//function : NextNumberForLabel +//purpose : +//======================================================================= + +Standard_Integer Interface_InterfaceModel::NextNumberForLabel + (const Standard_CString label, const Standard_Integer fromnum, + const Standard_Boolean exact) const +{ + Standard_Integer n = NbEntities(); + Handle(TCollection_HAsciiString) labs = new TCollection_HAsciiString(label); + Standard_Integer lnb = labs->Length(); + labs->LowerCase(); + + Standard_Integer i; // svv #1 + for (i = fromnum+1; i <= n; i ++) { + Handle(TCollection_HAsciiString) lab = StringLabel (Value(i)); + if (lab.IsNull()) continue; + if (exact) { + if (lab->IsSameString(labs,Standard_False)) return i; + } else { + if (lab->Length() < lnb) continue; + lab->LowerCase(); + if (lab->SearchFromEnd(labs) == lab->Length() - lnb + 1) return i; + } + } + +// En "non exact", on admet de recevoir le numero entre 1 et n + if (exact) return 0; + i = 0; + if (labs->IsIntegerValue()) i = atoi (labs->ToCString()); + if (i <= 0 || i > n) i = 0; + return i; +} + + +//======================================================================= +//function : HasTemplate +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::HasTemplate + (const Standard_CString name) +{ + return atemp.IsBound(name); +} + + +//======================================================================= +//function : Template +//purpose : +//======================================================================= + +Handle(Interface_InterfaceModel) Interface_InterfaceModel::Template + (const Standard_CString name) +{ + Handle(Interface_InterfaceModel) model,newmod; + if (!HasTemplate(name)) return model; + model = Handle(Interface_InterfaceModel)::DownCast(atemp.ChangeFind(name)); + newmod = model->NewEmptyModel(); + newmod->GetFromAnother (model); + return newmod; +} + + +//======================================================================= +//function : SetTemplate +//purpose : +//======================================================================= + +Standard_Boolean Interface_InterfaceModel::SetTemplate + (const Standard_CString name, const Handle(Interface_InterfaceModel)& model) +{ + return atemp.Bind(name, model); +} + + +//======================================================================= +//function : ListTemplates +//purpose : +//======================================================================= + +Handle(TColStd_HSequenceOfHAsciiString) Interface_InterfaceModel::ListTemplates () +{ + Handle(TColStd_HSequenceOfHAsciiString) list = new + TColStd_HSequenceOfHAsciiString(); + if (atemp.IsEmpty()) return list; + NCollection_DataMap::Iterator iter(atemp); + for (; iter.More(); iter.Next()) { + list->Append (new TCollection_HAsciiString (iter.Key()) ); + } + return list; +} diff --git a/src/DE/DE_DataModel.hxx b/src/DE/DE_DataModel.hxx new file mode 100644 index 0000000000..4cec14469e --- /dev/null +++ b/src/DE/DE_DataModel.hxx @@ -0,0 +1,427 @@ +// Created by: Christian CAILLET +// Copyright (c) 1992-1999 Matra Datavision +// Copyright (c) 1999-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Interface_InterfaceModel_HeaderFile +#define _Interface_InterfaceModel_HeaderFile + +#include +#include + +#include +#include +#include +#include +#include +#include +class Interface_Check; +class TCollection_HAsciiString; +class Interface_GTool; +class Interface_Protocol; +class Interface_ReportEntity; +class Interface_CheckIterator; +class Interface_GeneralLib; +class Interface_EntityIterator; + + +class Interface_InterfaceModel; +DEFINE_STANDARD_HANDLE(Interface_InterfaceModel, Standard_Transient) + +//! Defines an (Indexed) Set of data corresponding to a complete +//! Transfer by a File Interface, i.e. File Header and Transient +//! Entities (Objects) contained in a File. Contained Entities are +//! identified in the Model by unique and consecutive Numbers. +//! +//! In addition, a Model can attach to each entity, a specific +//! Label according to the norm (e.g. Name for VDA, #ident for +//! Step ...), intended to be output on a string or a stream +//! (remark : labels are not obliged to be unique) +//! +//! InterfaceModel itself is not Transient, it is intended to +//! work on a set of Transient Data. The services offered are +//! basic Listing and Identification operations on Transient +//! Entities, storage of Error Reports, Copying. +//! +//! Moreovere, it is possible to define and use templates. These +//! are empty Models, from which copies can be obtained in order +//! to be filled with effective data. This allows to record +//! standard definitions for headers, avoiding to recreate them +//! for each sendings, and assuring customisation of produced +//! files for a given site. +//! A template is attached to a name. It is possible to define a +//! template from another one (get it, edit it then record it +//! under another name). +//! +//! See also Graph, ShareTool, CheckTool for more +class Interface_InterfaceModel : public Standard_Transient +{ + +public: + + + //! Clears the list of entities (service WhenDelete) + Standard_EXPORT void Destroy(); +~Interface_InterfaceModel() +{ + Destroy(); +} + + //! Sets a Protocol for this Model + //! It is also set by a call to AddWithRefs with Protocol + //! It is used for : DumpHeader (as required), ClearEntities ... + Standard_EXPORT void SetProtocol (const Handle(Interface_Protocol)& proto); + + //! Returns the Protocol which has been set by SetProtocol, or + //! AddWithRefs with Protocol + Standard_EXPORT virtual Handle(Interface_Protocol) Protocol() const; + + //! Sets a GTool for this model, which already defines a Protocol + Standard_EXPORT void SetGTool (const Handle(Interface_GTool)& gtool); + + //! Returns the GTool, set by SetProtocol or by SetGTool + Standard_EXPORT Handle(Interface_GTool) GTool() const; + + //! Returns the Dispatch Status, either for get or set + //! A Model which is produced from Dispatch may share entities + //! with the original (according to the Protocol), hence these + //! non-copied entities should not be deleted + Standard_EXPORT Standard_Boolean& DispatchStatus(); + + //! Erases contained data; used when a Model is copied to others : + //! the new copied ones begin from clear + //! Clear calls specific method ClearHeader (see below) + Standard_EXPORT virtual void Clear(); + + //! Clears the entities; uses the general service WhenDelete, in + //! addition to the standard Memory Manager; can be redefined + Standard_EXPORT virtual void ClearEntities(); + + //! Erases information about labels, if any : specific to each + //! norm + Standard_EXPORT virtual void ClearLabels() = 0; + + //! Clears Model's header : specific to each norm + Standard_EXPORT virtual void ClearHeader() = 0; + + //! Returns count of contained Entities + Standard_EXPORT Standard_Integer NbEntities() const; + + //! Returns True if a Model contains an Entity (for a ReportEntity, + //! looks for the ReportEntity itself AND its Concerned Entity) + Standard_EXPORT Standard_Boolean Contains (const Handle(Standard_Transient)& anentity) const; + + //! Returns the Number of an Entity in the Model if it contains it. + //! Else returns 0. For a ReportEntity, looks at Concerned Entity. + //! Returns the Directory entry Number of an Entity in + //! the Model if it contains it. Else returns 0. For a + //! ReportEntity, looks at Concerned Entity. + Standard_EXPORT Standard_Integer Number (const Handle(Standard_Transient)& anentity) const; + + //! Returns an Entity identified by its number in the Model + //! Each sub-class of InterfaceModel can define its own method + //! Entity to return its specific class of Entity (e.g. for VDA, + //! VDAModel returns a VDAEntity), working by calling Value + //! Remark : For a Reported Entity, (Erroneous, Corrected, Unknown), this + //! method returns this Reported Entity. + //! See ReportEntity for other questions. + Standard_EXPORT const Handle(Standard_Transient)& Value (const Standard_Integer num) const; + + //! Returns the count of DISTINCT types under which an entity may + //! be processed. Defined by the Protocol, which gives default as + //! 1 (dynamic Type). + Standard_EXPORT Standard_Integer NbTypes (const Handle(Standard_Transient)& ent) const; + + //! Returns a type, given its rank : defined by the Protocol + //! (by default, the first one) + Standard_EXPORT Handle(Standard_Type) Type (const Handle(Standard_Transient)& ent, const Standard_Integer num = 1) const; + + //! Returns the type name of an entity, from the list of types + //! (one or more ...) + //! True (D) gives the complete type, else packages are + //! removed + //! WARNING : buffered, to be immediately copied or printed + Standard_EXPORT Standard_CString TypeName (const Handle(Standard_Transient)& ent, const Standard_Boolean complete = Standard_True) const; + + //! From a CDL Type Name, returns the Class part (package dropped) + //! WARNING : buffered, to be immediately copied or printed + Standard_EXPORT static Standard_CString ClassName (const Standard_CString typnam); + + //! Returns the State of an entity, given its number + Standard_EXPORT Interface_DataState EntityState (const Standard_Integer num) const; + + //! Returns True if identifies a ReportEntity in the Model + //! Hence, ReportEntity can be called. + //! + //! By default, queries main report, if is True, it + //! queries report for semantic check + //! + //! Remember that a Report Entity can be defined for an Unknown + //! Entity, or a Corrected or Erroneous (at read time) Entity. + //! The ReportEntity is defined before call to method AddEntity. + Standard_EXPORT Standard_Boolean IsReportEntity (const Standard_Integer num, const Standard_Boolean semantic = Standard_False) const; + + //! Returns a ReportEntity identified by its number in the Model, + //! or a Null Handle If does not identify a ReportEntity. + //! + //! By default, queries main report, if is True, it + //! queries report for semantic check + Standard_EXPORT Handle(Interface_ReportEntity) ReportEntity (const Standard_Integer num, const Standard_Boolean semantic = Standard_False) const; + + //! Returns True if identifies an Error Entity : in this + //! case, a ReportEntity brings Fail Messages and possibly an + //! "undefined" Content, see IsRedefinedEntity + Standard_EXPORT Standard_Boolean IsErrorEntity (const Standard_Integer num) const; + + //! Returns True if identifies an Entity which content is + //! redefined through a ReportEntity (i.e. with literal data only) + //! This happens when an entity is syntactically erroneous in the + //! way that its basic content remains empty. + //! For more details (such as content itself), see ReportEntity + Standard_EXPORT Standard_Boolean IsRedefinedContent (const Standard_Integer num) const; + + //! Removes the ReportEntity attached to Entity . Returns + //! True if done, False if no ReportEntity was attached to . + //! Warning : the caller must assume that this clearing is meaningful + Standard_EXPORT Standard_Boolean ClearReportEntity (const Standard_Integer num); + + //! Sets or Replaces a ReportEntity for the Entity . Returns + //! True if Report is replaced, False if it has been replaced + //! Warning : the caller must assume that this setting is meaningful + Standard_EXPORT Standard_Boolean SetReportEntity (const Standard_Integer num, const Handle(Interface_ReportEntity)& rep); + + //! Adds a ReportEntity as such. Returns False if the concerned + //! entity is not recorded in the Model + //! Else, adds it into, either the main report list or the + //! list for semantic checks, then returns True + Standard_EXPORT Standard_Boolean AddReportEntity (const Handle(Interface_ReportEntity)& rep, const Standard_Boolean semantic = Standard_False); + + //! Returns True if identifies an Unknown Entity : in this + //! case, a ReportEntity with no Check Messages designates it. + Standard_EXPORT Standard_Boolean IsUnknownEntity (const Standard_Integer num) const; + + //! Fills the list of semantic checks. + //! This list is computed (by CheckTool). Hence, it can be stored + //! in the model for later queries + //! True (D) : new list replaces + //! False : new list is cumulated + Standard_EXPORT void FillSemanticChecks (const Interface_CheckIterator& checks, const Standard_Boolean clear = Standard_True); + + //! Returns True if semantic checks have been filled + Standard_EXPORT Standard_Boolean HasSemanticChecks() const; + + //! Returns the check attached to an entity, designated by its + //! Number. 0 for global check + //! True : recorded semantic check + //! False : recorded syntactic check (see ReportEntity) + //! If no check is recorded for , returns an empty Check + Standard_EXPORT const Handle(Interface_Check)& Check (const Standard_Integer num, const Standard_Boolean syntactic) const; + + //! Does a reservation for the List of Entities (for optimized + //! storage management). If it is not called, storage management + //! can be less efficient. is the expected count of + //! Entities to store + Standard_EXPORT virtual void Reservate (const Standard_Integer nbent); + + //! Internal method for adding an Entity. Used by file reading + //! (defined by each Interface) and Transfer tools. It adds the + //! entity required to be added, not its refs : see AddWithRefs. + //! If is a ReportEntity, it is added to the list of + //! Reports, its Concerned Entity (Erroneous or Corrected, else + //! Unknown) is added to the list of Entities. + //! That is, the ReportEntity must be created before Adding + Standard_EXPORT virtual void AddEntity (const Handle(Standard_Transient)& anentity); + + //! Adds to the Model, an Entity with all its References, as they + //! are defined by General Services FillShared and ListImplied. + //! Process is recursive (any sub-levels) if = 0 (Default) + //! Else, adds sub-entities until the required sub-level. + //! Especially, if = 1, adds immediate subs and that's all + //! + //! If is False (Default), an entity ( itself + //! or one of its subs at any level) which is already recorded in + //! the Model is not analysed, only the newly added ones are. + //! If is True, all items are analysed (this allows to + //! ensure the consistency of an adding made by steps) + Standard_EXPORT void AddWithRefs (const Handle(Standard_Transient)& anent, const Handle(Interface_Protocol)& proto, const Standard_Integer level = 0, const Standard_Boolean listall = Standard_False); + + //! Same as above, but works with the Protocol of the Model + Standard_EXPORT void AddWithRefs (const Handle(Standard_Transient)& anent, const Standard_Integer level = 0, const Standard_Boolean listall = Standard_False); + + //! Same as above, but works with an already created GeneralLib + Standard_EXPORT void AddWithRefs (const Handle(Standard_Transient)& anent, const Interface_GeneralLib& lib, const Standard_Integer level = 0, const Standard_Boolean listall = Standard_False); + + //! Replace Entity with Number=nument on other entity - "anent" + Standard_EXPORT void ReplaceEntity (const Standard_Integer nument, const Handle(Standard_Transient)& anent); + + //! Reverses the Numbers of the Entities, between and the + //! total count of Entities. Thus, the entities : + //! 1,2 ... after, after+1 ... nb-1, nb become numbered as : + //! 1,2 ... after, nb, nb-1 ... after+1 + //! By default (after = 0) the whole list of Entities is reversed + Standard_EXPORT void ReverseOrders (const Standard_Integer after = 0); + + //! Changes the Numbers of some Entities : is moved to + //! , same for entities. Thus : + //! 1,2 ... newnum-1 newnum ... oldnum .. oldnum+count oldnum+count+1 .. gives + //! 1,2 ... newnum-1 oldnum .. oldnum+count newnum ... oldnum+count+1 + //! (can be seen as a circular permutation) + Standard_EXPORT void ChangeOrder (const Standard_Integer oldnum, const Standard_Integer newnum, const Standard_Integer count = 1); + + //! Gets contents from an EntityIterator, prepared by a + //! Transfer tool (e.g TransferCopy). Starts from clear + Standard_EXPORT void GetFromTransfer (const Interface_EntityIterator& aniter); + + //! Gets header (data specific of a defined Interface) from + //! another InterfaceModel; called from TransferCopy + Standard_EXPORT virtual void GetFromAnother (const Handle(Interface_InterfaceModel)& other) = 0; + + //! Returns a New Empty Model, same type as (whatever its + //! Type); called to Copy parts a Model into other ones, then + //! followed by a call to GetFromAnother (Header) then filling + //! with specified Entities, themselves copied + Standard_EXPORT virtual Handle(Interface_InterfaceModel) NewEmptyModel() const = 0; + + //! Records a category number for an entity number + //! Returns True when done, False if is out of range + Standard_EXPORT Standard_Boolean SetCategoryNumber (const Standard_Integer num, const Standard_Integer val); + + //! Returns the recorded category number for a given entity number + //! 0 if none was defined for this entity + Standard_EXPORT Standard_Integer CategoryNumber (const Standard_Integer num) const; + + //! Allows an EntityIterator to get a list of Entities + Standard_EXPORT void FillIterator (Interface_EntityIterator& iter) const; + + //! Returns the list of all Entities, as an Iterator on Entities + //! (the Entities themselves, not the Reports) + Standard_EXPORT Interface_EntityIterator Entities() const; + + //! Returns the list of all ReportEntities, i.e. data about + //! Entities read with Error or Warning information + //! (each item has to be casted to Report Entity then it can be + //! queried for Concerned Entity, Content, Check ...) + //! By default, returns the main reports, is is True it + //! returns the list for semantic checks + Standard_EXPORT Interface_EntityIterator Reports (const Standard_Boolean semantic = Standard_False) const; + + //! Returns the list of ReportEntities which redefine data + //! (generally, if concerned entity is "Error", a literal content + //! is added to it : this is a "redefined entity" + Standard_EXPORT Interface_EntityIterator Redefineds() const; + + //! Returns the GlobalCheck, which memorizes messages global to + //! the file (not specific to an Entity), especially Header + Standard_EXPORT const Handle(Interface_Check)& GlobalCheck (const Standard_Boolean syntactic = Standard_True) const; + + //! Allows to modify GlobalCheck, after getting then completing it + //! Remark : it is SYNTACTIC check. Semantics, see FillChecks + Standard_EXPORT void SetGlobalCheck (const Handle(Interface_Check)& ach); + + //! Minimum Semantic Global Check on data in model (header) + //! Can only check basic Data. See also GlobalCheck from Protocol + //! for a check which takes the Graph into account + //! Default does nothing, can be redefined + Standard_EXPORT virtual void VerifyCheck (Handle(Interface_Check)& ach) const; + + //! Dumps Header in a short, easy to read, form, onto a Stream + //! allows to print more or less parts of the header, + //! if necessary. 0 for basic print + Standard_EXPORT virtual void DumpHeader (Standard_OStream& S, const Standard_Integer level = 0) const = 0; + + //! Prints identification of a given entity in , in order to + //! be printed in a list or phrase + //! < 0 : prints only its number + //! = 1 : just calls PrintLabel + //! = 0 (D) : prints its number plus '/' plus PrintLabel + //! If == , simply prints "Global" + //! If is unknown, prints "??/its type" + Standard_EXPORT void Print (const Handle(Standard_Transient)& ent, Standard_OStream& s, const Standard_Integer mode = 0) const; + + //! Prints label specific to each norm, for a given entity. + //! Must only print label itself, in order to be included in a + //! phrase. Can call the result of StringLabel, but not obliged. + Standard_EXPORT virtual void PrintLabel (const Handle(Standard_Transient)& ent, Standard_OStream& S) const = 0; + + //! Prints label specific to each norm in log format, for + //! a given entity. + //! By default, just calls PrintLabel, can be redefined + Standard_EXPORT virtual void PrintToLog (const Handle(Standard_Transient)& ent, Standard_OStream& S) const; + + //! Returns a string with the label attached to a given entity. + //! Warning : While this string may be edited on the spot, if it is a read + //! field, the returned value must be copied before. + Standard_EXPORT virtual Handle(TCollection_HAsciiString) StringLabel (const Handle(Standard_Transient)& ent) const = 0; + + //! Searches a label which matches with one entity. + //! Begins from +1 (default:1) and scans the entities + //! until . For the first which matches