Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:14:43

0001 // Created on: 1992-04-06
0002 // Created by: Christophe MARION
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 _HLRAlgo_EdgesBlock_HeaderFile
0018 #define _HLRAlgo_EdgesBlock_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <NCollection_Array1.hxx>
0025 #include <Standard_Transient.hxx>
0026 #include <TopAbs_Orientation.hxx>
0027 
0028 //! An EdgesBlock is a set of Edges. It is used by the
0029 //! DataStructure to structure the Edges.
0030 //!
0031 //! An EdgesBlock contains:
0032 //!
0033 //! * An Array of index of Edges.
0034 //!
0035 //! * An Array of flagsf
0036 //! (Orientation
0037 //!  OutLine
0038 //!  Internal
0039 //!  Double
0040 //!  IsoLine)
0041 class HLRAlgo_EdgesBlock : public Standard_Transient
0042 {
0043 
0044 public:
0045   struct MinMaxIndices
0046   {
0047     int Min[8], Max[8];
0048 
0049     MinMaxIndices& Minimize(const MinMaxIndices& theMinMaxIndices)
0050     {
0051       for (int aI = 0; aI < 8; ++aI)
0052       {
0053         if (Min[aI] > theMinMaxIndices.Min[aI])
0054         {
0055           Min[aI] = theMinMaxIndices.Min[aI];
0056         }
0057         if (Max[aI] > theMinMaxIndices.Max[aI])
0058         {
0059           Max[aI] = theMinMaxIndices.Max[aI];
0060         }
0061       }
0062       return *this;
0063     }
0064 
0065     MinMaxIndices& Maximize(const MinMaxIndices& theMinMaxIndices)
0066     {
0067       for (int aI = 0; aI < 8; ++aI)
0068       {
0069         if (Min[aI] < theMinMaxIndices.Min[aI])
0070         {
0071           Min[aI] = theMinMaxIndices.Min[aI];
0072         }
0073         if (Max[aI] < theMinMaxIndices.Max[aI])
0074         {
0075           Max[aI] = theMinMaxIndices.Max[aI];
0076         }
0077       }
0078       return *this;
0079     }
0080   };
0081 
0082   //! Create a Block of Edges for a wire.
0083   Standard_EXPORT HLRAlgo_EdgesBlock(const int NbEdges);
0084 
0085   int NbEdges() const { return myEdges.Upper(); }
0086 
0087   void Edge(const int I, const int EI) { myEdges(I) = EI; }
0088 
0089   int Edge(const int I) const { return myEdges(I); }
0090 
0091   void Orientation(const int I, const TopAbs_Orientation Or)
0092   {
0093     myFlags(I) &= ~EMaskOrient;
0094     myFlags(I) |= ((int)Or & (int)EMaskOrient);
0095   }
0096 
0097   TopAbs_Orientation Orientation(const int I) const
0098   {
0099     return ((TopAbs_Orientation)(myFlags(I) & EMaskOrient));
0100   }
0101 
0102   bool OutLine(const int I) const { return (myFlags(I) & EMaskOutLine) != 0; }
0103 
0104   void OutLine(const int I, const bool B)
0105   {
0106     if (B)
0107       myFlags(I) |= EMaskOutLine;
0108     else
0109       myFlags(I) &= ~EMaskOutLine;
0110   }
0111 
0112   bool Internal(const int I) const { return (myFlags(I) & EMaskInternal) != 0; }
0113 
0114   void Internal(const int I, const bool B)
0115   {
0116     if (B)
0117       myFlags(I) |= EMaskInternal;
0118     else
0119       myFlags(I) &= ~EMaskInternal;
0120   }
0121 
0122   bool Double(const int I) const { return (myFlags(I) & EMaskDouble) != 0; }
0123 
0124   void Double(const int I, const bool B)
0125   {
0126     if (B)
0127       myFlags(I) |= EMaskDouble;
0128     else
0129       myFlags(I) &= ~EMaskDouble;
0130   }
0131 
0132   bool IsoLine(const int I) const { return (myFlags(I) & EMaskIsoLine) != 0; }
0133 
0134   void IsoLine(const int I, const bool B)
0135   {
0136     if (B)
0137       myFlags(I) |= EMaskIsoLine;
0138     else
0139       myFlags(I) &= ~EMaskIsoLine;
0140   }
0141 
0142   void UpdateMinMax(const MinMaxIndices& TotMinMax) { myMinMax = TotMinMax; }
0143 
0144   MinMaxIndices& MinMax() { return myMinMax; }
0145 
0146   DEFINE_STANDARD_RTTIEXT(HLRAlgo_EdgesBlock, Standard_Transient)
0147 
0148 protected:
0149   enum EMskFlags
0150   {
0151     EMaskOrient   = 15,
0152     EMaskOutLine  = 16,
0153     EMaskInternal = 32,
0154     EMaskDouble   = 64,
0155     EMaskIsoLine  = 128
0156   };
0157 
0158 private:
0159   NCollection_Array1<int> myEdges;
0160   NCollection_Array1<int> myFlags;
0161   MinMaxIndices           myMinMax;
0162 };
0163 
0164 #endif // _HLRAlgo_EdgesBlock_HeaderFile