DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0023762

Way of getting normals from Poly_Triangulation is inconvenient

Open CASCADEOCCT:Foundation Classesclosed1 public note

Search issues

Description

The current implementation of Poly_Triangulation::Normals() looks heavy and inconvenient:
const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
{

  if(myNormals.IsNull() || myNormals->Length() != 3*myNbNodes) {
    Standard_NullObject::Raise("Poly_Triangulation::Normals : "
                               "wrong length or null array");
  }

  return myNormals->Array1();
}


1. Why return a const reference to the internal array instead of returning myNormals directly?
2. Throwing an exception in case if normals data is not available requires special tricks or code duplication in order to write the conditional code that works both when normals are present and when they are not.
3. What is the purpose of Poly_Triangulation::ChangeNormals()? Why provide access to internal array of myNormals instead of simply returning myNormals itself and letting the applications decide what to do with it?

It is proposed to return myNormals in Poly_Trinagulation::Normals() and remove consistency checks leaving them to the applications that can e.g. use Poly_Triangulation::HasNormals() for this purpose. Poly_Trinagulation::ChangeNormals() is most likely to be removed, too. Normals() and SetNormals() methods seem sufficient.

Public activity

1 archived note

Participants are labeled by their role within this record.

01Commenter 2
#0026007 introduced Poly_Triangulation::Normal()/Poly_Triangulation::SetNormal() methods for accessing per-vertex normal values, and #0032133 deprecated access to internal array of normals (as well as to other internal arrays).

Therefore, I propose closing this issues.

Related records