|
||||
File indexing completed on 2025-01-18 10:05:36
0001 // Created on: 1997-05-14 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1997-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _XSControl_Reader_HeaderFile 0018 #define _XSControl_Reader_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <TColStd_SequenceOfTransient.hxx> 0025 #include <TopTools_SequenceOfShape.hxx> 0026 #include <Standard_CString.hxx> 0027 #include <IFSelect_ReturnStatus.hxx> 0028 #include <TColStd_HSequenceOfTransient.hxx> 0029 #include <Standard_Integer.hxx> 0030 #include <IFSelect_PrintCount.hxx> 0031 #include <Message_ProgressRange.hxx> 0032 0033 class XSControl_WorkSession; 0034 class Interface_InterfaceModel; 0035 class Standard_Transient; 0036 class TopoDS_Shape; 0037 0038 0039 //! A groundwork to convert a shape to data which complies 0040 //! with a particular norm. This data can be that of a whole 0041 //! model or that of a specific list of entities in the model. 0042 //! You specify the list using a single selection or a 0043 //! combination of selections. A selection is an operator which 0044 //! computes a list of entities from a list given in input. To 0045 //! specify the input, you can use: 0046 //! - A predefined selection such as "xst-transferrable-roots" 0047 //! - A filter based on a signature. 0048 //! A signature is an operator which returns a string from an 0049 //! entity according to its type. 0050 //! For example: 0051 //! - "xst-type" (CDL) 0052 //! - "iges-level" 0053 //! - "step-type". 0054 //! A filter can be based on a signature by giving a value to 0055 //! be matched by the string returned. For example, 0056 //! "xst-type(Curve)". 0057 //! If no list is specified, the selection computes its list of 0058 //! entities from the whole model. To use this class, you have to 0059 //! initialize the transfer norm first, as shown in the example below. 0060 //! Example: 0061 //! Control_Reader reader; 0062 //! IFSelect_ReturnStatus status = reader.ReadFile (filename.); 0063 //! When using IGESControl_Reader or STEPControl_Reader - as the 0064 //! above example shows - the reader initializes the norm directly. 0065 //! Note that loading the file only stores the data. It does 0066 //! not translate this data. Shapes are accumulated by 0067 //! successive transfers. The last shape is cleared by: 0068 //! - ClearShapes which allows you to handle a new batch 0069 //! - TransferRoots which restarts the list of shapes from scratch. 0070 class XSControl_Reader 0071 { 0072 public: 0073 0074 DEFINE_STANDARD_ALLOC 0075 0076 0077 //! Creates a Reader from scratch (creates an empty WorkSession) 0078 //! A WorkSession or a Controller must be provided before running 0079 Standard_EXPORT XSControl_Reader(); 0080 0081 //! Creates a Reader from scratch, with a norm name which 0082 //! identifies a Controller 0083 Standard_EXPORT XSControl_Reader(const Standard_CString norm); 0084 0085 //! Creates a Reader from an already existing Session, with a 0086 //! Controller already set 0087 //! Virtual destructor 0088 Standard_EXPORT XSControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); 0089 0090 //! Empty virtual destructor 0091 virtual ~XSControl_Reader() {} 0092 0093 //! Sets a specific norm to <me> 0094 //! Returns True if done, False if <norm> is not available 0095 Standard_EXPORT Standard_Boolean SetNorm (const Standard_CString norm); 0096 0097 //! Sets a specific session to <me> 0098 Standard_EXPORT void SetWS (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); 0099 0100 //! Returns the session used in <me> 0101 Standard_EXPORT Handle(XSControl_WorkSession) WS() const; 0102 0103 //! Loads a file and returns the read status 0104 //! Zero for a Model which compies with the Controller 0105 Standard_EXPORT virtual IFSelect_ReturnStatus ReadFile (const Standard_CString filename); 0106 0107 //! Loads a file from stream and returns the read status 0108 Standard_EXPORT virtual IFSelect_ReturnStatus ReadStream(const Standard_CString theName, std::istream& theIStream); 0109 0110 //! Returns the model. It can then be consulted (header, product) 0111 Standard_EXPORT Handle(Interface_InterfaceModel) Model() const; 0112 0113 //! Returns a list of entities from the IGES or STEP file 0114 //! according to the following rules: 0115 //! - if first and second are empty strings, the whole file is selected. 0116 //! - if first is an entity number or label, the entity referred to is selected. 0117 //! - if first is a list of entity numbers/labels separated by commas, the entities referred to are selected, 0118 //! - if first is the name of a selection in the worksession and second is not defined, 0119 //! the list contains the standard output for that selection. 0120 //! - if first is the name of a selection and second is defined, the criterion defined 0121 //! by second is applied to the result of the first selection. 0122 //! A selection is an operator which computes a list of entities from a list given in 0123 //! input according to its type. If no list is specified, the selection computes its 0124 //! list of entities from the whole model. 0125 //! A selection can be: 0126 //! - A predefined selection (xst-transferrable-mode) 0127 //! - A filter based on a signature 0128 //! A Signature is an operator which returns a string from an entity according to its type. For example: 0129 //! - "xst-type" (CDL) 0130 //! - "iges-level" 0131 //! - "step-type". 0132 //! For example, if you wanted to select only the advanced_faces in a STEP file you 0133 //! would use the following code: 0134 //! Example 0135 //! Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)"); 0136 //! Warning 0137 //! If the value given to second is incorrect, it will simply be ignored. 0138 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first = "", const Standard_CString second = ""); 0139 0140 //! Computes a List of entities from the model as follows 0141 //! <first> being a Selection, <ent> being an entity or a list 0142 //! of entities (as a HSequenceOfTransient) : 0143 //! the standard result of this selection applied to this list 0144 //! if <first> is erroneous, a null handle is returned 0145 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GiveList (const Standard_CString first, const Handle(Standard_Transient)& ent); 0146 0147 //! Determines the list of root entities which are candidate for 0148 //! a transfer to a Shape, and returns the number 0149 //! of entities in the list 0150 Standard_EXPORT virtual Standard_Integer NbRootsForTransfer(); 0151 0152 //! Returns an IGES or STEP root 0153 //! entity for translation. The entity is identified by its 0154 //! rank in a list. 0155 Standard_EXPORT Handle(Standard_Transient) RootForTransfer (const Standard_Integer num = 1); 0156 0157 //! Translates a root identified by the rank num in the model. 0158 //! false is returned if no shape is produced. 0159 Standard_EXPORT Standard_Boolean TransferOneRoot (const Standard_Integer num = 1, 0160 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0161 0162 //! Translates an IGES or STEP 0163 //! entity identified by the rank num in the model. 0164 //! false is returned if no shape is produced. 0165 Standard_EXPORT Standard_Boolean TransferOne (const Standard_Integer num, 0166 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0167 0168 //! Translates an IGES or STEP 0169 //! entity in the model. true is returned if a shape is 0170 //! produced; otherwise, false is returned. 0171 Standard_EXPORT Standard_Boolean TransferEntity (const Handle(Standard_Transient)& start, 0172 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0173 0174 //! Translates a list of entities. 0175 //! Returns the number of IGES or STEP entities that were 0176 //! successfully translated. The list can be produced with GiveList. 0177 //! Warning - This function does not clear the existing output shapes. 0178 Standard_EXPORT Standard_Integer TransferList (const Handle(TColStd_HSequenceOfTransient)& list, 0179 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0180 0181 //! Translates all translatable 0182 //! roots and returns the number of successful translations. 0183 //! Warning - This function clears existing output shapes first. 0184 Standard_EXPORT Standard_Integer TransferRoots(const Message_ProgressRange& theProgress = Message_ProgressRange()); 0185 0186 //! Clears the list of shapes that 0187 //! may have accumulated in calls to TransferOne or TransferRoot.C 0188 Standard_EXPORT void ClearShapes(); 0189 0190 //! Returns the number of shapes produced by translation. 0191 Standard_EXPORT Standard_Integer NbShapes() const; 0192 0193 //! Returns the shape resulting 0194 //! from a translation and identified by the rank num. 0195 //! num equals 1 by default. In other words, the first shape 0196 //! resulting from the translation is returned. 0197 Standard_EXPORT TopoDS_Shape Shape (const Standard_Integer num = 1) const; 0198 0199 //! Returns all of the results in 0200 //! a single shape which is: 0201 //! - a null shape if there are no results, 0202 //! - a shape if there is one result, 0203 //! - a compound containing the resulting shapes if there are more than one. 0204 Standard_EXPORT TopoDS_Shape OneShape() const; 0205 0206 //! Prints the check list attached to loaded data, on the Standard 0207 //! Trace File (starts at std::cout) 0208 //! All messages or fails only, according to <failsonly> 0209 //! mode = 0 : per entity, prints messages 0210 //! mode = 1 : per message, just gives count of entities per check 0211 //! mode = 2 : also gives entity numbers 0212 Standard_EXPORT void PrintCheckLoad (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; 0213 0214 //! Prints the check list attached to loaded data. 0215 Standard_EXPORT void PrintCheckLoad (Standard_OStream& theStream, const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; 0216 0217 //! Displays check results for the 0218 //! last translation of IGES or STEP entities to Open CASCADE 0219 //! entities. Only fail messages are displayed if failsonly is 0220 //! true. All messages are displayed if failsonly is 0221 //! false. mode determines the contents and the order of the 0222 //! messages according to the terms of the IFSelect_PrintCount enumeration. 0223 Standard_EXPORT void PrintCheckTransfer (const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; 0224 0225 //! Displays check results for the last translation of IGES or STEP entities to Open CASCADE entities. 0226 Standard_EXPORT void PrintCheckTransfer (Standard_OStream& theStream, const Standard_Boolean failsonly, const IFSelect_PrintCount mode) const; 0227 0228 //! Displays the statistics for 0229 //! the last translation. what defines the kind of 0230 //! statistics that are displayed as follows: 0231 //! - 0 gives general statistics (number of translated roots, 0232 //! number of warnings, number of fail messages), 0233 //! - 1 gives root results, 0234 //! - 2 gives statistics for all checked entities, 0235 //! - 3 gives the list of translated entities, 0236 //! - 4 gives warning and fail messages, 0237 //! - 5 gives fail messages only. 0238 //! The use of mode depends on the value of what. If what is 0, 0239 //! mode is ignored. If what is 1, 2 or 3, mode defines the following: 0240 //! - 0 lists the numbers of IGES or STEP entities in the respective model 0241 //! - 1 gives the number, identifier, type and result 0242 //! type for each IGES or STEP entity and/or its status 0243 //! (fail, warning, etc.) 0244 //! - 2 gives maximum information for each IGES or STEP entity (i.e. checks) 0245 //! - 3 gives the number of entities per type of IGES or STEP entity 0246 //! - 4 gives the number of IGES or STEP entities per result type and/or status 0247 //! - 5 gives the number of pairs (IGES or STEP or result type and status) 0248 //! - 6 gives the number of pairs (IGES or STEP or result type 0249 //! and status) AND the list of entity numbers in the IGES or STEP model. 0250 //! If what is 4 or 5, mode defines the warning and fail 0251 //! messages as follows: 0252 //! - if mode is 0 all warnings and checks per entity are returned 0253 //! - if mode is 2 the list of entities per warning is returned. 0254 //! If mode is not set, only the list of all entities per warning is given. 0255 Standard_EXPORT void PrintStatsTransfer (const Standard_Integer what, const Standard_Integer mode = 0) const; 0256 0257 //! Displays the statistics for the last translation. 0258 Standard_EXPORT void PrintStatsTransfer (Standard_OStream& theStream, const Standard_Integer what, const Standard_Integer mode = 0) const; 0259 0260 //! Gives statistics about Transfer 0261 Standard_EXPORT void GetStatsTransfer (const Handle(TColStd_HSequenceOfTransient)& list, Standard_Integer& nbMapped, Standard_Integer& nbWithResult, Standard_Integer& nbWithFail) const; 0262 0263 0264 0265 0266 protected: 0267 0268 0269 //! Returns a sequence of produced shapes 0270 Standard_EXPORT TopTools_SequenceOfShape& Shapes(); 0271 0272 0273 Standard_Boolean therootsta; 0274 TColStd_SequenceOfTransient theroots; 0275 0276 0277 private: 0278 0279 0280 0281 Handle(XSControl_WorkSession) thesession; 0282 TopTools_SequenceOfShape theshapes; 0283 0284 0285 }; 0286 0287 0288 0289 0290 0291 0292 0293 #endif // _XSControl_Reader_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |