Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:27:20

0001 // Created on: 1998-07-22
0002 // Created by: Philippe MANGIN
0003 // Copyright (c) 1998-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 _BRepFill_PipeShell_HeaderFile
0018 #define _BRepFill_PipeShell_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TopoDS_Wire.hxx>
0024 #include <TopoDS_Shape.hxx>
0025 #include <BRepFill_Section.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <NCollection_List.hxx>
0028 #include <TopTools_ShapeMapHasher.hxx>
0029 #include <NCollection_DataMap.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <NCollection_Array2.hxx>
0032 #include <NCollection_HArray2.hxx>
0033 #include <GeomFill_Trihedron.hxx>
0034 #include <BRepFill_TransitionStyle.hxx>
0035 #include <GeomFill_PipeError.hxx>
0036 #include <Standard_Transient.hxx>
0037 #include <BRepFill_TypeOfContact.hxx>
0038 class Law_Function;
0039 class BRepFill_LocationLaw;
0040 class BRepFill_SectionLaw;
0041 class gp_Ax2;
0042 class gp_Dir;
0043 class TopoDS_Vertex;
0044 class gp_Trsf;
0045 class BRepFill_Sweep;
0046 
0047 //! Computes a topological shell using some wires
0048 //! (spines and profiles) and displacement option
0049 //! Perform general sweeping construction
0050 class BRepFill_PipeShell : public Standard_Transient
0051 {
0052 
0053 public:
0054   //! Set an sweep's mode
0055   //! If no mode are set, the mode used in MakePipe is used
0056   Standard_EXPORT BRepFill_PipeShell(const TopoDS_Wire& Spine);
0057 
0058   //! Set an Frenet or an CorrectedFrenet trihedron
0059   //! to perform the sweeping
0060   Standard_EXPORT void Set(const bool Frenet = false);
0061 
0062   //! Set a Discrete trihedron to perform the sweeping
0063   Standard_EXPORT void SetDiscrete();
0064 
0065   //! Set an fixed trihedron to perform the sweeping
0066   //! all sections will be parallel.
0067   Standard_EXPORT void Set(const gp_Ax2& Axe);
0068 
0069   //! Set an fixed BiNormal direction to perform
0070   //! the sweeping
0071   Standard_EXPORT void Set(const gp_Dir& BiNormal);
0072 
0073   //! Set support to the spine to define the BiNormal
0074   //! at the spine, like the normal the surfaces.
0075   //! Warning: To be effective, Each edge of the <spine> must
0076   //! have an representation on one face of<SpineSupport>
0077   Standard_EXPORT bool Set(const TopoDS_Shape& SpineSupport);
0078 
0079   //! Set an auxiliary spine to define the Normal
0080   //! For each Point of the Spine P, an Point Q is evaluated
0081   //! on <AuxiliarySpine>
0082   //! If <CurvilinearEquivalence>
0083   //! Q split <AuxiliarySpine> with the same length ratio
0084   //! than P split <Spline>.
0085   //! Else the plan define by P and the tangent to the <Spine>
0086   //! intersect <AuxiliarySpine> in Q.
0087   //! If <KeepContact> equals BRepFill_NoContact: The Normal is defined
0088   //! by the vector PQ.
0089   //! If <KeepContact> equals BRepFill_Contact: The Normal is defined to
0090   //! achieve that the sweeped section is in contact to the
0091   //! auxiliarySpine. The width of section is constant all along the path.
0092   //! In other words, the auxiliary spine lies on the swept surface,
0093   //! but not necessarily is a boundary of this surface. However,
0094   //! the auxiliary spine has to be close enough to the main spine
0095   //! to provide intersection with any section all along the path.
0096   //! If <KeepContact> equals BRepFill_ContactOnBorder: The auxiliary spine
0097   //! becomes a boundary of the swept surface and the width of section varies
0098   //! along the path.
0099   Standard_EXPORT void Set(const TopoDS_Wire&           AuxiliarySpine,
0100                            const bool                   CurvilinearEquivalence = true,
0101                            const BRepFill_TypeOfContact KeepContact = BRepFill_NoContact);
0102 
0103   //! Define the maximum V degree of resulting surface
0104   Standard_EXPORT void SetMaxDegree(const int NewMaxDegree);
0105 
0106   //! Define the maximum number of spans in V-direction
0107   //! on resulting surface
0108   Standard_EXPORT void SetMaxSegments(const int NewMaxSegments);
0109 
0110   //! Set the flag that indicates attempt to approximate
0111   //! a C1-continuous surface if a swept surface proved
0112   //! to be C0.
0113   //! Give section to sweep.
0114   //! Possibilities are:
0115   //! - Give one or several profile
0116   //! - Give one profile and an homotetic law.
0117   //! - Automatic compute of correspondence between profile, and section on the sweeped shape
0118   //! - correspondence between profile, and section on the sweeped shape defined by a vertex of the
0119   //! spine
0120   Standard_EXPORT void SetForceApproxC1(const bool ForceApproxC1);
0121 
0122   //! Sets the build history flag.
0123   //! If set to True, the pipe shell will store the history of the sections
0124   //! and the spine, which can be used for further modifications or analysis.
0125   inline void SetIsBuildHistory(const bool theIsBuildHistory)
0126   {
0127     myIsBuildHistory = theIsBuildHistory;
0128   }
0129 
0130   //! Returns the build history flag.
0131   //! If True, the pipe shell stores the history of the sections and the spine.
0132   inline bool IsBuildHistory() const { return myIsBuildHistory; }
0133 
0134   //! Set an section. The correspondence with the spine, will be automatically performed.
0135   Standard_EXPORT void Add(const TopoDS_Shape& Profile,
0136                            const bool          WithContact    = false,
0137                            const bool          WithCorrection = false);
0138 
0139   //! Set an section. The correspondence with the spine, is given by Location.
0140   Standard_EXPORT void Add(const TopoDS_Shape&  Profile,
0141                            const TopoDS_Vertex& Location,
0142                            const bool           WithContact    = false,
0143                            const bool           WithCorrection = false);
0144 
0145   //! Set an section and an homotetic law.
0146   //! The homotetie's centers is given by point on the <Spine>.
0147   Standard_EXPORT void SetLaw(const TopoDS_Shape&              Profile,
0148                               const occ::handle<Law_Function>& L,
0149                               const bool                       WithContact    = false,
0150                               const bool                       WithCorrection = false);
0151 
0152   //! Set an section and an homotetic law.
0153   //! The homotetie center is given by point on the <Spine>
0154   Standard_EXPORT void SetLaw(const TopoDS_Shape&              Profile,
0155                               const occ::handle<Law_Function>& L,
0156                               const TopoDS_Vertex&             Location,
0157                               const bool                       WithContact    = false,
0158                               const bool                       WithCorrection = false);
0159 
0160   //! Delete an section.
0161   Standard_EXPORT void DeleteProfile(const TopoDS_Shape& Profile);
0162 
0163   //! Say if <me> is ready to build the shape
0164   //! return False if <me> do not have section definition
0165   Standard_EXPORT bool IsReady() const;
0166 
0167   //! Get a status, when Simulate or Build failed.
0168   Standard_EXPORT GeomFill_PipeError GetStatus() const;
0169 
0170   Standard_EXPORT void SetTolerance(const double Tol3d      = 1.0e-4,
0171                                     const double BoundTol   = 1.0e-4,
0172                                     const double TolAngular = 1.0e-2);
0173 
0174   //! Set the Transition Mode to manage discontinuities
0175   //! on the sweep.
0176   Standard_EXPORT void SetTransition(const BRepFill_TransitionStyle Mode   = BRepFill_Modified,
0177                                      const double                   Angmin = 1.0e-2,
0178                                      const double                   Angmax = 6.0);
0179 
0180   //! Perform simulation of the sweep:
0181   //! Some Section are returned.
0182   Standard_EXPORT void Simulate(const int                       NumberOfSection,
0183                                 NCollection_List<TopoDS_Shape>& Sections);
0184 
0185   //! Builds the resulting shape (redefined from MakeShape).
0186   Standard_EXPORT bool Build();
0187 
0188   //! Transform the sweeping Shell in Solid.
0189   //! If the section are not closed returns False
0190   Standard_EXPORT bool MakeSolid();
0191 
0192   //! Returns the result Shape.
0193   Standard_EXPORT const TopoDS_Shape& Shape() const;
0194 
0195   Standard_EXPORT double ErrorOnSurface() const;
0196 
0197   //! Returns the TopoDS Shape of the bottom of the sweep.
0198   Standard_EXPORT const TopoDS_Shape& FirstShape() const;
0199 
0200   //! Returns the TopoDS Shape of the top of the sweep.
0201   Standard_EXPORT const TopoDS_Shape& LastShape() const;
0202 
0203   //! Returns the list of original profiles
0204   void Profiles(NCollection_List<TopoDS_Shape>& theProfiles)
0205   {
0206     for (int i = 1; i <= mySeq.Length(); ++i)
0207       theProfiles.Append(mySeq(i).OriginalShape());
0208   }
0209 
0210   //! Returns the spine
0211   const TopoDS_Wire& Spine() { return mySpine; }
0212 
0213   //! Returns the list of shapes generated from the
0214   //! shape <S>.
0215   Standard_EXPORT void Generated(const TopoDS_Shape& S, NCollection_List<TopoDS_Shape>& L);
0216 
0217   DEFINE_STANDARD_RTTIEXT(BRepFill_PipeShell, Standard_Transient)
0218 
0219 private:
0220   Standard_EXPORT void Prepare();
0221 
0222   Standard_EXPORT void Place(const BRepFill_Section& Sec,
0223                              TopoDS_Wire&            W,
0224                              gp_Trsf&                Trsf,
0225                              double&                 param);
0226 
0227   Standard_EXPORT void ResetLoc();
0228 
0229   Standard_EXPORT void BuildHistory(const BRepFill_Sweep& theSweep);
0230 
0231   TopoDS_Wire                            mySpine;
0232   TopoDS_Shape                           myFirst;
0233   TopoDS_Shape                           myLast;
0234   TopoDS_Shape                           myShape;
0235   NCollection_Sequence<BRepFill_Section> mySeq;
0236   NCollection_Sequence<TopoDS_Shape>     WSeq;
0237   NCollection_Sequence<int>              myIndOfSec;
0238   NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0239     myEdgeNewEdges;
0240   NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0241                                                  myGenMap;
0242   double                                         myTol3d;
0243   double                                         myBoundTol;
0244   double                                         myTolAngular;
0245   double                                         angmin;
0246   double                                         angmax;
0247   int                                            myMaxDegree;
0248   int                                            myMaxSegments;
0249   bool                                           myForceApproxC1;
0250   occ::handle<Law_Function>                      myLaw;
0251   bool                                           myIsAutomaticLaw;
0252   occ::handle<BRepFill_LocationLaw>              myLocation;
0253   occ::handle<BRepFill_SectionLaw>               mySection;
0254   occ::handle<NCollection_HArray2<TopoDS_Shape>> myFaces;
0255   GeomFill_Trihedron                             myTrihedron;
0256   BRepFill_TransitionStyle                       myTransition;
0257   GeomFill_PipeError                             myStatus;
0258   double                                         myErrorOnSurf;
0259   bool                                           myIsBuildHistory;
0260 };
0261 
0262 #endif // _BRepFill_PipeShell_HeaderFile