Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:14:04

0001 // Created on: 1993-07-19
0002 // Created by: Remi LEQUETTE
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 _BRepTools_ShapeSet_HeaderFile
0018 #define _BRepTools_ShapeSet_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <BRep_Builder.hxx>
0025 #include <GeomTools_SurfaceSet.hxx>
0026 #include <GeomTools_CurveSet.hxx>
0027 #include <GeomTools_Curve2dSet.hxx>
0028 #include <Standard_Transient.hxx>
0029 #include <NCollection_IndexedMap.hxx>
0030 #include <TopTools_ShapeSet.hxx>
0031 #include <Standard_OStream.hxx>
0032 #include <Standard_IStream.hxx>
0033 #include <TopAbs_ShapeEnum.hxx>
0034 
0035 class TopoDS_Shape;
0036 
0037 //! Contains a Shape and all its subshapes, locations
0038 //! and geometries.
0039 //!
0040 //! The topology is inherited from TopTools.
0041 class BRepTools_ShapeSet : public TopTools_ShapeSet
0042 {
0043 public:
0044   DEFINE_STANDARD_ALLOC
0045 
0046   //! Builds an empty ShapeSet.
0047   //! @param theWithTriangles flag to write triangulation data
0048   Standard_EXPORT BRepTools_ShapeSet(const bool theWithTriangles = true,
0049                                      const bool theWithNormals   = false);
0050 
0051   //! Builds an empty ShapeSet.
0052   //! @param theWithTriangles flag to write triangulation data
0053   Standard_EXPORT BRepTools_ShapeSet(const BRep_Builder& theBuilder,
0054                                      const bool          theWithTriangles = true,
0055                                      const bool          theWithNormals   = false);
0056 
0057   Standard_EXPORT ~BRepTools_ShapeSet() override;
0058 
0059   //! Return true if shape should be stored with triangles.
0060   bool IsWithTriangles() const { return myWithTriangles; }
0061 
0062   //! Return true if shape should be stored triangulation with normals.
0063   bool IsWithNormals() const { return myWithNormals; }
0064 
0065   //! Define if shape will be stored with triangles.
0066   //! Ignored (always written) if face defines only triangulation (no surface).
0067   void SetWithTriangles(const bool theWithTriangles) { myWithTriangles = theWithTriangles; }
0068 
0069   //! Define if shape will be stored triangulation with normals.
0070   //! Ignored (always written) if face defines only triangulation (no surface).
0071   void SetWithNormals(const bool theWithNormals) { myWithNormals = theWithNormals; }
0072 
0073   //! Clears the content of the set.
0074   Standard_EXPORT void Clear() override;
0075 
0076   //! Stores the geometry of <S>.
0077   Standard_EXPORT void AddGeometry(const TopoDS_Shape& S) override;
0078 
0079   //! Dumps the geometry of me on the stream <OS>.
0080   Standard_EXPORT void DumpGeometry(Standard_OStream& OS) const override;
0081 
0082   //! Writes the geometry of me on the stream <OS> in a
0083   //! format that can be read back by Read.
0084   Standard_EXPORT void WriteGeometry(
0085     Standard_OStream&            OS,
0086     const Message_ProgressRange& theProgress = Message_ProgressRange()) override;
0087 
0088   //! Reads the geometry of me from the stream <IS>.
0089   Standard_EXPORT void ReadGeometry(
0090     Standard_IStream&            IS,
0091     const Message_ProgressRange& theProgress = Message_ProgressRange()) override;
0092 
0093   //! Dumps the geometry of <S> on the stream <OS>.
0094   Standard_EXPORT void DumpGeometry(const TopoDS_Shape& S, Standard_OStream& OS) const override;
0095 
0096   //! Writes the geometry of <S> on the stream <OS> in a
0097   //! format that can be read back by Read.
0098   Standard_EXPORT void WriteGeometry(const TopoDS_Shape& S, Standard_OStream& OS) const override;
0099 
0100   //! Reads the geometry of a shape of type <T> from the
0101   //! stream <IS> and returns it in <S>.
0102   Standard_EXPORT void ReadGeometry(const TopAbs_ShapeEnum T,
0103                                     Standard_IStream&      IS,
0104                                     TopoDS_Shape&          S) override;
0105 
0106   //! Inserts the shape <S2> in the shape <S1>. This
0107   //! method must be redefined to use the correct
0108   //! builder.
0109   Standard_EXPORT void AddShapes(TopoDS_Shape& S1, const TopoDS_Shape& S2) override;
0110 
0111   Standard_EXPORT void Check(const TopAbs_ShapeEnum T, TopoDS_Shape& S) override;
0112 
0113   //! Reads the 3d polygons of me
0114   //! from the stream <IS>.
0115   Standard_EXPORT void ReadPolygon3D(
0116     Standard_IStream&            IS,
0117     const Message_ProgressRange& theProgress = Message_ProgressRange());
0118 
0119   //! Writes the 3d polygons
0120   //! on the stream <OS> in a format that can
0121   //! be read back by Read.
0122   Standard_EXPORT void WritePolygon3D(
0123     Standard_OStream&            OS,
0124     const bool                   Compact     = true,
0125     const Message_ProgressRange& theProgress = Message_ProgressRange()) const;
0126 
0127   //! Dumps the 3d polygons
0128   //! on the stream <OS>.
0129   Standard_EXPORT void DumpPolygon3D(Standard_OStream& OS) const;
0130 
0131   //! Reads the triangulation of me
0132   //! from the stream <IS>.
0133   Standard_EXPORT void ReadTriangulation(
0134     Standard_IStream&            IS,
0135     const Message_ProgressRange& theProgress = Message_ProgressRange());
0136 
0137   //! Writes the triangulation
0138   //! on the stream <OS> in a format that can
0139   //! be read back by Read.
0140   Standard_EXPORT void WriteTriangulation(
0141     Standard_OStream&            OS,
0142     const bool                   Compact     = true,
0143     const Message_ProgressRange& theProgress = Message_ProgressRange()) const;
0144 
0145   //! Dumps the triangulation
0146   //! on the stream <OS>.
0147   Standard_EXPORT void DumpTriangulation(Standard_OStream& OS) const;
0148 
0149   //! Reads the polygons on triangulation of me
0150   //! from the stream <IS>.
0151   Standard_EXPORT void ReadPolygonOnTriangulation(
0152     Standard_IStream&            IS,
0153     const Message_ProgressRange& theProgress = Message_ProgressRange());
0154 
0155   //! Writes the polygons on triangulation
0156   //! on the stream <OS> in a format that can
0157   //! be read back by Read.
0158   Standard_EXPORT void WritePolygonOnTriangulation(
0159     Standard_OStream&            OS,
0160     const bool                   Compact     = true,
0161     const Message_ProgressRange& theProgress = Message_ProgressRange()) const;
0162 
0163   //! Dumps the polygons on triangulation
0164   //! on the stream <OS>.
0165   Standard_EXPORT void DumpPolygonOnTriangulation(Standard_OStream& OS) const;
0166 
0167 private:
0168   BRep_Builder                                            myBuilder;
0169   GeomTools_SurfaceSet                                    mySurfaces;
0170   GeomTools_CurveSet                                      myCurves;
0171   GeomTools_Curve2dSet                                    myCurves2d;
0172   NCollection_IndexedMap<occ::handle<Standard_Transient>> myPolygons2D;
0173   NCollection_IndexedMap<occ::handle<Standard_Transient>> myPolygons3D;
0174   NCollection_IndexedDataMap<occ::handle<Poly_Triangulation>,
0175                              // clang-format off
0176                              bool> myTriangulations; //!< Contains a boolean flag with information
0177                                                                  //!  to save normals for triangulation
0178   // clang-format on
0179   NCollection_IndexedMap<occ::handle<Standard_Transient>> myNodes;
0180   bool                                                    myWithTriangles;
0181   bool                                                    myWithNormals;
0182 };
0183 
0184 #endif // _BRepTools_ShapeSet_HeaderFile