Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:17:28

0001 // Created on: 1992-01-24
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1992-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 _TopAbs_HeaderFile
0018 #define _TopAbs_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopAbs_Orientation.hxx>
0025 #include <Standard_OStream.hxx>
0026 #include <TopAbs_ShapeEnum.hxx>
0027 #include <TopAbs_State.hxx>
0028 
0029 //! This package gives resources for Topology oriented
0030 //! applications such as: Topological Data Structure,
0031 //! Topological Algorithms.
0032 //!
0033 //! It contains the:
0034 //!
0035 //! * ShapeEnum enumeration to describe the
0036 //! different topological shapes.
0037 //!
0038 //! * Orientation enumeration to describe the
0039 //! orientation of a topological shape.
0040 //!
0041 //! * State enumeration to describes the
0042 //! position of a point relative to a Shape.
0043 //!
0044 //! * Methods to manage the enumerations.
0045 
0046 class TopAbs
0047 {
0048 public:
0049   DEFINE_STANDARD_ALLOC
0050 
0051   //! Compose the Orientation <Or1> and <Or2>. This
0052   //! composition is not symmetric (if you switch <Or1> and
0053   //! <Or2> the result is different). It assumes that <Or1>
0054   //! is the Orientation of a Shape S1 containing a Shape S2
0055   //! of Orientation Or2. The result is the cumulated
0056   //! orientation of S2 in S1. The composition law is:
0057   //!
0058   //! \ Or2     FORWARD  REVERSED INTERNAL EXTERNAL
0059   //! Or1       -------------------------------------
0060   //! FORWARD   | FORWARD  REVERSED INTERNAL EXTERNAL
0061   //! |
0062   //! REVERSED  | REVERSED FORWARD  INTERNAL EXTERNAL
0063   //! |
0064   //! INTERNAL  | INTERNAL INTERNAL INTERNAL INTERNAL
0065   //! |
0066   //! EXTERNAL  | EXTERNAL EXTERNAL EXTERNAL EXTERNAL
0067   //! Note: The top corner in the table is the most important
0068   //! for the purposes of Open CASCADE topology and shape sharing.
0069   static TopAbs_Orientation Compose(const TopAbs_Orientation Or1,
0070                                     const TopAbs_Orientation Or2) noexcept
0071   {
0072     static constexpr TopAbs_Orientation aTable[4][4] = {
0073       {TopAbs_FORWARD, TopAbs_REVERSED, TopAbs_INTERNAL, TopAbs_EXTERNAL},
0074       {TopAbs_REVERSED, TopAbs_FORWARD, TopAbs_INTERNAL, TopAbs_EXTERNAL},
0075       {TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL, TopAbs_INTERNAL},
0076       {TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL, TopAbs_EXTERNAL}};
0077     return aTable[static_cast<int>(Or2)][static_cast<int>(Or1)];
0078   }
0079 
0080   //! Exchanges the interior/exterior status of the two
0081   //! sides. This is what happens when the sense of
0082   //! direction is reversed. The following rules apply:
0083   //!
0084   //! FORWARD          REVERSED
0085   //! REVERSED         FORWARD
0086   //! INTERNAL         INTERNAL
0087   //! EXTERNAL         EXTERNAL
0088   //!
0089   //! Reverse exchange the material sides.
0090   static TopAbs_Orientation Reverse(const TopAbs_Orientation Or) noexcept
0091   {
0092     static constexpr TopAbs_Orientation aTable[4] = {TopAbs_REVERSED,
0093                                                      TopAbs_FORWARD,
0094                                                      TopAbs_INTERNAL,
0095                                                      TopAbs_EXTERNAL};
0096     return aTable[static_cast<int>(Or)];
0097   }
0098 
0099   //! Reverses the interior/exterior status of each side of
0100   //! the object. So, to take the complement of an object
0101   //! means to reverse the interior/exterior status of its
0102   //! boundary, i.e. inside becomes outside.
0103   //! The method returns the complementary orientation,
0104   //! following the rules in the table below:
0105   //! FORWARD          REVERSED
0106   //! REVERSED         FORWARD
0107   //! INTERNAL         EXTERNAL
0108   //! EXTERNAL         INTERNAL
0109   //!
0110   //! Complement complements the material side.
0111   //! Inside becomes outside.
0112   static TopAbs_Orientation Complement(const TopAbs_Orientation Or) noexcept
0113   {
0114     static constexpr TopAbs_Orientation aTable[4] = {TopAbs_REVERSED,
0115                                                      TopAbs_FORWARD,
0116                                                      TopAbs_EXTERNAL,
0117                                                      TopAbs_INTERNAL};
0118     return aTable[static_cast<int>(Or)];
0119   }
0120 
0121   //! Prints the name of Shape type as a String on the Stream.
0122   static Standard_OStream& Print(const TopAbs_ShapeEnum theShapeType, Standard_OStream& theStream)
0123   {
0124     return (theStream << ShapeTypeToString(theShapeType));
0125   }
0126 
0127   //! Prints the name of the Orientation as a String on the Stream.
0128   static Standard_OStream& Print(const TopAbs_Orientation theOrientation,
0129                                  Standard_OStream&        theStream)
0130   {
0131     return (theStream << ShapeOrientationToString(theOrientation));
0132   }
0133 
0134   //! Prints the name of the State <St> as a String on
0135   //! the Stream <S> and returns <S>.
0136   Standard_EXPORT static Standard_OStream& Print(const TopAbs_State St, Standard_OStream& S);
0137 
0138   //! Returns the string name for a given shape type.
0139   //! @param theType shape type
0140   //! @return string identifier from the list COMPOUND, COMPSOLID, SOLID, SHELL, FACE, WIRE, EDGE,
0141   //! VERTEX, SHAPE
0142   Standard_EXPORT static const char* ShapeTypeToString(TopAbs_ShapeEnum theType);
0143 
0144   //! Returns the shape type from the given string identifier (using case-insensitive comparison).
0145   //! @param theTypeString string identifier
0146   //! @return shape type or TopAbs_SHAPE if string identifier is invalid
0147   static TopAbs_ShapeEnum ShapeTypeFromString(const char* theTypeString)
0148   {
0149     TopAbs_ShapeEnum aType = TopAbs_SHAPE;
0150     ShapeTypeFromString(theTypeString, aType);
0151     return aType;
0152   }
0153 
0154   //! Determines the shape type from the given string identifier (using case-insensitive
0155   //! comparison).
0156   //! @param theTypeString string identifier
0157   //! @param theType detected shape type
0158   //! @return TRUE if string identifier is known
0159   Standard_EXPORT static bool ShapeTypeFromString(const char*       theTypeString,
0160                                                   TopAbs_ShapeEnum& theType);
0161 
0162   //! Returns the string name for a given shape orientation.
0163   //! @param theOrientation shape orientation
0164   //! @return string identifier from the list FORWARD, REVERSED, INTERNAL, EXTERNAL
0165   Standard_EXPORT static const char* ShapeOrientationToString(TopAbs_Orientation theOrientation);
0166 
0167   //! Returns the shape orientation from the given string identifier (using case-insensitive
0168   //! comparison).
0169   //! @param theOrientationString string identifier
0170   //! @return shape orientation or TopAbs_FORWARD if string identifier is invalid
0171   static TopAbs_Orientation ShapeOrientationFromString(const char* const theOrientationString)
0172   {
0173     TopAbs_Orientation aType = TopAbs_FORWARD;
0174     ShapeOrientationFromString(theOrientationString, aType);
0175     return aType;
0176   }
0177 
0178   //! Determines the shape orientation from the given string identifier (using case-insensitive
0179   //! comparison).
0180   //! @param theOrientationString string identifier
0181   //! @param theOrientation detected shape orientation
0182   //! @return TRUE if string identifier is known
0183   Standard_EXPORT static bool ShapeOrientationFromString(const char* const   theOrientationString,
0184                                                          TopAbs_Orientation& theOrientation);
0185 };
0186 
0187 #endif // _TopAbs_HeaderFile