]> OCCT Git - occt-copy.git/commitdiff
0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal...
authorvro <vladislav.romashko@opencascade.com>
Mon, 15 Feb 2021 11:27:53 +0000 (14:27 +0300)
committervro <vladislav.romashko@opencascade.com>
Mon, 15 Feb 2021 11:27:53 +0000 (14:27 +0300)
// Fixed a twice-reverse of normals (revealed in bugs vis... tests).

src/Poly/Poly.cxx
src/Poly/Poly_CoherentTriangulation.cxx
src/Poly/Poly_Triangulation.hxx
src/RWObj/RWObj_TriangulationReader.cxx
src/Select3D/Select3D_SensitiveTriangulation.cxx
src/StdPrs/StdPrs_ShadedShape.cxx

index c163683aeeb1cb499e71acb5a0c83ca201a309de..3b0b98db01104337c8f6ae9de20e199d1ed85318 100644 (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);
index 82cf42f4b466882b7b08f28ac5f009434510811a..4123041c504524951ca3cb2e28db76fc69784de2 100644 (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())
index 7b0c8eb2d2c143c25488f25b193bf3e43ecbaac5..a5cc885b17bb08eb5294512031a229aa7c3c4da4 100644 (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.
index 912dce87fea34cfee28327d754969e1c69f01398..c4ef86170db96db47cffd0c6b6b5884535d11619 100644 (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());
     }
   }
 
index 3a7631404a3ef7d6469bc23b2b0ba36cd69acac1..c611974c2122c6dd4492e7feaf9c7ec38fbe3506 100644 (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)
index 2ba10dcc7c069258282cd573ace5e482114faea0..a434c61daacff9d4203e733a54e2d4e534232331 100644 (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)