Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:20

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 class TDataXtd_Triangulation;
0030 DEFINE_STANDARD_HANDLE(TDataXtd_Triangulation, TDF_Attribute)
0031 
0032 //! An Ocaf attribute containing a mesh (Poly_Triangulation).
0033 //! It duplicates all methods from Poly_Triangulation.
0034 //! It is highly recommended to modify the mesh through the methods of this attribute,
0035 //! but not directly via the underlying Poly_Triangulation object.
0036 //! In this case Undo/Redo will work fine and robust.
0037 class TDataXtd_Triangulation : public TDF_Attribute
0038 {
0039 public:
0040 
0041   //! Static methods
0042   //  ==============
0043 
0044   //! Returns the ID of the triangulation attribute.
0045   Standard_EXPORT static const Standard_GUID& GetID();
0046   
0047   //! Finds or creates a triangulation attribute.
0048   Standard_EXPORT static Handle(TDataXtd_Triangulation) Set(const TDF_Label& theLabel);
0049 
0050   //! Finds or creates a triangulation attribute.
0051   //! Initializes the attribute by a Poly_Triangulation object.
0052   Standard_EXPORT static Handle(TDataXtd_Triangulation) Set(const TDF_Label& theLabel, const Handle(Poly_Triangulation)& theTriangulation);
0053 
0054   //! Object methods
0055   //  ==============
0056 
0057   //! A constructor.
0058   //! Don't use it directly, 
0059   //! use please the static method Set(),
0060   //! which returns the attribute attached to a label.
0061   Standard_EXPORT TDataXtd_Triangulation();
0062 
0063   //! Sets the triangulation.
0064   Standard_EXPORT void Set(const Handle(Poly_Triangulation)& theTriangulation);
0065 
0066   //! Returns the underlying triangulation.
0067   Standard_EXPORT const Handle(Poly_Triangulation)& Get() const;
0068 
0069 
0070   //! Poly_Triangulation methods
0071   //  =================
0072 
0073   //! The methods are "covered" by this attribute to prevent direct modification of the mesh.
0074   //! There is no performance problem to call Poly_Triangulation method through this attribute.
0075   //! The most of the methods are considered as "inline" by the compiler in release mode.
0076 
0077   //! Returns the deflection of this triangulation.
0078   Standard_EXPORT Standard_Real Deflection() const;
0079 
0080   //! Sets the deflection of this triangulation to theDeflection.
0081   //! See more on deflection in Polygon2D
0082   Standard_EXPORT void Deflection (const Standard_Real theDeflection);
0083 
0084   //! Deallocates the UV nodes.
0085   Standard_EXPORT void RemoveUVNodes();
0086 
0087   //! @return the number of nodes for this triangulation.
0088   Standard_EXPORT Standard_Integer NbNodes() const;
0089 
0090   //! @return the number of triangles for this triangulation.
0091   Standard_EXPORT Standard_Integer NbTriangles() const;
0092 
0093   //! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
0094   Standard_EXPORT Standard_Boolean HasUVNodes() const;
0095 
0096   //! @return node at the given index.
0097   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0098   Standard_EXPORT gp_Pnt Node (const Standard_Integer theIndex) const;
0099 
0100   //! The method differs from Poly_Triangulation!
0101   //! Sets a node at the given index.
0102   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0103   Standard_EXPORT void SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode);
0104 
0105   //! @return UVNode at the given index.
0106   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0107   Standard_EXPORT gp_Pnt2d UVNode (const Standard_Integer theIndex) const;
0108 
0109   //! The method differs from Poly_Triangulation!
0110   //! Sets a UVNode at the given index.
0111   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
0112   Standard_EXPORT void SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode);
0113 
0114   //! @return triangle at the given index.
0115   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
0116   Standard_EXPORT Poly_Triangle Triangle (const Standard_Integer theIndex) const;
0117 
0118   //! The method differs from Poly_Triangulation!
0119   //! Sets a triangle at the given index.
0120   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
0121   Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
0122 
0123   //! Changes normal at the given index.
0124   //! Raises Standard_OutOfRange exception.
0125   Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
0126                                   const gp_Dir&          theNormal);
0127 
0128   //! Returns Standard_True if nodal normals are defined.
0129   Standard_EXPORT Standard_Boolean HasNormals() const;
0130 
0131   //! @return normal at the given index.
0132   //! Raises Standard_OutOfRange exception.
0133   Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
0134 
0135   //! Inherited attribute methods
0136   //  ===========================
0137 
0138   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0139 
0140   Standard_EXPORT void Restore (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
0141 
0142   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0143 
0144   Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
0145 
0146   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
0147 
0148   DEFINE_STANDARD_RTTI_INLINE(TDataXtd_Triangulation,TDF_Attribute)
0149 
0150 private:
0151 
0152   Handle(Poly_Triangulation) myTriangulation;
0153 };
0154 
0155 #endif // _TDataXtd_Triangulation_HeaderFile