|
|
|||
Warning, file /include/opencascade/XSControl_Reader.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 <DE_ShapeFixParameters.hxx> 0021 #include <ShapeProcess.hxx> 0022 #include <Standard.hxx> 0023 #include <Standard_DefineAlloc.hxx> 0024 #include <Standard_Handle.hxx> 0025 #include <Standard_Transient.hxx> 0026 #include <NCollection_Sequence.hxx> 0027 #include <TopoDS_Shape.hxx> 0028 #include <Standard_CString.hxx> 0029 #include <IFSelect_ReturnStatus.hxx> 0030 #include <NCollection_HSequence.hxx> 0031 #include <Standard_Integer.hxx> 0032 #include <IFSelect_PrintCount.hxx> 0033 #include <Message_ProgressRange.hxx> 0034 #include <XSAlgo_ShapeProcessor.hxx> 0035 0036 class XSControl_WorkSession; 0037 class Interface_InterfaceModel; 0038 class Standard_Transient; 0039 class Transfer_ActorOfTransientProcess; 0040 class TopoDS_Shape; 0041 0042 //! A groundwork to convert a shape to data which complies 0043 //! with a particular norm. This data can be that of a whole 0044 //! model or that of a specific list of entities in the model. 0045 //! You specify the list using a single selection or a 0046 //! combination of selections. A selection is an operator which 0047 //! computes a list of entities from a list given in input. To 0048 //! specify the input, you can use: 0049 //! - A predefined selection such as "xst-transferrable-roots" 0050 //! - A filter based on a signature. 0051 //! A signature is an operator which returns a string from an 0052 //! entity according to its type. 0053 //! For example: 0054 //! - "xst-type" (CDL) 0055 //! - "iges-level" 0056 //! - "step-type". 0057 //! A filter can be based on a signature by giving a value to 0058 //! be matched by the string returned. For example, 0059 //! "xst-type(Curve)". 0060 //! If no list is specified, the selection computes its list of 0061 //! entities from the whole model. To use this class, you have to 0062 //! initialize the transfer norm first, as shown in the example below. 0063 //! Example: 0064 //! Control_Reader reader; 0065 //! IFSelect_ReturnStatus status = reader.ReadFile (filename.); 0066 //! When using IGESControl_Reader or STEPControl_Reader - as the 0067 //! above example shows - the reader initializes the norm directly. 0068 //! Note that loading the file only stores the data. It does 0069 //! not translate this data. Shapes are accumulated by 0070 //! successive transfers. The last shape is cleared by: 0071 //! - ClearShapes which allows you to handle a new batch 0072 //! - TransferRoots which restarts the list of shapes from scratch. 0073 class XSControl_Reader 0074 { 0075 public: 0076 DEFINE_STANDARD_ALLOC 0077 0078 //! Creates a Reader from scratch (creates an empty WorkSession) 0079 //! A WorkSession or a Controller must be provided before running 0080 Standard_EXPORT XSControl_Reader(); 0081 0082 //! Creates a Reader from scratch, with a norm name which 0083 //! identifies a Controller 0084 Standard_EXPORT XSControl_Reader(const char* const norm); 0085 0086 //! Creates a Reader from an already existing Session, with a 0087 //! Controller already set 0088 //! Virtual destructor 0089 Standard_EXPORT XSControl_Reader(const occ::handle<XSControl_WorkSession>& WS, 0090 const bool scratch = true); 0091 0092 //! Empty virtual destructor 0093 virtual ~XSControl_Reader() = default; 0094 0095 //! Sets a specific norm to <me> 0096 //! Returns True if done, False if <norm> is not available 0097 Standard_EXPORT bool SetNorm(const char* const norm); 0098 0099 //! Sets a specific session to <me> 0100 Standard_EXPORT void SetWS(const occ::handle<XSControl_WorkSession>& WS, 0101 const bool scratch = true); 0102 0103 //! Returns the session used in <me> 0104 Standard_EXPORT occ::handle<XSControl_WorkSession> WS() const; 0105 0106 //! Loads a file and returns the read status 0107 //! Zero for a Model which complies with the Controller 0108 Standard_EXPORT virtual IFSelect_ReturnStatus ReadFile(const char* const filename); 0109 0110 //! Loads a file from stream and returns the read status 0111 Standard_EXPORT virtual IFSelect_ReturnStatus ReadStream(const char* const theName, 0112 std::istream& theIStream); 0113 0114 //! Returns the model. It can then be consulted (header, product) 0115 Standard_EXPORT occ::handle<Interface_InterfaceModel> Model() const; 0116 0117 //! Returns a list of entities from the IGES or STEP file 0118 //! according to the following rules: 0119 //! - if first and second are empty strings, the whole file is selected. 0120 //! - if first is an entity number or label, the entity referred to is selected. 0121 //! - if first is a list of entity numbers/labels separated by commas, the entities referred to 0122 //! are selected, 0123 //! - if first is the name of a selection in the worksession and second is not defined, 0124 //! the list contains the standard output for that selection. 0125 //! - if first is the name of a selection and second is defined, the criterion defined 0126 //! by second is applied to the result of the first selection. 0127 //! A selection is an operator which computes a list of entities from a list given in 0128 //! input according to its type. If no list is specified, the selection computes its 0129 //! list of entities from the whole model. 0130 //! A selection can be: 0131 //! - A predefined selection (xst-transferrable-mode) 0132 //! - A filter based on a signature 0133 //! A Signature is an operator which returns a string from an entity according to its type. For 0134 //! example: 0135 //! - "xst-type" (CDL) 0136 //! - "iges-level" 0137 //! - "step-type". 0138 //! For example, if you wanted to select only the advanced_faces in a STEP file you 0139 //! would use the following code: 0140 //! Example 0141 //! Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)"); 0142 //! Warning 0143 //! If the value given to second is incorrect, it will simply be ignored. 0144 Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>> GiveList( 0145 const char* const first = "", 0146 const char* const second = ""); 0147 0148 //! Computes a List of entities from the model as follows 0149 //! <first> being a Selection, <ent> being an entity or a list 0150 //! of entities (as a HSequenceOfTransient) : 0151 //! the standard result of this selection applied to this list 0152 //! if <first> is erroneous, a null handle is returned 0153 Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>> GiveList( 0154 const char* const first, 0155 const occ::handle<Standard_Transient>& ent); 0156 0157 //! Determines the list of root entities which are candidate for 0158 //! a transfer to a Shape, and returns the number 0159 //! of entities in the list 0160 Standard_EXPORT virtual int NbRootsForTransfer(); 0161 0162 //! Returns an IGES or STEP root 0163 //! entity for translation. The entity is identified by its 0164 //! rank in a list. 0165 Standard_EXPORT occ::handle<Standard_Transient> RootForTransfer(const int num = 1); 0166 0167 //! Translates a root identified by the rank num in the model. 0168 //! false is returned if no shape is produced. 0169 Standard_EXPORT bool TransferOneRoot( 0170 const int num = 1, 0171 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0172 0173 //! Translates an IGES or STEP 0174 //! entity identified by the rank num in the model. 0175 //! false is returned if no shape is produced. 0176 Standard_EXPORT bool TransferOne( 0177 const int num, 0178 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0179 0180 //! Translates an IGES or STEP 0181 //! entity in the model. true is returned if a shape is 0182 //! produced; otherwise, false is returned. 0183 Standard_EXPORT bool TransferEntity( 0184 const occ::handle<Standard_Transient>& start, 0185 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0186 0187 //! Translates a list of entities. 0188 //! Returns the number of IGES or STEP entities that were 0189 //! successfully translated. The list can be produced with GiveList. 0190 //! Warning - This function does not clear the existing output shapes. 0191 Standard_EXPORT int TransferList( 0192 const occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>& list, 0193 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0194 0195 //! Translates all translatable 0196 //! roots and returns the number of successful translations. 0197 //! Warning - This function clears existing output shapes first. 0198 Standard_EXPORT int TransferRoots( 0199 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0200 0201 //! Clears the list of shapes that 0202 //! may have accumulated in calls to TransferOne or TransferRoot.C 0203 Standard_EXPORT void ClearShapes(); 0204 0205 //! Returns the number of shapes produced by translation. 0206 Standard_EXPORT int NbShapes() const; 0207 0208 //! Returns the shape resulting 0209 //! from a translation and identified by the rank num. 0210 //! num equals 1 by default. In other words, the first shape 0211 //! resulting from the translation is returned. 0212 Standard_EXPORT TopoDS_Shape Shape(const int num = 1) const; 0213 0214 //! Returns all of the results in 0215 //! a single shape which is: 0216 //! - a null shape if there are no results, 0217 //! - a shape if there is one result, 0218 //! - a compound containing the resulting shapes if there are more than one. 0219 Standard_EXPORT TopoDS_Shape OneShape() const; 0220 0221 //! Prints the check list attached to loaded data, on the Standard 0222 //! Trace File (starts at std::cout) 0223 //! All messages or fails only, according to <failsonly> 0224 //! mode = 0 : per entity, prints messages 0225 //! mode = 1 : per message, just gives count of entities per check 0226 //! mode = 2 : also gives entity numbers 0227 Standard_EXPORT void PrintCheckLoad(const bool failsonly, const IFSelect_PrintCount mode) const; 0228 0229 //! Prints the check list attached to loaded data. 0230 Standard_EXPORT void PrintCheckLoad(Standard_OStream& theStream, 0231 const bool failsonly, 0232 const IFSelect_PrintCount mode) const; 0233 0234 //! Displays check results for the 0235 //! last translation of IGES or STEP entities to Open CASCADE 0236 //! entities. Only fail messages are displayed if failsonly is 0237 //! true. All messages are displayed if failsonly is 0238 //! false. mode determines the contents and the order of the 0239 //! messages according to the terms of the IFSelect_PrintCount enumeration. 0240 Standard_EXPORT void PrintCheckTransfer(const bool failsonly, 0241 const IFSelect_PrintCount mode) const; 0242 0243 //! Displays check results for the last translation of IGES or STEP entities to Open CASCADE 0244 //! entities. 0245 Standard_EXPORT void PrintCheckTransfer(Standard_OStream& theStream, 0246 const bool failsonly, 0247 const IFSelect_PrintCount mode) const; 0248 0249 //! Displays the statistics for 0250 //! the last translation. what defines the kind of 0251 //! statistics that are displayed as follows: 0252 //! - 0 gives general statistics (number of translated roots, 0253 //! number of warnings, number of fail messages), 0254 //! - 1 gives root results, 0255 //! - 2 gives statistics for all checked entities, 0256 //! - 3 gives the list of translated entities, 0257 //! - 4 gives warning and fail messages, 0258 //! - 5 gives fail messages only. 0259 //! The use of mode depends on the value of what. If what is 0, 0260 //! mode is ignored. If what is 1, 2 or 3, mode defines the following: 0261 //! - 0 lists the numbers of IGES or STEP entities in the respective model 0262 //! - 1 gives the number, identifier, type and result 0263 //! type for each IGES or STEP entity and/or its status 0264 //! (fail, warning, etc.) 0265 //! - 2 gives maximum information for each IGES or STEP entity (i.e. checks) 0266 //! - 3 gives the number of entities per type of IGES or STEP entity 0267 //! - 4 gives the number of IGES or STEP entities per result type and/or status 0268 //! - 5 gives the number of pairs (IGES or STEP or result type and status) 0269 //! - 6 gives the number of pairs (IGES or STEP or result type 0270 //! and status) AND the list of entity numbers in the IGES or STEP model. 0271 //! If what is 4 or 5, mode defines the warning and fail 0272 //! messages as follows: 0273 //! - if mode is 0 all warnings and checks per entity are returned 0274 //! - if mode is 2 the list of entities per warning is returned. 0275 //! If mode is not set, only the list of all entities per warning is given. 0276 Standard_EXPORT void PrintStatsTransfer(const int what, const int mode = 0) const; 0277 0278 //! Displays the statistics for the last translation. 0279 Standard_EXPORT void PrintStatsTransfer(Standard_OStream& theStream, 0280 const int what, 0281 const int mode = 0) const; 0282 0283 //! Gives statistics about Transfer 0284 Standard_EXPORT void GetStatsTransfer( 0285 const occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>& list, 0286 int& nbMapped, 0287 int& nbWithResult, 0288 int& nbWithFail) const; 0289 0290 //! Sets parameters for shape processing. 0291 //! @param theParameters the parameters for shape processing. 0292 Standard_EXPORT void SetShapeFixParameters( 0293 const XSAlgo_ShapeProcessor::ParameterMap& theParameters); 0294 0295 //! Sets parameters for shape processing. 0296 //! Parameters are moved from the input map. 0297 //! @param theParameters the parameters for shape processing. 0298 Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters); 0299 0300 //! Sets parameters for shape processing. 0301 //! Parameters from @p theParameters are copied to the internal map. 0302 //! Parameters from @p theAdditionalParameters are copied to the internal map 0303 //! if they are not present in @p theParameters. 0304 //! @param theParameters the parameters for shape processing. 0305 //! @param theAdditionalParameters the additional parameters for shape processing. 0306 Standard_EXPORT void SetShapeFixParameters( 0307 const DE_ShapeFixParameters& theParameters, 0308 const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {}); 0309 0310 //! Returns parameters for shape processing that was set by SetParameters() method. 0311 //! @return the parameters for shape processing. Empty map if no parameters were set. 0312 Standard_EXPORT const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const; 0313 0314 //! Sets flags defining operations to be performed on shapes. 0315 //! @param theFlags The flags defining operations to be performed on shapes. 0316 Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags); 0317 0318 //! Returns flags defining operations to be performed on shapes. 0319 //! @return Pair of values defining operations to be performed on shapes and a boolean value 0320 //! that indicates whether the flags were set. 0321 Standard_EXPORT const XSAlgo_ShapeProcessor::ProcessingFlags& GetShapeProcessFlags() const; 0322 0323 protected: 0324 //! Returns a sequence of produced shapes 0325 Standard_EXPORT NCollection_Sequence<TopoDS_Shape>& Shapes(); 0326 0327 //! Returns default parameters for shape fixing. 0328 //! This method should be implemented in the derived classes to return default parameters for 0329 //! shape fixing. 0330 //! @return Default parameters for shape fixing. 0331 virtual DE_ShapeFixParameters GetDefaultShapeFixParameters() const 0332 { 0333 return DE_ShapeFixParameters(); 0334 } 0335 0336 //! Returns default flags for shape processing. 0337 //! This method should be implemented in the derived classes to return default flags for shape 0338 //! processing. 0339 //! @return Default flags for shape processing. 0340 virtual ShapeProcess::OperationsFlags GetDefaultShapeProcessFlags() const 0341 { 0342 return ShapeProcess::OperationsFlags(); 0343 } 0344 0345 private: 0346 //! Returns the Actor for the Transfer of an Entity. 0347 //! This Actor is used by the Reader to perform the Transfer. 0348 //! @return the Actor for the Transfer of an Entity. May be nullptr. 0349 occ::handle<Transfer_ActorOfTransientProcess> GetActor() const; 0350 0351 //! If parameters haven't yet been provided, initializes them with default values 0352 //! provided by GetDefaultShapeFixParameters() method. 0353 void InitializeMissingParameters(); 0354 0355 protected: 0356 bool therootsta; 0357 NCollection_Sequence<occ::handle<Standard_Transient>> theroots; 0358 0359 private: 0360 occ::handle<XSControl_WorkSession> thesession; 0361 NCollection_Sequence<TopoDS_Shape> theshapes; 0362 }; 0363 0364 #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 |
|