From fa9fbda259b7bb4a0dcd6dde259ff7ad36ad66e4 Mon Sep 17 00:00:00 2001 From: ssv Date: Wed, 1 Jul 2015 15:04:26 +0300 Subject: [PATCH] API has been changed to be more convenient (indices of nodes are passed) --- src/Poly/Poly_Mesh.cxx | 39 ++++++++++++++++++++++++++++----------- src/Poly/Poly_Mesh.hxx | 26 ++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/Poly/Poly_Mesh.cxx b/src/Poly/Poly_Mesh.cxx index b4e75664ac..fdeedb5baa 100644 --- a/src/Poly/Poly_Mesh.cxx +++ b/src/Poly/Poly_Mesh.cxx @@ -29,14 +29,16 @@ Poly_Mesh::Poly_Mesh (const Standard_Boolean theHasUVNodes) {} //======================================================================= -//function : AddTriangle +//function : AddElement //purpose : //======================================================================= -Standard_Integer Poly_Mesh::AddTriangle (const Poly_Triangle& theTriangle) +Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1, + const Standard_Integer theN2, + const Standard_Integer theN3) { - Standard_Integer anIndex = Poly_Triangulation::AddTriangle (theTriangle); - return AddElement (Poly_Element (anIndex, 0)); + Standard_Integer anIndex = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN2, theN3) ); + return addElement( Poly_Element(anIndex, 0) ); } //======================================================================= @@ -44,14 +46,14 @@ Standard_Integer Poly_Mesh::AddTriangle (const Poly_Triangle& theTriangle) //purpose : //======================================================================= -Standard_Integer Poly_Mesh::AddElement (const Poly_Element& theElement) +Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1, + const Standard_Integer theN2, + const Standard_Integer theN3, + const Standard_Integer theN4) { - myElements.Append (theElement); - if (theElement.Value (2) != 0) - { - myNbQuads++; - } - return myElements.Size(); + Standard_Integer anIndex1 = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN2, theN3) ); + Standard_Integer anIndex2 = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN3, theN4) ); + return addElement( Poly_Element(anIndex1, anIndex2) ); } //======================================================================= @@ -87,3 +89,18 @@ void Poly_Mesh::SetElement (const Standard_Integer theIndex, const Poly_Element& myElements.SetValue (theIndex - 1, theElement); } + +//======================================================================= +//function : addElement +//purpose : +//======================================================================= + +Standard_Integer Poly_Mesh::addElement (const Poly_Element& theElement) +{ + myElements.Append (theElement); + if (theElement.Value (2) != 0) + { + myNbQuads++; + } + return myElements.Size(); +} diff --git a/src/Poly/Poly_Mesh.hxx b/src/Poly/Poly_Mesh.hxx index c1bc5a7b25..fd39114d4b 100644 --- a/src/Poly/Poly_Mesh.hxx +++ b/src/Poly/Poly_Mesh.hxx @@ -31,14 +31,25 @@ public: //! theHasUVNodes flag indicates whether 2D nodes will be associated with 3D ones, (i.e. to enable a 2D representation). Standard_EXPORT Poly_Mesh (const Standard_Boolean theHasUVNodes = Standard_False); - //! Adds triangle to the mesh. + //! Adds element to the mesh. + //! @param theN1 index of the first node. + //! @param theN2 index of the second node. + //! @param theN3 index of the third node. //! @return index of the added element. - Standard_EXPORT Standard_Integer AddTriangle (const Poly_Triangle& theTriangle) Standard_OVERRIDE; + Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1, + const Standard_Integer theN2, + const Standard_Integer theN3); //! Adds element to the mesh. + //! @param theN1 index of the first node. + //! @param theN2 index of the second node. + //! @param theN3 index of the third node. + //! @param theN4 index of the fourth node. //! @return index of the added element. - //! Raises exception if at least one of the element indices is less than 1 or greater than NbTriangles. - Standard_EXPORT Standard_Integer AddElement (const Poly_Element& theElement); + Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1, + const Standard_Integer theN2, + const Standard_Integer theN3, + const Standard_Integer theN4); //! @return the number of elements for this mesh. Standard_Integer NbElements() const { return myElements.Size(); } @@ -54,6 +65,13 @@ public: //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements. Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement); +protected: + + //! Adds element to the mesh. + //! @param theElement element to add. + //! @return index of the added element. + Standard_EXPORT Standard_Integer addElement (const Poly_Element& theElement); + private: NCollection_Vector myElements; -- 2.39.5