Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-30 09:04:56

0001 // Created on: 2000-08-21
0002 // Created by: Andrey BETENEV
0003 // Copyright (c) 2000-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _ShapeProcess_HeaderFile
0017 #define _ShapeProcess_HeaderFile
0018 
0019 #include <Message_ProgressRange.hxx>
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 #include <NCollection_LinearVector.hxx>
0024 
0025 #include <bitset>
0026 #include <utility>
0027 
0028 class ShapeProcess_Operator;
0029 class ShapeProcess_Context;
0030 
0031 //! Shape Processing module
0032 //! allows to define and apply general Shape Processing as a
0033 //! customizable sequence of Shape Healing operators. The
0034 //! customization is implemented via user-editable resource
0035 //! file which defines sequence of operators to be executed
0036 //! and their parameters.
0037 class ShapeProcess
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Describes all available operations.
0043   //! C++11 enum class is not used to allow implicit conversion to underlying type.
0044   enum Operation : uint8_t
0045   {
0046     First       = 0, // First operation index.
0047     DirectFaces = First,
0048     SameParameter,
0049     SetTolerance,
0050     SplitAngle,
0051     BSplineRestriction,
0052     ElementaryToRevolution,
0053     SweptToElementary,
0054     SurfaceToBSpline,
0055     ToBezier,
0056     SplitContinuity,
0057     SplitClosedFaces,
0058     FixWireGaps,
0059     FixFaceSize,
0060     DropSmallSolids,
0061     DropSmallEdges,
0062     FixShape,
0063     SplitClosedEdges,
0064     SplitCommonVertex,
0065     Last = SplitCommonVertex // Last operation index.
0066   };
0067 
0068   // Bitset of operations. It is used to specify which operations should be performed.
0069   // For example, to perform DirectFaces and SameParameter operations, use:
0070   // ShapeProcess::OperationsFlags flags;
0071   // flags.set(ShapeProcess::Operation::DirectFaces);
0072   // flags.set(ShapeProcess::Operation::SameParameter);
0073   // ShapeProcess::Perform(context, flags);
0074   using OperationsFlags = std::bitset<Operation::Last + 1>;
0075 
0076 public:
0077   //! Registers operator to make it visible for Performer
0078   Standard_EXPORT static bool RegisterOperator(const char* const                         name,
0079                                                const occ::handle<ShapeProcess_Operator>& op);
0080 
0081   //! Finds operator by its name
0082   Standard_EXPORT static bool FindOperator(const char* const                   name,
0083                                            occ::handle<ShapeProcess_Operator>& op);
0084 
0085   //! Performs a specified sequence of operators on Context
0086   //! Resource file and other data should be already loaded
0087   //! to Context (including description of sequence seq)
0088   Standard_EXPORT static bool Perform(
0089     const occ::handle<ShapeProcess_Context>& context,
0090     const char* const                        seq,
0091     const Message_ProgressRange&             theProgress = Message_ProgressRange());
0092 
0093   //! Performs a specified sequence of operators on @p theContext.
0094   //! @param theContext Context to perform operations on. Contains the shape to process
0095   //!        and processing parameters. If processing parameters are not set, default values are
0096   //!        used. Parameters should be in a scope of operation, for example, instead of
0097   //!        "FromSTEP.FixShape.Tolerance3d"    we should use just "FixShape.Tolerance3d".
0098   //! @param theOperations Bitset of operations to perform.
0099   //! @param theProgress Progress indicator.
0100   //! @return true if at least one operation was performed, false otherwise.
0101   Standard_EXPORT static bool Perform(
0102     const occ::handle<ShapeProcess_Context>& theContext,
0103     const OperationsFlags&                   theOperations,
0104     const Message_ProgressRange&             theProgress = Message_ProgressRange());
0105 
0106   //! Converts operation name to operation flag.
0107   //! @param theName Operation name.
0108   //! @return Operation flag and true if the operation name is valid, false otherwise.
0109   Standard_EXPORT static std::pair<Operation, bool> ToOperationFlag(const char* theName);
0110 
0111 private:
0112   //! Returns operators to be performed according to the specified flags.
0113   //! @param theFlags Bitset of operations flags.
0114   //! @return List of operators to perform: pairs of operator name and operator handle.
0115   static NCollection_LinearVector<std::pair<const char*, occ::handle<ShapeProcess_Operator>>>
0116     getOperators(const OperationsFlags& theFlags);
0117 
0118   //! Converts operation flag to its name.
0119   //! @param theOperation Operation flag.
0120   //! @return Operation name.
0121   static const char* toOperationName(const Operation theOperation);
0122 };
0123 
0124 #endif // _ShapeProcess_HeaderFile