myNbQuads (0)
{}
+//=======================================================================
+//function : Poly_Mesh
+//purpose :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
+: Poly_Triangulation ( theTriangulation->NbNodes(),
+ theTriangulation->NbTriangles(),
+ theTriangulation->HasUVNodes() ),
+ myNbQuads (0)
+{
+ // Copy nodes
+ const Standard_Boolean hasUV = theTriangulation->HasUVNodes();
+ for ( Standard_Integer i = 1; i <= theTriangulation->NbNodes(); ++i )
+ {
+ Poly_Triangulation::ChangeNode(i) = theTriangulation->Node(i);
+
+ if ( hasUV )
+ Poly_Triangulation::ChangeUVNode(i) = theTriangulation->UVNode(i);
+ }
+
+ // Populate elements
+ const Standard_Boolean hasNormals = theTriangulation->HasNormals();
+ Standard_Integer aN1, aN2, aN3;
+ for ( Standard_Integer i = 1; i <= theTriangulation->NbTriangles(); ++i )
+ {
+ const Poly_Triangle& aNewTri = theTriangulation->Triangle(i);
+ Poly_Triangle& aTri = Poly_Triangulation::ChangeTriangle(i);
+
+ // Copy node indices to the new triangle
+ aNewTri.Get(aN1, aN2, aN3);
+ aTri.Set(aN1, aN2, aN3);
+
+ // Add element to mesh
+ addElement( Poly_Element(i, 0) );
+
+ // Pass normal vector (if any)
+ if ( hasNormals )
+ Poly_Triangulation::SetNormal( i, theTriangulation->Normal(i) );
+ }
+
+ // Set deflection
+ Poly_Triangulation::Deflection( theTriangulation->Deflection() );
+}
+
//=======================================================================
//function : AddElement
//purpose :
const Standard_Integer theN2,
const Standard_Integer theN3)
{
- Standard_Integer anIndex = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN2, theN3) );
+ Standard_Integer anIndex = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN2, theN3) );
return addElement( Poly_Element(anIndex, 0) );
}
const Standard_Integer theN3,
const Standard_Integer theN4)
{
- Standard_Integer anIndex1 = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN2, theN3) );
- Standard_Integer anIndex2 = Poly_Triangulation::AddTriangle ( Poly_Triangle(theN1, theN3, theN4) );
+ 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) );
}
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);
+ Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > myElements.Size(),
+ "Poly_Element::Element : index out of range");
+ return myElements.Value(theIndex - 1);
}
//=======================================================================
void Poly_Mesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
{
- Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myElements.Size(),
- "Poly_Element::SetElement : index out of range");
+ Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > myElements.Size(),
+ "Poly_Element::SetElement : index out of range");
- if (myElements.Value (theIndex - 1).Value (2) == 0 && theElement.Value (2) != 0)
+ if (myElements.Value(theIndex - 1).Value(2) == 0 && theElement.Value(2) != 0)
{
myNbQuads++;
}
- else if (myElements.Value (theIndex - 1).Value (2) != 0 && theElement.Value (2) == 0)
+ else if (myElements.Value(theIndex - 1).Value(2) != 0 && theElement.Value(2) == 0)
{
myNbQuads--;
}
- myElements.SetValue (theIndex - 1, theElement);
+ myElements.SetValue(theIndex - 1, theElement);
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Integer Poly_Mesh::addElement (const Poly_Element& theElement)
+Standard_Integer Poly_Mesh::addElement(const Poly_Element& theElement)
{
- myElements.Append (theElement);
- if (theElement.Value (2) != 0)
+ myElements.Append(theElement);
+ if (theElement.Value(2) != 0)
{
myNbQuads++;
}