]> OCCT Git - occt-copy.git/commitdiff
New Element() method was added at the level of Poly_Mesh class. This method is more...
authorssv <ssv@opencascade.com>
Thu, 2 Jul 2015 11:25:30 +0000 (14:25 +0300)
committerssv <ssv@opencascade.com>
Thu, 2 Jul 2015 11:25:30 +0000 (14:25 +0300)
src/Poly/Poly_Mesh.cxx
src/Poly/Poly_Mesh.hxx

index fdeedb5baa792fb0ab4aa3a002c1eac9c9bae77c..c8b1e6a235002a93dcd55b4f4709ff024a65a8c5 100644 (file)
@@ -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  :
index fd39114d4b0a4b59e7c9c4c1fc4cdcc44734d25b..ffcab8f73d690531c8b7f7b59fb72e7df1e07a57 100644 (file)
@@ -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.