1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

API has been changed to be more convenient (indices of nodes are passed)

This commit is contained in:
ssv
2015-07-01 15:04:26 +03:00
parent 6c1f47fd0f
commit fa9fbda259
2 changed files with 50 additions and 15 deletions

View 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();
}

View 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;