]> OCCT Git - occt-copy.git/commitdiff
API has been changed to be more convenient (indices of nodes are passed)
authorssv <ssv@opencascade.com>
Wed, 1 Jul 2015 12:04:26 +0000 (15:04 +0300)
committerssv <ssv@opencascade.com>
Wed, 1 Jul 2015 12:04:26 +0000 (15:04 +0300)
src/Poly/Poly_Mesh.cxx
src/Poly/Poly_Mesh.hxx

index b4e75664ac1416557b5a0739c38480e0557c199f..fdeedb5baa792fb0ab4aa3a002c1eac9c9bae77c 100644 (file)
@@ -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();
+}
index c1bc5a7b25677f0a58a81d6f81061e78fce442d5..fd39114d4b0a4b59e7c9c4c1fc4cdcc44734d25b 100644 (file)
@@ -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<Poly_Element> myElements;