Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:22:21

0001 // Created on: 2016-11-10
0002 // Created by: Anton KOZULIN
0003 // Copyright (c) 2016 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _TDataXtd_Triangulation_HeaderFile
0017 #define _TDataXtd_Triangulation_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 
0021 #include <Poly_Triangulation.hxx>
0022 #include <TDF_Attribute.hxx>
0023 #include <Standard_Integer.hxx>
0024 #include <Standard_OStream.hxx>
0025 class Standard_GUID;
0026 class TDF_Label;
0027 class TDF_RelocationTable;
0028 
0029 //! An Ocaf attribute containing a mesh (Poly_Triangulation).
0030 //! It duplicates all methods from Poly_Triangulation.
0031 //! It is highly recommended to modify the mesh through the methods of this attribute,
0032 //! but not directly via the underlying Poly_Triangulation object.
0033 //! In this case Undo/Redo will work fine and robust.
0034 class TDataXtd_Triangulation : public TDF_Attribute
0035 {
0036 public:
0037   //! Static methods
0038   //  ==============
0039 
0040   //! Returns the ID of the triangulation attribute.
0041   Standard_EXPORT static const Standard_GUID& GetID();
0042 
0043   //! Finds or creates a triangulation attribute.
0044   Standard_EXPORT static occ::handle<TDataXtd_Triangulation> Set(const TDF_Label& theLabel);
0045 
0046   //! Finds or creates a triangulation attribute.
0047   //! Initializes the attribute by a Poly_Triangulation object.
0048   Standard_EXPORT static occ::handle<TDataXtd_Triangulation> Set(
0049     const TDF_Label&                       theLabel,
0050     const occ::handle<Poly_Triangulation>& theTriangulation);
0051 
0052   //! Object methods
0053   //  ==============
0054 
0055   //! A constructor.
0056   //! Don't use it directly,
0057   //! use please the static method Set(),
0058   //! which returns the attribute attached to a label.
0059   Standard_EXPORT TDataXtd_Triangulation();
0060 
0061   //! Sets the triangulation.
0062   Standard_EXPORT void Set(const occ::handle<Poly_Triangulation>& theTriangulation);
0063 
0064   //! Returns the underlying triangulation.
0065   Standard_EXPORT const occ::handle<Poly_Triangulation>& Get() const;
0066 
0067   //! Poly_Triangulation methods
0068   //  =================
0069 
0070   //! The methods are "covered" by this attribute to prevent direct modification of the mesh.
0071   //! There is no performance problem to call Poly_Triangulation method through this attribute.
0072   //! The most of the methods are considered as "inline" by the compiler in release mode.
0073 
0074   //! Returns the deflection of this triangulation.
0075   Standard_EXPORT double Deflection() const;
0076 
0077   //! Sets the deflection of this triangulation to theDeflection.
0078   //! See more on deflection in Polygon2D
0079   Standard_EXPORT void Deflection(const double theDeflection);
0080 
0081   //! Deallocates the UV nodes.
0082   Standard_EXPORT void RemoveUVNodes();
0083 
0084   //! @return the number of nodes for this triangulation.
0085   Standard_EXPORT int NbNodes() const;
0086 
0087   //! @return the number of triangles for this triangulation.
0088   Standard_EXPORT int NbTriangles() const;
0089 
0090   //! @return true if 2D nodes are associated with 3D nodes for this triangulation.
0091   Standard_EXPORT bool HasUVNodes() const;
0092 
0093   //! @return node at the given index.
0094   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0095   Standard_EXPORT gp_Pnt Node(const int theIndex) const;
0096 
0097   //! The method differs from Poly_Triangulation!
0098   //! Sets a node at the given index.
0099   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0100   Standard_EXPORT void SetNode(const int theIndex, const gp_Pnt& theNode);
0101 
0102   //! @return UVNode at the given index.
0103   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0104   Standard_EXPORT gp_Pnt2d UVNode(const int theIndex) const;
0105 
0106   //! The method differs from Poly_Triangulation!
0107   //! Sets a UVNode at the given index.
0108   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0109   Standard_EXPORT void SetUVNode(const int theIndex, const gp_Pnt2d& theUVNode);
0110 
0111   //! @return triangle at the given index.
0112   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
0113   Standard_EXPORT Poly_Triangle Triangle(const int theIndex) const;
0114 
0115   //! The method differs from Poly_Triangulation!
0116   //! Sets a triangle at the given index.
0117   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
0118   Standard_EXPORT void SetTriangle(const int theIndex, const Poly_Triangle& theTriangle);
0119 
0120   //! Changes normal at the given index.
0121   //! Raises Standard_OutOfRange exception.
0122   Standard_EXPORT void SetNormal(const int theIndex, const gp_Dir& theNormal);
0123 
0124   //! Returns true if nodal normals are defined.
0125   Standard_EXPORT bool HasNormals() const;
0126 
0127   //! @return normal at the given index.
0128   //! Raises Standard_OutOfRange exception.
0129   Standard_EXPORT gp_Dir Normal(const int theIndex) const;
0130 
0131   //! Inherited attribute methods
0132   //  ===========================
0133 
0134   Standard_EXPORT const Standard_GUID& ID() const override;
0135 
0136   Standard_EXPORT void Restore(const occ::handle<TDF_Attribute>& theAttribute) override;
0137 
0138   Standard_EXPORT occ::handle<TDF_Attribute> NewEmpty() const override;
0139 
0140   Standard_EXPORT void Paste(const occ::handle<TDF_Attribute>&       Into,
0141                              const occ::handle<TDF_RelocationTable>& RT) const override;
0142 
0143   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& anOS) const override;
0144 
0145   DEFINE_STANDARD_RTTI_INLINE(TDataXtd_Triangulation, TDF_Attribute)
0146 
0147 private:
0148   occ::handle<Poly_Triangulation> myTriangulation;
0149 };
0150 
0151 #endif // _TDataXtd_Triangulation_HeaderFile