From: ssv Date: Thu, 2 Jul 2015 11:25:30 +0000 (+0300) Subject: New Element() method was added at the level of Poly_Mesh class. This method is more... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=62317aefeebf74e20da8e79ebd0b97d7f1bdf4b9;p=occt-copy.git New Element() method was added at the level of Poly_Mesh class. This method is more convenient than direct accessing of Poly_Element structures with low-level treatment of its internal triangles. Moreover, the new method encapsulates the conventional order of nodes in the pair of triangles composing a quad. --- diff --git a/src/Poly/Poly_Mesh.cxx b/src/Poly/Poly_Mesh.cxx index fdeedb5baa..c8b1e6a235 100644 --- a/src/Poly/Poly_Mesh.cxx +++ b/src/Poly/Poly_Mesh.cxx @@ -61,13 +61,42 @@ Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1, //purpose : //======================================================================= -const Poly_Element& Poly_Mesh::Element (const Standard_Integer theIndex) +const Poly_Element& Poly_Mesh::Element (const Standard_Integer theIndex) const { Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myElements.Size(), "Poly_Element::Element : index out of range"); return myElements.Value (theIndex - 1); } +//======================================================================= +//function : Element +//purpose : +//======================================================================= + +void Poly_Mesh::Element (const Standard_Integer theIndex, + Standard_Integer& theN1, + Standard_Integer& theN2, + Standard_Integer& theN3, + Standard_Integer& theN4) const +{ + const Poly_Element& anElem = Element(theIndex); + Standard_Integer aTriIdx1, aTriIdx2; + anElem.Get(aTriIdx1, aTriIdx2); + + // Get node indices for the first triangle + const Poly_Triangle& aTri1 = Poly_Triangulation::Triangle(aTriIdx1); + aTri1.Get(theN1, theN2, theN3); + + // If the second triangle exists, take its node indices for quad + if (aTriIdx2) + { + const Poly_Triangle& aTri2 = Poly_Triangulation::Triangle(aTriIdx2); + aTri2.Get(theN1, theN3, theN4); + } + else + theN4 = 0; +} + //======================================================================= //function : SetElement //purpose : diff --git a/src/Poly/Poly_Mesh.hxx b/src/Poly/Poly_Mesh.hxx index fd39114d4b..ffcab8f73d 100644 --- a/src/Poly/Poly_Mesh.hxx +++ b/src/Poly/Poly_Mesh.hxx @@ -59,7 +59,15 @@ public: //! @return element at the given index. //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements. - Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex); + Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const; + + //! @return nodes of the element at the given index. + //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements. + Standard_EXPORT void Element (const Standard_Integer theIndex, + Standard_Integer& theN1, + Standard_Integer& theN2, + Standard_Integer& theN3, + Standard_Integer& theN4) const; //! Give access to the element at the given index. //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.