1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal mesh)

// Fixed a twice-reverse of normals (revealed in bugs vis... tests).
This commit is contained in:
vro
2021-02-15 14:27:53 +03:00
parent b0b103c05c
commit fd76595d64
6 changed files with 14 additions and 17 deletions

View File

@@ -480,7 +480,6 @@ void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
}
// Normalize all vectors
gp_Dir aNormal;
gp_XYZ aNormXYZ;
for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
{
@@ -488,9 +487,13 @@ void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
const Standard_Real aMod2 = aNormXYZ.SquareModulus();
if (aMod2 > anEps2)
aNormal = aNormXYZ;
{
aNormXYZ /= Sqrt (aMod2);
}
else
aNormal = gp::DZ();
{
aNormXYZ = gp::DZ().XYZ();
}
// Set normal.
theTri->SetNormal (aNodeIter + 1, aNormXYZ);

View File

@@ -126,6 +126,8 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
if (aNode.IsFreeNode())
vecNodeId.SetValue(i, 0);
else {
vecNodeId.SetValue(i, ++aCount);
const gp_XYZ aNormal = aNode.GetNormal();
if (aNormal.SquareModulus() > Precision::Confusion()) {
aResult->SetNormal (aCount, static_cast<Standard_ShortReal>(aNormal.X()),
@@ -133,9 +135,7 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
static_cast<Standard_ShortReal>(aNormal.Z()));
}
vecNodeId.SetValue(i, ++aCount);
aResult->ChangeNode (aCount) = aNode;
aResult->ChangeUVNode (aCount) = gp_Pnt2d (aNode.GetU(), aNode.GetV());
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
Precision::Confusion())

View File

@@ -188,7 +188,7 @@ public:
const Vec3f& theNormal)
{
// If an array for normals is not allocated yet, do it now.
if (myNormals.IsEmpty())
if (myNormals.IsEmpty() || myNormals.Size() != myNodes.Size())
myNormals.Resize (1, myNodes.Size(), Standard_False);
// Set a normal.

View File

@@ -179,7 +179,6 @@ Handle(Poly_Triangulation) RWObj_TriangulationReader::GetTriangulation()
{
aPoly->SetNormal (aNodeIter + 1, 0.0f, 0.0f, 1.0f);
}
aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
}
}

View File

@@ -111,9 +111,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
myBndBox.Clear();
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
{
myBndBox.Add (SelectMgr_Vec3 (myTriangul->Node (aNodeIdx).X(),
myTriangul->Node (aNodeIdx).Y(),
myTriangul->Node (aNodeIdx).Z()));
const gp_Pnt& aNode = myTriangul->Node (aNodeIdx);
myBndBox.Add (SelectMgr_Vec3 (aNode.X(), aNode.Y(), aNode.Z()));
}
if (theIsInterior)

View File

@@ -205,10 +205,6 @@ namespace
{
aPoint = aT->Node (aNodeIter);
gp_Dir aNorm = aNormals (aNodeIter);
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aNorm.Reverse();
}
if (!aLoc.IsIdentity())
{
aPoint.Transform (aTrsf);
@@ -242,9 +238,9 @@ namespace
aT->Triangle (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
}
gp_Pnt aP1 = aT->Node (anIndex[0]);
gp_Pnt aP2 = aT->Node (anIndex[1]);
gp_Pnt aP3 = aT->Node (anIndex[2]);
const gp_Pnt& aP1 = aT->Node (anIndex[0]);
const gp_Pnt& aP2 = aT->Node (anIndex[1]);
const gp_Pnt& aP3 = aT->Node (anIndex[2]);
gp_Vec aV1 (aP1, aP2);
if (aV1.SquareMagnitude() <= aPreci)