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