Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:38

0001 // Created on: 1996-02-21
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1996-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 _Poly_PolygonOnTriangulation_HeaderFile
0018 #define _Poly_PolygonOnTriangulation_HeaderFile
0019 
0020 #include <Standard_NullObject.hxx>
0021 #include <Standard_Type.hxx>
0022 #include <Standard_Transient.hxx>
0023 #include <TColStd_Array1OfInteger.hxx>
0024 #include <TColStd_HArray1OfReal.hxx>
0025 
0026 DEFINE_STANDARD_HANDLE(Poly_PolygonOnTriangulation, Standard_Transient)
0027 
0028 //! This class provides a polygon in 3D space, based on the triangulation
0029 //! of a surface. It may be the approximate representation of a
0030 //! curve on the surface, or more generally the shape.
0031 //! A PolygonOnTriangulation is defined by a table of
0032 //! nodes. Each node is an index in the table of nodes specific
0033 //! to a triangulation, and represents a point on the surface. If
0034 //! the polygon is closed, the index of the point of closure is
0035 //! repeated at the end of the table of nodes.
0036 //! If the polygon is an approximate representation of a curve
0037 //! on a surface, you can associate with each of its nodes the
0038 //! value of the parameter of the corresponding point on the
0039 //! curve.represents a 3d Polygon
0040 class Poly_PolygonOnTriangulation : public Standard_Transient
0041 {
0042   DEFINE_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation, Standard_Transient)
0043 public:
0044 
0045   //! Constructs a 3D polygon on the triangulation of a shape with specified size of nodes.
0046   Standard_EXPORT Poly_PolygonOnTriangulation (const Standard_Integer theNbNodes,
0047                                                const Standard_Boolean theHasParams);
0048 
0049   //! Constructs a 3D polygon on the triangulation of a shape,
0050   //! defined by the table of nodes, <Nodes>.
0051   Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes);
0052 
0053   //! Constructs a 3D polygon on the triangulation of a shape, defined by:
0054   //! -   the table of nodes, Nodes, and the table of parameters, <Parameters>.
0055   //! where:
0056   //! -   a node value is an index in the table of nodes specific
0057   //! to an existing triangulation of a shape
0058   //! -   and a parameter value is the value of the parameter of
0059   //! the corresponding point on the curve approximated by
0060   //! the constructed polygon.
0061   //! Warning
0062   //! The tables Nodes and Parameters must be the same size.
0063   //! This property is not checked at construction time.
0064   Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes, const TColStd_Array1OfReal& Parameters);
0065 
0066   //! Creates a copy of current polygon
0067   Standard_EXPORT virtual Handle(Poly_PolygonOnTriangulation) Copy() const;
0068 
0069   //! Returns the deflection of this polygon
0070   Standard_Real Deflection() const { return myDeflection; }
0071 
0072   //! Sets the deflection of this polygon.
0073   //! See more on deflection in Poly_Polygones2D.
0074   void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
0075 
0076   //! Returns the number of nodes for this polygon.
0077   //! Note: If the polygon is closed, the point of closure is
0078   //! repeated at the end of its table of nodes. Thus, on a closed
0079   //! triangle, the function NbNodes returns 4.
0080   Standard_Integer NbNodes() const { return myNodes.Length(); }
0081 
0082   //! Returns node at the given index.
0083   Standard_Integer Node (Standard_Integer theIndex) const { return myNodes.Value (theIndex); }
0084 
0085   //! Sets node at the given index.
0086   void SetNode (Standard_Integer theIndex,
0087                 Standard_Integer theNode)
0088   {
0089     myNodes.SetValue (theIndex, theNode);
0090   }
0091 
0092   //! Returns true if parameters are associated with the nodes in this polygon.
0093   Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
0094 
0095   //! Returns parameter at the given index.
0096   Standard_Real Parameter (Standard_Integer theIndex) const
0097   {
0098     Standard_NullObject_Raise_if (myParameters.IsNull(), "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
0099     return myParameters->Value (theIndex);
0100   }
0101 
0102   //! Sets parameter at the given index.
0103   void SetParameter (Standard_Integer theIndex,
0104                      Standard_Real theValue)
0105   {
0106     Standard_NullObject_Raise_if (myParameters.IsNull(), "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
0107     myParameters->SetValue (theIndex, theValue);
0108   }
0109 
0110   //! Sets the table of the parameters associated with each node in this polygon.
0111   //! Raises exception if array size doesn't much number of polygon nodes.
0112   Standard_EXPORT void SetParameters (const Handle(TColStd_HArray1OfReal)& theParameters);
0113 
0114   //! Dumps the content of me into the stream
0115   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0116 
0117 public:
0118 
0119   //! Returns the table of nodes for this polygon.
0120   //! A node value is an index in the table of nodes specific to an existing triangulation of a shape.
0121   const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
0122 
0123   //! Returns the table of the parameters associated with each node in this polygon.
0124   //! Warning! Use the function HasParameters to check if parameters are associated with the nodes in this polygon.
0125   const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
0126 
0127   Standard_DEPRECATED("Deprecated method, SetNode() should be used instead")
0128   TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
0129 
0130   Standard_DEPRECATED("Deprecated method, SetParameter() should be used instead")
0131   TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
0132 
0133 private:
0134 
0135   Standard_Real myDeflection;
0136   TColStd_Array1OfInteger myNodes;
0137   Handle(TColStd_HArray1OfReal) myParameters;
0138 
0139 };
0140 
0141 #endif // _Poly_PolygonOnTriangulation_HeaderFile