Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-02 08:33:11

0001 // Created on: 1995-06-12
0002 // Created by: Joelle CHAUVET
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 _ChFi2d_Builder_HeaderFile
0018 #define _ChFi2d_Builder_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <ChFi2d_ConstructionError.hxx>
0024 #include <TopoDS_Face.hxx>
0025 #include <TopTools_SequenceOfShape.hxx>
0026 #include <TopTools_DataMapOfShapeShape.hxx>
0027 #include <Standard_Integer.hxx>
0028 
0029 class TopoDS_Edge;
0030 class TopoDS_Vertex;
0031 
0032 // resolve name collisions with X11 headers
0033 #ifdef Status
0034   #undef Status
0035 #endif
0036 
0037 //! This  class contains  the algorithm  used to build
0038 //! fillet on planar wire.
0039 class ChFi2d_Builder
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   Standard_EXPORT ChFi2d_Builder();
0045 
0046   //! The face  <F> can be build  on a closed or an open
0047   //! wire.
0048   Standard_EXPORT ChFi2d_Builder(const TopoDS_Face& F);
0049 
0050   Standard_EXPORT void Init(const TopoDS_Face& F);
0051 
0052   Standard_EXPORT void Init(const TopoDS_Face& RefFace, const TopoDS_Face& ModFace);
0053 
0054   //! Add  a fillet  of   radius  <Radius> on  the  wire
0055   //! between the two edges connected to the vertex <V>.
0056   //! <AddFillet> returns the  fillet edge. The returned
0057   //! edge has  sense only   if the status   <status> is
0058   //! <IsDone>
0059   Standard_EXPORT TopoDS_Edge AddFillet(const TopoDS_Vertex& V, const Standard_Real Radius);
0060 
0061   //! modify the fillet radius and return the new fillet
0062   //! edge. this    edge has sense  only if   the status
0063   //! <status> is <IsDone>.
0064   Standard_EXPORT TopoDS_Edge ModifyFillet(const TopoDS_Edge& Fillet, const Standard_Real Radius);
0065 
0066   //! removes the fillet <Fillet> and returns the vertex
0067   //! connecting the two adjacent edges to  this fillet.
0068   Standard_EXPORT TopoDS_Vertex RemoveFillet(const TopoDS_Edge& Fillet);
0069 
0070   //! Add a chamfer on  the  wire between the two  edges
0071   //! connected <E1> and  <E2>. <AddChamfer> returns the
0072   //! chamfer  edge. This  edge  has  sense only if  the
0073   //! status <status> is <IsDone>.
0074   Standard_EXPORT TopoDS_Edge AddChamfer(const TopoDS_Edge&  E1,
0075                                          const TopoDS_Edge&  E2,
0076                                          const Standard_Real D1,
0077                                          const Standard_Real D2);
0078 
0079   //! Add  a chamfer on the   wire between the two edges
0080   //! connected to the vertex <V>. The chamfer will make
0081   //! an  angle <Ang> with the edge  <E>, and one of its
0082   //! extremities  will be on  <E>  at distance <D>. The
0083   //! returned   edge has sense   only   if the   status
0084   //! <status> is <IsDone>.
0085   //! Warning: The value of <Ang> must be expressed in Radian.
0086   Standard_EXPORT TopoDS_Edge AddChamfer(const TopoDS_Edge&   E,
0087                                          const TopoDS_Vertex& V,
0088                                          const Standard_Real  D,
0089                                          const Standard_Real  Ang);
0090 
0091   //! modify the chamfer <Chamfer>  and returns  the new
0092   //! chamfer edge.
0093   //! This edge as sense only  if the status <status> is
0094   //! <IsDone>.
0095   Standard_EXPORT TopoDS_Edge ModifyChamfer(const TopoDS_Edge&  Chamfer,
0096                                             const TopoDS_Edge&  E1,
0097                                             const TopoDS_Edge&  E2,
0098                                             const Standard_Real D1,
0099                                             const Standard_Real D2);
0100 
0101   //! modify the  chamfer <Chamfer>  and returns the new
0102   //! chamfer edge. This    edge as sense  only   if the
0103   //! status <status>   is  <IsDone>.
0104   //! Warning: The value of <Ang> must be expressed in Radian.
0105   Standard_EXPORT TopoDS_Edge ModifyChamfer(const TopoDS_Edge&  Chamfer,
0106                                             const TopoDS_Edge&  E,
0107                                             const Standard_Real D,
0108                                             const Standard_Real Ang);
0109 
0110   //! removes   the chamfer  <Chamfer>   and returns the
0111   //! vertex connecting  the two adjacent  edges to this
0112   //! chamfer.
0113   Standard_EXPORT TopoDS_Vertex RemoveChamfer(const TopoDS_Edge& Chamfer);
0114 
0115   //! returns the modified face
0116   TopoDS_Face Result() const;
0117 
0118   Standard_Boolean IsModified(const TopoDS_Edge& E) const;
0119 
0120   //! returns the list of new edges
0121   const TopTools_SequenceOfShape& FilletEdges() const;
0122 
0123   Standard_Integer NbFillet() const;
0124 
0125   //! returns the list of new edges
0126   const TopTools_SequenceOfShape& ChamferEdges() const;
0127 
0128   Standard_Integer NbChamfer() const;
0129 
0130   Standard_Boolean HasDescendant(const TopoDS_Edge& E) const;
0131 
0132   //! returns the modified edge if <E> has descendant or
0133   //! <E> in the other case.
0134   const TopoDS_Edge& DescendantEdge(const TopoDS_Edge& E) const;
0135 
0136   //! Returns the parent edge of  <E>
0137   //! Warning: If <E>is a basis edge,  the returned edge would be
0138   //! equal to <E>
0139   Standard_EXPORT const TopoDS_Edge& BasisEdge(const TopoDS_Edge& E) const;
0140 
0141   ChFi2d_ConstructionError Status() const;
0142 
0143 protected:
0144 private:
0145   //! Is internally used by <AddFillet>.
0146   //! Warning: <TrimE1>, <TrimE2>, <Fillet> has sense only if the
0147   //! status <status> is equal to <IsDone>
0148   Standard_EXPORT void ComputeFillet(const TopoDS_Vertex& V,
0149                                      const TopoDS_Edge&   E1,
0150                                      const TopoDS_Edge&   E2,
0151                                      const Standard_Real  Radius,
0152                                      TopoDS_Edge&         TrimE1,
0153                                      TopoDS_Edge&         TrimE2,
0154                                      TopoDS_Edge&         Fillet);
0155 
0156   //! Is internally used by  <AddChamfer>. The chamfer is
0157   //! computed  from  a  vertex,   two  edges   and  two
0158   //! distances
0159   //! Warning: <TrimE1>, <TrimE2> and <Chamfer> has sense only if
0160   //! if the status <status> is equal to <IsDone>
0161   Standard_EXPORT void ComputeChamfer(const TopoDS_Vertex& V,
0162                                       const TopoDS_Edge&   E1,
0163                                       const TopoDS_Edge&   E2,
0164                                       const Standard_Real  D1,
0165                                       const Standard_Real  D2,
0166                                       TopoDS_Edge&         TrimE1,
0167                                       TopoDS_Edge&         TrimE2,
0168                                       TopoDS_Edge&         Chamfer);
0169 
0170   //! Is internally used by <AddChamfer>.  The chamfer is
0171   //! computed from   an  edge,  a  vertex,   a distance
0172   //! and an angle
0173   //! Warning: <TrimE1>,  <TrimE2>, and <Chamfer> has
0174   //! sense only   if  the status <status> is   equal to
0175   //! <IsDone>
0176   Standard_EXPORT void ComputeChamfer(const TopoDS_Vertex& V,
0177                                       const TopoDS_Edge&   E1,
0178                                       const Standard_Real  D,
0179                                       const Standard_Real  Ang,
0180                                       const TopoDS_Edge&   E2,
0181                                       TopoDS_Edge&         TrimE1,
0182                                       TopoDS_Edge&         TrimE2,
0183                                       TopoDS_Edge&         Chamfer);
0184 
0185   //! Is   internally  used     by  <ComputeFillet>.
0186   //! <NewExtr1> and  <NewExtr2>  will  contains the new
0187   //! extremities of <AdjEdge1> and <AdjEdge2>
0188   //! Warning: The  returned  edge has sense   only if the status
0189   //! <status> is equal to <IsDone>
0190   //! or to one of those specific cases :
0191   //! <FirstEdgeDegenerated>
0192   //! <LastEdgeDegenerated>
0193   //! <BothEdgesDegenerated>
0194   Standard_EXPORT TopoDS_Edge BuildFilletEdge(const TopoDS_Vertex& V,
0195                                               const TopoDS_Edge&   AdjEdge1,
0196                                               const TopoDS_Edge&   AdjEdge2,
0197                                               const Standard_Real  Radius,
0198                                               TopoDS_Vertex&       NewExtr1,
0199                                               TopoDS_Vertex&       NewExtr2);
0200 
0201   //! Is   internally  used     by  <ComputeFillet>.
0202   //! <NewExtr1> and  <NewExtr2>  will  contains the new
0203   //! extremities of <AdjEdge1> and <AdjEdge2>
0204   //! Warning: The  returned  edge has sense   only if the status
0205   //! <status> is equal to <IsDone>
0206   Standard_EXPORT TopoDS_Edge BuildChamferEdge(const TopoDS_Vertex& V,
0207                                                const TopoDS_Edge&   AdjEdge1,
0208                                                const TopoDS_Edge&   AdjEdge2,
0209                                                const Standard_Real  D1,
0210                                                const Standard_Real  D2,
0211                                                TopoDS_Vertex&       NewExtr1,
0212                                                TopoDS_Vertex&       NewExtr2);
0213 
0214   //! Is   internally  used     by  <ComputeFillet>.
0215   //! <NewExtr1> and  <NewExtr2>  will  contains the new
0216   //! extremities of <AdjEdge1> and <AdjEdge2>
0217   //! Warning: The  returned  edge has sense   only if the status
0218   //! <status> is equal to <IsDone>
0219   Standard_EXPORT TopoDS_Edge BuildChamferEdge(const TopoDS_Vertex& V,
0220                                                const TopoDS_Edge&   AdjEdge2,
0221                                                const Standard_Real  D,
0222                                                const Standard_Real  Ang,
0223                                                const TopoDS_Edge&   AdjEdge1,
0224                                                TopoDS_Vertex&       NewExtr1,
0225                                                TopoDS_Vertex&       NewExtr2);
0226 
0227   //! replaces in  the  new face  <newFace> <OldE1>  and
0228   //! <OldE2>  by <E1>, <Fillet> and <E2>
0229   //! or by <Fillet> and <E2> if <E1> is degenerated
0230   //! or by <E1> and <Fillet> if <E2> is degenerated
0231   //! or by <Fillet> if <E1> and <E2> are degenerated .
0232   Standard_EXPORT void BuildNewWire(const TopoDS_Edge& OldE1,
0233                                     const TopoDS_Edge& OldE2,
0234                                     const TopoDS_Edge& E1,
0235                                     const TopoDS_Edge& Fillet,
0236                                     const TopoDS_Edge& E2);
0237 
0238   //! Changes <OldExtr> of <E1> by <NewExtr>
0239   Standard_EXPORT TopoDS_Edge BuildNewEdge(const TopoDS_Edge&   E1,
0240                                            const TopoDS_Vertex& OldExtr,
0241                                            const TopoDS_Vertex& NewExtr) const;
0242 
0243   //! Changes <OldExtr> of <E1> by <NewExtr>
0244   //! returns E1 and IsDegenerated = Standard_True
0245   //! if the new edge is degenerated
0246   Standard_EXPORT TopoDS_Edge BuildNewEdge(const TopoDS_Edge&   E1,
0247                                            const TopoDS_Vertex& OldExtr,
0248                                            const TopoDS_Vertex& NewExtr,
0249                                            Standard_Boolean&    IsDegenerated) const;
0250 
0251   //! Writes <NewEdge> in  <fillets> if <Id> is equal to
0252   //! 1, or in <chamfers> if <Id> is Equal to 2.
0253   //! Writes  the  modifications  in  <history> :
0254   //! <TrimE1> is given by <E1>, <TrimE2> by <E2>
0255   //! if <TrimE1> and <TrimE2> are not degenerated.
0256   Standard_EXPORT void UpDateHistory(const TopoDS_Edge&     E1,
0257                                      const TopoDS_Edge&     E2,
0258                                      const TopoDS_Edge&     TrimE1,
0259                                      const TopoDS_Edge&     TrimE2,
0260                                      const TopoDS_Edge&     NewEdge,
0261                                      const Standard_Integer Id);
0262 
0263   //! Writes the  modifications in  <history> . <TrimE1>
0264   //! is given by <E1>, <TrimE2> by <E2>.
0265   Standard_EXPORT void UpDateHistory(const TopoDS_Edge& E1,
0266                                      const TopoDS_Edge& E2,
0267                                      const TopoDS_Edge& TrimE1,
0268                                      const TopoDS_Edge& TrimE2);
0269 
0270   Standard_EXPORT Standard_Boolean IsAFillet(const TopoDS_Edge& E) const;
0271 
0272   Standard_EXPORT Standard_Boolean IsAChamfer(const TopoDS_Edge& E) const;
0273 
0274   ChFi2d_ConstructionError     status;
0275   TopoDS_Face                  refFace;
0276   TopoDS_Face                  newFace;
0277   TopTools_SequenceOfShape     fillets;
0278   TopTools_SequenceOfShape     chamfers;
0279   TopTools_DataMapOfShapeShape history;
0280 };
0281 
0282 #include <ChFi2d_Builder.lxx>
0283 
0284 #endif // _ChFi2d_Builder_HeaderFile