Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:03:30

0001 // Created on: 1993-01-11
0002 // Created by: Christophe MARION
0003 // Copyright (c) 1993-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 _HLRBRep_Data_HeaderFile
0018 #define _HLRBRep_Data_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <TopTools_ShapeMapHasher.hxx>
0025 #include <NCollection_IndexedMap.hxx>
0026 #include <HLRBRep_EdgeData.hxx>
0027 #include <NCollection_Array1.hxx>
0028 #include <HLRBRep_FaceData.hxx>
0029 #include <Standard_ShortReal.hxx>
0030 #include <HLRAlgo_Projector.hxx>
0031 #include <HLRBRep_CLProps.hxx>
0032 #include <HLRBRep_SLProps.hxx>
0033 #include <Standard_Real.hxx>
0034 #include <HLRBRep_FaceIterator.hxx>
0035 #include <GeomAbs_SurfaceType.hxx>
0036 #include <Standard_Boolean.hxx>
0037 #include <GeomAbs_CurveType.hxx>
0038 #include <TopAbs_Orientation.hxx>
0039 #include <HLRBRep_Intersector.hxx>
0040 #include <HLRAlgo_Interference.hxx>
0041 #include <Standard_Transient.hxx>
0042 #include <TopoDS_Shape.hxx>
0043 #include <BRepTopAdaptor_Tool.hxx>
0044 #include <NCollection_DataMap.hxx>
0045 #include <TopAbs_State.hxx>
0046 #include <NCollection_List.hxx>
0047 class BRepTopAdaptor_TopolTool;
0048 class gp_Dir2d;
0049 class HLRBRep_EdgeData;
0050 class HLRBRep_FaceData;
0051 class HLRBRep_Surface;
0052 class IntRes2d_IntersectionPoint;
0053 class TableauRejection;
0054 
0055 class HLRBRep_Data : public Standard_Transient
0056 {
0057 
0058 public:
0059   //! Create an empty data structure of <NV> vertices,
0060   //! <NE> edges and <NF> faces.
0061   Standard_EXPORT HLRBRep_Data(const int NV, const int NE, const int NF);
0062 
0063   //! Write <DS> in me with a translation of
0064   //! <dv>,<de>,<df>.
0065   Standard_EXPORT void Write(const occ::handle<HLRBRep_Data>& DS,
0066                              const int                        dv,
0067                              const int                        de,
0068                              const int                        df);
0069 
0070   NCollection_Array1<HLRBRep_EdgeData>& EDataArray();
0071 
0072   NCollection_Array1<HLRBRep_FaceData>& FDataArray();
0073 
0074   //! Set the tolerance for the rejections during the
0075   //! exploration
0076   void Tolerance(const float tol);
0077 
0078   //! returns the tolerance for the rejections during
0079   //! the exploration
0080   float Tolerance() const;
0081 
0082   //! end of building of the Data and updating
0083   //! all the information linked to the projection.
0084   Standard_EXPORT void Update(const HLRAlgo_Projector& P);
0085 
0086   HLRAlgo_Projector& Projector();
0087 
0088   int NbVertices() const;
0089 
0090   int NbEdges() const;
0091 
0092   int NbFaces() const;
0093 
0094   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& EdgeMap();
0095 
0096   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& FaceMap();
0097 
0098   //! to compare with only non rejected edges.
0099   Standard_EXPORT void InitBoundSort(const HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxTot,
0100                                      const int                                e1,
0101                                      const int                                e2);
0102 
0103   //! Begin an iteration only on visible Edges
0104   //! crossing the face number <FI>.
0105   Standard_EXPORT void InitEdge(
0106     const int                                                                        FI,
0107     NCollection_DataMap<TopoDS_Shape, BRepTopAdaptor_Tool, TopTools_ShapeMapHasher>& MST);
0108 
0109   Standard_EXPORT bool MoreEdge();
0110 
0111   Standard_EXPORT void NextEdge(const bool skip = true);
0112 
0113   //! Returns the current Edge
0114   Standard_EXPORT int Edge() const;
0115 
0116   //! Returns true if the current edge to be hidden
0117   //! belongs to the hiding face.
0118   bool HidingTheFace() const;
0119 
0120   //! Returns true if the current hiding face is not an
0121   //! auto-intersected one.
0122   bool SimpleHidingFace() const;
0123 
0124   //! Intersect the current Edge with the boundary of
0125   //! the hiding face. The interferences are given by
0126   //! the More, Next, and Value methods.
0127   Standard_EXPORT void InitInterference();
0128 
0129   bool MoreInterference() const;
0130 
0131   Standard_EXPORT void NextInterference();
0132 
0133   //! Returns True if the interference is rejected.
0134   Standard_EXPORT bool RejectedInterference();
0135 
0136   //! Returns True if the rejected interference is above
0137   //! the face.
0138   Standard_EXPORT bool AboveInterference();
0139 
0140   HLRAlgo_Interference& Interference();
0141 
0142   //! Returns the local description of the projection of
0143   //! the current LEdge at parameter <Param>.
0144   Standard_EXPORT void LocalLEGeometry2D(const double Param,
0145                                          gp_Dir2d&    Tg,
0146                                          gp_Dir2d&    Nm,
0147                                          double&      Cu);
0148 
0149   //! Returns the local description of the projection of
0150   //! the current FEdge at parameter <Param>.
0151   Standard_EXPORT void LocalFEGeometry2D(const int    FE,
0152                                          const double Param,
0153                                          gp_Dir2d&    Tg,
0154                                          gp_Dir2d&    Nm,
0155                                          double&      Cu);
0156 
0157   //! Returns the local 3D state of the intersection
0158   //! between the current edge and the current face at the
0159   //! <p1> and <p2> parameters.
0160   Standard_EXPORT void EdgeState(const double  p1,
0161                                  const double  p2,
0162                                  TopAbs_State& stbef,
0163                                  TopAbs_State& staf);
0164 
0165   //! Returns the true if the Edge <ED> belongs to the
0166   //! Hiding Face.
0167   bool EdgeOfTheHidingFace(const int E, const HLRBRep_EdgeData& ED) const;
0168 
0169   //! Returns the number of levels of hiding face above
0170   //! the first point of the edge <ED>. The
0171   //! InterferenceList is given to compute far away of
0172   //! the Interferences and then come back.
0173   Standard_EXPORT int HidingStartLevel(const int                                     E,
0174                                        const HLRBRep_EdgeData&                       ED,
0175                                        const NCollection_List<HLRAlgo_Interference>& IL);
0176 
0177   //! Returns the state of the Edge <ED> after
0178   //! classification.
0179   Standard_EXPORT TopAbs_State Compare(const int E, const HLRBRep_EdgeData& ED);
0180 
0181   //! Simple classification of part of edge [p1, p2].
0182   //! Returns OUT if at least 1 of Nbp points of edge is out; otherwise returns IN.
0183   //! It is used to check "suspicion" hidden part of edge.
0184   Standard_EXPORT TopAbs_State SimplClassify(const int               E,
0185                                              const HLRBRep_EdgeData& ED,
0186                                              const int               Nbp,
0187                                              const double            p1,
0188                                              const double            p2);
0189 
0190   //! Classification of an edge.
0191   Standard_EXPORT TopAbs_State Classify(const int               E,
0192                                         const HLRBRep_EdgeData& ED,
0193                                         const bool              LevelFlag,
0194                                         int&                    Level,
0195                                         const double            param);
0196 
0197   //! Returns true if the current face is bad.
0198   Standard_EXPORT bool IsBadFace() const;
0199 
0200   Standard_EXPORT void Destroy();
0201 
0202   ~HLRBRep_Data() override { Destroy(); }
0203 
0204   DEFINE_STANDARD_RTTIEXT(HLRBRep_Data, Standard_Transient)
0205 
0206 private:
0207   //! Orient the OutLines (left must be inside projection).
0208   //! Returns True if the face of a closed shell has been
0209   //! inverted.
0210   Standard_EXPORT bool OrientOutLine(const int I, HLRBRep_FaceData& FD);
0211 
0212   //! Orient the Edges which are not Internal OutLine,
0213   //! not Double and not IsoLine.
0214   Standard_EXPORT void OrientOthEdge(const int I, HLRBRep_FaceData& FD);
0215 
0216   //! Returns True if the intersection is rejected.
0217   Standard_EXPORT bool RejectedPoint(const IntRes2d_IntersectionPoint& PInter,
0218                                      const TopAbs_Orientation          BoundOri,
0219                                      const int                         NumSeg);
0220 
0221   //! Returns True if there is a common vertex between
0222   //! myLE and myFE depending on <head1> and <head2>.
0223   Standard_EXPORT bool SameVertex(const bool head1, const bool head2);
0224 
0225 private:
0226   int                                                           myNbVertices;
0227   int                                                           myNbEdges;
0228   int                                                           myNbFaces;
0229   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> myEMap;
0230   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> myFMap;
0231   NCollection_Array1<HLRBRep_EdgeData>                          myEData;
0232   NCollection_Array1<HLRBRep_FaceData>                          myFData;
0233   NCollection_Array1<int>                                       myEdgeIndices;
0234   float                                                         myToler;
0235   HLRAlgo_Projector                                             myProj;
0236   HLRBRep_CLProps                                               myLLProps;
0237   HLRBRep_CLProps                                               myFLProps;
0238   HLRBRep_SLProps                                               mySLProps;
0239   double                                                        myBigSize;
0240   HLRBRep_FaceIterator                                          myFaceItr1;
0241   HLRBRep_FaceIterator                                          myFaceItr2;
0242   int                                                           iFace;
0243   HLRBRep_FaceData*                                             iFaceData;
0244   HLRBRep_Surface*                                              iFaceGeom;
0245   HLRAlgo_EdgesBlock::MinMaxIndices*                            iFaceMinMax;
0246   GeomAbs_SurfaceType                                           iFaceType;
0247   bool                                                          iFaceBack;
0248   bool                                                          iFaceSimp;
0249   bool                                                          iFaceSmpl;
0250   bool                                                          iFaceTest;
0251   int                                                           myHideCount;
0252   double                                                        myDeca[16];
0253   double                                                        mySurD[16];
0254   int                                                           myCurSortEd;
0255   int                                                           myNbrSortEd;
0256   int                                                           myLE;
0257   bool                                                          myLEOutLine;
0258   bool                                                          myLEInternal;
0259   bool                                                          myLEDouble;
0260   bool                                                          myLEIsoLine;
0261   HLRBRep_EdgeData*                                             myLEData;
0262   const HLRBRep_Curve*                                          myLEGeom;
0263   HLRAlgo_EdgesBlock::MinMaxIndices*                            myLEMinMax;
0264   GeomAbs_CurveType                                             myLEType;
0265   float                                                         myLETol;
0266   int                                                           myFE;
0267   TopAbs_Orientation                                            myFEOri;
0268   bool                                                          myFEOutLine;
0269   bool                                                          myFEInternal;
0270   bool                                                          myFEDouble;
0271   HLRBRep_EdgeData*                                             myFEData;
0272   HLRBRep_Curve*                                                myFEGeom;
0273   GeomAbs_CurveType                                             myFEType;
0274   float                                                         myFETol;
0275   HLRBRep_Intersector                                           myIntersector;
0276   occ::handle<BRepTopAdaptor_TopolTool>                         myClassifier;
0277   bool                                                          mySameVertex;
0278   bool                                                          myIntersected;
0279   int                                                           myNbPoints;
0280   int                                                           myNbSegments;
0281   int                                                           iInterf;
0282   HLRAlgo_Interference                                          myIntf;
0283   bool                                                          myAboveIntf;
0284   TableauRejection*                                             myReject;
0285 };
0286 
0287 #include <HLRBRep_Data.lxx>
0288 
0289 #endif // _HLRBRep_Data_HeaderFile