Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:50

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