Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-03 10:54:49

0001 // Created on: 1993-10-25
0002 // Created by: Jean Marc LACHAUME
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 _Geom2dHatch_Hatcher_HeaderFile
0018 #define _Geom2dHatch_Hatcher_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Geom2dAdaptor_Curve.hxx>
0023 #include <Geom2dHatch_Intersector.hxx>
0024 #include <Geom2dHatch_Elements.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Geom2dHatch_Hatching.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <TopAbs_Orientation.hxx>
0029 #include <HatchGen_ErrorStatus.hxx>
0030 
0031 class HatchGen_PointOnHatching;
0032 class HatchGen_Domain;
0033 
0034 // resolve name collisions with X11 headers
0035 #ifdef Status
0036   #undef Status
0037 #endif
0038 
0039 class Geom2dHatch_Hatcher
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   //! Returns an empty hatcher.
0045   Standard_EXPORT Geom2dHatch_Hatcher(const Geom2dHatch_Intersector& Intersector,
0046                                       const double                   Confusion2d,
0047                                       const double                   Confusion3d,
0048                                       const bool                     KeepPnt = false,
0049                                       const bool                     KeepSeg = false);
0050 
0051   //! Sets the associated intersector.
0052   Standard_EXPORT void Intersector(const Geom2dHatch_Intersector& Intersector);
0053 
0054   //! Returns the associated intersector.
0055   const Geom2dHatch_Intersector& Intersector();
0056 
0057   //! Returns the associated intersector.
0058   Geom2dHatch_Intersector& ChangeIntersector();
0059 
0060   //! Sets the confusion tolerance.
0061   Standard_EXPORT void Confusion2d(const double Confusion);
0062 
0063   //! Returns the 2d confusion tolerance, i.e. the value under
0064   //! which two points are considered identical in the
0065   //! parametric space of the hatching.
0066   double Confusion2d() const;
0067 
0068   //! Sets the confusion tolerance.
0069   Standard_EXPORT void Confusion3d(const double Confusion);
0070 
0071   //! Returns the 3d confusion tolerance, i.e. the value under
0072   //! which two points are considered identical in the
0073   //! 3d space of the hatching.
0074   double Confusion3d() const;
0075 
0076   //! Sets the above flag.
0077   Standard_EXPORT void KeepPoints(const bool Keep);
0078 
0079   //! Returns the flag about the points consideration.
0080   bool KeepPoints() const;
0081 
0082   //! Sets the above flag.
0083   Standard_EXPORT void KeepSegments(const bool Keep);
0084 
0085   //! Returns the flag about the segments consideration.
0086   bool KeepSegments() const;
0087 
0088   //! Removes all the hatchings and all the elements.
0089   void Clear();
0090 
0091   //! Returns the curve associated to the IndE-th element.
0092   const Geom2dAdaptor_Curve& ElementCurve(const int IndE) const;
0093 
0094   //! Adds an element to the hatcher and returns its index.
0095   Standard_EXPORT int AddElement(const Geom2dAdaptor_Curve& Curve,
0096                                  const TopAbs_Orientation   Orientation = TopAbs_FORWARD);
0097 
0098   //! Adds an element to the hatcher and returns its index.
0099   int AddElement(const occ::handle<Geom2d_Curve>& Curve,
0100                  const TopAbs_Orientation         Orientation = TopAbs_FORWARD)
0101   {
0102     Geom2dAdaptor_Curve aGAC(Curve);
0103     return AddElement(aGAC, Orientation);
0104   }
0105 
0106   //! Removes the IndE-th element from the hatcher.
0107   Standard_EXPORT void RemElement(const int IndE);
0108 
0109   //! Removes all the elements from the hatcher.
0110   Standard_EXPORT void ClrElements();
0111 
0112   //! Returns the curve associated to the IndH-th hatching.
0113   const Geom2dAdaptor_Curve& HatchingCurve(const int IndH) const;
0114 
0115   //! Adds a hatching to the hatcher and returns its index.
0116   Standard_EXPORT int AddHatching(const Geom2dAdaptor_Curve& Curve);
0117 
0118   //! Removes the IndH-th hatching from the hatcher.
0119   Standard_EXPORT void RemHatching(const int IndH);
0120 
0121   //! Removes all the hatchings from the hatcher.
0122   Standard_EXPORT void ClrHatchings();
0123 
0124   //! Returns the number of intersection points of
0125   //! the IndH-th hatching.
0126   int NbPoints(const int IndH) const;
0127 
0128   //! Returns the IndP-th intersection point of the
0129   //! IndH-th hatching.
0130   const HatchGen_PointOnHatching& Point(const int IndH, const int IndP) const;
0131 
0132   //! Trims all the hatchings of the hatcher by all the
0133   //! elements of the hatcher.
0134   Standard_EXPORT void Trim();
0135 
0136   //! Adds a hatching to the hatcher and trims it by
0137   //! the elements already given and returns its index.
0138   Standard_EXPORT int Trim(const Geom2dAdaptor_Curve& Curve);
0139 
0140   //! Trims the IndH-th hatching by the elements
0141   //! already given.
0142   Standard_EXPORT void Trim(const int IndH);
0143 
0144   //! Computes the domains of all the hatchings.
0145   Standard_EXPORT void ComputeDomains();
0146 
0147   //! Computes the domains of the IndH-th hatching.
0148   Standard_EXPORT void ComputeDomains(const int IndH);
0149 
0150   //! Returns the fact that the intersections were computed
0151   //! for the IndH-th hatching.
0152   bool TrimDone(const int IndH) const;
0153 
0154   //! Returns the fact that the intersections failed
0155   //! for the IndH-th hatching.
0156   bool TrimFailed(const int IndH) const;
0157 
0158   //! Returns the fact that the domains were computed
0159   //! for all the hatchings.
0160   bool IsDone() const;
0161 
0162   //! Returns the fact that the domains were computed
0163   //! for the IndH-th hatching.
0164   bool IsDone(const int IndH) const;
0165 
0166   //! Returns the status about the IndH-th hatching.
0167   HatchGen_ErrorStatus Status(const int IndH) const;
0168 
0169   //! Returns the number of domains of the IndH-th hatching.
0170   //! Only ONE "INFINITE" domain means that the hatching is
0171   //! fully included in the contour defined by the elements.
0172   int NbDomains(const int IndH) const;
0173 
0174   //! Returns the IDom-th domain of the IndH-th hatching.
0175   Standard_EXPORT const HatchGen_Domain& Domain(const int IndH, const int IDom) const;
0176 
0177   //! Dump the hatcher.
0178   Standard_EXPORT void Dump() const;
0179 
0180 protected:
0181   //! Returns the IndE-th element.
0182   Geom2dHatch_Element& Element(const int IndE);
0183 
0184   //! Returns the IndH-th hatching.
0185   Geom2dHatch_Hatching& Hatching(const int IndH);
0186 
0187 private:
0188   //! Trims the IndH-th hatching of the hatcher by the
0189   //! IndE-th element.
0190   Standard_EXPORT bool Trim(const int IndH, const int IndE);
0191 
0192   //! Sets the global transition (the before and after
0193   //! states and segment extremities flags) of the point.
0194   Standard_EXPORT bool GlobalTransition(HatchGen_PointOnHatching& Point);
0195 
0196   Geom2dHatch_Intersector                        myIntersector;
0197   double                                         myConfusion2d;
0198   double                                         myConfusion3d;
0199   bool                                           myKeepPoints;
0200   bool                                           myKeepSegments;
0201   int                                            myNbElements;
0202   Geom2dHatch_Elements                           myElements;
0203   int                                            myNbHatchings;
0204   NCollection_DataMap<int, Geom2dHatch_Hatching> myHatchings;
0205 };
0206 
0207 #include <Geom2dHatch_Hatcher.lxx>
0208 
0209 #endif // _Geom2dHatch_Hatcher_HeaderFile