Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:16:51

0001 // Created on: 1995-07-17
0002 // Created by: Jing-Cheng MEI
0003 // Copyright (c) 1995-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 _BRepOffsetAPI_ThruSections_HeaderFile
0018 #define _BRepOffsetAPI_ThruSections_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <BRepFill_ThruSectionErrorStatus.hxx>
0025 #include <TopoDS_Shape.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <TopoDS_Face.hxx>
0028 #include <TopTools_ShapeMapHasher.hxx>
0029 #include <NCollection_DataMap.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <NCollection_List.hxx>
0032 #include <GeomAbs_Shape.hxx>
0033 #include <Approx_ParametrizationType.hxx>
0034 #include <BRepBuilderAPI_MakeShape.hxx>
0035 #include <NCollection_Array1.hxx>
0036 #include <NCollection_Handle.hxx>
0037 
0038 class TopoDS_Wire;
0039 class TopoDS_Vertex;
0040 class TopoDS_Shape;
0041 class Geom_BSplineSurface;
0042 class BRepFill_Generator;
0043 
0044 //! Describes functions to build a loft. This is a shell or a
0045 //! solid passing through a set of sections in a given
0046 //! sequence. Usually sections are wires, but the first and
0047 //! the last sections may be vertices (punctual sections).
0048 class BRepOffsetAPI_ThruSections : public BRepBuilderAPI_MakeShape
0049 {
0050 public:
0051   DEFINE_STANDARD_ALLOC
0052 
0053   //! Initializes an algorithm for building a shell or a solid
0054   //! passing through a set of sections, where:
0055   //! -          isSolid is set to true if the construction algorithm is
0056   //! required to build a solid or to false if it is required to build
0057   //! a shell (the default value),
0058   //! -          ruled is set to true if the faces generated between
0059   //! the edges of two consecutive wires are ruled surfaces or to
0060   //! false (the default value) if they are smoothed out by approximation,
0061   //! -          pres3d defines the precision criterion used by the
0062   //! approximation algorithm; the default value is 1.0e-6.
0063   //! Use AddWire and AddVertex to define the
0064   //! successive sections of the shell or solid to be built.
0065   Standard_EXPORT BRepOffsetAPI_ThruSections(const bool   isSolid = false,
0066                                              const bool   ruled   = false,
0067                                              const double pres3d  = 1.0e-06);
0068 
0069   //! Initializes this algorithm for building a shell or a solid
0070   //! passing through a set of sections, where:
0071   //! - isSolid is set to true if this construction algorithm is
0072   //! required to build a solid or to false if it is required to
0073   //! build a shell. false is the default value;
0074   //! - ruled is set to true if the faces generated between the
0075   //! edges of two consecutive wires are ruled surfaces or
0076   //! to false (the default value) if they are smoothed out by approximation,
0077   //! - pres3d defines the precision criterion used by the
0078   //! approximation algorithm; the default value is 1.0e-6.
0079   //! Use AddWire and AddVertex to define the successive
0080   //! sections of the shell or solid to be built.
0081   Standard_EXPORT void Init(const bool   isSolid = false,
0082                             const bool   ruled   = false,
0083                             const double pres3d  = 1.0e-06);
0084 
0085   //! Adds the wire wire to the set of
0086   //! sections through which the shell or solid is built.
0087   //! Use the Build function to construct the shape.
0088   Standard_EXPORT void AddWire(const TopoDS_Wire& wire);
0089 
0090   //! Adds the vertex Vertex (punctual section) to the set of sections
0091   //! through which the shell or solid is built. A vertex may be added to the
0092   //! set of sections only as first or last section. At least one wire
0093   //! must be added to the set of sections by the method AddWire.
0094   //! Use the Build function to construct the shape.
0095   Standard_EXPORT void AddVertex(const TopoDS_Vertex& aVertex);
0096 
0097   //! Sets/unsets the option to
0098   //! compute origin and orientation on wires to avoid twisted results
0099   //! and update wires to have same number of edges.
0100   Standard_EXPORT void CheckCompatibility(const bool check = true);
0101 
0102   //! Define the approximation algorithm
0103   Standard_EXPORT void SetSmoothing(const bool UseSmoothing);
0104 
0105   //! Define the type of parametrization used in the approximation
0106   Standard_EXPORT void SetParType(const Approx_ParametrizationType ParType);
0107 
0108   //! Define the Continuity used in the approximation
0109   Standard_EXPORT void SetContinuity(const GeomAbs_Shape C);
0110 
0111   //! define the Weights associed to the criterium used in
0112   //! the optimization.
0113   //!
0114   //! if Wi <= 0
0115   Standard_EXPORT void SetCriteriumWeight(const double W1, const double W2, const double W3);
0116 
0117   //! Define the maximal U degree of result surface
0118   Standard_EXPORT void SetMaxDegree(const int MaxDeg);
0119 
0120   //! returns the type of parametrization used in the approximation
0121   Standard_EXPORT Approx_ParametrizationType ParType() const;
0122 
0123   //! returns the Continuity used in the approximation
0124   Standard_EXPORT GeomAbs_Shape Continuity() const;
0125 
0126   //! returns the maximal U degree of result surface
0127   Standard_EXPORT int MaxDegree() const;
0128 
0129   //! Define the approximation algorithm
0130   Standard_EXPORT bool UseSmoothing() const;
0131 
0132   //! returns the Weights associed to the criterium used in
0133   //! the optimization.
0134   Standard_EXPORT void CriteriumWeight(double& W1, double& W2, double& W3) const;
0135 
0136   Standard_EXPORT void Build(
0137     const Message_ProgressRange& theRange = Message_ProgressRange()) override;
0138 
0139   //! Returns the TopoDS Shape of the bottom of the loft if solid
0140   Standard_EXPORT const TopoDS_Shape& FirstShape() const;
0141 
0142   //! Returns the TopoDS Shape of the top of the loft if solid
0143   Standard_EXPORT const TopoDS_Shape& LastShape() const;
0144 
0145   //! if Ruled
0146   //! Returns the Face generated by each edge
0147   //! except the last wire
0148   //! if smoothed
0149   //! Returns the Face generated by each edge of the first wire
0150   Standard_EXPORT TopoDS_Shape GeneratedFace(const TopoDS_Shape& Edge) const;
0151 
0152   //! Sets the mutable input state.
0153   //! If true then the input profile can be modified inside
0154   //! the thrusection operation. Default value is true.
0155   Standard_EXPORT void SetMutableInput(const bool theIsMutableInput);
0156 
0157   //! Returns a list of new shapes generated from the shape
0158   //! S by the shell-generating algorithm.
0159   //! This function is redefined from BRepBuilderAPI_MakeShape::Generated.
0160   //! S can be an edge or a vertex of a given Profile (see methods AddWire and AddVertex).
0161   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Generated(const TopoDS_Shape& S) override;
0162 
0163   //! Returns the list of original wires
0164   const NCollection_List<TopoDS_Shape>& Wires() const { return myInputWires; }
0165 
0166   //! Returns the current mutable input state
0167   Standard_EXPORT bool IsMutableInput() const;
0168 
0169   //! Returns the status of thrusection operation
0170   BRepFill_ThruSectionErrorStatus GetStatus() const { return myStatus; }
0171 
0172 private:
0173   Standard_EXPORT void CreateRuled();
0174 
0175   Standard_EXPORT void CreateSmoothed();
0176 
0177   Standard_EXPORT occ::handle<Geom_BSplineSurface> TotalSurf(
0178     const NCollection_Array1<TopoDS_Shape>& shapes,
0179     const int                               NbSect,
0180     const int                               NbEdges,
0181     const bool                              w1Point,
0182     const bool                              w2Point,
0183     const bool                              vClosed) const;
0184 
0185   NCollection_List<TopoDS_Shape>     myInputWires; //!< List of input wires
0186   NCollection_Sequence<TopoDS_Shape> myWires;      //!< Working wires
0187   NCollection_DataMap<TopoDS_Shape, NCollection_List<int>, TopTools_ShapeMapHasher>
0188                                                                            myEdgeNewIndices;
0189   NCollection_DataMap<TopoDS_Shape, int, TopTools_ShapeMapHasher>          myVertexIndex;
0190   int                                                                      myNbEdgesInSection;
0191   bool                                                                     myIsSolid;
0192   bool                                                                     myIsRuled;
0193   bool                                                                     myWCheck;
0194   double                                                                   myPres3d;
0195   TopoDS_Face                                                              myFirst;
0196   TopoDS_Face                                                              myLast;
0197   bool                                                                     myDegen1;
0198   bool                                                                     myDegen2;
0199   NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher> myEdgeFace;
0200   GeomAbs_Shape                                                            myContinuity;
0201   Approx_ParametrizationType                                               myParamType;
0202   int                                                                      myDegMax;
0203   double                                                                   myCritWeights[3];
0204   bool                                                                     myUseSmoothing;
0205   bool                                                                     myMutableInput;
0206   NCollection_Handle<BRepFill_Generator>                                   myBFGenerator;
0207   BRepFill_ThruSectionErrorStatus                                          myStatus;
0208 };
0209 
0210 #endif // _BRepOffsetAPI_ThruSections_HeaderFile