]> 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, 8 Feb 2021 14:36:34 +0000 (17:36 +0300)
committervro <vladislav.romashko@opencascade.com>
Mon, 8 Feb 2021 14:36:34 +0000 (17:36 +0300)
// Recompilation of IFC external library

77 files changed:
src/AIS/AIS_Manipulator.cxx
src/AIS/AIS_Triangulation.cxx
src/BRepBndLib/BRepBndLib.cxx
src/BRepBndLib/BRepBndLib_1.cxx
src/BRepCheck/BRepCheck_Edge.cxx
src/BRepExtrema/BRepExtrema_Poly.cxx
src/BRepExtrema/BRepExtrema_TriangleSet.cxx
src/BRepGProp/BRepGProp_MeshCinert.cxx
src/BRepGProp/BRepGProp_MeshProps.cxx
src/BRepGProp/BRepGProp_MeshProps.hxx
src/BRepLib/BRepLib.cxx
src/BRepMesh/BRepMesh_BaseMeshAlgo.cxx
src/BRepMesh/BRepMesh_EdgeTessellationExtractor.cxx
src/BRepMesh/BRepMesh_EdgeTessellationExtractor.hxx
src/BRepMesh/BRepMesh_ModelPreProcessor.cxx
src/BRepMesh/BRepMesh_ShapeTool.cxx
src/BRepTools/BRepTools_Modification.cxx
src/BRepTools/BRepTools_ShapeSet.cxx
src/BRepTools/BRepTools_ShapeSet.hxx
src/BinMDataXtd/BinMDataXtd.cxx
src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.cxx [new file with mode: 0644]
src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.hxx [new file with mode: 0644]
src/BinMDataXtd/BinMDataXtd_TriangulationDriver.cxx
src/BinMDataXtd/FILES
src/BinTools/BinTools_ShapeSet.cxx
src/DBRep/DBRep_DrawableShape.cxx
src/DDataStd/DDataStd_BasicCommands.cxx
src/DrawTrSurf/DrawTrSurf_Triangulation.cxx
src/DrawTrSurf/DrawTrSurf_Triangulation2D.cxx
src/HLRBRep/HLRBRep_PolyAlgo.cxx
src/IVtkOCC/IVtkOCC_ShapeMesher.cxx
src/MeshTest/MeshTest.cxx
src/MeshTest/MeshTest_CheckTopology.cxx
src/MeshTest/MeshTest_PluginCommands.cxx
src/Poly/FILES
src/Poly/Poly.cxx
src/Poly/Poly_CoherentTriangulation.cxx
src/Poly/Poly_Connect.cxx
src/Poly/Poly_PolygonOnTriangulation.cxx
src/Poly/Poly_PolygonOnTriangulation.hxx
src/Poly/Poly_Triangulation.cxx
src/Poly/Poly_Triangulation.hxx
src/Prs3d/Prs3d.cxx
src/Prs3d/Prs3d_ToolQuadric.cxx
src/QABugs/QABugs_19.cxx
src/QABugs/QABugs_BVH.cxx
src/RWGltf/RWGltf_TriangulationReader.cxx
src/RWGltf/RWGltf_TriangulationReader.hxx
src/RWMesh/RWMesh_FaceIterator.cxx
src/RWMesh/RWMesh_FaceIterator.hxx
src/RWStl/RWStl.cxx
src/Select3D/Select3D_SensitiveTriangulation.cxx
src/ShapePersistent/ShapePersistent_Poly.cxx
src/StdPrs/StdPrs_Isolines.cxx
src/StdPrs/StdPrs_ShadedShape.cxx
src/StdPrs/StdPrs_ToolTriangulatedShape.cxx
src/StdPrs/StdPrs_WFShape.cxx
src/StdSelect/StdSelect_BRepSelectionTool.cxx
src/StlAPI/StlAPI_Reader.cxx
src/StlAPI/StlAPI_Writer.cxx
src/TDataXtd/FILES
src/TDataXtd/TDataXtd.cxx
src/TDataXtd/TDataXtd_SurfacicMesh.cxx [new file with mode: 0644]
src/TDataXtd/TDataXtd_SurfacicMesh.hxx [new file with mode: 0644]
src/ViewerTest/ViewerTest_ObjectCommands.cxx
src/VrmlConverter/VrmlConverter_ShadedShape.cxx
src/VrmlData/VrmlData_IndexedFaceSet.cxx
src/VrmlData/VrmlData_ShapeConvert.cxx
src/XDEDRAW/XDEDRAW_Props.cxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.cxx
src/XmlMDataXtd/FILES
src/XmlMDataXtd/XmlMDataXtd.cxx
src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.cxx [new file with mode: 0644]
src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.hxx [new file with mode: 0644]
src/XmlMDataXtd/XmlMDataXtd_TriangulationDriver.cxx
tests/caf/basic/Z1 [new file with mode: 0644]

index 53d75ed00030e3b2a77e86504550eca93bbef375..b8bf6302c5732fc1b9211d80f6b140cc56eee342 100644 (file)
@@ -1336,11 +1336,11 @@ void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
                                          const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
                                          const gp_Dir& theNormal)
 {
-  myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 1, theP1);
-  myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 2, theP2);
-  myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 3, theP3);
+  myTriangulation->ChangeNode (theIndex * 3 + 1) = theP1;
+  myTriangulation->ChangeNode (theIndex * 3 + 2) = theP2;
+  myTriangulation->ChangeNode (theIndex * 3 + 3) = theP3;
 
-  myTriangulation->ChangeTriangles().SetValue (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
+  myTriangulation->ChangeTriangle (theIndex + 1) = Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3);
   myArray->AddVertex (theP1, theNormal);
   myArray->AddVertex (theP2, theNormal);
   myArray->AddVertex (theP3, theNormal);
index b8559671d877c90cd797b90f22b8ef9a765e68a6..dc2906ba14744ea0ca747394607895ac31eedadd 100644 (file)
@@ -123,9 +123,6 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
   switch (aMode)
   {
     case 0:
-      const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes();             //Nodes
-      const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();  //Triangle
-
       Standard_Boolean hasVNormals = myTriangulation->HasNormals();
       Standard_Boolean hasVColors  = HasVertexColors();
 
@@ -135,29 +132,25 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
       Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
 
       Standard_Integer i;
-      Standard_Integer j;
 
       const Standard_Real ambient = 0.2;
       if (hasVNormals)
       {
-        const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
         if (hasVColors)
         {
           const TColStd_Array1OfInteger& colors = myColor->Array1();
-          for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+          for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
           {
-            j = (i - nodes.Lower()) * 3;
-            anArray->AddVertex(nodes(i), attenuateColor(colors(i), ambient));
-            anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
+            anArray->AddVertex(myTriangulation->Node (i), attenuateColor(colors(i), ambient));
+            anArray->SetVertexNormal(i, myTriangulation->Normal (i));
           }
         }
         else // !hasVColors
         {
-          for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+          for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
           {
-            j = (i - nodes.Lower()) * 3;
-            anArray->AddVertex(nodes(i));
-            anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
+            anArray->AddVertex(myTriangulation->Node (i));
+            anArray->SetVertexNormal(i, myTriangulation->Normal (i));
           }
         }
       }
@@ -166,23 +159,23 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
         if (hasVColors)
         {
           const TColStd_Array1OfInteger& colors = myColor->Array1();
-          for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+          for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
           {
-            anArray->AddVertex(nodes(i), attenuateColor(colors(i), ambient));
+            anArray->AddVertex(myTriangulation->Node (i), attenuateColor(colors(i), ambient));
           }
         }
         else // !hasVColors
         {
-          for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+          for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
           {
-            anArray->AddVertex(nodes(i));
+            anArray->AddVertex(myTriangulation->Node (i));
           }
         }
       }
 
       Standard_Integer indexTriangle[3] = {0,0,0};
-      for ( i = triangles.Lower(); i<= triangles.Upper(); i++ ) {
-        triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
+      for ( i = 1; i<= myTriangulation->NbTriangles(); i++ ) {
+        myTriangulation->Triangle (i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
         anArray->AddEdge(indexTriangle[0]);
         anArray->AddEdge(indexTriangle[1]);
         anArray->AddEdge(indexTriangle[2]);
index 6ed0dc72810f517892d03d1363f948d9cf909146..8cd03af4fe8e67b0cec19a11443d9c73eed7c518 100644 (file)
@@ -149,20 +149,19 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
       if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
       {
         const TColStd_Array1OfInteger& Indices = Poly->Nodes();
-        const TColgp_Array1OfPnt& Nodes = T->Nodes();
         nbNodes = Indices.Length();
         if (l.IsIdentity())
         {
           for (i = 1; i <= nbNodes; i++)
           {
-            B.Add(Nodes(Indices[i]));
+            B.Add (T->Node (Indices[i]));
           }
         }
         else
         {
           for (i = 1; i <= nbNodes; i++)
           {
-            B.Add(Nodes(Indices[i]).Transformed(l));
+            B.Add (T->Node (Indices[i]).Transformed (l));
           }
         }
         //     B.Enlarge(T->Deflection());
@@ -341,12 +340,11 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B,
       if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
       {
         const TColStd_Array1OfInteger& Indices = Poly->Nodes();
-        const TColgp_Array1OfPnt& Nodes = T->Nodes();
         nbNodes = Indices.Length();
         for (i = 1; i <= nbNodes; i++)
         {
-          if (l.IsIdentity()) aLocBox.Add(Nodes(Indices[i]));
-          else aLocBox.Add(Nodes(Indices[i]).Transformed(l));
+          if (l.IsIdentity()) aLocBox.Add (T->Node (Indices[i]));
+          else aLocBox.Add (T->Node (Indices[i]).Transformed (l));
         }
         Standard_Real Tol = useShapeTolerance?  BRep_Tool::Tolerance(E) : 0.;
         aLocBox.Enlarge(Poly->Deflection() + Tol);
index bc3d872280d9a913b75e80a1ed5c6f99bd83c937..ae9320112bbe1c531f188bb1a94e548c46ad1434 100644 (file)
@@ -191,13 +191,12 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS,
       return 0;
 
     const Standard_Integer aCNode = aTrng->NbNodes();
-    const TColgp_Array1OfPnt& aNodesArr = aTrng->Nodes();
     for (Standard_Integer i = 1; i <= aCNode; i++)
     {
       if (thePts)
       {
-        const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr[i] :
-          aNodesArr[i].Transformed(aLoc);
+        const gp_Pnt aP = aLoc.IsIdentity() ? aTrng->Node (i) :
+            aTrng->Node (i).Transformed(aLoc);
         (*thePts)(aRetVal) = aP;
       }
 
index 7adbadfb55733d22a9d7697d84af352688985257..402c064f8fa67d9c322dca057019b14c8034bf0f 100644 (file)
@@ -704,7 +704,6 @@ BRepCheck_Status BRepCheck_Edge::
       aCR->PolygonOnTriangulation2() : 
     aCR->PolygonOnTriangulation();
     const TColStd_Array1OfInteger& anIndices = aPOnTriag->Nodes();
-    const TColgp_Array1OfPnt& Nodes = aTriang->Nodes();
     const Standard_Integer aNbNodes = anIndices.Length();
 
     const Standard_Real aTol = aPOnTriag->Deflection() +
@@ -717,7 +716,7 @@ BRepCheck_Status BRepCheck_Edge::
       {
         const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
         const gp_Pnt  aPE(aBC.Value(aParam)), 
-          aPnt(Nodes(anIndices(i)).Transformed(aLL));
+                      aPnt(aTriang->Node (anIndices(i)).Transformed(aLL));
 
         const Standard_Real aSQDist = aPE.SquareDistance(aPnt);
         if(aSQDist > aTol*aTol)
@@ -736,9 +735,9 @@ BRepCheck_Status BRepCheck_Edge::
       for (Standard_Integer i = 1; i <= aNbNodes; i++)
       {
         if (aLL.IsIdentity())
-          aB.Add(Nodes(anIndices(i)));
+          aB.Add(aTriang->Node (anIndices(i)));
         else
-          aB.Add(Nodes(anIndices(i)).Transformed(aLL));
+          aB.Add(aTriang->Node (anIndices(i)).Transformed(aLL));
       }
 
       aB.Enlarge(aTol);
index ff9a0a04aec025330e739f762ba889fe4d7ee14c..ec17a2653cc024da48379b907840bd4b64cd8d89 100644 (file)
@@ -75,12 +75,11 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
     Tr = BRep_Tool::Triangulation(F,L);
     if (!Tr.IsNull())
     {
-      const TColgp_Array1OfPnt& Nod = Tr->Nodes();
       n = Tr->NbNodes();
       for (i = 1; i <= n; i++)
       {
         nbn1++; 
-        TP1.SetValue(nbn1,Nod(i).Transformed(L));
+        TP1.SetValue(nbn1,Tr->Node (i).Transformed(L));
       }
     }
   }
@@ -96,12 +95,11 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
     Tr = BRep_Tool::Triangulation(F,L);
     if (!Tr.IsNull())
     {
-      const TColgp_Array1OfPnt& Nod = Tr->Nodes();
       n = Tr->NbNodes();
       for (i = 1; i <= n; i++)
       {
         nbn2++; 
-        TP2.SetValue(nbn2,Nod(i).Transformed(L));
+        TP2.SetValue(nbn2,Tr->Node (i).Transformed(L));
       }
     }
   }
index 0ca048354ff431bba86546769fdc9b85112587e7..c2b54acb833187049cc38d718f214604d6a1bc79 100644 (file)
@@ -179,7 +179,7 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
 
     for (Standard_Integer aVertIdx = 1; aVertIdx <= aTriangulation->NbNodes(); ++aVertIdx)
     {
-      gp_Pnt aVertex = aTriangulation->Nodes().Value (aVertIdx);
+      gp_Pnt aVertex = aTriangulation->Node (aVertIdx);
 
       aVertex.Transform (aLocation.Transformation());
 
@@ -194,9 +194,9 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
       Standard_Integer aVertex2;
       Standard_Integer aVertex3;
 
-      aTriangulation->Triangles().Value (aTriIdx).Get (aVertex1,
-                                                       aVertex2,
-                                                       aVertex3);
+      aTriangulation->Triangle (aTriIdx).Get (aVertex1,
+                                              aVertex2,
+                                              aVertex3);
 
       myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
                                         aVertex2 + aVertOffset,
index 1daa65884df6d59185617a359ab7680e1d923cc5..349ee14a71391b555105fa6207535c5beb3126f7 100644 (file)
@@ -180,13 +180,12 @@ void BRepGProp_MeshCinert::PreparePolygon(const TopoDS_Edge& theE,
     Standard_Integer aNbNodes = aPOnTri->NbNodes();
     thePolyg = new TColgp_HArray1OfPnt(1, aNbNodes);
     const TColStd_Array1OfInteger& aNodeInds = aPOnTri->Nodes();
-    const TColgp_Array1OfPnt& aNodes = aTri->Nodes();
     Standard_Integer i;
     if (aLoc.IsIdentity())
     {
       for (i = 1; i <= aNbNodes; ++i)
       {
-        thePolyg->SetValue(i, aNodes(aNodeInds(i)));
+        thePolyg->SetValue (i, aTri->Node (aNodeInds (i)));
       }
     }
     else
@@ -194,7 +193,7 @@ void BRepGProp_MeshCinert::PreparePolygon(const TopoDS_Edge& theE,
       const gp_Trsf& aTr = aLoc.Transformation();
       for (i = 1; i <= aNbNodes; ++i)
       {
-        thePolyg->SetValue(i, aNodes.Value(aNodeInds(i)).Transformed(aTr));
+        thePolyg->SetValue (i, aTri->Node (aNodeInds (i)).Transformed (aTr));
       }
     }
     return;
index 24b14885d0b6b61402a342573d472ef881f7f682..4e794aab842e760c9bee00c5bf03052990db3cad 100644 (file)
@@ -171,7 +171,7 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
   }
   if (theLoc.IsIdentity())
   {
-    Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
+    Perform (theMesh, theOri);
   }
   else
   {
@@ -181,21 +181,25 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
                                 Abs(Abs(aTr.ScaleFactor()) - 1.) > gp::Resolution();
     if (isToCopy)
     {
-      TColgp_Array1OfPnt aNodes(1, theMesh->NbNodes());
-      const TColgp_Array1OfPnt& aMeshNodes = theMesh->Nodes();
+      // Copy and transform nodes.
       Standard_Integer i;
-      for (i = 1; i <= aMeshNodes.Length(); ++i)
-      {
-        aNodes(i) = aMeshNodes.Value(i).Transformed(aTr);
-      }
-      Perform(aNodes, theMesh->Triangles(), theOri);
+      TColgp_Array1OfPnt aNodes (1, theMesh->NbNodes());
+      for (i = 1; i <= theMesh->NbNodes(); ++i)
+        aNodes (i) = theMesh->Node (i).Transformed (aTr);
+
+      // Copy triangles.
+      Poly_Array1OfTriangle aTriangles (1, theMesh->NbTriangles());
+      for (i = 1; i <= theMesh->NbTriangles();++i)
+        aTriangles (i) = theMesh->Triangle (i);
+
+      Perform(new Poly_Triangulation(aNodes, aTriangles), theOri);
       return;
     }
     //
     gp_Trsf aTrInv = aTr.Inverted();
     gp_Pnt loc_save = loc;
     loc.Transform(aTrInv);
-    Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
+    Perform(theMesh, theOri);
     //Computes the inertia tensor at mesh gravity center
     gp_Mat HMat, inertia0;
     gp_Pnt g0 = g;
@@ -229,11 +233,10 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
-                                   const Poly_Array1OfTriangle& theTriangles,
+void BRepGProp_MeshProps::Perform (const Handle(Poly_Triangulation)& theMesh,
                                    const TopAbs_Orientation theOri)
 {
-  if (theNodes.IsEmpty() || theTriangles.IsEmpty())
+  if (theMesh.IsNull() || !theMesh->NbNodes() || !theMesh->NbTriangles())
   {
     return;
   }
@@ -257,11 +260,11 @@ void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
 
   Standard_Boolean isVolume = myType == Vinert;
   Standard_Integer i;
-  Standard_Integer n1, n2, n3; //node indices
-  for (i = theTriangles.Lower(); i <= theTriangles.Upper(); ++i)
+  Standard_Integer n1, n2, n3; //node indeces
+  for (i = 1; i <= theMesh->NbTriangles(); ++i)
   {
-    const Poly_Triangle& aTri = theTriangles(i);
-    aTri.Get(n1, n2, n3);
+    const Poly_Triangle& aTri = theMesh->Triangle (i);
+    aTri.Get (n1, n2, n3);
     if (theOri == TopAbs_REVERSED)
     {
       Standard_Integer nn = n2;
@@ -269,10 +272,10 @@ void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
       n3 = nn;
     }
     // Calculate properties of a pyramid built on face and apex
-    const gp_Pnt& p1 = theNodes(n1);
-    const gp_Pnt& p2 = theNodes(n2);
-    const gp_Pnt& p3 = theNodes(n3);
-    CalculateProps(p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
+    const gp_Pnt& p1 = theMesh->Node (n1);
+    const gp_Pnt& p2 = theMesh->Node (n2);
+    const gp_Pnt& p3 = theMesh->Node (n3);
+    CalculateProps (p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
   }
 
   dim = aGProps[0];
index 379d6ef41dac4708e9c6088f03af46770c013f27..5ec46cece66de31740bd5f0acd12c88b64f0e5dc 100644 (file)
@@ -55,8 +55,7 @@ public:
                                const TopLoc_Location& theLoc,
                                const TopAbs_Orientation theOri);
 
-  Standard_EXPORT void Perform(const TColgp_Array1OfPnt& theNodes,
-                               const Poly_Array1OfTriangle& theTriangles, 
+  Standard_EXPORT void Perform(const Handle(Poly_Triangulation)& theMesh,
                                const TopAbs_Orientation theOri);
 
   //! Computes the global properties of triangle {p1, p2, p3} relatively 
index a76be168ab4801cbf1d6473008c84dc8b0a839fe..6284fcabd8122fe51ab76a083cac8642066e8a52 100644 (file)
@@ -2346,9 +2346,9 @@ Standard_Boolean BRepLib::
     const Standard_Integer anArrDim = 3*aPT->NbNodes();
     Handle(TShort_HArray1OfShortReal) aNormArr = new TShort_HArray1OfShortReal(1, anArrDim);
     Standard_Integer anNormInd = aNormArr->Lower();
-    for(Standard_Integer i = aPT->UVNodes().Lower(); i <= aPT->UVNodes().Upper(); i++)
+    for(Standard_Integer i = 1; i <= aPT->NbNodes(); i++)
     {
-      const gp_Pnt2d &aP2d = aPT->UVNodes().Value(i);
+      const gp_Pnt2d &aP2d = aPT->UVNode (i);
       aSLP.SetParameters(aP2d.X(), aP2d.Y());
 
       gp_XYZ aNorm(0.,0.,0.);
@@ -2407,9 +2407,6 @@ Standard_Boolean BRepLib::
     const Handle(Poly_PolygonOnTriangulation)& aPTEF2 = 
                                 BRep_Tool::PolygonOnTriangulation(anEdg, aPT2, aLoc2);
 
-    TShort_Array1OfShortReal& aNormArr1 = aPT1->ChangeNormals();
-    TShort_Array1OfShortReal& aNormArr2 = aPT2->ChangeNormals();
-
     if (aPTEF1->Nodes().Lower() != aPTEF2->Nodes().Lower() || 
         aPTEF1->Nodes().Upper() != aPTEF2->Nodes().Upper()) 
       continue; 
@@ -2421,31 +2418,15 @@ Standard_Boolean BRepLib::
       const Standard_Integer aFNodF1 = aPTEF1->Nodes().Value(anEdgNode);
       const Standard_Integer aFNodF2 = aPTEF2->Nodes().Value(anEdgNode);
 
-      const Standard_Integer aFNorm1FirstIndex = aNormArr1.Lower() + 3*
-                                                    (aFNodF1 - aPT1->Nodes().Lower());
-      const Standard_Integer aFNorm2FirstIndex = aNormArr2.Lower() + 3*
-                                                    (aFNodF2 - aPT2->Nodes().Lower());
-
-      gp_XYZ aNorm1(aNormArr1.Value(aFNorm1FirstIndex),
-                    aNormArr1.Value(aFNorm1FirstIndex+1),
-                    aNormArr1.Value(aFNorm1FirstIndex+2));
-      gp_XYZ aNorm2(aNormArr2.Value(aFNorm2FirstIndex),
-                    aNormArr2.Value(aFNorm2FirstIndex+1),
-                    aNormArr2.Value(aFNorm2FirstIndex+2));
+      gp_XYZ aNorm1 (aPT1->Normal (aFNodF1).XYZ());
+      gp_XYZ aNorm2 (aPT2->Normal (aFNodF2).XYZ());
       const Standard_Real aDot = aNorm1 * aNorm2;
 
       if(aDot > aThresDot)
       {
         gp_XYZ aNewNorm = (aNorm1 + aNorm2).Normalized();
-        aNormArr1.ChangeValue(aFNorm1FirstIndex) =
-          aNormArr2.ChangeValue(aFNorm2FirstIndex) =
-          static_cast<Standard_ShortReal>(aNewNorm.X());
-        aNormArr1.ChangeValue(aFNorm1FirstIndex+1) =
-          aNormArr2.ChangeValue(aFNorm2FirstIndex+1) =
-          static_cast<Standard_ShortReal>(aNewNorm.Y());
-        aNormArr1.ChangeValue(aFNorm1FirstIndex+2) =
-          aNormArr2.ChangeValue(aFNorm2FirstIndex+2) =
-          static_cast<Standard_ShortReal>(aNewNorm.Z());
+        aPT1->SetNormal (aFNodF1, aNewNorm);
+        aPT2->SetNormal (aFNodF2, aNewNorm);
         aRetVal = Standard_True;
       }
     }
index bf28ea24e3d08c5094571524601cb912ab25ce24..30aaa275f03b58e70a95a5061d29931d102918f4 100644 (file)
@@ -284,7 +284,9 @@ Handle(Poly_Triangulation) BRepMesh_BaseMeshAlgo::collectTriangles()
   Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation(
     myUsedNodes->Extent(), aTriangles.Extent(), Standard_True);
 
-  aTriangulation->ChangeTriangles() = aPolyTrianges;
+  for (Standard_Integer iTri = 1; iTri <= aPolyTrianges.Upper(); iTri++)
+    aTriangulation->ChangeTriangle (iTri) = aPolyTrianges (iTri);
+
   return aTriangulation;
 }
 
@@ -295,10 +297,6 @@ Handle(Poly_Triangulation) BRepMesh_BaseMeshAlgo::collectTriangles()
 void BRepMesh_BaseMeshAlgo::collectNodes(
   const Handle(Poly_Triangulation)& theTriangulation)
 {
-  // Store mesh nodes
-  TColgp_Array1OfPnt&   aNodes   = theTriangulation->ChangeNodes();
-  TColgp_Array1OfPnt2d& aNodes2d = theTriangulation->ChangeUVNodes();
-
   for (Standard_Integer i = 1; i <= myNodesMap->Size(); ++i)
   {
     if (myUsedNodes->IsBound(i))
@@ -306,8 +304,8 @@ void BRepMesh_BaseMeshAlgo::collectNodes(
       const BRepMesh_Vertex& aVertex = myStructure->GetNode(i);
 
       const Standard_Integer aNodeIndex = myUsedNodes->Find(i);
-      aNodes(aNodeIndex) = myNodesMap->Value(aVertex.Location3d());
-      aNodes2d(aNodeIndex) = getNodePoint2d(aVertex);
+      theTriangulation->ChangeNode (aNodeIndex) = myNodesMap->Value(aVertex.Location3d());
+      theTriangulation->ChangeUVNode (aNodeIndex) = getNodePoint2d(aVertex);
     }
   }
 }
index 6f9e1ab8bbf4c0f4136e81f884618ebd6818d93c..c2eb6ec857dfce34c999a06e8fd1ceff51c4477d 100644 (file)
@@ -14,6 +14,7 @@
 // commercial license or contractual agreement.
 
 #include <BRepMesh_EdgeTessellationExtractor.hxx>
+#include <Poly_Triangulation.hxx>
 #include <BRepMesh_ShapeTool.hxx>
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
@@ -36,7 +37,7 @@ BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor (
   Handle (Poly_PolygonOnTriangulation) aPolygon =
     BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc);
 
-  myNodes   = &aTriangulation->Nodes ();
+  myTriangulation = aTriangulation;
   myIndices = &aPolygon->Nodes ();
   myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
 }
@@ -67,7 +68,7 @@ Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value (
   gp_Pnt&                thePoint,
   Standard_Real&         theParameter) const
 {
-  const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex));
+  const gp_Pnt& theRefPnt = myTriangulation->Node ((*myIndices)(theIndex));
   thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc);
 
   theParameter = myProvider.Parameter (theIndex, thePoint);
index 48e0a915bf7336ec042574eba1fe4074639eb0ef..022c25e16876528a139d73c2e5ad853dfcbe17e7 100644 (file)
@@ -55,7 +55,7 @@ public:
 private:
 
   BRepMesh_EdgeParameterProvider<Handle(TColStd_HArray1OfReal)>  myProvider;
-  const TColgp_Array1OfPnt*                                      myNodes;
+  Handle(Poly_Triangulation)                                     myTriangulation;
   const TColStd_Array1OfInteger*                                 myIndices;
   TopLoc_Location                                                myLoc;
 };
index fd43b3f61cb3945df46e98ccc590e44b17286c62..eaf5d4bbeaaaa5c8face95edaf9e34365549cf3b 100644 (file)
@@ -63,19 +63,16 @@ namespace
         if (isTriangulationConsistent)
         {
           // #25080: check that indices of links forming triangles are in range.
-          const Standard_Integer aNodesNb = aTriangulation->NbNodes();
-          const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
-          Standard_Integer i = aTriangles.Lower();
-          for (; i <= aTriangles.Upper() && isTriangulationConsistent; ++i)
+          Standard_Integer i = 1;
+          for (; i <= aTriangulation->NbTriangles() && isTriangulationConsistent; ++i)
           {
-            const Poly_Triangle& aTriangle = aTriangles(i);
+            const Poly_Triangle& aTriangle = aTriangulation->Triangle (i);
 
             Standard_Integer aNode[3];
             aTriangle.Get(aNode[0], aNode[1], aNode[2]);
             for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j)
             {
-              isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aNodesNb);
+              isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aTriangulation->NbNodes());
             }
           }
         }
index 0b00be6df6b92af8bb226dc84eaf93f51ae3dd77..82a2c8eb03a8599be90a33cf2b5f47fa1b6f9d5e 100644 (file)
@@ -208,10 +208,8 @@ void BRepMesh_ShapeTool::AddInFace(
   {
     gp_Trsf aTrsf = aLoc.Transformation();
     aTrsf.Invert();
-
-    TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
-    for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i)
-      aNodes(i).Transform(aTrsf);
+    for (Standard_Integer i = 1; i <= theTriangulation->NbNodes(); ++i)
+        theTriangulation->ChangeNode (i).Transform (aTrsf);
   }
 
   BRep_Builder aBuilder;
index 8fa8a1acdfbbb65f061e60406a9221146b0b01fd..d7e2c5716a13aab60841046aec16b468ff69df45 100644 (file)
 
 
 #include <BRepTools_Modification.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Surface.hxx>
-#include <gp_Pnt.hxx>
-#include <Standard_Type.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <Poly_PolygonOnTriangulation.hxx>
 #include <Poly_Triangulation.hxx>
+#include <TopoDS_Face.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BRepTools_Modification,Standard_Transient)
 
index 5bb69bcbf06b67d2fbdb3e72166bbeda9dd31848..c18049c0e7d66d00f581339cbedc44565c45b0e8 100644 (file)
@@ -54,6 +54,7 @@
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <Poly_Mesh.hxx>
 
 #ifdef MacOS
 #define strcasecmp(p,q) strcmp(p,q)
@@ -1421,7 +1422,7 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream&      OS,
                                             const Standard_Boolean Compact,
                                             const Message_ProgressRange& theProgress)const
 {
-  Standard_Integer i, j, nbNodes, nbtri = myTriangulations.Extent();
+  Standard_Integer i, j, k, nbNodes, nbtri = myTriangulations.Extent();
   Standard_Integer nbTriangles = 0, n1, n2, n3;
 
   Message_ProgressScope aPS(theProgress, "Triangulations", nbtri);
@@ -1467,28 +1468,26 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream&      OS,
     if (!Compact) OS << "\n3D Nodes :\n";
     
     nbNodes = T->NbNodes();
-    const TColgp_Array1OfPnt& Nodes = T->Nodes();
     for (j = 1; j <= nbNodes; j++) {
       if (!Compact) OS << std::setw(10) << j << " : ";
       if (!Compact) OS << std::setw(17);
-      OS << Nodes(j).X() << " ";
+      OS << T->Node (j).X() << " ";
       if (!Compact) OS << std::setw(17);
-      OS << Nodes(j).Y() << " ";
+      OS << T->Node (j).Y() << " ";
       if (!Compact) OS << std::setw(17);
-      OS << Nodes(j).Z();
+      OS << T->Node (j).Z();
       if (!Compact) OS << "\n";
       else OS << " ";
     }
     
     if (T->HasUVNodes()) {
       if (!Compact) OS << "\nUV Nodes :\n";
-      const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
       for (j = 1; j <= nbNodes; j++) {
         if (!Compact) OS << std::setw(10) << j << " : ";
         if (!Compact) OS << std::setw(17);
-        OS << UVNodes(j).X() << " ";
+        OS << T->UVNode (j).X() << " ";
         if (!Compact) OS << std::setw(17);
-        OS << UVNodes(j).Y();
+        OS << T->UVNode (j).Y();
         if (!Compact) OS << "\n";
         else OS << " ";
       }
@@ -1496,10 +1495,9 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream&      OS,
     
     if (!Compact) OS << "\nTriangles :\n";
     nbTriangles = T->NbTriangles();
-    const Poly_Array1OfTriangle& Triangles = T->Triangles();
     for (j = 1; j <= nbTriangles; j++) {
       if (!Compact) OS << std::setw(10) << j << " : ";
-      Triangles(j).Get(n1, n2, n3);
+      T->Triangle (j).Get (n1, n2, n3);
       if (!Compact) OS << std::setw(10);
       OS << n1 << " ";
       if (!Compact) OS << std::setw(10);
@@ -1515,22 +1513,24 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream&      OS,
       if (T->HasNormals() && toWriteNormals)
       {
         if (!Compact) OS << "\nNormals :\n";
-        const TShort_Array1OfShortReal& Normals = T->Normals();
-        for (j = 1; j <= nbNodes * 3; j++)
+        for (j = 1; j <= nbNodes; j++)
         {
           if (!Compact)
           {
             OS << std::setw(10) << j << " : ";
             OS << std::setw(17);
           }
-          OS << Normals(j) << " ";
-          if (!Compact)
-          {
-            OS << "\n";
-          }
-          else
+          for (k = 1; k <= 3; k++)
           {
-            OS << " ";
+            OS << T->Normal (j).Coord (k) << " ";
+            if (!Compact)
+            {
+              OS << "\n";
+            }
+            else
+            {
+              OS << " ";
+            }
           }
         }
       }
@@ -1633,3 +1633,176 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
     myTriangulations.Add(T, hasNormals);
   }
 }
+
+// Writes meshes (Poly_Mesh).
+void BRepTools_ShapeSet::WriteMeshes (Standard_OStream& theOS,
+                                      const TColStd_IndexedMapOfTransient& theMeshes,
+                                      const Standard_Boolean theCompact)
+{
+  const Standard_Integer nbMeshes = theMeshes.Extent();
+
+  if (theCompact)
+    theOS << "Meshes " << nbMeshes << "\n";
+  else {
+    theOS << " -------\n";
+    theOS <<"Dump of " << nbMeshes << " meshes\n";
+    theOS << " -------\n";
+  }
+
+  Standard_Integer i = 1;
+  for (; i <= nbMeshes; i++)
+  {
+    const Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (theMeshes (i));
+    const Standard_Integer nbNodes = aMesh->NbNodes();
+    const Standard_Integer nbElements = aMesh->NbElements();
+    const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
+
+    if (theCompact)
+    {
+      theOS << nbNodes << " " << nbElements << " ";
+      theOS << (hasUVNodes ? "1" : "0") << " ";
+    }
+    else
+    {
+      theOS << "  "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbElements <<" Triangles and Quadrangles\n";
+      theOS << "      "<<(hasUVNodes ? "with" : "without") << " UV nodes\n";
+    }
+    
+    // write the deflection
+    if (!theCompact) 
+      theOS << "  Deflection : ";
+    theOS << aMesh->Deflection() << "\n";
+    
+    // write the 3d nodes
+    if (!theCompact)
+      theOS << "\n3D Nodes :\n";
+    
+    Standard_Integer j;
+    for (j = 1; j <= nbNodes; j++)
+    {
+      if (!theCompact) theOS << std::setw (10) << j << " : ";
+      if (!theCompact) theOS << std::setw (17);
+      theOS << aMesh->Node (j).X() << " ";
+      if (!theCompact) theOS << std::setw (17);
+      theOS << aMesh->Node (j).Y() << " ";
+      if (!theCompact) theOS << std::setw (17);
+      theOS << aMesh->Node (j).Z();
+      if (!theCompact) theOS << "\n";
+      else theOS << " ";
+    }
+    
+    // write 2d nodes
+    if (hasUVNodes)
+    {
+      if (!theCompact) theOS << "\nUV Nodes :\n";
+      for (j = 1; j <= nbNodes; j++)
+      {
+        if (!theCompact) theOS << std::setw (10) << j << " : ";
+        if (!theCompact) theOS << std::setw (17);
+        theOS << aMesh->UVNode (j).X() << " ";
+        if (!theCompact) theOS << std::setw (17);
+        theOS << aMesh->UVNode (j).Y();
+        if (!theCompact) theOS << "\n";
+        else theOS << " ";
+      }
+    }
+    
+    // write triangles and quadrangles
+    if (!theCompact) theOS << "\nElements :\n";
+    Standard_Integer n, n1, n2, n3, n4;
+    for (j = 1; j <= nbElements; j++)
+    {
+      if (!theCompact) theOS << std::setw (10) << j << " : ";
+      aMesh->Element (j, n1, n2, n3, n4);
+      n = (n4 > 0) ? 4 : 3;
+      if (!theCompact) theOS << std::setw (10);
+      theOS << n << " ";
+      if (!theCompact) theOS << std::setw (10);
+      theOS << n1 << " ";
+      if (!theCompact) theOS << std::setw (10);
+      theOS << n2 << " ";
+      if (!theCompact) theOS << std::setw (10);
+      theOS << n3;
+      if (n4 > 0)
+      {
+        theOS << " ";
+        if (!theCompact) theOS << std::setw (10);
+        theOS << n4;
+      }
+      if (!theCompact) theOS << "\n";
+      else theOS << " ";
+    }
+    theOS << "\n";
+  }
+}
+
+// Reads meshes (Poly_Mesh).
+void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
+                                     TColStd_IndexedMapOfTransient& theMeshes)
+{
+  char buffer[255];
+  Standard_Integer i, j;
+  Standard_Integer n, n1(0), n2(0), n3(0), n4(0);
+  Standard_Real deflection, x, y, z;
+  Standard_Integer nbMeshes(0), nbNodes(0), nbElements(0);
+  Standard_Boolean hasUV(Standard_False);
+  gp_Pnt p;
+
+  // Read the "Meshes" head-line.
+  theIS >> buffer;
+  if (strstr (buffer, "Meshes") == NULL)
+    return;
+
+  // Read number of meshes.
+  theIS >> nbMeshes;
+
+  for (i = 1; i <= nbMeshes; i++)
+  {
+    theIS >> nbNodes >> nbElements >> hasUV;
+    GeomTools::GetReal (theIS, deflection);
+
+    // Allocate the mesh.
+    Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
+    aMesh->Deflection (deflection);
+
+    // Read nodes.
+    for (j = 1; j <= nbNodes; j++)
+    {
+      GeomTools::GetReal (theIS, x);
+      GeomTools::GetReal (theIS, y);
+      GeomTools::GetReal (theIS, z);
+      p.SetCoord (x, y, z);
+      aMesh->AddNode (p);
+    }
+
+    // Reads 2d-nodes.
+    if (hasUV)
+    {
+      for (j = 1; j <= nbNodes; j++)
+      {
+        GeomTools::GetReal (theIS, x);
+        GeomTools::GetReal (theIS, y);
+        aMesh->ChangeUVNode (j).SetCoord (x, y);
+      }
+    }
+
+    // Reads the triangles and quadrangles.
+    for (j = 1; j <= nbElements; j++)
+    {
+      // Read the element.
+      theIS >> n;
+      if (n == 3)
+        theIS >> n1 >> n2 >> n3;
+      else if (n == 4)
+        theIS >> n1 >> n2 >> n3 >> n4;
+
+      // Set the element to the mesh.
+      if (n == 3)
+        aMesh->AddElement (n1, n2, n3);
+      else if (n == 4)
+        aMesh->AddElement (n1, n2, n3, n4);
+    }
+
+    theMeshes.Add (aMesh);
+  }
+}
index 2d1bfe36eb1f6bcf270f69b26acdb803d84e5c3a..77a352289b61f4ea2edc5c70b2c86f0d9dd996b6 100644 (file)
@@ -155,7 +155,16 @@ public:
   //! on the stream <OS>.
   Standard_EXPORT void DumpPolygonOnTriangulation (Standard_OStream& OS) const;
 
-
+  //! Writes meshes (Poly_Mesh).
+  //! TODO: Call this method when BRep_TFace refers to a list of meshes of type Poly_Mesh.
+  Standard_EXPORT static void WriteMeshes (Standard_OStream& theOS,
+                                           const TColStd_IndexedMapOfTransient& theMeshes,
+                                           const Standard_Boolean theCompact = Standard_True);
+
+  //! Reads meshes (Poly_Mesh).
+  //! TODO: Call this method when BRep_TFace refers to a list of meshes of type Poly_Mesh.
+  Standard_EXPORT static void ReadMeshes (Standard_IStream& theIS,
+                                          TColStd_IndexedMapOfTransient& theMeshes);
 
 
 protected:
index 564dbf803d79c54cf33c24542535cdecdb643802..f54ccea0421d084359b96822d965329183e073bd 100644 (file)
@@ -24,7 +24,8 @@
 #include <BinMDataXtd_PresentationDriver.hxx>
 #include <BinMDataXtd_PositionDriver.hxx>
 #include <BinMDataXtd_TriangulationDriver.hxx>
-
+#include <BinMDataXtd_SurfacicMeshDriver.hxx>
+       
 static Standard_Integer myDocumentVersion = -1;
 //=======================================================================
 //function : AddDrivers
@@ -38,6 +39,7 @@ void BinMDataXtd::AddDrivers (const Handle(BinMDF_ADriverTable)& theDriverTable,
   theDriverTable->AddDriver (new BinMDataXtd_GeometryDriver     (theMsgDriver) );
   theDriverTable->AddDriver (new BinMDataXtd_PatternStdDriver   (theMsgDriver) );
   theDriverTable->AddDriver (new BinMDataXtd_TriangulationDriver(theMsgDriver) );
+  theDriverTable->AddDriver (new BinMDataXtd_SurfacicMeshDriver (theMsgDriver) );
 
   theDriverTable->AddDriver (new BinMDataXtd_PresentationDriver (theMsgDriver) );
   theDriverTable->AddDriver (new BinMDataXtd_PositionDriver     (theMsgDriver) );
diff --git a/src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.cxx b/src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.cxx
new file mode 100644 (file)
index 0000000..7de8b23
--- /dev/null
@@ -0,0 +1,170 @@
+// Created on: 2015-12-17
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BinMDataXtd_SurfacicMeshDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <Standard_Type.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <TDF_Attribute.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMDataXtd_SurfacicMeshDriver,BinMDF_ADriver)
+
+//=======================================================================
+//function : BinMDataXtd_SurfacicMeshDriver
+//purpose  : Constructor
+//=======================================================================
+BinMDataXtd_SurfacicMeshDriver::BinMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMsgDriver)
+     : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataXtd_SurfacicMesh)->Name())
+{
+
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose  : 
+//=======================================================================
+Handle(TDF_Attribute) BinMDataXtd_SurfacicMeshDriver::NewEmpty() const
+{
+  return new TDataXtd_SurfacicMesh();
+}
+
+//=======================================================================
+//function : Paste
+//purpose  : persistent -> transient (retrieve)
+//=======================================================================
+Standard_Boolean BinMDataXtd_SurfacicMeshDriver::Paste (const BinObjMgt_Persistent&  theSource,
+                                                const Handle(TDF_Attribute)& theTarget,
+                                                BinObjMgt_RRelocationTable&  ) const
+{
+  Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theTarget);
+
+  Standard_Integer i;
+  Standard_Real deflection, x, y, z;
+  Standard_Integer n, n1, n2, n3, n4;
+  Standard_Integer nbNodes(0), nbElements(0);
+  Standard_Boolean hasUV(Standard_False);
+  gp_Pnt p;
+
+  theSource >> nbNodes;
+  theSource >> nbElements;
+  theSource >> hasUV;
+  theSource >> deflection;
+
+  // allocate the mesh
+  Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
+
+  // deflection
+  aMesh->Deflection (deflection);
+
+  // read nodes
+  for (i = 1; i <= nbNodes; i++)
+  {
+    theSource >> x;
+    theSource >> y;
+    theSource >> z;
+    p.SetCoord (x, y, z);
+    aMesh->AddNode (p);
+  }
+      
+  // read 2d nodes
+  if (hasUV)
+  {
+    for (i = 1; i <= nbNodes; i++)
+    {
+      theSource >> x;
+      theSource >> y;
+      aMesh->ChangeUVNode (i).SetCoord (x,y);
+    }
+  }
+      
+  // read triangles and quadrangles
+  for (i = 1; i <= nbElements; i++)
+  {
+    theSource >> n;
+    theSource >> n1;
+    theSource >> n2;
+    theSource >> n3;
+    if (n == 3)
+      aMesh->AddElement (n1, n2, n3);
+    else if (n == 4)
+    {
+      theSource >> n4;
+      aMesh->AddElement (n1, n2, n3, n4);
+    }
+  }
+
+  // Set mesh to Ocaf attribute
+  attrMesh->Set (aMesh);
+  return !aMesh.IsNull();
+}
+
+//=======================================================================
+//function : Paste
+//purpose  : transient -> persistent (store)
+//=======================================================================
+void BinMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSource,
+                                    BinObjMgt_Persistent&        theTarget,
+                                    BinObjMgt_SRelocationTable&  ) const
+{
+  const Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theSource);
+  const Handle(Poly_Mesh)& aMesh = attrMesh->Get();
+  if (!aMesh.IsNull())
+  {
+    Standard_Integer nbNodes = aMesh->NbNodes();
+    Standard_Integer nbElements = aMesh->NbElements();
+
+    // write number of elements
+    theTarget << nbNodes;
+    theTarget << nbElements;
+    theTarget << (aMesh->HasUVNodes() ? 1 : 0);
+    // write the deflection
+    theTarget << aMesh->Deflection();
+
+    // write 3d nodes
+    Standard_Integer i;
+    for (i = 1; i <= nbNodes; i++)
+    {
+      const gp_Pnt& aNode = aMesh->Node(i);
+      theTarget << aNode.X();
+      theTarget << aNode.Y();
+      theTarget << aNode.Z();
+    }
+
+    // write 2d nodes
+    if (aMesh->HasUVNodes())
+    {
+      for (i = 1; i <= nbNodes; i++)
+      {
+        const gp_Pnt2d& aUVNode = aMesh->UVNode(i);
+        theTarget << aUVNode.X();
+        theTarget << aUVNode.Y();
+      }
+    }
+
+    // write triangles and quadrangles
+    Standard_Integer n, n1, n2, n3, n4;
+    for (i = 1; i <= nbElements; i++)
+    {
+      aMesh->Element (i, n1, n2, n3, n4);
+      n = (n4 > 0) ? 4 : 3;
+      theTarget << n;
+      theTarget << n1;
+      theTarget << n2;
+      theTarget << n3;
+      if (n4 > 0)
+        theTarget << n4;
+    }
+  }
+}
diff --git a/src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.hxx b/src/BinMDataXtd/BinMDataXtd_SurfacicMeshDriver.hxx
new file mode 100644 (file)
index 0000000..33bcd53
--- /dev/null
@@ -0,0 +1,51 @@
+// Created on: 2015-12-17
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinMDataXtd_SurfacicMeshDriver_HeaderFile
+#define _BinMDataXtd_SurfacicMeshDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <BinMDF_ADriver.hxx>
+#include <BinObjMgt_RRelocationTable.hxx>
+#include <BinObjMgt_SRelocationTable.hxx>
+
+class TDF_Attribute;
+class Message_Messenger;
+class BinObjMgt_Persistent;
+
+DEFINE_STANDARD_HANDLE(BinMDataXtd_SurfacicMeshDriver, BinMDF_ADriver)
+
+//! TDataXtd_SurfacicMesh attribute bin-driver.
+class BinMDataXtd_SurfacicMeshDriver : public BinMDF_ADriver
+{
+
+public:
+  
+  Standard_EXPORT BinMDataXtd_SurfacicMeshDriver(const Handle(Message_Messenger)& theMessageDriver);
+  
+  Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+  
+  Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
+                                                  const Handle(TDF_Attribute)& theTarget, 
+                                                  BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+  
+  Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, 
+                                      BinObjMgt_Persistent& theTarget, 
+                                      BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTIEXT(BinMDataXtd_SurfacicMeshDriver, BinMDF_ADriver)
+};
+
+#endif // _BinMDataXtd_SurfacicMeshDriver_HeaderFile
index 90b65288f00813c0b24f816e9b9a78f8ae965cec..bc7046b7703caffea4cb888b620d52d9fc2a1284 100644 (file)
@@ -135,9 +135,9 @@ void BinMDataXtd_TriangulationDriver::Paste(const Handle(TDF_Attribute)& theSour
     Standard_Integer i;
     for (i = 1; i <= nbNodes; i++)
     {
-      theTarget << PT->Node(i).X();
-      theTarget << PT->Node(i).Y();
-      theTarget << PT->Node(i).Z();
+      theTarget << PT->Node (i).X();
+      theTarget << PT->Node (i).Y();
+      theTarget << PT->Node (i).Z();
     }
 
     // write 2d nodes
@@ -145,16 +145,15 @@ void BinMDataXtd_TriangulationDriver::Paste(const Handle(TDF_Attribute)& theSour
     {
       for (i = 1; i <= nbNodes; i++)
       {
-        theTarget << PT->UVNode(i).X();
-        theTarget << PT->UVNode(i).Y();
+        theTarget << PT->UVNode (i).X();
+        theTarget << PT->UVNode (i).Y();
       }
     }
 
     // Write triangles
-    const Poly_Array1OfTriangle& Triangles = PT->Triangles();
     for (i = 1; i <= nbTriangles; i++)
     {
-      Triangles(i).Get(n1, n2, n3);
+      PT->Triangle (i).Get (n1, n2, n3);
       theTarget << n1;
       theTarget << n2;
       theTarget << n3;
index fb15e5951d19e95dad851b998cf7c1cbcbf3ec9b..6a93b239786a47d1367b1c0d4c688a9784dbf928 100644 (file)
@@ -12,3 +12,5 @@ BinMDataXtd_PositionDriver.hxx
 BinMDataXtd_PositionDriver.cxx
 BinMDataXtd_TriangulationDriver.cxx
 BinMDataXtd_TriangulationDriver.hxx
+BinMDataXtd_SurfacicMeshDriver.cxx
+BinMDataXtd_SurfacicMeshDriver.hxx
index 6af7ad3d61c77f50423f70f7eeb65bd2e4113cbc..3e53e0191b19867a1ebaf414e103bcc117ca4437 100644 (file)
@@ -1321,10 +1321,11 @@ void BinTools_ShapeSet::ReadPolygonOnTriangulation
       Standard_Integer aNbNodes = 0;
       BinTools::GetInteger(IS, aNbNodes);
       Handle(Poly_PolygonOnTriangulation) aPoly = new Poly_PolygonOnTriangulation (aNbNodes, Standard_False);
-      TColStd_Array1OfInteger& aNodes = aPoly->ChangeNodes();
       for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
       {
-        BinTools::GetInteger(IS, aNodes.ChangeValue (aNodeIter));
+        Standard_Integer aNode;
+        BinTools::GetInteger(IS, aNode);
+        aPoly->SetNode (aNodeIter, aNode);
       }
 
       Standard_Real aDefl = 0.0;
@@ -1498,10 +1499,9 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
       BinTools::PutReal(OS, aTriangulation->Deflection());
 
       // write the 3d nodes
-      const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
       for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
       {
-        const gp_Pnt& aPnt = aNodes.Value (aNodeIter);
+        const gp_Pnt& aPnt = aTriangulation->Node (aNodeIter);
         BinTools::PutReal(OS, aPnt.X());
         BinTools::PutReal(OS, aPnt.Y());
         BinTools::PutReal(OS, aPnt.Z());
@@ -1509,19 +1509,17 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
 
       if (aTriangulation->HasUVNodes())
       {
-        const TColgp_Array1OfPnt2d& aUVNodes = aTriangulation->UVNodes();
         for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
         {
-          const gp_Pnt2d aUV = aUVNodes.Value (aNodeIter);
+          const gp_Pnt2d& aUV = aTriangulation->UVNode (aNodeIter);
           BinTools::PutReal(OS, aUV.X());
           BinTools::PutReal(OS, aUV.Y());
         }
       }
 
-      const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
       for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
       {
-        const Poly_Triangle& aTri = aTriangles.Value (aTriIter);
+        const Poly_Triangle& aTri = aTriangulation->Triangle (aTriIter);
         BinTools::PutInteger(OS, aTri.Value (1));
         BinTools::PutInteger(OS, aTri.Value (2));
         BinTools::PutInteger(OS, aTri.Value (3));
@@ -1532,11 +1530,12 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
       {
         if (aTriangulation->HasNormals() && NeedToWriteNormals)
         {
-          const TShort_Array1OfShortReal& aNormals = aTriangulation->Normals();
-          for (Standard_Integer aNormalIter = 1; aNormalIter <= 3 * aNbNodes; ++aNormalIter)
+          for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
           {
-            const Standard_ShortReal& aNormal = aNormals.Value(aNormalIter);
-            BinTools::PutShortReal(OS, aNormal);
+            const gp_Dir aNormal = aTriangulation->Normal (aNormalIter);
+            BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.X());
+            BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Y());
+            BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Z());
           }
         }
       }
@@ -1589,45 +1588,40 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
       Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (aNbNodes, aNbTriangles, hasUV, hasNormals);
       aTriangulation->Deflection (aDefl);
 
-      TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
       for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
       {
-        Standard_Real* anXYZ = aNodes.ChangeValue (aNodeIter).ChangeCoord().ChangeData();
-        BinTools::GetReal(IS, anXYZ[0]);
-        BinTools::GetReal(IS, anXYZ[1]);
-        BinTools::GetReal(IS, anXYZ[2]);
+        BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(1));
+        BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(2));
+        BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(3));
       }
 
       if (hasUV)
       {
-        TColgp_Array1OfPnt2d& aUVNodes = aTriangulation->ChangeUVNodes();
         for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
         {
-          gp_XY& anUV = aUVNodes.ChangeValue (aNodeIter).ChangeCoord();
-          BinTools::GetReal(IS, anUV.ChangeCoord (1));
-          BinTools::GetReal(IS, anUV.ChangeCoord (2));
+          BinTools::GetReal(IS, aTriangulation->ChangeUVNode (aNodeIter).ChangeCoord().ChangeCoord (1));
+          BinTools::GetReal(IS, aTriangulation->ChangeUVNode (aNodeIter).ChangeCoord().ChangeCoord (2));
         }
       }
 
       // read the triangles
-      Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
       for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
       {
-        Poly_Triangle& aTri = aTriangles.ChangeValue (aTriIter);
-        BinTools::GetInteger(IS, aTri.ChangeValue (1));
-        BinTools::GetInteger(IS, aTri.ChangeValue (2));
-        BinTools::GetInteger(IS, aTri.ChangeValue (3));
+        BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (1));
+        BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (2));
+        BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (3));
       }
 
       if (hasNormals)
       {
-        TShort_Array1OfShortReal& aNormals = aTriangulation->ChangeNormals();
-        for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes*3; ++aNormalIter)
+        for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
         {
-          Standard_ShortReal aNormalFromFile;
-          BinTools::GetShortReal(IS, aNormalFromFile);
-          Standard_ShortReal& aNormalCoordinate = aNormals.ChangeValue(aNormalIter);
-          aNormalCoordinate = aNormalFromFile;
+          Standard_ShortReal aNormalX, aNormalY, aNormalZ;
+          BinTools::GetShortReal(IS, aNormalX);
+          BinTools::GetShortReal(IS, aNormalY);
+          BinTools::GetShortReal(IS, aNormalZ);
+          gp_Dir aNormal(aNormalX, aNormalY, aNormalZ);
+          aTriangulation->SetNormal (aNormalIter, aNormal);
         }
       }
 
index a68f49f7e4a8307b3e95ce716ea1b55a92419692..b9fd5016e50a2016062d981a9a7c8242e059415f 100644 (file)
@@ -779,10 +779,9 @@ void  DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
        BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, PolyTr, loc);
        if (!Poly.IsNull()) {
          const TColStd_Array1OfInteger& Indices = Poly->Nodes();
-         const TColgp_Array1OfPnt& Nodes = PolyTr->Nodes();
          for (i=Indices.Lower()+1; i<=Indices.Upper(); i++) {
-           dis.Draw(Nodes(Indices(i-1)).Transformed(loc),
-                    Nodes(Indices(i)).Transformed(loc));
+           dis.Draw (PolyTr->Node (Indices (i-1)).Transformed (loc),
+                         PolyTr->Node (Indices (i)).Transformed (loc));
            if (dis.HasPicked()) {
              pickshape = E->Edge();
              upick = 0;
@@ -1079,11 +1078,11 @@ void  DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
   NCollection_Vector< NCollection_Vec2<Standard_Integer> > anInternal;
 
   Standard_Integer fr = 1;
-  const Poly_Array1OfTriangle& triangles = T->Triangles();
+
   Standard_Integer n[3];
   for (i = 1; i <= nbTriangles; i++) {
     pc.Triangles(i,t[0],t[1],t[2]);
-    triangles(i).Get(n[0],n[1],n[2]);
+    T->Triangle (i).Get (n[0],n[1],n[2]);
     for (j = 0; j < 3; j++) {
       Standard_Integer k = (j+1) % 3;
       if (t[j] == 0) {
@@ -1099,16 +1098,14 @@ void  DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
   }
 
   // Display the edges
-  const TColgp_Array1OfPnt& Nodes = T->Nodes();
-//  std::cout<<"nb nodes = "<<Nodes.Length()<<std::endl;
   
   // free edges
   Standard_Integer nn;
   dis.SetColor(Draw_rouge);
   nn = Free.Length() / 2;
   for (i = 1; i <= nn; i++) {
-    dis.Draw(Nodes(Free(2*i-1)).Transformed(tr),
-            Nodes(Free(2*i)).Transformed(tr));
+    dis.Draw (T->Node (Free (2*i-1)).Transformed (tr),
+              T->Node (Free (2*i)).Transformed (tr));
   }
   
   // internal edges
@@ -1118,7 +1115,7 @@ void  DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
   {
     const Standard_Integer n1 = anInterIter.Value()[0];
     const Standard_Integer n2 = anInterIter.Value()[1];
-    dis.Draw (Nodes(n1).Transformed(tr), Nodes(n2).Transformed(tr));
+    dis.Draw (T->Node (n1).Transformed (tr), T->Node (n2).Transformed (tr));
   }
 }
 
@@ -1139,11 +1136,10 @@ Standard_Boolean DBRep_DrawableShape::addMeshNormals (NCollection_Vector<std::pa
     return Standard_False;
   }
 
-  const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
   BRepAdaptor_Surface aSurface (theFace);
-  for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+  for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
   {
-    gp_Pnt aP1 = aNodes (aNodeIter);
+    gp_Pnt aP1 = aTriangulation->Node (aNodeIter);
     if (!aLoc.IsIdentity())
     {
       aP1.Transform (aLoc.Transformation());
index 3cc31d101745ca740aa72f0d3c983a6fbb73d2a5..be43740d03c50c60c73abc7875289aa1ae9727f6 100644 (file)
@@ -54,6 +54,7 @@
 
 // LES ATTRIBUTES
 #include <TDataStd.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
 #include <TDataXtd_Triangulation.hxx>
 #include <TDataStd_Comment.hxx>
 #include <TDataStd_Name.hxx>
@@ -4357,9 +4358,9 @@ static Standard_Integer DDataStd_SetTriangulation (Draw_Interpretor& di,
 //purpose  : DumpTriangulation (DF, entry)
 //=======================================================================
 
-static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
-                                           Standard_Integer nb,
-                                           const char** arg)
+static Standard_Integer DDataStd_DumpTriangulation (Draw_Interpretor& di,
+                                                    Standard_Integer nb,
+                                                    const char** arg)
 {
   if (nb == 3)
   {
@@ -4395,6 +4396,98 @@ static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
   return 1;
 }
 
+//=======================================================================
+//function : DDataStd_SetMesh
+//purpose  : SetMesh (DF, entry, face)
+//=======================================================================
+
+static Standard_Integer DDataStd_SetMesh (Draw_Interpretor& di,
+                                          Standard_Integer nb, 
+                                          const char** arg) 
+{     
+  if (nb == 4)
+  {    
+    Handle(TDF_Data) aDF;
+    if (!DDF::GetDF (arg[1], aDF))
+      return 1;
+
+    TDF_Label aLabel;
+    if (!DDF::AddLabel (aDF, arg[2], aLabel))
+      return 1;
+
+    // Get face.
+    TopoDS_Shape aFace = DBRep::Get (arg[3]);
+    if (aFace.IsNull() ||
+        aFace.ShapeType() != TopAbs_FACE)
+    {
+      di << "The face is null or not a face.\n";
+      return 1;
+    }
+
+    // Get triangulation of the face.
+    TopLoc_Location aLoc;
+    Handle(Poly_Triangulation) aTris = BRep_Tool::Triangulation (TopoDS::Face (aFace), aLoc);
+    if (aTris.IsNull())
+    {
+      di << "No triangulation in the face.\n";
+      return 1;
+    }
+
+    // Make a mesh.
+    Handle(Poly_Mesh) aMesh = new Poly_Mesh (aTris);
+
+    // Set the attribute.
+    TDataXtd_SurfacicMesh::Set (aLabel, aMesh);
+    return 0;
+  }
+  di << "DDataStd_SetMesh : Error\n";
+  return 1;
+}
+
+//=======================================================================
+//function : DDataStd_DumpMesh
+//purpose  : DumpMesh (DF, entry)
+//=======================================================================
+
+static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
+                                           Standard_Integer nb, 
+                                           const char** arg) 
+{     
+  if (nb == 3)
+  {
+    Handle(TDF_Data) aDF;
+    if (!DDF::GetDF (arg[1], aDF))
+      return 1;
+
+    Handle(TDataXtd_SurfacicMesh) aMesh;
+    if (!DDF::Find (aDF, arg[2], TDataXtd_SurfacicMesh::GetID(), aMesh))
+    {
+      di << "The attribute mesh doesn't exist at the label.\n";
+      return 1;
+    }
+
+    // Dump of the mesh.
+    if (aMesh->Get().IsNull())
+    {
+      di << "No mesh in the attribute.\n";
+      return 1;
+    }
+
+    di << "Deflection            " << aMesh->Deflection() <<"\n";
+    di << "Number of nodes       " << aMesh->NbNodes() << "\n";
+    di << "Number of triangles   " << aMesh->NbTriangles() << "\n";
+    di << "Number of quadrangles " << aMesh->NbQuads() << "\n";
+    if (aMesh->HasUVNodes())
+      di << "It has 2d-nodes\n";
+    if (aMesh->HasNormals())
+      di << "It has normals\n";
+
+    return 0;
+  }
+  di << "DDataStd_DumpMesh : Error\n";
+  return 1;
+}
+
 //=======================================================================
 //function : BasicCommands
 //purpose  : 
@@ -4516,6 +4609,11 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
                    "SetTriangulation (DF, entry, face) - adds label with passed entry to \
                     DF and put an attribute with the triangulation from passed face",
                    __FILE__, DDataStd_SetTriangulation, g);
+  
+   theCommands.Add ("SetMesh", 
+                   "SetMesh (DF, entry, face) - adds label with passed entry to \
+                    DF and put an attribute with the triangulation from passed face",
+                   __FILE__, DDataStd_SetMesh, g);
 
    theCommands.Add ("InsertBeforeExtStringList", 
                    "InsertBeforeExtStringList (DF, entry, index, value )",
@@ -4826,6 +4924,11 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
    theCommands.Add ("DumpTriangulation", 
                    "DumpTriangulations (DF, entry) - dumps info about triangulation that \
                     stored in DF in triangulation attribute of a label with the passed entry",
+                    __FILE__, DDataStd_DumpTriangulation, g);
+
+   theCommands.Add ("DumpMesh", 
+                   "DumpMesh (DF, entry) - dumps info about mesh that stored \
+                    in DF in mesh attribute of a label with the passed entry",
                     __FILE__, DDataStd_DumpMesh, g);
 
 //======================================================================
index ddc1ad269699a1024739a621b39428825087a5ff..2e3f59828d814f29a760085b4e496807c418dd69 100644 (file)
@@ -64,11 +64,10 @@ DrawTrSurf_Triangulation::DrawTrSurf_Triangulation
   TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
 
   Standard_Integer fr = 1, in = 1;
-  const Poly_Array1OfTriangle& triangles = T->Triangles();
   Standard_Integer n[3];
   for (i = 1; i <= nbTriangles; i++) {
     pc.Triangles(i,t[0],t[1],t[2]);
-    triangles(i).Get(n[0],n[1],n[2]);
+    T->Triangle (i).Get (n[0],n[1],n[2]);
     for (j = 0; j < 3; j++) {
       Standard_Integer k = (j+1) % 3;
       if (t[j] == 0) {
@@ -146,15 +145,14 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
   // Display the edges
   Standard_Integer i,n;
 
-  const TColgp_Array1OfPnt& Nodes = myTriangulation->Nodes();
-  
   // free edges
 
   dis.SetColor(Draw_rouge);
   const TColStd_Array1OfInteger& Free = myFree->Array1();
   n = Free.Length() / 2;
   for (i = 1; i <= n; i++) {
-    dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
+    dis.Draw (myTriangulation->Node (Free (2*i-1)),
+              myTriangulation->Node (Free (2*i)));
   }
   
   // internal edges
@@ -163,7 +161,8 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
   const TColStd_Array1OfInteger& Internal = myInternals->Array1();
   n = Internal.Length() / 2;
   for (i = 1; i <= n; i++) {
-    dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
+    dis.Draw (myTriangulation->Node (Internal (2*i-1)),
+              myTriangulation->Node (Internal (2*i)));
   }
 
   // texts
@@ -173,7 +172,7 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
     n = myTriangulation->NbNodes();
     for (i = 1; i <= n; i++) {
       Sprintf(text,"%d",i);
-      dis.DrawString(Nodes(i),text);
+      dis.DrawString (myTriangulation->Node (i), text);
     }
   }
 
@@ -181,13 +180,12 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
     dis.SetColor(Draw_vert);
     n = myTriangulation->NbTriangles();
     Standard_Integer t[3],j;
-    const Poly_Array1OfTriangle& triangle = myTriangulation->Triangles();
     for (i = 1; i <= n; i++) {
-      triangle(i).Get(t[0],t[1],t[2]);
+      myTriangulation->Triangle (i).Get (t[0],t[1],t[2]);
       gp_Pnt P(0,0,0);
       gp_XYZ& bary = P.ChangeCoord();
       for (j = 0; j < 3; j++)
-       bary.Add(Nodes(t[j]).Coord());
+           bary.Add (myTriangulation->Node (t[j]).Coord());
       bary.Multiply(1./3.);
 
       Sprintf(text,"%d",i);
index 88ba30c3f8b4c24589fead44d73a5a1fca3e27c8..05f62a296c7f42b75ce825240ee6e43e12e4bcd8 100644 (file)
@@ -67,11 +67,10 @@ DrawTrSurf_Triangulation2D::DrawTrSurf_Triangulation2D
   TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
 
   Standard_Integer fr = 1, in = 1;
-  const Poly_Array1OfTriangle& triangles = T->Triangles();
   Standard_Integer n[3];
   for (i = 1; i <= nbTriangles; i++) {
     pc.Triangles(i,t[0],t[1],t[2]);
-    triangles(i).Get(n[0],n[1],n[2]);
+    T->Triangle(i).Get (n[0],n[1],n[2]);
     for (j = 0; j < 3; j++) {
       Standard_Integer k = (j+1) % 3;
       if (t[j] == 0) {
@@ -109,16 +108,15 @@ void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
   // Display the edges
   Standard_Integer i,n;
   if (myTriangulation->HasUVNodes()) {
-    
-    const TColgp_Array1OfPnt2d& Nodes = myTriangulation->UVNodes();
-    
+
     // free edges
     
     dis.SetColor(Draw_rouge);
     const TColStd_Array1OfInteger& Free = myFree->Array1();
     n = Free.Length() / 2;
     for (i = 1; i <= n; i++) {
-      dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
+      dis.Draw (myTriangulation->UVNode (Free (2*i-1)),
+                myTriangulation->UVNode (Free (2*i)));
     }
     
     // internal edges
@@ -127,7 +125,8 @@ void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
     const TColStd_Array1OfInteger& Internal = myInternals->Array1();
     n = Internal.Length() / 2;
     for (i = 1; i <= n; i++) {
-      dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
+      dis.Draw (myTriangulation->UVNode (Internal (2*i-1)),
+                myTriangulation->UVNode (Internal (2*i)));
     }
     
   }
index 17e9c053645591e8599ae3e072caa51bc54ab4ee..b49b29bd029848a108a11be149b755e00bf3bf10 100644 (file)
@@ -428,10 +428,8 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
          TTMa[2][0] = ttma.Value(3,1);
          TTMa[2][1] = ttma.Value(3,2);
          TTMa[2][2] = ttma.Value(3,3);
-         Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
-         TColgp_Array1OfPnt    & Nod = Tr->ChangeNodes();
-         Standard_Integer nbN = Nod.Upper();
-         Standard_Integer nbT = Tri.Upper();
+         Standard_Integer nbN = Tr->NbNodes();
+         Standard_Integer nbT = Tr->NbTriangles();
          PD (f) = new HLRAlgo_PolyData();
          psd->PolyData().ChangeValue(iFace) = PD(f);
          PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
@@ -452,22 +450,19 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
          HLRAlgo_Array1OfTData* TData = &pid->TData();
          HLRAlgo_Array1OfPISeg* PISeg = &pid->PISeg();
          HLRAlgo_Array1OfPINod* PINod = &pid->PINod();
-         Poly_Triangle       * OT = &(Tri.ChangeValue(1));
          HLRAlgo_TriangleData* NT = &TData->ChangeValue(1);
 
          for (i = 1; i <= nbT; i++) {
-           OT->Get(NT->Node1, NT->Node2, NT->Node3);
+           Tr->Triangle (i).Get (NT->Node1, NT->Node2, NT->Node3);
            NT->Flags = 0;
            if (reversed) {
              j         = NT->Node1;
              NT->Node1 = NT->Node3;
              NT->Node3 = j;
            }
-           OT++;
            NT++;
          }
 
-         gp_Pnt                          * ON = &(Nod.ChangeValue(1));
          Handle(HLRAlgo_PolyInternalNode)* NN = &PINod->ChangeValue(1);
 
          for (i = 1; i <= nbN; i++) {
@@ -475,23 +470,20 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
            HLRAlgo_PolyInternalNode::NodeIndices& aNodIndices = (*NN)->Indices();
            aNodIndices.NdSg = 0;
            aNodIndices.Flag = 0;
-      Nod1RValues.Point = ON->Coord();
+        Nod1RValues.Point = Tr->Node (i).Coord();
            TTMultiply(Nod1RValues.Point);
-           ON++;
            NN++;
          }
          pid->UpdateLinks(TData,PISeg,PINod);
          if (Tr->HasUVNodes()) {
            myBSurf.Initialize(F,Standard_False);
-           TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
-           gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
            NN             = &(((HLRAlgo_Array1OfPINod*)PINod)->
                               ChangeValue(1));
            
            for (i = 1; i <= nbN; i++) {
              HLRAlgo_PolyInternalNode::NodeIndices& aNodIndices = (*NN)->Indices();
              HLRAlgo_PolyInternalNode::NodeData& Nod1RValues = (*NN)->Data();
-        Nod1RValues.UV = OUVN->Coord();
+          Nod1RValues.UV = Tr->UVNode (i).Coord();
              if (Normal(i,aNodIndices,Nod1RValues,
                         TData,PISeg,PINod,Standard_False))
                aNodIndices.Flag |=  NMsk_Norm;
@@ -499,7 +491,6 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
                aNodIndices.Flag &= ~NMsk_Norm;
                Nod1RValues.Scal = 0;
              }
-             OUVN++;
              NN++;
            }
          }
index 13e9113d9e812aa87c34eadb80a31adb1c714b51..f89a543b1d7718d6accea7c5c3d5117be42241e9 100644 (file)
@@ -386,7 +386,12 @@ void IVtkOCC_ShapeMesher::addEdge (const TopoDS_Edge&  theEdge,
   {
     Standard_Integer aNbNodes = aPolyOnTriangulation->NbNodes();
     const TColStd_Array1OfInteger& aPointIds = aPolyOnTriangulation->Nodes();
-    const TColgp_Array1OfPnt& aPoints = aTriangulation->Nodes();
+
+    TColgp_Array1OfPnt aPoints(1, aTriangulation->NbNodes());
+    for (Standard_Integer anI = 1; anI <= aTriangulation->NbNodes(); anI++)
+    {
+      aPoints.SetValue (anI, aTriangulation->Node (anI));
+    }
 
     processPolyline (aNbNodes,
                      aPoints,
@@ -493,7 +498,6 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
   }
 
   // Get triangulation points.
-  const TColgp_Array1OfPnt& aPoints = anOcctTriangulation->Nodes();
   Standard_Integer aNbPoints = anOcctTriangulation->NbNodes();
 
   // Keep inserted points id's of triangulation in an array.
@@ -503,7 +507,7 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
   Standard_Integer anI;
   for (anI = 1; anI <= aNbPoints; anI++)
   {
-    gp_Pnt aPoint = aPoints (anI);
+    gp_Pnt aPoint = anOcctTriangulation->Node (anI);
 
     if (!noTransform)
     {
@@ -516,12 +520,11 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
   }
 
   // Create triangles on the created triangulation points.
-  const Poly_Array1OfTriangle& aTriangles = anOcctTriangulation->Triangles();
   Standard_Integer aNbTriangles = anOcctTriangulation->NbTriangles();
   Standard_Integer aN1, aN2, aN3;
   for (anI = 1; anI <= aNbTriangles; anI++)
   {
-    aTriangles(anI).Get (aN1, aN2, aN3); // get indexes of triangle's points
+    anOcctTriangulation->Triangle (anI).Get (aN1, aN2, aN3); // get indexes of triangle's points
     // Insert new triangle on these points into output shape data.
     myShapeData->InsertTriangle (
       theShapeId, aPointIds(aN1), aPointIds(aN2), aPointIds(aN3), MT_ShadedFace);
index 7b9b1c662584bce6e63608612d42c468ee108566..d18a49c6affd34fbd84fc32b39c80bd453b85487 100644 (file)
@@ -334,7 +334,6 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
     new Poly_Triangulation (aNbNodes, aNbTriangles, Standard_False);
 
   // fill nodes
-  TColgp_Array1OfPnt &aNodes = aTriangulation->ChangeNodes();
   GeomAdaptor_Surface anAdSurf (aSurf);
   double aDU = (aUMax - aUMin) / aNbU;
   double aDV = (aVMax - aVMin) / aNbV;
@@ -345,12 +344,11 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
     {
       double aV = aVMin + iV * aDV;
       gp_Pnt aP = anAdSurf.Value (aU, aV);
-      aNodes.SetValue (iShift + iV, aP);
+      aTriangulation->ChangeNode (iShift + iV) = aP;
     }
   }
 
   // fill triangles
-  Poly_Array1OfTriangle &aTriangles = aTriangulation->ChangeTriangles();
   for (int iU = 0, iShift = 1, iTri = 0; iU < aNbU; iU++, iShift += aNbV + 1)
   {
     for (int iV = 0; iV < aNbV; iV++)
@@ -358,8 +356,8 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
       int iBase = iShift + iV;
       Poly_Triangle aTri1 (iBase, iBase + aNbV + 2, iBase + 1);
       Poly_Triangle aTri2 (iBase, iBase + aNbV + 1, iBase + aNbV + 2);
-      aTriangles.SetValue (++iTri, aTri1);
-      aTriangles.SetValue (++iTri, aTri2);
+      aTriangulation->ChangeTriangle (++iTri) = aTri1;
+      aTriangulation->ChangeTriangle (++iTri) = aTri2;
     }
   }
 
@@ -574,21 +572,18 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
     Standard_Real deflemax = 0, deflemin = 1.e100;
     if (!T.IsNull()) {
       Standard_Real defstock = T->Deflection();
-      const Poly_Array1OfTriangle& triangles  = T->Triangles();
-      const TColgp_Array1OfPnt2d&  Nodes2d    = T->UVNodes();
-      const TColgp_Array1OfPnt&    Nodes      = T->Nodes();
 
       S = BRep_Tool::Surface(F, L);
 
-      for(i = 1; i <= triangles.Length(); i++) {
+      for(i = 1; i <= T->NbTriangles(); i++) {
         if (F.Orientation() == TopAbs_REVERSED) 
-          triangles(i).Get(n1,n3,n2);
+          T->Triangle (i).Get (n1,n3,n2);
         else 
-          triangles(i).Get(n1,n2,n3);
+          T->Triangle (i).Get (n1,n2,n3);
 
-        const gp_XY& xy1 = Nodes2d(n1).XY();
-        const gp_XY& xy2 = Nodes2d(n2).XY();
-        const gp_XY& xy3 = Nodes2d(n3).XY();
+        const gp_XY& xy1 = T->UVNode (n1).XY();
+        const gp_XY& xy2 = T->UVNode (n2).XY();
+        const gp_XY& xy3 = T->UVNode (n3).XY();
 
         mi2d1.SetCoord((xy2.X()+xy3.X())*0.5, 
           (xy2.Y()+xy3.Y())*0.5);
@@ -597,9 +592,9 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
         mi2d3.SetCoord((xy1.X()+xy2.X())*0.5, 
           (xy1.Y()+xy2.Y())*0.5);
 
-        gp_XYZ p1 = Nodes(n1).Transformed(L.Transformation()).XYZ();
-        gp_XYZ p2 = Nodes(n2).Transformed(L.Transformation()).XYZ();
-        gp_XYZ p3 = Nodes(n3).Transformed(L.Transformation()).XYZ();
+        gp_XYZ p1 = T->Node (n1).Transformed (L.Transformation()).XYZ();
+        gp_XYZ p2 = T->Node (n2).Transformed (L.Transformation()).XYZ();
+        gp_XYZ p3 = T->Node (n3).Transformed (L.Transformation()).XYZ();
 
         vecEd1=p2-p1;
         vecEd2=p3-p2;
@@ -721,11 +716,10 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
     TColStd_Array1OfInteger Internal(0,2*nInternal);
 
     Standard_Integer fr = 1, in = 1;
-    const Poly_Array1OfTriangle& triangles = T->Triangles();
     Standard_Integer nodes[3];
     for (i = 1; i <= nbTriangles; i++) {
       pc.Triangles(i,t[0],t[1],t[2]);
-      triangles(i).Get(nodes[0],nodes[1],nodes[2]);
+      T->Triangle (i).Get (nodes[0],nodes[1],nodes[2]);
       for (j = 0; j < 3; j++) {
         Standard_Integer k = (j+1) % 3;
         if (t[j] == 0) {
@@ -744,17 +738,15 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
 
     // Display the edges
     if (T->HasUVNodes()) {
-      const TColgp_Array1OfPnt2d& Nodes2d = T->UVNodes();
-
       Handle(Draw_Segment2D) Seg;
 
       // free edges
       Standard_Integer nn;
       nn = Free.Length() / 2;
       for (i = 1; i <= nn; i++) {
-        Seg = new Draw_Segment2D(Nodes2d(Free(2*i-1)),
-          Nodes2d(Free(2*i)),
-          Draw_rouge);
+        Seg = new Draw_Segment2D (T->UVNode (Free (2*i-1)),
+                                  T->UVNode (Free (2*i)),
+                                  Draw_rouge);
         dout << Seg;
       }
 
@@ -762,9 +754,9 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
 
       nn = nInternal;
       for (i = 1; i <= nn; i++) {
-        Seg = new Draw_Segment2D(Nodes2d(Internal(2*i-1)),
-          Nodes2d(Internal(2*i)),
-          Draw_bleu);
+        Seg = new Draw_Segment2D (T->UVNode (Internal (2*i-1)),
+                                  T->UVNode (Internal (2*i)),
+                                  Draw_bleu);
         dout << Seg;
       }
     }
@@ -833,11 +825,10 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
 
     if (!Tr.IsNull()) {
       nbNodes = Tr->NbNodes();
-      const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
 
       // les noeuds.
       for (i = 1; i <= nbNodes; i++) {
-        gp_Pnt Pnt = Nodes(i).Transformed(L.Transformation());
+        gp_Pnt Pnt = Tr->Node (i).Transformed (L.Transformation());
         x = Pnt.X();
         y = Pnt.Y();
         z = Pnt.Z();
@@ -850,12 +841,11 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
       // les normales.
 
       if (Tr->HasUVNodes()) {
-        const TColgp_Array1OfPnt2d& UVNodes = Tr->UVNodes();
         BRepAdaptor_Surface BS(F, Standard_False);
 
         for (i = 1; i <= nbNodes; i++) {
-          U = UVNodes(i).X();
-          V = UVNodes(i).Y();
+          U = Tr->UVNode (i).X();
+          V = Tr->UVNode (i).Y();
 
           BS.D1(U,V,P,D1U,D1V);
           CSLib::Normal (D1U, D1V, Precision::Angular(), aStatus, Nor);
@@ -875,14 +865,12 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
 
       // les triangles.
       Standard_Integer nbTriangles = Tr->NbTriangles();
-      const Poly_Array1OfTriangle& triangles = Tr->Triangles();
-
 
       for (i = 1; i <= nbTriangles; i++) {
         if (F.Orientation()  == TopAbs_REVERSED)
-          triangles(i).Get(n1, n3, n2);
+          Tr->Triangle (i).Get (n1, n3, n2);
         else 
-          triangles(i).Get(n1, n2, n3);
+          Tr->Triangle (i).Get (n1, n2, n3);
         k1 = n1+totalnodes;
         k2 = n2+totalnodes;
         k3 = n3+totalnodes;
@@ -950,14 +938,13 @@ static Standard_Integer triedgepoints(Draw_Interpretor& di, Standard_Integer nba
       BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(it.Key()), aPoly, aT, aLoc);
       if ( aT.IsNull() || aPoly.IsNull() )
         continue;
-      
-      const TColgp_Array1OfPnt&      Nodes   = aT->Nodes();
+
       const TColStd_Array1OfInteger& Indices = aPoly->Nodes();
       const Standard_Integer         nbnodes = Indices.Length();
 
       for( Standard_Integer j = 1; j <= nbnodes; j++ )
       {
-        gp_Pnt P3d = Nodes(Indices(j));
+        gp_Pnt P3d = aT->Node (Indices (j));
         if( !aLoc.IsIdentity() )
           P3d.Transform(aLoc.Transformation());
 
index 5c3b92ba5f7389dfee235e15cd1ed24a17ac2fb1..428bd3c947d571bf392892ee97eff510dde08b81 100644 (file)
@@ -112,8 +112,6 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
       // check distances between corresponding points
       Standard_Real aSqDefle = BRep_Tool::Tolerance(aEdge);
       aSqDefle *= aSqDefle;
-      const TColgp_Array1OfPnt& aPoints1 = aT1->Nodes();
-      const TColgp_Array1OfPnt& aPoints2 = aT2->Nodes();
       Standard_Integer iF1 = aMapF.FindIndex(aFace1);
       Standard_Integer iF2 = aMapF.FindIndex(aFace2);
       Standard_Integer i1 = aNodes1.Lower();
@@ -121,17 +119,17 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
       const gp_Trsf &aTrsf1 = aFace1.Location().Transformation();
       const gp_Trsf &aTrsf2 = aFace2.Location().Transformation();
       for (; i1 <= aNodes1.Upper(); i1++, i2++) {
-       const gp_Pnt aP1 = aPoints1(aNodes1(i1)).Transformed(aTrsf1);
-       const gp_Pnt aP2 = aPoints2(aNodes2(i2)).Transformed(aTrsf2);
-       const Standard_Real aSqDist = aP1.SquareDistance(aP2);
+           const gp_Pnt aP1 = aT1->Node (aNodes1 (i1)).Transformed (aTrsf1);
+           const gp_Pnt aP2 = aT2->Node (aNodes2 (i2)).Transformed (aTrsf2);
+           const Standard_Real aSqDist = aP1.SquareDistance(aP2);
         if (aSqDist > aSqDefle)
         {
-         myErrors.Append(iF1);
-         myErrors.Append(i1);
-         myErrors.Append(iF2);
-         myErrors.Append(i2);
+             myErrors.Append(iF1);
+             myErrors.Append(i1);
+             myErrors.Append(iF2);
+             myErrors.Append(i2);
           myErrorsVal.Append(Sqrt(aSqDist));
-       }
+           }
       }
     }
   }
@@ -167,10 +165,9 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
 
     // check of free links and nodes
     Poly_Connect aConn(aT);
-    const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
     Standard_Integer nbTri = aT->NbTriangles(), i, j, n[3], t[3];
     for (i = 1; i <= nbTri; i++) {
-      aTriangles(i).Get(n[0], n[1], n[2]);
+      aT->Triangle (i).Get (n[0], n[1], n[2]);
       
       aUsedNodes.Add (n[0]);
       aUsedNodes.Add (n[1]);
index f65194a5823f6721a55000ca705997a0395f71ca..b7591f830acb929537e77e14cc410e5d701363b9 100644 (file)
@@ -303,15 +303,13 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
         std::cout << "face "<<i<<" has no triangulation"<<std::endl;
         continue;
       }
-      const Poly_Array1OfTriangle& triangles = aPoly->Triangles();
-      const TColgp_Array1OfPnt& nodes = aPoly->Nodes();
-      for (int j=triangles.Lower(); j <= triangles.Upper(); j++) {
-        const Poly_Triangle& tri = triangles(j);
+      for (int j = 1; j <= aPoly->NbTriangles(); j++) {
+        const Poly_Triangle& tri = aPoly->Triangle (j);
         int n1, n2, n3;
         tri.Get (n1, n2, n3);
-        const gp_Pnt& p1 = nodes(n1);
-        const gp_Pnt& p2 = nodes(n2);
-        const gp_Pnt& p3 = nodes(n3);
+        const gp_Pnt& p1 = aPoly->Node (n1);
+        const gp_Pnt& p2 = aPoly->Node (n2);
+        const gp_Pnt& p3 = aPoly->Node (n3);
         gp_Vec v1(p1, p2);
         gp_Vec v2(p1, p3);
         double ar = v1.CrossMagnitude(v2);
@@ -370,7 +368,6 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       const TopoDS_Face& aFace = TopoDS::Face(aShape);
       TopLoc_Location aLoc;
       Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
-      const TColgp_Array1OfPnt& aPoints = aT->Nodes();
       const gp_Trsf& trsf = aLoc.Transformation();
 
       TColgp_Array1OfPnt pnts(1,2);
@@ -379,17 +376,16 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
         Standard_Integer n1, n2;
         aCheck.GetFreeLink(k, i, n1, n2);
         di << "{" << n1 << " " << n2 << "} ";
-        pnts(1) = aPoints(n1).Transformed(trsf);
-        pnts(2) = aPoints(n2).Transformed(trsf);
+        pnts (1) = aT->Node (n1).Transformed (trsf);
+        pnts (2) = aT->Node (n2).Transformed (trsf);
         Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
         DrawTrSurf::Set (name, poly);
         DrawTrSurf::Set (name, pnts(1));
         DrawTrSurf::Set (name, pnts(2));
         if (aT->HasUVNodes())
         {
-          const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
-          pnts2d(1) = aPoints2d(n1);
-          pnts2d(2) = aPoints2d(n2);
+          pnts2d (1) = aT->UVNode (n1);
+          pnts2d (2) = aT->UVNode (n2);
           Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
           DrawTrSurf::Set (name, poly2d);
           DrawTrSurf::Set (name, pnts2d(1));
@@ -435,12 +431,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iface));
       TopLoc_Location aLoc;
       Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
-      const TColgp_Array1OfPnt& aPoints = aT->Nodes();
       const gp_Trsf& trsf = aLoc.Transformation();
-      DrawTrSurf::Set (name, aPoints(inode).Transformed(trsf));
+      DrawTrSurf::Set (name, aT->Node (inode).Transformed (trsf));
       if (aT->HasUVNodes())
       {
-        DrawTrSurf::Set (name, aT->UVNodes()(inode));
+        DrawTrSurf::Set (name, aT->UVNode (inode));
       }
 
       di << "{" << iface << " " << inode << "} ";
@@ -464,12 +459,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       const Poly_Triangle &aTri = aT->Triangle(aTriID);
       Standard_Integer aN1, aN2, aN3;
       aTri.Get(aN1, aN2, aN3);
-      const TColgp_Array1OfPnt& aPoints = aT->Nodes();
 
       TColgp_Array1OfPnt aPoles(1, 4);
-      aPoles(1) = aPoles(4) = aPoints(aN1).Transformed(aTrsf);
-      aPoles(2) = aPoints(aN2).Transformed(aTrsf);
-      aPoles(3) = aPoints(aN3).Transformed(aTrsf);
+      aPoles (1) = aPoles (4) = aT->Node (aN1).Transformed (aTrsf);
+      aPoles (2) = aT->Node (aN2).Transformed (aTrsf);
+      aPoles (3) = aT->Node (aN3).Transformed (aTrsf);
 
       TColStd_Array1OfInteger aMults(1, 4);
       aMults(1) = aMults(4) = 2;
@@ -488,9 +482,9 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       if (aT->HasUVNodes())
       {
         TColgp_Array1OfPnt2d aPoles2d(1, 4);
-        aPoles2d(1) = aPoles2d(4) = aT->UVNodes()(aN1);
-        aPoles2d(2) = aT->UVNodes()(aN2);
-        aPoles2d(3) = aT->UVNodes()(aN3);
+        aPoles2d (1) = aPoles2d (4) = aT->UVNode (aN1);
+        aPoles2d (2) = aT->UVNode (aN2);
+        aPoles2d (3) = aT->UVNode (aN3);
 
         Handle(Geom2d_BSplineCurve) aBS2d = new Geom2d_BSplineCurve(aPoles2d, aKnots, aMults, 1);
 
@@ -562,12 +556,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       break;
     }
 
-    const Poly_Array1OfTriangle& aTris = aT->Triangles();
     NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
-    Standard_Integer aTriNum = aTris.Length();
+    Standard_Integer aTriNum = aT->NbTriangles();
     for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
     {
-      const Poly_Triangle& aTri = aTris(aTriIndx);
+      const Poly_Triangle& aTri = aT->Triangle (aTriIndx);
       Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
 
       for (Standard_Integer j = 1; j <= 3; ++j)
@@ -590,7 +583,6 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
     {
       di << "Not connected mesh inside face " << aFaceId << "\n";
 
-      const TColgp_Array1OfPnt& aPoints = aT->Nodes();
       const gp_Trsf& trsf = aLoc.Transformation();
 
       TColgp_Array1OfPnt pnts(1,2);
@@ -600,17 +592,16 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
       {
         const BRepMesh_Edge& aLink = aMapIt.Key();
         di << "{" << aLink.FirstNode() << " " << aLink.LastNode() << "} ";
-        pnts(1) = aPoints(aLink.FirstNode()).Transformed(trsf);
-        pnts(2) = aPoints(aLink.LastNode()).Transformed(trsf);
+        pnts (1) = aT->Node (aLink.FirstNode()).Transformed (trsf);
+        pnts (2) = aT->Node (aLink.LastNode()).Transformed (trsf);
         Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
         DrawTrSurf::Set (name, poly);
         DrawTrSurf::Set (name, pnts(1));
         DrawTrSurf::Set (name, pnts(2));
         if (aT->HasUVNodes())
         {
-          const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
-          pnts2d(1) = aPoints2d(aLink.FirstNode());
-          pnts2d(2) = aPoints2d(aLink.LastNode());
+          pnts2d (1) = aT->UVNode (aLink.FirstNode());
+          pnts2d (2) = aT->UVNode (aLink.LastNode());
           Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
           DrawTrSurf::Set (name, poly2d);
           DrawTrSurf::Set (name, pnts2d(1));
index 53661cd543570e588f9501b6a0bf390b0178a88e..917eca557b94ab69dfb12fb35ba56d601f863478 100755 (executable)
@@ -13,10 +13,14 @@ Poly_CoherentTriPtr.cxx
 Poly_CoherentTriPtr.hxx
 Poly_Connect.cxx
 Poly_Connect.hxx
+Poly_Element.cxx
+Poly_Element.hxx
 Poly_HArray1OfTriangle.hxx
 Poly_ListOfTriangulation.hxx
 Poly_MakeLoops.cxx
 Poly_MakeLoops.hxx
+Poly_Mesh.cxx
+Poly_Mesh.hxx
 Poly_Polygon2D.cxx
 Poly_Polygon2D.hxx
 Poly_Polygon3D.cxx
index 179a657446fa0811d01e660e9fb878c45bb8c6f8..eeeb74c05a4ba5af1137e7cbaa2c2a0e3ccc0187 100644 (file)
@@ -57,23 +57,19 @@ Handle(Poly_Triangulation) Poly::Catenate (const Poly_ListOfTriangulation& lstTr
     Standard_Integer i, iNode[3];
     nNodes = 0;
     nTrian = 0;
-    TColgp_Array1OfPnt&    arrNode  = aResult->ChangeNodes();
-    Poly_Array1OfTriangle& arrTrian = aResult->ChangeTriangles();
     for (anIter.Init(lstTri); anIter.More(); anIter.Next()) {
       const Handle(Poly_Triangulation)& aTri = anIter.Value();
       if (aTri.IsNull() == Standard_False) {
-        const TColgp_Array1OfPnt&    srcNode  = aTri->Nodes();
-        const Poly_Array1OfTriangle& srcTrian = aTri->Triangles();
         const Standard_Integer nbNodes = aTri->NbNodes(); 
         const Standard_Integer nbTrian = aTri->NbTriangles(); 
         for (i = 1; i <= nbNodes; i++) {
-          arrNode.SetValue(i + nNodes, srcNode(i));
+          aResult->ChangeNode (i + nNodes) = aTri->Node (i);
         }
         for (i = 1; i <= nbTrian; i++) {
-          srcTrian(i).Get(iNode[0], iNode[1], iNode[2]);
-          arrTrian.SetValue(i + nTrian, Poly_Triangle(iNode[0] + nNodes,
-                                                      iNode[1] + nNodes,
-                                                      iNode[2] + nNodes));
+          aTri->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
+          aResult->ChangeTriangle (i + nTrian) = Poly_Triangle (iNode[0] + nNodes,
+                                                                iNode[1] + nNodes,
+                                                                iNode[2] + nNodes);
         }
         nNodes += nbNodes;
         nTrian += nbTrian;
@@ -113,36 +109,33 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
   if (!Compact) OS << "\n3D Nodes :\n";
 
   Standard_Integer i, nbNodes = T->NbNodes();
-  const TColgp_Array1OfPnt& Nodes = T->Nodes();
   for (i = 1; i <= nbNodes; i++) {
     if (!Compact) OS << std::setw(10) << i << " : ";
     if (!Compact) OS << std::setw(17);
-    OS << Nodes(i).X() << " ";
+    OS << T->Node (i).X() << " ";
     if (!Compact) OS << std::setw(17);
-    OS << Nodes(i).Y() << " ";
+    OS << T->Node (i).Y() << " ";
     if (!Compact) OS << std::setw(17);
-    OS << Nodes(i).Z() << "\n";
+    OS << T->Node (i).Z() << "\n";
   }
 
   if (T->HasUVNodes()) {
     if (!Compact) OS << "\nUV Nodes :\n";
-    const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
     for (i = 1; i <= nbNodes; i++) {
       if (!Compact) OS << std::setw(10) << i << " : ";
     if (!Compact) OS << std::setw(17);
-      OS << UVNodes(i).X() << " ";
+      OS << T->UVNode (i).X() << " ";
     if (!Compact) OS << std::setw(17);
-      OS << UVNodes(i).Y() << "\n";
+      OS << T->UVNode (i).Y() << "\n";
     }
   }
 
   if (!Compact) OS << "\nTriangles :\n";
   Standard_Integer nbTriangles = T->NbTriangles();
   Standard_Integer n1, n2, n3;
-  const Poly_Array1OfTriangle& Triangles = T->Triangles();
   for (i = 1; i <= nbTriangles; i++) {
     if (!Compact) OS << std::setw(10) << i << " : ";
-    Triangles(i).Get(n1, n2, n3);
+    T->Triangle (i).Get (n1, n2, n3);
     if (!Compact) OS << std::setw(10);
     OS << n1 << " ";
     if (!Compact) OS << std::setw(10);
@@ -447,21 +440,19 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
 //=======================================================================
 void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
 {
-  const TColgp_Array1OfPnt& aNodes   = theTri->Nodes();
-  const Standard_Integer    aNbNodes = aNodes.Size();
-
+  const Standard_Integer    aNbNodes = theTri->NbNodes();
   const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, aNbNodes * 3);
   aNormals->Init (0.0f);
   Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
 
   Standard_Integer anElem[3] = {0, 0, 0};
   const Standard_Real anEps2 = gp::Resolution();
-  for (Poly_Array1OfTriangle::Iterator aTriIter (theTri->Triangles()); aTriIter.More(); aTriIter.Next())
+  for (Standard_Integer iTri = 1; iTri <= theTri->NbTriangles(); iTri++)
   {
-    aTriIter.Value().Get (anElem[0], anElem[1], anElem[2]);
-    const gp_Pnt& aNode0 = aNodes.Value (anElem[0]);
-    const gp_Pnt& aNode1 = aNodes.Value (anElem[1]);
-    const gp_Pnt& aNode2 = aNodes.Value (anElem[2]);
+    theTri->Triangle (iTri).Get (anElem[0], anElem[1], anElem[2]);
+    const gp_Pnt& aNode0 = theTri->Node (anElem[0]);
+    const gp_Pnt& aNode1 = theTri->Node (anElem[1]);
+    const gp_Pnt& aNode2 = theTri->Node (anElem[2]);
 
     const gp_XYZ aVec01 = aNode1.XYZ() - aNode0.XYZ();
     const gp_XYZ aVec02 = aNode2.XYZ() - aNode0.XYZ();
index 772ee8183ece144566534c6774776ff7dc8f4030..0288ee37848495dcef29dab897b27d41d8cfcdd9 100644 (file)
@@ -51,44 +51,37 @@ Poly_CoherentTriangulation::Poly_CoherentTriangulation
              : theAlloc)
 {
   if (theTriangulation.IsNull() == Standard_False) {
-    const TColgp_Array1OfPnt&    arrNodes    = theTriangulation->Nodes();
-    const Poly_Array1OfTriangle& arrTriangle = theTriangulation->Triangles();
     const Standard_Integer nNodes = theTriangulation->NbNodes();
-    const Standard_Integer nTri   = theTriangulation->NbTriangles();
     Standard_Integer i;
 
     // Copy the nodes
     for (i = 0; i < nNodes; i++) {
-      const Standard_Integer anOldInd = i + arrNodes.Lower();
-      const Standard_Integer aNewInd = SetNode(arrNodes(anOldInd).XYZ(), i);
+      const Standard_Integer anOldInd = i + 1;
+      const Standard_Integer aNewInd = SetNode (theTriangulation->Node (anOldInd).XYZ(), i);
       Poly_CoherentNode& aCopiedNode = myNodes(aNewInd);
       aCopiedNode.SetIndex(anOldInd);
     }
 
     // Copy the triangles
-    for (i = 0; i < nTri; i++) {
+    for (i = 1; i <= theTriangulation->NbTriangles(); i++) {
       Standard_Integer iNode[3];
-      arrTriangle(i + arrTriangle.Lower()).Get(iNode[0], iNode[1], iNode[2]);
+      theTriangulation->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
       if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0])
         AddTriangle (iNode[0]-1, iNode[1]-1, iNode[2]-1);
     }
 
     // Copy UV coordinates of nodes
     if (theTriangulation->HasUVNodes()) {
-      const TColgp_Array1OfPnt2d& arrNodes2d = theTriangulation->UVNodes();
       for (i = 0; i < nNodes; i++) {
-        const gp_Pnt2d& anUV = arrNodes2d(i + arrNodes2d.Lower());
+        const gp_Pnt2d& anUV = theTriangulation->UVNode (i + 1);
         myNodes(i).SetUV(anUV.X(), anUV.Y());
       }
     }
 
     // Copy the normals at nodes
     if (theTriangulation->HasNormals()) {
-      const TShort_Array1OfShortReal& arrNorm = theTriangulation->Normals();
       for (i = 0; i < nNodes; i++) {
-        const gp_XYZ aNormal (arrNorm(3 * i + 0 + arrNorm.Lower()),
-                              arrNorm(3 * i + 1 + arrNorm.Lower()),
-                              arrNorm(3 * i + 2 + arrNorm.Lower()));
+        const gp_XYZ aNormal = theTriangulation->Normal (i + 1).XYZ();
         myNodes(i).SetNormal(aNormal);
       }
     }
@@ -125,9 +118,6 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
       new TShort_HArray1OfShortReal(1, 3 * nNodes);
     Standard_ShortReal * arrNormal = &harrNormal->ChangeValue(1);
 
-    TColgp_Array1OfPnt&    arrNodes    = aResult->ChangeNodes();
-    TColgp_Array1OfPnt2d&  arrNodesUV  = aResult->ChangeUVNodes();
-    Poly_Array1OfTriangle& arrTriangle = aResult->ChangeTriangles();
     NCollection_Vector<Standard_Integer> vecNodeId;
     Standard_Integer i, aCount(0);
     Standard_Boolean hasUV (Standard_False);
@@ -145,9 +135,9 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
         arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
 
         vecNodeId.SetValue(i, ++aCount);
-        arrNodes.SetValue(aCount, aNode);
+        aResult->ChangeNode (aCount) = aNode;
 
-        arrNodesUV.SetValue(aCount, gp_Pnt2d(aNode.GetU(), aNode.GetV()));
+        aResult->ChangeUVNode (aCount) = gp_Pnt2d (aNode.GetU(), aNode.GetV());
         if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
             Precision::Confusion())
           hasUV = Standard_True;
@@ -164,10 +154,9 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
     for (; anIterT.More(); anIterT.Next()) {
       const Poly_CoherentTriangle& aTri = anIterT.Value();
       if (aTri.IsEmpty() == Standard_False) {
-        const Poly_Triangle aPolyTriangle (vecNodeId(aTri.Node(0)),
-                                           vecNodeId(aTri.Node(1)),
-                                           vecNodeId(aTri.Node(2)));
-        arrTriangle.SetValue(++aCount, aPolyTriangle);
+        aResult->ChangeTriangle (++aCount) = Poly_Triangle (vecNodeId (aTri.Node (0)),
+                                                            vecNodeId (aTri.Node (1)),
+                                                            vecNodeId (aTri.Node (2)));;
       }
     }
     if (hasNormals)
index f1200515c8cad9af70e553e8b28227128b518012..8c6c6bd7bf03ef9ad75402490c6eac37136da270 100644 (file)
@@ -226,8 +226,7 @@ void Poly_Connect::Initialize(const Standard_Integer N)
   if (mymore)
   {
     Standard_Integer i, no[3];
-    const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
-    triangles(myfirst).Get(no[0], no[1], no[2]);
+    myTriangulation->Triangle (myfirst).Get (no[0], no[1], no[2]);
     for (i = 0; i < 3; i++)
       if (no[i] == mynode) break;
     myothernode = no[(i+2)%3];
@@ -244,12 +243,11 @@ void Poly_Connect::Next()
   Standard_Integer i, j;
   Standard_Integer n[3];
   Standard_Integer t[3];
-  const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
   Triangles(mytr, t[0], t[1], t[2]);
   if (mysense) {
     for (i = 0; i < 3; i++) {
       if (t[i] != 0) {
-       triangles(t[i]).Get(n[0], n[1], n[2]);
+       myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
        for (j = 0; j < 3; j++) {
          if ((n[j] == mynode) && (n[(j+1)%3] == myothernode)) {
            mytr = t[i];
@@ -261,7 +259,7 @@ void Poly_Connect::Next()
       }
     }
     // sinon, depart vers la gauche.
-    triangles(myfirst).Get(n[0], n[1], n[2]);
+    myTriangulation->Triangle (myfirst).Get (n[0], n[1], n[2]);
     for (i = 0; i < 3; i++)
       if (n[i] == mynode) break;
     myothernode = n[(i+1)%3];
@@ -272,7 +270,7 @@ void Poly_Connect::Next()
   if (!mysense) {
     for (i = 0; i < 3; i++) {
       if (t[i] != 0) {
-       triangles(t[i]).Get(n[0], n[1], n[2]);
+       myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
        for (j = 0; j < 3; j++) {
          if ((n[j] == mynode) && (n[(j+2)%3] == myothernode)) {
            mytr = t[i];
index 19a0052372c1beb00ff07a1b2d7a9c52b8298314..c7832eedbd22ad6710cfb15a12dca7df3be09266 100644 (file)
@@ -15,6 +15,7 @@
 // commercial license or contractual agreement.
 
 #include <Poly_PolygonOnTriangulation.hxx>
+#include <Standard_NullObject.hxx>
 #include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation,Standard_Transient)
@@ -78,6 +79,46 @@ Handle(Poly_PolygonOnTriangulation) Poly_PolygonOnTriangulation::Copy() const
   return aCopy;
 }
 
+//=======================================================================
+//function : SetNode
+//purpose  : 
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetNode (const Standard_Integer theIndex, const Standard_Integer theNode)
+{
+  Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myNodes.Length()),
+                                "Poly_PolygonOnTriangulation::SetNode : index out of range");
+  myNodes.SetValue (theIndex, theNode);
+}
+
+//=======================================================================
+//function : Parameter
+//purpose  : 
+//=======================================================================
+
+Standard_Real Poly_PolygonOnTriangulation::Parameter (const Standard_Integer theIndex) const 
+{
+  Standard_NullObject_Raise_if (myParameters.IsNull(),
+                                "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+  Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+                                "Poly_PolygonOnTriangulation::Parameter : index out of range");
+  return myParameters->Value (theIndex);
+}
+
+//=======================================================================
+//function : SetParameter
+//purpose  : 
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetParameter (const Standard_Integer theIndex, const Standard_Real theValue)
+{
+  Standard_NullObject_Raise_if (myParameters.IsNull(),
+                                "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+  Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+                                "Poly_PolygonOnTriangulation::Parameter : index out of range");
+  myParameters->SetValue (theIndex, theValue);
+}
+
 //=======================================================================
 //function : SetParameters
 //purpose  :
index 1ab2dc7e9b291a22ab445f85d39ba5e7676e8572..a4764e078d820a953de681efeb9f2e2da9b44102 100644 (file)
@@ -84,8 +84,13 @@ public:
   //! triangulation of a shape.
   const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
 
-  //! Returns the table of nodes for this polygon for modification.
-  TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
+  //! Return node at the given index.
+  //! Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
+  Standard_EXPORT Standard_Integer Node(const Standard_Integer theIndex) const;
+
+  //! Sets node at the given index.
+  //! Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
+  Standard_EXPORT void SetNode(const Standard_Integer theIndex, const Standard_Integer theNode);
 
   //! Returns true if parameters are associated with the nodes in this polygon.
   Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
@@ -96,9 +101,16 @@ public:
   //! are associated with the nodes in this polygon.
   const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
 
-  //! Returns the table of the parameters associated with each node in this polygon.
-  //! Warning! HasParameters() should be called beforehand to check if parameters array is allocated.
-  TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
+  //! Return parameter at the given index.
+  //! Raises Standard_NullObject exception if parameters has not been initialized.
+  //! Raises Standard_OutOfRange exception if theIndex is less than ParametersLowerIndex or bigger than ParametersUpperIndex.
+  Standard_EXPORT Standard_Real Parameter(const Standard_Integer theIndex) const;
+
+  //! Sets parameter at the given index.
+  //! Raises Standard_NullObject exception if parameters has not been initialized.
+  //! Raises Standard_OutOfRange exception if theIndex is less than ParametersLowerIndex or bigger than ParametersUpperIndex. 
+  Standard_EXPORT void SetParameter(const Standard_Integer theIndex, const Standard_Real theValue);
+
 
   //! Sets the table of the parameters associated with each node in this polygon.
   //! Raises exception if array size doesn't much number of polygon nodes.
index ae7ed0df2e73ad7ddfb9c703fad3d319ced2a3da..2d708010668b18409c3b32e385b67fa2188b320c 100644 (file)
@@ -31,7 +31,8 @@ IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
 //=======================================================================
 Poly_Triangulation::Poly_Triangulation()
 : myCachedMinMax (NULL),
-  myDeflection   (0)
+  myDeflection   (0),
+  myHasUVNodes   (Standard_False)
 {
 }
 
@@ -44,10 +45,20 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
                                        const Standard_Boolean theHasUVNodes)
 : myCachedMinMax (NULL),
   myDeflection   (0),
-  myNodes        (1, theNbNodes),
-  myTriangles    (1, theNbTriangles)
+  myHasUVNodes   (theHasUVNodes)
 {
-  if (theHasUVNodes) myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
+  if (theNbNodes > 0)
+  {
+    myNodes.SetValue (theNbNodes - 1, gp_Pnt());
+    if (myHasUVNodes)
+    {
+      myUVNodes.SetValue (theNbNodes - 1, gp_Pnt2d());
+    }
+  }
+  if (theNbTriangles > 0)
+  {
+    myTriangles.SetValue (theNbTriangles - 1, Poly_Triangle());
+  }
 }
 
 //=======================================================================
@@ -58,17 +69,11 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
                                        const Standard_Integer theNbTriangles,
                                        const Standard_Boolean theHasUVNodes,
                                        const Standard_Boolean theHasNormals)
-: myDeflection(0),
-  myNodes     (1, theNbNodes),
-  myTriangles (1, theNbTriangles)
+: Poly_Triangulation(theNbNodes, theNbTriangles, theHasUVNodes)
 {
-  if (theHasUVNodes)
-  {
-    myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
-  }
   if (theHasNormals)
   {
-    myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
+    myNormals.SetValue (theNbNodes - 1, gp_Dir());
   }
 }
 
@@ -80,11 +85,16 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt&    theNodes,
                                        const Poly_Array1OfTriangle& theTriangles)
 : myCachedMinMax (NULL),
   myDeflection   (0),
-  myNodes        (1, theNodes.Length()),
-  myTriangles    (1, theTriangles.Length())
+  myHasUVNodes   (Standard_False)
 {
-  myNodes = theNodes;
-  myTriangles = theTriangles;
+  for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
+  {
+    myNodes.SetValue (anIndex - 1, theNodes (anIndex));
+  }
+  for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
+  {
+    myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
+  }
 }
 
 //=======================================================================
@@ -97,13 +107,23 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt&    theNodes,
                                        const Poly_Array1OfTriangle& theTriangles)
 : myCachedMinMax (NULL),
   myDeflection   (0),
-  myNodes        (1, theNodes.Length()),
-  myTriangles    (1, theTriangles.Length())
+  myHasUVNodes   (theNodes.Length() == theUVNodes.Length())
 {
-  myNodes = theNodes;
-  myTriangles = theTriangles;
-  myUVNodes = new TColgp_HArray1OfPnt2d (1, theNodes.Length());
-  myUVNodes->ChangeArray1() = theUVNodes;
+  for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
+  {
+    myNodes.SetValue (anIndex - 1, theNodes (anIndex));
+  }
+  if (myHasUVNodes)
+  {
+    for (Standard_Integer anIndex = theUVNodes.Upper(); anIndex >= theUVNodes.Lower(); anIndex--)
+    {
+      myUVNodes.SetValue (anIndex - 1, theUVNodes (anIndex));
+    }
+  }
+  for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
+  {
+    myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
+  }
 }
 
 //=======================================================================
@@ -122,7 +142,13 @@ Poly_Triangulation::~Poly_Triangulation()
 
 Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
 {
-  return new Poly_Triangulation (this);
+  Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (NbNodes(), NbTriangles(), HasUVNodes());
+  aCopy->myNodes = myNodes;
+  aCopy->myTriangles = myTriangles;
+  aCopy->myUVNodes = myUVNodes;
+  aCopy->myDeflection = myDeflection;
+  aCopy->myNormals = myNormals;
+  return aCopy;
 }
 
 //=======================================================================
@@ -132,19 +158,17 @@ Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
 
 Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation)
 : myCachedMinMax(NULL),
-  myDeflection(theTriangulation->myDeflection),
-  myNodes(theTriangulation->Nodes()),
-  myTriangles(theTriangulation->Triangles())
+  myDeflection  (theTriangulation->myDeflection),
+  myHasUVNodes  (theTriangulation->myHasUVNodes)
 {
   SetCachedMinMax (theTriangulation->CachedMinMax());
-  if (theTriangulation->HasUVNodes())
-  {
-    myUVNodes = new TColgp_HArray1OfPnt2d(theTriangulation->myUVNodes->Array1());
-  }
-  if (theTriangulation->HasNormals())
+  myNodes.Assign(theTriangulation->myNodes);
+  if (myHasUVNodes)
   {
-    myNormals = new TShort_HArray1OfShortReal(theTriangulation->myNormals->Array1());
+    myUVNodes.Assign(theTriangulation->myUVNodes);
   }
+  myTriangles.Assign(theTriangulation->myTriangles);
+  myNormals.Assign(theTriangulation->myNormals);
 }
 
 //=======================================================================
@@ -152,7 +176,7 @@ Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTri
 //purpose  : 
 //=======================================================================
 
-void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
+void Poly_Triangulation::Deflection (const Standard_Real theDeflection)
 {
   myDeflection = theDeflection;
 }
@@ -164,7 +188,30 @@ void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
 
 void Poly_Triangulation::RemoveUVNodes()
 {
-  myUVNodes.Nullify();
+  myUVNodes.Clear();
+  myHasUVNodes = Standard_False;
+}
+
+//=======================================================================
+//function : AddNode
+//purpose  : 
+//=======================================================================
+Standard_Integer Poly_Triangulation::AddNode (const gp_Pnt& theNode)
+{
+  myNodes.Append (theNode);
+
+  if (myHasUVNodes)
+  {
+    myUVNodes.Append (gp_Pnt2d());
+  }
+
+  if (!myNormals.IsEmpty())
+  {
+    Standard_Integer aNbNormals = myNodes.Size();
+    myNormals.SetValue (aNbNormals, gp_Dir());
+  }
+
+  return myNodes.Size();
 }
 
 //=======================================================================
@@ -178,7 +225,7 @@ const gp_Pnt& Poly_Triangulation::Node (const Standard_Integer theIndex) const
   {
     throw Standard_OutOfRange ("Poly_Triangulation::Node : index out of range");
   }
-  return myNodes.Value (theIndex);
+  return myNodes.Value (theIndex - 1);
 }
 
 //=======================================================================
@@ -192,7 +239,7 @@ gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
   {
     throw Standard_OutOfRange ("Poly_Triangulation::ChangeNode : index out of range");
   }
-  return myNodes.ChangeValue (theIndex);
+  return myNodes.ChangeValue (theIndex - 1);
 }
 
 //=======================================================================
@@ -202,11 +249,11 @@ gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
 
 const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
 {
-  if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
+  if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
   {
     throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
   }
-  return myUVNodes->Value (theIndex);
+  return myUVNodes.Value (theIndex - 1);
 }
 
 //=======================================================================
@@ -216,11 +263,22 @@ const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) con
 
 gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
 {
-  if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
+  if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
   {
     throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
   }
-  return myUVNodes->ChangeValue (theIndex);
+  return myUVNodes.ChangeValue (theIndex - 1);
+}
+
+//=======================================================================
+//function : Triangle
+//purpose  : 
+//=======================================================================
+
+Standard_Integer Poly_Triangulation::AddTriangle (const Poly_Triangle& theTriangle)
+{
+  myTriangles.Append (theTriangle);
+  return myTriangles.Size();
 }
 
 //=======================================================================
@@ -234,7 +292,7 @@ const Poly_Triangle& Poly_Triangulation::Triangle (const Standard_Integer theInd
   {
     throw Standard_OutOfRange ("Poly_Triangulation::Triangle : index out of range");
   }
-  return myTriangles.Value (theIndex);
+  return myTriangles.Value (theIndex - 1);
 }
 
 //=======================================================================
@@ -248,7 +306,7 @@ Poly_Triangle& Poly_Triangulation::ChangeTriangle (const Standard_Integer theInd
   {
     throw Standard_OutOfRange ("Poly_Triangulation::ChangeTriangle : index out of range");
   }
-  return myTriangles.ChangeValue (theIndex);
+  return myTriangles.ChangeValue (theIndex - 1);
 }
 
 //=======================================================================
@@ -263,39 +321,32 @@ void Poly_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& th
     throw Standard_DomainError("Poly_Triangulation::SetNormals : wrong length");
   }
 
-  myNormals = theNormals;
-}
-
-//=======================================================================
-//function : Normals
-//purpose  : 
-//=======================================================================
-
-const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
-{
-
-  if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
-    throw Standard_NullObject("Poly_Triangulation::Normals : "
-                              "wrong length or null array");
+  Standard_Integer anArrayLower = theNormals->Lower();
+  Standard_Integer anArrayInd;
+  for (Standard_Integer anIndex = NbNodes() - 1; anIndex >= 0; anIndex--)
+  {
+    anArrayInd = anArrayLower + anIndex * 3;
+    gp_Dir aNormal(theNormals->Value(anArrayInd),
+                   theNormals->Value(anArrayInd),
+                   theNormals->Value(anArrayInd));
+    myNormals.SetValue (anIndex, aNormal);
   }
-
-  return myNormals->Array1();
 }
 
 //=======================================================================
-//function : ChangeNormals
+//function : SetNormal
 //purpose  : 
 //=======================================================================
 
-TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
+void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
 {
 
-  if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
+  if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size()) {
     throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
                               "wrong length or null array");
   }
 
-  return myNormals->ChangeArray1();
+  myNormals.ChangeValue (theIndex - 1) = theNormal;
 }
 
 //=======================================================================
@@ -305,46 +356,24 @@ TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
 
 Standard_Boolean Poly_Triangulation::HasNormals() const
 {
-  if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
+  if (myNormals.IsEmpty() || myNormals.Length() != NbNodes()) {
     return Standard_False;
   }
   return Standard_True;
 }
 
-//=======================================================================
-//function : SetNormal
-//purpose  : 
-//=======================================================================
-
-void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
-{
-  if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
-  {
-    throw Standard_NullObject ("Poly_Triangulation::SetNormal : empty array or index out of range");
-  }
-
-  myNormals->ChangeValue (theIndex * 3 - 2) = (Standard_ShortReal) theNormal.X();
-  myNormals->ChangeValue (theIndex * 3 - 1) = (Standard_ShortReal) theNormal.Y();
-  myNormals->ChangeValue (theIndex * 3)     = (Standard_ShortReal) theNormal.Z();
-}
-
 //=======================================================================
 //function : Normal
 //purpose  : 
 //=======================================================================
 
-gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
+const gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
 {
-  if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
+  if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size())
   {
     throw Standard_NullObject ("Poly_Triangulation::Normal : empty array or index out of range");
   }
-
-  gp_Dir N(myNormals->Value(theIndex * 3 - 2),
-           myNormals->Value(theIndex * 3 - 1),
-           myNormals->Value(theIndex * 3));
-
-  return N;
+  return myNormals (theIndex - 1);
 }
 
 // =======================================================================
@@ -358,10 +387,10 @@ void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Intege
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDeflection)
 
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNodes.Size())
-  if (!myUVNodes.IsNull())
-    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUVNodes->Size())
-  if (!myNormals.IsNull())
-    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNormals->Size())
+  if (!myUVNodes.IsEmpty())
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUVNodes.Size())
+  if (!myNormals.IsEmpty())
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNormals.Size())
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTriangles.Size())
 }
 
index 8808209d1f4af60eecb63b52a5b8c723ac2e56b3..78474c046505fa1d2d13a78c3a65ac07e2742e28 100644 (file)
 #include <Standard_Boolean.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
 #include <TShort_Array1OfShortReal.hxx>
+#include <NCollection_Vector.hxx>
 class Standard_DomainError;
 class Standard_NullObject;
 
-
-class Poly_Triangulation;
-DEFINE_STANDARD_HANDLE(Poly_Triangulation, Standard_Transient)
-
-//! Provides a triangulation for a surface, a set of surfaces, or
-//! more generally a shape.
-//! A triangulation consists of an approximate representation
-//! of the actual shape, using a collection of points and
-//! triangles. The points are located on the surface. The
-//! edges of the triangles connect adjacent points with a
+//! Provides a triangulation for a surface, a set of surfaces, or more generally a shape.
+//! A triangulation consists of an approximate representation of the actual shape, using a collection of points and triangles.
+//! The points are located on the surface. The edges of the triangles connect adjacent points with a
 //! straight line that approximates the true curve on the surface.
 //! A triangulation comprises:
 //! -   A table of 3D nodes (3D points on the surface).
-//! -   A table of triangles. Each triangle (Poly_Triangle
-//! object) comprises a triplet of indices in the table of 3D
-//! nodes specific to the triangulation.
-//! -   A table of 2D nodes (2D points), parallel to the table of
-//! 3D nodes. This table is optional. If it exists, the
-//! coordinates of a 2D point are the (u, v) parameters
-//! of the corresponding 3D point on the surface
-//! approximated by the triangulation.
-//! -   A deflection (optional), which maximizes the distance
-//! from a point on the surface to the corresponding point
-//! on its approximate triangulation.
-//! In many cases, algorithms do not need to work with the
-//! exact representation of a surface. A triangular
-//! representation induces simpler and more robust adjusting,
-//! faster performances, and the results are as good.
-//! This is a Transient class.
+//! -   A table of triangles. Each triangle (Poly_Triangle object) comprises a triplet of indices in the table of 3D
+//!     nodes specific to the triangulation.
+//! -   A table of 2D nodes (2D points), parallel to the table of 3D nodes. This table is optional.
+//!     If it exists, the coordinates of a 2D point are the (u, v) parameters of the corresponding 3D point on the surface approximated by the triangulation.
+//! -   A deflection (optional), which maximizes the distance from a point on the surface to the corresponding point on its approximate triangulation.
+//! In many cases, algorithms do not need to work with the exact representation of a surface.
+//! A triangular representation induces simpler and more robust adjusting, faster performances, and the results are as good.
 class Poly_Triangulation : public Standard_Transient
 {
 
@@ -127,26 +112,21 @@ public:
   //! Returns TRUE if triangulation has some geometry.
   virtual Standard_Boolean HasGeometry() const { return !myNodes.IsEmpty() && !myTriangles.IsEmpty(); }
 
-  //! Returns the number of nodes for this triangulation.
-  Standard_Integer NbNodes() const { return myNodes.Length(); }
+  //! @return the number of nodes for this triangulation.
+  Standard_Integer NbNodes() const { return myNodes.Size(); }
 
-  //! Returns the number of triangles for this triangulation.
-  Standard_Integer NbTriangles() const { return myTriangles.Length(); }
+  //! @return the number of triangles for this triangulation.
+  Standard_Integer NbTriangles() const { return myTriangles.Size(); }
 
-  //! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
-  Standard_Boolean HasUVNodes() const { return !myUVNodes.IsNull(); }
+  //! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+  Standard_Boolean HasUVNodes() const { return myHasUVNodes; }
 
-  //! Returns the table of 3D nodes (3D points) for this triangulation.
-  const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
+  //! Adds Node to the triangulation. If triangulation has UVNodes or Normals
+  //! they will be expanded and set to zero values to match the new number of nodes.
+  //! @return index of the added Node.
+  Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
 
-  //! Returns the table of 3D nodes (3D points) for this triangulation.
-  //! The returned array is
-  //! shared. Therefore if the table is selected by reference, you
-  //! can, by simply modifying it, directly modify the data
-  //! structure of this triangulation.
-  TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
-
-  //! Returns node at the given index.
+  //! @return node at the given index.
   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
   Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
 
@@ -154,22 +134,7 @@ public:
   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
   Standard_EXPORT gp_Pnt& ChangeNode (const Standard_Integer theIndex);
 
-  //! Returns the table of 2D nodes (2D points) associated with
-  //! each 3D node of this triangulation.
-  //! The function HasUVNodes  checks if 2D nodes
-  //! are associated with the 3D nodes of this triangulation.
-  //! Const reference on the 2d nodes values.
-  const TColgp_Array1OfPnt2d& UVNodes() const { return myUVNodes->Array1(); }
-
-  //! Returns the table of 2D nodes (2D points) associated with
-  //! each 3D node of this triangulation.
-  //! Function ChangeUVNodes shares  the returned array.
-  //! Therefore if the table is selected by reference,
-  //! you can, by simply modifying it, directly modify the data
-  //! structure of this triangulation.
-  TColgp_Array1OfPnt2d& ChangeUVNodes() { return myUVNodes->ChangeArray1(); }
-
-  //! Returns UVNode at the given index.
+  //! @return UVNode at the given index.
   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
   Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
 
@@ -177,17 +142,11 @@ public:
   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
   Standard_EXPORT gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex);
 
-  //! Returns the table of triangles for this triangulation.
-  const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
-
-  //! Returns the table of triangles for this triangulation.
-  //! Function ChangeUVNodes shares  the returned array.
-  //! Therefore if the table is selected by reference,
-  //! you can, by simply modifying it, directly modify the data
-  //! structure of this triangulation.
-  Poly_Array1OfTriangle& ChangeTriangles() { return myTriangles; }
+  //! Adds triangle to the triangulation.
+  //! @return index of the added triangle.
+  Standard_EXPORT virtual Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
 
-  //! Returns triangle at the given index.
+  //! @return triangle at the given index.
   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
   Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
 
@@ -196,26 +155,23 @@ public:
   Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
 
   //! Sets the table of node normals.
-  //! raises exception if length of theNormals != 3*NbNodes
+  //! Raises exception if length of theNormals != 3 * NbNodes
+  Standard_DEPRECATED("Deprecated method SetNormals() should be replaced \
+ by method with array as object instead of handle. \
+ Array of floats should be replaced by vector of normals")
   Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
 
-  //! Returns the table of node normals.
-  Standard_EXPORT const TShort_Array1OfShortReal& Normals() const;
-
-  //! Gives access to the table of node normals.
-  Standard_EXPORT TShort_Array1OfShortReal& ChangeNormals();
+  //! Changes normal at the given index.
+  //! Raises Standard_OutOfRange exception.
+  Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
+                                  const gp_Dir&          theNormal);
 
   //! Returns Standard_True if nodal normals are defined.
   Standard_EXPORT Standard_Boolean HasNormals() const;
 
   //! @return normal at the given index.
   //! Raises Standard_OutOfRange exception.
-  Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
-
-  //! Changes normal at the given index.
-  //! Raises Standard_OutOfRange exception.
-  Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
-                                  const gp_Dir&          theNormal);
+  Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
 
   //! Returns cached min - max range of triangulation data,
   //! which is VOID by default (e.g, no cached information).
@@ -264,12 +220,13 @@ protected:
 
 protected:
 
-  Bnd_Box*                           myCachedMinMax;
-  Standard_Real                      myDeflection;
-  TColgp_Array1OfPnt                 myNodes;
-  Handle(TColgp_HArray1OfPnt2d)      myUVNodes;
-  Poly_Array1OfTriangle              myTriangles;
-  Handle(TShort_HArray1OfShortReal)  myNormals;
+  Bnd_Box*                          myCachedMinMax;
+  Standard_Real                     myDeflection;
+  Standard_Boolean                  myHasUVNodes;
+  NCollection_Vector<gp_Pnt>        myNodes;
+  NCollection_Vector<gp_Pnt2d>      myUVNodes;
+  NCollection_Vector<Poly_Triangle> myTriangles;
+  NCollection_Vector<gp_Dir>        myNormals;
 
 };
 
index 9c780a10214de3acbfebd68984ad82ec540bb89f..3e9b17f02ca729b0a55852f6874fa96a58c05993 100644 (file)
@@ -36,11 +36,8 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
     return;
   }
 
-  const TColgp_Array1OfPnt& aNodes = thePolyTri->Nodes();
-
   // Build the connect tool.
   Poly_Connect aPolyConnect (thePolyTri);
-
   Standard_Integer aNbTriangles = thePolyTri->NbTriangles();
   Standard_Integer aT[3];
   Standard_Integer aN[3];
@@ -66,11 +63,10 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
   TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
 
   Standard_Integer aFreeIndex = 1;
-  const Poly_Array1OfTriangle& aTriangles = thePolyTri->Triangles();
   for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI)
   {
     aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
-    aTriangles (anI).Get (aN[0], aN[1], aN[2]);
+    thePolyTri->Triangle (anI).Get (aN[0], aN[1], aN[2]);
     for (Standard_Integer aJ = 0; aJ < 3; aJ++)
     {
       Standard_Integer k = (aJ + 1) % 3;
@@ -87,8 +83,8 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
   Standard_Integer aFreeHalfNb = aFree.Length() / 2;
   for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI)
   {
-    const gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (theLocation);
-    const gp_Pnt aPoint2 = aNodes (aFree (2 * anI    )).Transformed (theLocation);
+    const gp_Pnt aPoint1 = thePolyTri->Node (aFree (2 * anI - 1)).Transformed (theLocation);
+    const gp_Pnt aPoint2 = thePolyTri->Node (aFree (2 * anI    )).Transformed (theLocation);
     theSegments.Append (aPoint1);
     theSegments.Append (aPoint2);
   }
index e74c50023e3fe51c423a39d18e9ab89aaa37d6fd..eb1104de0deb679bb45b1a80a25abd4fd9a89f54 100644 (file)
@@ -100,9 +100,6 @@ Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolQuadric::CreateTriangulation (const
 Handle(Poly_Triangulation) Prs3d_ToolQuadric::CreatePolyTriangulation (const gp_Trsf& theTrsf) const
 {
   Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (VerticesNb(), TrianglesNb(), Standard_False);
-  TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
-  Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
-
   Standard_ShortReal aStepU = 1.0f / mySlicesNb;
   Standard_ShortReal aStepV = 1.0f / myStacksNb;
 
@@ -116,11 +113,11 @@ Handle(Poly_Triangulation) Prs3d_ToolQuadric::CreatePolyTriangulation (const gp_
       const Standard_Integer   aVertId = aU * (myStacksNb + 1) + (aV + 1);
       gp_Pnt aVertex = Vertex (aParamU, aParamV).Transformed (theTrsf);
 
-      aNodes.SetValue (aVertId, aVertex);
+      aTriangulation->ChangeNode (aVertId) = aVertex;
       if (aU != 0 && aV != 0)
       {
-        aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1));
-        aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1));
+        aTriangulation->ChangeTriangle (++anIndex) = Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1);
+        aTriangulation->ChangeTriangle (++anIndex) = Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1);
       }
     }
   }
index 6bb78642860584fd0b1ef07cca3c48833a0b8a76..686d13b20810aa102957f3440c63e162173a0368 100644 (file)
@@ -4030,25 +4030,15 @@ static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theA
       continue;
 
     Poly::ComputeNormals(aT);
-    const TColgp_Array1OfPnt&       aVertices = aT->Nodes();
-    const TShort_Array1OfShortReal& aNormals  = aT->Normals();
 
     // Number of nodes in the triangulation
-    int aVertexNb = aT->Nodes().Length();
-    if (aVertexNb*3 != aNormals.Length())
-    {
-      theDI << "Failed. Different number of normals vs. vertices\n";
-      return 1;
-    }
+    int aVertexNb = aT->NbNodes();
 
     // Get each vertex index, checking common vertexes between shapes
     for( int i=0; i < aVertexNb; i++ )
     {
-      gp_Pnt aPoint = aVertices.Value( i+1 );
-      gp_Vec aNormal = gp_Vec(
-        aNormals.Value( i*3 + 1 ),
-        aNormals.Value( i*3 + 2 ),
-        aNormals.Value( i*3 + 3 ) );
+      gp_Pnt aPoint = aT->Node ( i+1 );
+      gp_Dir aNormal = aT->Normal ( i+1 );
 
       if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
       {
index 158dde846549a9859ca1cb6052ec47ae78978644..7e11112fbd393b315878e0425f029b8e8e83d0df 100644 (file)
@@ -648,20 +648,17 @@ static Standard_Integer QABVH_PairDistance (Draw_Interpretor& theDI,
       TopLoc_Location aLoc;
       const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(aF, aLoc);
 
-      const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
-      const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
-      const int aNbTriangles = aTriangles.Length();
+      const int aNbTriangles = aTriangulation->NbTriangles();
       for (int iT = 1; iT <= aNbTriangles; ++iT)
       {
-        const Poly_Triangle& aTriangle = aTriangles (iT);
+        const Poly_Triangle& aTriangle = aTriangulation->Triangle (iT);
         // Nodes indices
         Standard_Integer id1, id2, id3;
         aTriangle.Get (id1, id2, id3);
 
-        const gp_Pnt& aP1 = aNodes(id1).Transformed(aLoc.Transformation());
-        const gp_Pnt& aP2 = aNodes(id2).Transformed(aLoc.Transformation());
-        const gp_Pnt& aP3 = aNodes(id3).Transformed(aLoc.Transformation());
+        const gp_Pnt aP1 = aTriangulation->Node (id1).Transformed (aLoc.Transformation());
+        const gp_Pnt aP2 = aTriangulation->Node (id2).Transformed (aLoc.Transformation());
+        const gp_Pnt aP3 = aTriangulation->Node (id3).Transformed (aLoc.Transformation());
 
         BVH_Vec3d aBVHP1 (aP1.X(), aP1.Y(), aP1.Z());
         BVH_Vec3d aBVHP2 (aP2.X(), aP2.Y(), aP2.Z());
@@ -711,20 +708,17 @@ public:
     TopLoc_Location aLoc;
     const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
 
-    const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
-    const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
-    const int aNbTriangles = aTriangles.Length();
+    const int aNbTriangles = aTriangulation->NbTriangles();
     for (int iT = 1; iT <= aNbTriangles; ++iT)
     {
-      const Poly_Triangle& aTriangle = aTriangles (iT);
+      const Poly_Triangle& aTriangle = aTriangulation->Triangle (iT);
       // Nodes indices
       Standard_Integer id1, id2, id3;
       aTriangle.Get (id1, id2, id3);
 
-      const gp_Pnt& aP1 = aNodes(id1).Transformed(aLoc.Transformation());
-      const gp_Pnt& aP2 = aNodes(id2).Transformed(aLoc.Transformation());
-      const gp_Pnt& aP3 = aNodes(id3).Transformed(aLoc.Transformation());
+      const gp_Pnt aP1 = aTriangulation->Node (id1).Transformed (aLoc.Transformation());
+      const gp_Pnt aP2 = aTriangulation->Node (id2).Transformed (aLoc.Transformation());
+      const gp_Pnt aP3 = aTriangulation->Node (id3).Transformed (aLoc.Transformation());
 
       BVH_Vec3d aBVHP1 (aP1.X(), aP1.Y(), aP1.Z());
       BVH_Vec3d aBVHP2 (aP2.X(), aP2.Y(), aP2.Z());
index b6d6eeb94c8a532e1e7f143d4af0d006e6993f22..041c162da3c4912e8e5f843688b9eba07f58622b 100644 (file)
@@ -48,19 +48,7 @@ RWGltf_TriangulationReader::RWGltf_TriangulationReader()
 // =======================================================================
 void RWGltf_TriangulationReader::reset()
 {
-  myTriangulation = new Poly_Triangulation (1, 1, true);
-  {
-    TColgp_Array1OfPnt anEmpty;
-    myTriangulation->ChangeNodes().Move (anEmpty);
-  }
-  {
-    TColgp_Array1OfPnt2d anEmpty;
-    myTriangulation->ChangeUVNodes().Move (anEmpty);
-  }
-  {
-    Poly_Array1OfTriangle anEmpty;
-    myTriangulation->ChangeTriangles().Move (anEmpty);
-  }
+  myTriangulation = new Poly_Triangulation (0, 0, true);
 }
 
 // =======================================================================
@@ -73,11 +61,6 @@ Handle(Poly_Triangulation) RWGltf_TriangulationReader::result()
   {
     return Handle(Poly_Triangulation)();
   }
-  if (myTriangulation->UVNodes().Size() != myTriangulation->NbNodes())
-  {
-    myTriangulation->RemoveUVNodes();
-  }
-
   if (myTriangulation->NbTriangles() < 1)
   {
     // reconstruct indexes
index 37bf9bc8efc943702876c9e4101718fb7dc1c56f..c6d859c8d3811b96e107d4dcd077fe282785ed5c 100644 (file)
@@ -56,7 +56,9 @@ protected: //! @name interface for filling triangulation data
     {
       return false;
     }
-    myTriangulation->ChangeNodes().Resize (1, theNbNodes, false);
+    Standard_Integer i = myTriangulation->NbNodes();
+    while (++i <= theNbNodes)
+      myTriangulation->AddNode (gp::Origin());
     return true;
   }
 
@@ -77,7 +79,8 @@ protected: //! @name interface for filling triangulation data
     {
       return false;
     }
-    myTriangulation->ChangeUVNodes().Resize (1, theNbNodes, false);
+
+    // Resizing of the array of nodes extends the array of UV-nodes too.
     return true;
   }
 
@@ -116,7 +119,10 @@ protected: //! @name interface for filling triangulation data
   {
     if (theNbTris >= 1)
     {
-      myTriangulation->ChangeTriangles().Resize (1, theNbTris, false);
+      Poly_Triangle emptyTri (0, 0, 0);
+      Standard_Integer i = myTriangulation->NbTriangles();
+      while (++i <= theNbTris)
+        myTriangulation->AddTriangle (emptyTri);
       return true;
     }
     return false;
@@ -129,9 +135,9 @@ protected: //! @name interface for filling triangulation data
   virtual bool setTriangle (Standard_Integer theIndex,
                             const Poly_Triangle& theTriangle)
   {
-    if (theTriangle.Value (1) < myTriangulation->Nodes().Lower() || theTriangle.Value (1) > myTriangulation->Nodes().Upper()
-     || theTriangle.Value (2) < myTriangulation->Nodes().Lower() || theTriangle.Value (2) > myTriangulation->Nodes().Upper()
-     || theTriangle.Value (3) < myTriangulation->Nodes().Lower() || theTriangle.Value (3) > myTriangulation->Nodes().Upper())
+    if (theTriangle.Value (1) < 1 || theTriangle.Value (1) > myTriangulation->NbNodes()
+     || theTriangle.Value (2) < 1 || theTriangle.Value (2) > myTriangulation->NbNodes()
+     || theTriangle.Value (3) < 1 || theTriangle.Value (3) > myTriangulation->NbNodes())
     {
       return false;
     }
index 51b95f7a8b5148419f7c75f6cdf0916f1124d986..45bea53a8f28315a1d7f1dc224dc3af7c096322d 100644 (file)
@@ -31,9 +31,6 @@ RWMesh_FaceIterator::RWMesh_FaceIterator (const TDF_Label&       theLabel,
 : myDefStyle (theStyle),
   myToMapColors (theToMapColors),
   mySLTool  (1, 1e-12),
-  myNodes   (NULL),
-  myNormals (NULL),
-  myNodeUVs (NULL),
   myHasNormals (false),
   myIsMirrored (false),
   myHasFaceColor (false)
@@ -133,21 +130,16 @@ void RWMesh_FaceIterator::dispatchStyles (const TDF_Label&       theLabel,
 gp_Dir RWMesh_FaceIterator::normal (Standard_Integer theNode)
 {
   gp_Dir aNormal (gp::DZ());
-  if (myNormals != NULL)
+  if (myPolyTriang->HasNormals())
   {
-    const Standard_Integer aNodeIndex = theNode - myNodes->Lower();
-    const Graphic3d_Vec3 aNormVec3 (myNormals->Value (myNormals->Lower() + aNodeIndex * 3),
-                                    myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 1),
-                                    myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 2));
-    if (aNormVec3.Modulus() != 0.0f)
-    {
-      aNormal.SetCoord (aNormVec3.x(), aNormVec3.y(), aNormVec3.z());
-    }
-  }
+    aNormal = myPolyTriang->Normal (theNode);
+    if (aNormal.XYZ().Modulus() < Precision::Confusion())
+      aNormal = gp::DZ();
+  }    
   else if (myHasNormals
-        && myNodeUVs != NULL)
+        && myPolyTriang->HasUVNodes())
   {
-    const gp_XY& anUV = myNodeUVs->Value (theNode).XY();
+    const gp_XY& anUV = myPolyTriang->UVNode (theNode).XY();
     mySLTool.SetParameters (anUV.X(), anUV.Y());
     if (mySLTool.IsNormalDefined())
     {
@@ -169,7 +161,7 @@ void RWMesh_FaceIterator::Next()
     myPolyTriang = BRep_Tool::Triangulation (myFace, myFaceLocation);
     myTrsf       = myFaceLocation.Transformation();
     if (myPolyTriang.IsNull()
-     || myPolyTriang->Triangles().Length() == 0)
+     || myPolyTriang->NbTriangles() == 0)
     {
       resetFace();
       continue;
@@ -192,29 +184,20 @@ void RWMesh_FaceIterator::initFace()
   myHasNormals   = false;
   myHasFaceColor = false;
   myIsMirrored   = myTrsf.VectorialPart().Determinant() < 0.0;
-  myNormals = NULL;
-  myNodeUVs = NULL;
-
-  myNodes = &myPolyTriang->Nodes();
   if (myPolyTriang->HasNormals())
   {
-    myNormals = &myPolyTriang->Normals();
     myHasNormals = true;
   }
-  if (myPolyTriang->HasUVNodes())
+  if (myPolyTriang->HasUVNodes() && !myHasNormals)
   {
-    myNodeUVs = &myPolyTriang->UVNodes();
-    if (!myHasNormals)
+    TopoDS_Face aFaceFwd = TopoDS::Face (myFace.Oriented (TopAbs_FORWARD));
+    aFaceFwd.Location (TopLoc_Location());
+    TopLoc_Location aLoc;
+    if (!BRep_Tool::Surface (aFaceFwd, aLoc).IsNull())
     {
-      TopoDS_Face aFaceFwd = TopoDS::Face (myFace.Oriented (TopAbs_FORWARD));
-      aFaceFwd.Location (TopLoc_Location());
-      TopLoc_Location aLoc;
-      if (!BRep_Tool::Surface (aFaceFwd, aLoc).IsNull())
-      {
-        myFaceAdaptor.Initialize (aFaceFwd, false);
-        mySLTool.SetSurface (myFaceAdaptor);
-        myHasNormals = true;
-      }
+      myFaceAdaptor.Initialize (aFaceFwd, false);
+      mySLTool.SetSurface (myFaceAdaptor);
+      myHasNormals = true;
     }
   }
   if (!myToMapColors)
index 0e2f248e311579549c40080aae3249e6954dfe43..15758f7f1407e1f9d53d163da737d6a569ccdf2f 100644 (file)
@@ -75,10 +75,10 @@ public:
   Standard_Integer NbTriangles() const { return myPolyTriang->NbTriangles(); }
 
   //! Lower element index in current triangulation.
-  Standard_Integer ElemLower() const { return myPolyTriang->Triangles().Lower(); }
+  Standard_Integer ElemLower() const { return 1; }
 
   //! Upper element index in current triangulation.
-  Standard_Integer ElemUpper() const { return myPolyTriang->Triangles().Upper(); }
+  Standard_Integer ElemUpper() const { return myPolyTriang->NbTriangles(); }
 
   //! Return triangle with specified index with applied Face orientation.
   Poly_Triangle TriangleOriented (Standard_Integer theElemIndex) const
@@ -97,7 +97,7 @@ public:
   bool HasNormals() const { return myHasNormals; }
 
   //! Return true if triangulation has defined normals.
-  bool HasTexCoords() const { return myNodeUVs != NULL; }
+  bool HasTexCoords() const { return myPolyTriang->HasUVNodes(); }
 
   //! Return normal at specified node index with face transformation applied and face orientation applied.
   gp_Dir NormalTransformed (Standard_Integer theNode)
@@ -118,15 +118,15 @@ public:
   Standard_Integer NbNodes() const
   {
     return !myPolyTriang.IsNull()
-          ? myPolyTriang->Nodes().Length()
+          ? myPolyTriang->NbNodes()
           : 0;
   }
 
   //! Lower node index in current triangulation.
-  Standard_Integer NodeLower() const { return myPolyTriang->Nodes().Lower(); }
+  Standard_Integer NodeLower() const { return 1; }
 
   //! Upper node index in current triangulation.
-  Standard_Integer NodeUpper() const { return myPolyTriang->Nodes().Upper(); }
+  Standard_Integer NodeUpper() const { return myPolyTriang->NbNodes(); }
 
   //! Return the node with specified index with applied transformation.
   gp_Pnt NodeTransformed (const Standard_Integer theNode) const
@@ -139,19 +139,19 @@ public:
   //! Return texture coordinates for the node.
   gp_Pnt2d NodeTexCoord (const Standard_Integer theNode) const
   {
-    return myNodeUVs != NULL ? myNodeUVs->Value (theNode) : gp_Pnt2d();
+    return myPolyTriang->HasUVNodes() ? myPolyTriang->UVNode (theNode) : gp_Pnt2d();
   }
 
 public:
 
   //! Return the node with specified index with applied transformation.
-  gp_Pnt node (const Standard_Integer theNode) const { return myPolyTriang->Nodes().Value (theNode); }
+  gp_Pnt node (const Standard_Integer theNode) const { return myPolyTriang->Node (theNode); }
 
   //! Return normal at specified node index without face transformation applied.
   Standard_EXPORT gp_Dir normal (Standard_Integer theNode);
 
   //! Return triangle with specified index.
-  Poly_Triangle triangle (Standard_Integer theElemIndex) const { return myPolyTriang->Triangles().Value (theElemIndex); }
+  Poly_Triangle triangle (Standard_Integer theElemIndex) const { return myPolyTriang->Triangle (theElemIndex); }
 
 private:
 
@@ -165,9 +165,6 @@ private:
   {
     myPolyTriang.Nullify();
     myFace.Nullify();
-    myNodes   = NULL;
-    myNormals = NULL;
-    myNodeUVs = NULL;
     myHasNormals = false;
     myHasFaceColor = false;
     myFaceColor = Quantity_ColorRGBA();
@@ -190,9 +187,6 @@ private:
   TopLoc_Location                 myFaceLocation; //!< current face location
   BRepLProp_SLProps               mySLTool;       //!< auxiliary tool for fetching normals from surface
   BRepAdaptor_Surface             myFaceAdaptor;  //!< surface adaptor for fetching normals from surface
-  const TColgp_Array1OfPnt*       myNodes;        //!< node positions of current face
-  const TShort_Array1OfShortReal* myNormals;      //!< node normals of current face
-  const TColgp_Array1OfPnt2d*     myNodeUVs;      //!< node UV coordinates of current face
   Standard_Boolean                myHasNormals;   //!< flag indicating that current face has normals
   gp_Trsf                         myTrsf;         //!< current face transformation
   Standard_Boolean                myIsMirrored;   //!< flag indicating that face triangles should be mirrored
index 3224982c5584670cf7664cc4e074da3ef7d533b3..9b61afd2cbd76afbf6090a37bb2de2fe778e3984 100644 (file)
@@ -284,17 +284,15 @@ Standard_Boolean RWStl::writeASCII (const Handle(Poly_Triangulation)& theMesh,
   const Standard_Integer NBTriangles = theMesh->NbTriangles();
   Message_ProgressScope aPS (theProgress, "Triangles", NBTriangles);
 
-  const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
-  const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
   Standard_Integer anElem[3] = {0, 0, 0};
   for (Standard_Integer aTriIter = 1; aTriIter <= NBTriangles; ++aTriIter)
   {
-    const Poly_Triangle& aTriangle = aTriangles (aTriIter);
+    const Poly_Triangle& aTriangle = theMesh->Triangle (aTriIter);
     aTriangle.Get (anElem[0], anElem[1], anElem[2]);
 
-    const gp_Pnt aP1 = aNodes (anElem[0]);
-    const gp_Pnt aP2 = aNodes (anElem[1]);
-    const gp_Pnt aP3 = aNodes (anElem[2]);
+    const gp_Pnt& aP1 = theMesh->Node (anElem[0]);
+    const gp_Pnt& aP2 = theMesh->Node (anElem[1]);
+    const gp_Pnt& aP3 = theMesh->Node (anElem[2]);
 
     const gp_Vec aVec1 (aP1, aP2);
     const gp_Vec aVec2 (aP1, aP3);
@@ -365,9 +363,6 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
   NCollection_Array1<Standard_Character> aData (1, aChunkSize);
   Standard_Character* aDataChunk = &aData.ChangeFirst();
 
-  const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
-  const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
-
   Standard_Character aConv[4];
   convertInteger (aNBTriangles, aConv);
   if (fwrite (aConv, 1, 4, theFile) != 4)
@@ -379,12 +374,12 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
   for (Standard_Integer aTriIter = 1; aTriIter <= aNBTriangles; ++aTriIter)
   {
     Standard_Integer id[3];
-    const Poly_Triangle& aTriangle = aTriangles (aTriIter);
+    const Poly_Triangle& aTriangle = theMesh->Triangle (aTriIter);
     aTriangle.Get (id[0], id[1], id[2]);
 
-    const gp_Pnt aP1 = aNodes (id[0]);
-    const gp_Pnt aP2 = aNodes (id[1]);
-    const gp_Pnt aP3 = aNodes (id[2]);
+    const gp_Pnt& aP1 = theMesh->Node (id[0]);
+    const gp_Pnt& aP2 = theMesh->Node (id[1]);
+    const gp_Pnt& aP3 = theMesh->Node (id[2]);
 
     gp_Vec aVec1 (aP1, aP2);
     gp_Vec aVec2 (aP1, aP3);
index 32254ddfdd794b79ec294e0dedfbf1cd0ca84bff..3a7631404a3ef7d6469bc23b2b0ba36cd69acac1 100644 (file)
@@ -63,8 +63,6 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
 {
   myInvInitLocation = myInitLocation.Transformation().Inverted();
   mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
-  const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
-  const TColgp_Array1OfPnt& aNodes = myTriangul->Nodes();
   Standard_Integer aNbTriangles (myTriangul->NbTriangles());
   gp_XYZ aCenter (0.0, 0.0, 0.0);
 
@@ -83,8 +81,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
     for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= aNbTriangles; aTriangleIdx++)
     {
       aPoly.Triangles (aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
-      aTriangles (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
-      aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
+      myTriangul->Triangle (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
+      aCenter += (myTriangul->Node (aTrNodeIdx[0]).XYZ() + myTriangul->Node (aTrNodeIdx[1]).XYZ()+ myTriangul->Node (aTrNodeIdx[2]).XYZ()) / 3.0;
       for (Standard_Integer aVertIdx = 0; aVertIdx < 3; aVertIdx++)
       {
         Standard_Integer aNextVert = (aVertIdx + 1) % 3;
@@ -102,8 +100,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
     Standard_Integer aTrNodeIdx[3];
     for (Standard_Integer aTrIdx = 1; aTrIdx <= aNbTriangles; aTrIdx++)
     {
-      aTriangles (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
-      aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
+      myTriangul->Triangle (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
+      aCenter += (myTriangul->Node (aTrNodeIdx[0]).XYZ() + myTriangul->Node (aTrNodeIdx[1]).XYZ()+ myTriangul->Node (aTrNodeIdx[2]).XYZ()) / 3.0;
     }
   }
   if (aNbTriangles != 0)
@@ -113,9 +111,9 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
   myBndBox.Clear();
   for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
   {
-    myBndBox.Add (SelectMgr_Vec3 (aNodes (aNodeIdx).X(),
-                                  aNodes (aNodeIdx).Y(),
-                                  aNodes (aNodeIdx).Z()));
+    myBndBox.Add (SelectMgr_Vec3 (myTriangul->Node (aNodeIdx).X(),
+                                  myTriangul->Node (aNodeIdx).Y(),
+                                  myTriangul->Node (aNodeIdx).Z()));
   }
 
   if (theIsInterior)
@@ -154,7 +152,7 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
 {
   myInvInitLocation = myInitLocation.Transformation().Inverted();
   mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
-  myPrimitivesNb = theIsInterior ? theTrg->Triangles().Length() : theFreeEdges->Length() / 2;
+  myPrimitivesNb = theIsInterior ? theTrg->NbTriangles() : theFreeEdges->Length() / 2;
   myBVHPrimIndexes = new TColStd_HArray1OfInteger(0, myPrimitivesNb - 1);
   if (theIsInterior)
   {
@@ -196,11 +194,11 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
   if (mySensType == Select3D_TOS_INTERIOR)
   {
     Standard_Integer aNode1, aNode2, aNode3;
-    myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
+    myTriangul->Triangle (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
 
-    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
-    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
-    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
+    const gp_Pnt& aPnt1 = myTriangul->Node (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Node (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Node (aNode3);
 
     aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
                               Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
@@ -213,8 +211,8 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
   {
     Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
     Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
-    const gp_Pnt& aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
-    const gp_Pnt& aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
+    const gp_Pnt& aNode1 = myTriangul->Node (aNodeIdx1);
+    const gp_Pnt& aNode2 = myTriangul->Node (aNodeIdx2);
 
     aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
                               Min (aNode1.Y(), aNode2.Y()),
@@ -281,9 +279,9 @@ bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTr
     return false;
   }
 
-  theTriNodes[0] = myTriangul->Nodes().Value (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
-  theTriNodes[1] = myTriangul->Nodes().Value (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
-  theTriNodes[2] = myTriangul->Nodes().Value (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
+  theTriNodes[0] = myTriangul->Node (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
+  theTriNodes[1] = myTriangul->Node (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
+  theTriNodes[2] = myTriangul->Node (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
   return true;
 }
 
@@ -310,8 +308,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
 
     const gp_Pnt anEdgePnts[2] =
     {
-      myTriangul->Nodes().Value (aSegmStartIdx),
-      myTriangul->Nodes().Value (aSegmEndIdx)
+      myTriangul->Node (aSegmStartIdx),
+      myTriangul->Node (aSegmEndIdx)
     };
     TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
     Standard_Boolean isMatched = theMgr.Overlaps (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
@@ -319,12 +317,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
   }
   else
   {
-    const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
     Standard_Integer aNode1, aNode2, aNode3;
-    aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
-    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
-    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
-    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
+    myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
+    const gp_Pnt& aPnt1 = myTriangul->Node (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Node (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Node (aNode3);
     return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
   }
 }
@@ -345,8 +342,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
   const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
   if (mySensType == Select3D_TOS_BOUNDARY)
   {
-    const gp_Pnt& aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
-    const gp_Pnt& aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
+    const gp_Pnt& aSegmPnt1 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
+    const gp_Pnt& aSegmPnt2 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
     if (theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Polyline)
     {
       SelectBasics_PickResult aDummy;
@@ -357,11 +354,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
   else
   {
     Standard_Integer aNode1, aNode2, aNode3;
-    myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
+    myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
 
-    const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
-    const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
-    const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
+    const gp_Pnt& aPnt1 = myTriangul->Node (aNode1);
+    const gp_Pnt& aPnt2 = myTriangul->Node (aNode2);
+    const gp_Pnt& aPnt3 = myTriangul->Node (aNode3);
     if (theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Polyline)
     {
       SelectBasics_PickResult aDummy;
@@ -435,12 +432,12 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::BoundingBox()
   if (myBndBox.IsValid())
     return applyTransformation();
 
-  const Standard_Integer aLower = myTriangul->Nodes().Lower();
-  const Standard_Integer anUpper = myTriangul->Nodes().Upper();
+  const Standard_Integer aLower = 1;
+  const Standard_Integer anUpper = myTriangul->NbNodes();
   Select3D_BndBox3d aBndBox;
   for (Standard_Integer aNodeIdx = aLower; aNodeIdx <= anUpper; ++aNodeIdx)
   {
-    const gp_Pnt& aNode = myTriangul->Nodes().Value (aNodeIdx);
+    const gp_Pnt& aNode = myTriangul->Node (aNodeIdx);
     const SelectMgr_Vec3 aNodeTransf = SelectMgr_Vec3 (aNode.X(), aNode.Y(), aNode.Z());
     aBndBox.Add (aNodeTransf);
   }
@@ -466,7 +463,7 @@ gp_Pnt Select3D_SensitiveTriangulation::CenterOfGeometry() const
 //=======================================================================
 Standard_Integer Select3D_SensitiveTriangulation::NbSubElements() const
 {
-  return myTriangul->Nodes().Length();
+  return myTriangul->NbNodes();
 }
 
 //=======================================================================
index f471c49f7e7e0af37a79b735c591cf3201d3896f..1acbaa32205ab44c0a08a472d1d04dc0e782acee 100644 (file)
@@ -198,13 +198,31 @@ ShapePersistent_Poly::Translate(const Handle(Poly_Triangulation)& thePolyTriang,
     {
       aPT = new Triangulation;
       aPT->myPersistent = new pTriangulation;
+
+      // Create an array of nodes.
+      Standard_Integer i;
+      TColgp_Array1OfPnt pArrayOfNodes (1, thePolyTriang->NbNodes());
+      for (i = 1; i <= thePolyTriang->NbNodes(); i++)
+        pArrayOfNodes.SetValue (i, thePolyTriang->Node (i));
+
+      // Create an array of triangles.
+      Poly_Array1OfTriangle pArrayOfTriangles (1, thePolyTriang->NbTriangles());
+      for (i = 1; i <= thePolyTriang->NbTriangles(); i++)
+        pArrayOfTriangles.SetValue (i, thePolyTriang->Triangle (i));
+
       aPT->myPersistent->myNodes = 
-        StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePolyTriang->Nodes());
+        StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", pArrayOfNodes);
       aPT->myPersistent->myTriangles = 
-        StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", thePolyTriang->Triangles());
+        StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", pArrayOfTriangles);
       if (thePolyTriang->HasUVNodes()) {
+
+        // Create an array of UV-nodes.
+        TColgp_Array1OfPnt2d pArrayOfUVNodes (1, thePolyTriang->NbNodes());
+        for (i = 1; i <= thePolyTriang->NbNodes(); i++)
+          pArrayOfUVNodes.SetValue (i, thePolyTriang->UVNode (i));
+
         aPT->myPersistent->myUVNodes = 
-          StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePolyTriang->UVNodes());
+          StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", pArrayOfUVNodes);
       }
       theMap.Bind(thePolyTriang, aPT);
     }
index 5447502d9e87651d965b0bbbda8448a94e5c05c6..8db2debbdfaa59a15bf7eb6a82b8319c78be061a 100644 (file)
@@ -253,9 +253,6 @@ void StdPrs_Isolines::addOnTriangulation (const Handle(Poly_Triangulation)& theT
                                           Prs3d_NListOfSequenceOfPnt&       theUPolylines,
                                           Prs3d_NListOfSequenceOfPnt&       theVPolylines)
 {
-  const Poly_Array1OfTriangle& aTriangles = theTriangulation->Triangles();
-  const TColgp_Array1OfPnt&    aNodes     = theTriangulation->Nodes();
-  const TColgp_Array1OfPnt2d&  aUVNodes   = theTriangulation->UVNodes();
   for (Standard_Integer anUVIter = 0; anUVIter < 2; ++anUVIter)
   {
     const Standard_Boolean        isUIso      = anUVIter == 0;
@@ -278,16 +275,16 @@ void StdPrs_Isolines::addOnTriangulation (const Handle(Poly_Triangulation)& theT
         anIsoPnts = aPolylines.ChangeValue (anIsoIndexes.Value (anIsoIdx));
       }
 
-      for (Standard_Integer aTriIter = aTriangles.Lower(); aTriIter <= aTriangles.Upper(); ++aTriIter)
+      for (Standard_Integer aTriIter = 1; aTriIter <= theTriangulation->NbTriangles(); ++aTriIter)
       {
         Standard_Integer aNodeIdxs[3];
-        aTriangles.Value (aTriIter).Get (aNodeIdxs[0], aNodeIdxs[1],aNodeIdxs[2]);
-        const gp_Pnt aNodesXYZ[3] = { aNodes.Value (aNodeIdxs[0]),
-                                      aNodes.Value (aNodeIdxs[1]),
-                                      aNodes.Value (aNodeIdxs[2]) };
-        const gp_Pnt2d aNodesUV[3] = { aUVNodes.Value (aNodeIdxs[0]),
-                                       aUVNodes.Value (aNodeIdxs[1]),
-                                       aUVNodes.Value (aNodeIdxs[2]) };
+        theTriangulation->Triangle (aTriIter).Get (aNodeIdxs[0], aNodeIdxs[1],aNodeIdxs[2]);
+        const gp_Pnt aNodesXYZ[3] = { theTriangulation->Node (aNodeIdxs[0]),
+                                      theTriangulation->Node (aNodeIdxs[1]),
+                                      theTriangulation->Node (aNodeIdxs[2]) };
+        const gp_Pnt2d aNodesUV[3] = { theTriangulation->UVNode (aNodeIdxs[0]),
+                                       theTriangulation->UVNode (aNodeIdxs[1]),
+                                       theTriangulation->UVNode (aNodeIdxs[2]) };
 
         // Find intersections with triangle in uv space and its projection on triangulation.
         SegOnIso aSegment;
index bc4cfece0ee855afe7251c300741ad337b56a67e..2ba10dcc7c069258282cd573ace5e482114faea0 100644 (file)
@@ -188,14 +188,10 @@ namespace
       // Determinant of transform matrix less then 0 means that mirror transform applied.
       Standard_Boolean isMirrored = aTrsf.VectorialPart().Determinant() < 0;
 
+      Poly_Connect aPolyConnect (aT);
       // Extracts vertices & normals from nodes
-      const TColgp_Array1OfPnt&   aNodes   = aT->Nodes();
-      const TColgp_Array1OfPnt2d* aUVNodes = theHasTexels && aT->HasUVNodes() && aT->UVNodes().Upper() == aNodes.Upper()
-                                           ? &aT->UVNodes()
-                                           : NULL;
-      StdPrs_ToolTriangulatedShape::ComputeNormals (aFace, aT);
-      const TShort_Array1OfShortReal& aNormals = aT->Normals();
-      const Standard_ShortReal*       aNormArr = &aNormals.First();
+      TColgp_Array1OfDir aNormals (1, aT->NbNodes());
+      StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
 
       if (theHasTexels)
       {
@@ -205,11 +201,10 @@ namespace
       }
 
       const Standard_Integer aDecal = anArray->VertexNumber();
-      for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+      for (Standard_Integer aNodeIter = 1; aNodeIter <= aT->NbNodes(); ++aNodeIter)
       {
-        aPoint = aNodes (aNodeIter);
-        const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
-        gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
+        aPoint = aT->Node (aNodeIter);
+        gp_Dir aNorm = aNormals (aNodeIter);
         if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
         {
           aNorm.Reverse();
@@ -220,12 +215,12 @@ namespace
           aNorm.Transform (aTrsf);
         }
 
-        if (aUVNodes != NULL)
+        if (theHasTexels && aT->HasUVNodes())
         {
           const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0)
-                                ? aUVNodes->Value (aNodeIter)
-                                : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes->Value (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
-                                            (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes->Value (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
+                                ? aT->UVNode (aNodeIter)
+                                : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aT->UVNode (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
+                                            (-theUVOrigin.Y() + (theUVRepeat.Y() * (aT->UVNode (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
           anArray->AddVertex (aPoint, aNorm, aTexel);
         }
         else
@@ -235,22 +230,21 @@ namespace
       }
 
       // Fill array with vertex and edge visibility info
-      const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
       Standard_Integer anIndex[3];
       for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
       {
         if ((aFace.Orientation() == TopAbs_REVERSED))
         {
-          aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
+          aT->Triangle (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
         }
         else
         {
-          aTriangles (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
+          aT->Triangle (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
         }
 
-        gp_Pnt aP1 = aNodes (anIndex[0]);
-        gp_Pnt aP2 = aNodes (anIndex[1]);
-        gp_Pnt aP3 = aNodes (anIndex[2]);
+        gp_Pnt aP1 = aT->Node (anIndex[0]);
+        gp_Pnt aP2 = aT->Node (anIndex[1]);
+        gp_Pnt aP3 = aT->Node (anIndex[2]);
 
         gp_Vec aV1 (aP1, aP2);
         if (aV1.SquareMagnitude() <= aPreci)
@@ -415,7 +409,6 @@ namespace
       }
 
       // get edge nodes indexes from face triangulation
-      const TColgp_Array1OfPnt&      aTriNodes   = aTriangulation->Nodes();
       const TColStd_Array1OfInteger& anEdgeNodes = anEdgePoly->Nodes();
 
       // collect the edge nodes
@@ -425,7 +418,7 @@ namespace
         // node index in face triangulation
         // get node and apply location transformation to the node
         const Standard_Integer aTriIndex = anEdgeNodes.Value (aNodeIdx);
-        gp_Pnt aTriNode = aTriNodes.Value (aTriIndex);
+        gp_Pnt aTriNode = aTriangulation->Node (aTriIndex);
         if (!aTrsf.IsIdentity())
         {
           aTriNode.Transform (aTrsf);
index 7e257bfa7ccb1980f241922f5ab558b7b03203da..e037077ccf81fe0d1307f8852230597ea76d9a4e 100644 (file)
@@ -149,7 +149,6 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
   // take in face the surface location
   const TopoDS_Face    aZeroFace = TopoDS::Face (theFace.Located (TopLoc_Location()));
   Handle(Geom_Surface) aSurf     = BRep_Tool::Surface (aZeroFace);
-  const Poly_Array1OfTriangle& aTriangles = theTris->Triangles();
   if (!theTris->HasUVNodes() || aSurf.IsNull())
   {
     // compute normals by averaging triangulation normals sharing the same vertex
@@ -159,14 +158,12 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
 
   const Standard_Real aTol = Precision::Confusion();
   Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, theTris->NbNodes() * 3);
-  const TColgp_Array1OfPnt2d& aNodesUV = theTris->UVNodes();
   Standard_Integer aTri[3];
-  const TColgp_Array1OfPnt& aNodes = theTris->Nodes();
   gp_Dir aNorm;
-  for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+  for (Standard_Integer aNodeIter = 1; aNodeIter <= theTris->NbNodes(); ++aNodeIter)
   {
     // try to retrieve normal from real surface first, when UV coordinates are available
-    if (GeomLib::NormEstim (aSurf, aNodesUV.Value (aNodeIter), aTol, aNorm) > 1)
+    if (GeomLib::NormEstim (aSurf, theTris->UVNode (aNodeIter), aTol, aNorm) > 1)
     {
       if (thePolyConnect.Triangulation() != theTris)
       {
@@ -177,9 +174,9 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
       gp_XYZ eqPlan (0.0, 0.0, 0.0);
       for (thePolyConnect.Initialize (aNodeIter); thePolyConnect.More(); thePolyConnect.Next())
       {
-        aTriangles (thePolyConnect.Value()).Get (aTri[0], aTri[1], aTri[2]);
-        const gp_XYZ v1 (aNodes (aTri[1]).Coord() - aNodes (aTri[0]).Coord());
-        const gp_XYZ v2 (aNodes (aTri[2]).Coord() - aNodes (aTri[1]).Coord());
+        theTris->Triangle (thePolyConnect.Value()).Get (aTri[0], aTri[1], aTri[2]);
+        const gp_XYZ v1 (theTris->Node (aTri[1]).Coord() - theTris->Node (aTri[0]).Coord());
+        const gp_XYZ v2 (theTris->Node (aTri[2]).Coord() - theTris->Node (aTri[1]).Coord());
         const gp_XYZ vv = v1 ^ v2;
         const Standard_Real aMod = vv.Modulus();
         if (aMod >= aTol)
@@ -191,7 +188,7 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
       aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
     }
 
-    const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 3;
+    const Standard_Integer anId = (aNodeIter - 1) * 3;
     aNormals->SetValue (anId + 1, (Standard_ShortReal )aNorm.X());
     aNormals->SetValue (anId + 2, (Standard_ShortReal )aNorm.Y());
     aNormals->SetValue (anId + 3, (Standard_ShortReal )aNorm.Z());
@@ -213,21 +210,14 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face&  theFace,
     ComputeNormals (theFace, aPolyTri, thePolyConnect);
   }
 
-  const TColgp_Array1OfPnt&       aNodes   = aPolyTri->Nodes();
-  const TShort_Array1OfShortReal& aNormals = aPolyTri->Normals();
-  const Standard_ShortReal*       aNormArr = &aNormals.First();
-  for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+  for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
   {
-    const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
-    const gp_Dir aNorm (aNormArr[anId + 0],
-                        aNormArr[anId + 1],
-                        aNormArr[anId + 2]);
-    theNormals (aNodeIter) = aNorm;
+    theNormals.ChangeValue (aNodeIter) = aPolyTri->Normal (aNodeIter);
   }
 
   if (theFace.Orientation() == TopAbs_REVERSED)
   {
-    for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+    for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
     {
       theNormals.ChangeValue (aNodeIter).Reverse();
     }
index b7b929b976ed43cdbe0f513d9a24075b81228d2a..72ea755ccafd7b3adfda0611acae45468c0aff82 100644 (file)
@@ -332,21 +332,20 @@ void StdPrs_WFShape::addEdges (const TopTools_ListOfShape&  theEdges,
     {
       // Presentation based on triangulation of a face.
       const TColStd_Array1OfInteger& anIndices = anEdgeIndicies->Nodes();
-      const TColgp_Array1OfPnt&      aNodes    = aTriangulation->Nodes();
 
       Standard_Integer anIndex = anIndices.Lower();
       if (aLocation.IsIdentity())
       {
         for (; anIndex <= anIndices.Upper(); ++anIndex)
         {
-          aPoints->Append (aNodes (anIndices (anIndex)));
+          aPoints->Append (aTriangulation->Node (anIndices (anIndex)));
         }
       }
       else
       {
         for (; anIndex <= anIndices.Upper(); ++anIndex)
         {
-          aPoints->Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
+          aPoints->Append (aTriangulation->Node (anIndices (anIndex)).Transformed (aLocation));
         }
       }
     }
index f945bda72f5a1aa78085bdbd87973de2f8210e65..c9865896d5a831b331fbd1053ed70e39cdcab758 100644 (file)
@@ -350,7 +350,6 @@ static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theE
   if (!anHIndices.IsNull())
   {
     const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
-    const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
 
     aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
 
@@ -358,14 +357,14 @@ static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theE
     {
       for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
       {
-        aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
+        aResultPoints->SetValue (aPntId, aTriangulation->Node (anIndices (anIndex)));
       }
     }
     else
     {
       for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
       {
-        aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
+        aResultPoints->SetValue (aPntId, aTriangulation->Node (anIndices (anIndex)).Transformed (aLocation));
       }
     }
     return aResultPoints;
index 00407cd101b8dee590928aa8c04d5a5d89d8f5d3..0f2d5b90b77ec9d30376d51ce9a1f097cf7e0de9 100644 (file)
@@ -52,20 +52,18 @@ Standard_Boolean StlAPI_Reader::Read (TopoDS_Shape&          theShape,
   BRep_Builder BuildTool;
   BuildTool.MakeCompound (aComp);
 
-  const TColgp_Array1OfPnt& aNodes = aMesh->Nodes();
-  const Poly_Array1OfTriangle& aTriangles = aMesh->Triangles();
-  for (Standard_Integer aTriIdx  = aTriangles.Lower();
-                        aTriIdx <= aTriangles.Upper();
+  for (Standard_Integer aTriIdx  = 1;
+                        aTriIdx <= aMesh->NbTriangles();
                       ++aTriIdx)
   {
-    const Poly_Triangle& aTriangle = aTriangles(aTriIdx);
+    const Poly_Triangle& aTriangle = aMesh->Triangle (aTriIdx);
 
     Standard_Integer anId[3];
     aTriangle.Get(anId[0], anId[1], anId[2]);
 
-    const gp_Pnt& aPnt1 = aNodes (anId[0]);
-    const gp_Pnt& aPnt2 = aNodes (anId[1]);
-    const gp_Pnt& aPnt3 = aNodes (anId[2]);
+    const gp_Pnt& aPnt1 = aMesh->Node (anId[0]);
+    const gp_Pnt& aPnt2 = aMesh->Node (anId[1]);
+    const gp_Pnt& aPnt3 = aMesh->Node (anId[2]);
     if ((!(aPnt1.IsEqual (aPnt2, 0.0)))
      && (!(aPnt1.IsEqual (aPnt3, 0.0))))
     {
index bf85e8a8be7b58c45bf87ea30d4135ab41823d42..19293c23a0e03ed5f0e3c1c2c9b6330de10d8660 100644 (file)
@@ -83,23 +83,20 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape&    theShape,
       continue;
     }
 
-    const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
-    const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
     // copy nodes
     gp_Trsf aTrsf = aLoc.Transformation();
-    for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+    for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
     {
-      gp_Pnt aPnt = aNodes (aNodeIter);
+      gp_Pnt aPnt = aTriangulation->Node (aNodeIter);
       aPnt.Transform (aTrsf);
       aMesh->ChangeNode (aNodeIter + aNodeOffset) = aPnt;
     }
 
     // copy triangles
     const TopAbs_Orientation anOrientation = anExpSF.Current().Orientation();
-    for (Standard_Integer aTriIter = aTriangles.Lower(); aTriIter <= aTriangles.Upper(); ++aTriIter)
+    for (Standard_Integer aTriIter = 1; aTriIter <= aTriangulation->NbTriangles(); ++aTriIter)
     {
-      Poly_Triangle aTri = aTriangles (aTriIter);
+      Poly_Triangle aTri = aTriangulation->Triangle (aTriIter);
 
       Standard_Integer anId[3];
       aTri.Get (anId[0], anId[1], anId[2]);
@@ -120,8 +117,8 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape&    theShape,
       aMesh->ChangeTriangle (aTriIter + aTriangleOffet) =  aTri;
     }
 
-    aNodeOffset += aNodes.Size();
-    aTriangleOffet += aTriangles.Size();
+    aNodeOffset += aTriangulation->NbNodes();
+    aTriangleOffet += aTriangulation->NbTriangles();
   }
 
   OSD_Path aPath (theFileName);
index 28cddb10edac45c2510ce6ad0996249fcf951e2f..2fabc036707e5a8b2c1c08e634f7651959c2a8c4 100644 (file)
@@ -29,3 +29,5 @@ TDataXtd_Shape.cxx
 TDataXtd_Shape.hxx
 TDataXtd_Triangulation.cxx
 TDataXtd_Triangulation.hxx
+TDataXtd_SurfacicMesh.cxx
+TDataXtd_SurfacicMesh.hxx
index 2074adba51a5e3892cefbe3898e69a502d1120e4..5037eeec538de1cb7edea2acc309feed601b0dce 100644 (file)
@@ -24,6 +24,7 @@
 #include <TDataXtd_Point.hxx>
 #include <TDataXtd_Position.hxx>
 #include <TDataXtd_Shape.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
 #include <TDF_IDList.hxx>
 
 //=======================================================================
 //=======================================================================
 void TDataXtd::IDList(TDF_IDList& anIDList)
 {  
-  anIDList.Append(TDataXtd_Axis::GetID());
-  anIDList.Append(TDataXtd_Constraint::GetID());
-  anIDList.Append(TDataXtd_Geometry::GetID());
-  anIDList.Append(TDataXtd_PatternStd::GetID());
-  anIDList.Append(TDataXtd_Placement::GetID());
-  anIDList.Append(TDataXtd_Point::GetID());
-  anIDList.Append(TDataXtd_Plane::GetID());
-  anIDList.Append(TDataXtd_Position::GetID());
-  anIDList.Append(TDataXtd_Shape::GetID());
-  
+  anIDList.Append (TDataXtd_Axis::GetID());
+  anIDList.Append (TDataXtd_Constraint::GetID());
+  anIDList.Append (TDataXtd_Geometry::GetID());
+  anIDList.Append (TDataXtd_PatternStd::GetID());
+  anIDList.Append (TDataXtd_Placement::GetID());
+  anIDList.Append (TDataXtd_Point::GetID());
+  anIDList.Append (TDataXtd_Plane::GetID());
+  anIDList.Append (TDataXtd_Position::GetID());
+  anIDList.Append (TDataXtd_Shape::GetID());
+  anIDList.Append (TDataXtd_SurfacicMesh::GetID());
 }
 
 //=======================================================================
diff --git a/src/TDataXtd/TDataXtd_SurfacicMesh.cxx b/src/TDataXtd/TDataXtd_SurfacicMesh.cxx
new file mode 100644 (file)
index 0000000..280f9e9
--- /dev/null
@@ -0,0 +1,472 @@
+// Created on: 2015-12-10
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <Standard_GUID.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_RelocationTable.hxx>
+
+//=======================================================================
+//function : GetID
+//purpose  : 
+//=======================================================================
+const Standard_GUID& TDataXtd_SurfacicMesh::GetID() 
+{ 
+  static Standard_GUID TDataXtd_SurfacicMeshID ("D7E3F1CF-38A4-4DCA-94F4-51C31F3FCBA5");
+  return TDataXtd_SurfacicMeshID; 
+}
+
+//=======================================================================
+//function : SetAttr
+//purpose  : 
+//=======================================================================
+static Handle(TDataXtd_SurfacicMesh) SetAttr (const TDF_Label& theLabel, 
+                                      const Standard_GUID& theID)
+{
+  Handle(TDataXtd_SurfacicMesh) hMesh;
+  if (!theLabel.FindAttribute (theID, hMesh)) {
+    hMesh = new TDataXtd_SurfacicMesh();
+    hMesh->SetID (theID);
+    theLabel.AddAttribute (hMesh);
+  }
+  return hMesh;
+}
+
+//=======================================================================
+//function : Set
+//purpose  : 
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel)
+{
+  return SetAttr (theLabel, GetID());
+}
+
+//=======================================================================
+//function : Set
+//purpose  : 
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+                                          const Standard_GUID& theID)
+{
+  return SetAttr (theLabel, theID);
+}
+
+//=======================================================================
+//function : Set
+//purpose  : 
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+                                          const Handle(Poly_Mesh)& theMesh)
+{
+  Handle(TDataXtd_SurfacicMesh) hMesh = Set (theLabel);
+  hMesh->Set (theMesh);
+  return hMesh;
+}
+
+//=======================================================================
+//function : Set
+//purpose  : 
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+                                          const Standard_GUID& theID,
+                                          const Handle(Poly_Mesh)& theMesh)
+{
+  Handle(TDataXtd_SurfacicMesh) hMesh = Set (theLabel, theID);
+  hMesh->Set (theMesh);
+  return hMesh;
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose  : 
+//=======================================================================
+TDataXtd_SurfacicMesh::TDataXtd_SurfacicMesh():myID (GetID())
+{
+
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::Set (const Handle(Poly_Mesh)& theMesh)
+{
+  Backup();
+  myMesh = theMesh;
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose  : 
+//=======================================================================
+const Handle(Poly_Mesh)& TDataXtd_SurfacicMesh::Get() const
+{
+  return myMesh;
+}
+
+// Poly_Mesh methods
+
+//=======================================================================
+//function : Deflection
+//purpose  : 
+//=======================================================================
+Standard_Real TDataXtd_SurfacicMesh::Deflection() const
+{
+  return myMesh->Deflection();
+}
+
+//=======================================================================
+//function : Deflection
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::Deflection (const Standard_Real theDeflection)
+{
+  Backup();
+  myMesh->Deflection (theDeflection);
+}
+
+//=======================================================================
+//function : RemoveUVNodes
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::RemoveUVNodes()
+{
+  Backup();
+  myMesh->RemoveUVNodes();
+}
+
+//=======================================================================
+//function : NbNodes
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbNodes() const
+{
+  return myMesh->NbNodes();
+}
+
+//=======================================================================
+//function : NbTriangles
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbTriangles() const
+{
+  return myMesh->NbTriangles();
+}
+
+//=======================================================================
+//function : HasUVNodes
+//purpose  : 
+//=======================================================================
+Standard_Boolean TDataXtd_SurfacicMesh::HasUVNodes() const
+{
+  return myMesh->HasUVNodes();
+}
+
+//=======================================================================
+//function : AddNode
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddNode (const gp_Pnt& theNode)
+{
+  Backup();
+  return myMesh->AddNode (theNode);
+}
+
+//=======================================================================
+//function : Node
+//purpose  : 
+//=======================================================================
+const gp_Pnt& TDataXtd_SurfacicMesh::Node (const Standard_Integer theIndex) const
+{
+  return myMesh->Node (theIndex);
+}
+
+//=======================================================================
+//function : SetNode
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode)
+{
+  Backup();
+  myMesh->ChangeNode (theIndex) = theNode;
+}
+
+//=======================================================================
+//function : UVNode
+//purpose  : 
+//=======================================================================
+const gp_Pnt2d& TDataXtd_SurfacicMesh::UVNode (const Standard_Integer theIndex) const
+{
+  return myMesh->UVNode (theIndex);
+}
+
+//=======================================================================
+//function : SetUVNode
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode)
+{
+  Backup();
+  myMesh->ChangeUVNode (theIndex) = theUVNode;
+}
+
+//=======================================================================
+//function : AddTriangle
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddTriangle (const Poly_Triangle& theTriangle)
+{
+  Backup();
+  return myMesh->AddTriangle (theTriangle);
+}
+
+//=======================================================================
+//function : Triangle
+//purpose  : 
+//=======================================================================
+const Poly_Triangle& TDataXtd_SurfacicMesh::Triangle (const Standard_Integer theIndex) const
+{
+  return myMesh->Triangle (theIndex);
+}
+
+//=======================================================================
+//function : SetTriangle
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle)
+{
+  Backup();
+  myMesh->ChangeTriangle (theIndex) = theTriangle;
+}
+
+//=======================================================================
+//function : SetNormal
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetNormal (const Standard_Integer theIndex,
+                               const gp_Dir&          theNormal)
+{
+  Backup();
+  myMesh->SetNormal (theIndex, theNormal);
+}
+
+//=======================================================================
+//function : HasNormals
+//purpose  : 
+//=======================================================================
+Standard_Boolean TDataXtd_SurfacicMesh::HasNormals() const
+{
+  return myMesh->HasNormals();
+}
+
+//=======================================================================
+//function : Normal
+//purpose  : 
+//=======================================================================
+const gp_Dir TDataXtd_SurfacicMesh::Normal (const Standard_Integer theIndex) const
+{
+  return myMesh->Normal (theIndex);
+}
+
+//=======================================================================
+//function : AddElement
+//purpose  :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
+                                            const Standard_Integer theN2,
+                                            const Standard_Integer theN3)
+{
+  Backup();
+  return myMesh->AddElement (theN1, theN2, theN3);
+}
+
+//=======================================================================
+//function : AddElement
+//purpose  :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
+                                            const Standard_Integer theN2,
+                                            const Standard_Integer theN3,
+                                            const Standard_Integer theN4)
+{
+  Backup();
+  return myMesh->AddElement (theN1, theN2, theN3, theN4);
+}
+
+//=======================================================================
+//function : NbElements
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbElements() const
+{
+  return myMesh->NbElements();
+}
+
+//=======================================================================
+//function : NbQuads
+//purpose  : 
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbQuads() const
+{
+  return myMesh->NbQuads();
+}
+
+//=======================================================================
+//function : Element
+//purpose  : 
+//=======================================================================
+const Poly_Element& TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex) const
+{
+  return myMesh->Element (theIndex);
+}
+
+//=======================================================================
+//function : Element
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex,
+                             Standard_Integer& theN1,
+                             Standard_Integer& theN2,
+                             Standard_Integer& theN3,
+                             Standard_Integer& theN4) const
+{
+  myMesh->Element (theIndex, theN1, theN2, theN3, theN4);
+}
+
+//=======================================================================
+//function : SetElement
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
+{
+  Backup();
+  myMesh->SetElement (theIndex, theElement);
+}
+
+//=======================================================================
+//function : SetID
+//purpose  :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetID (const Standard_GUID& theID)
+{
+  if (myID != theID) {
+    Backup();
+    myID = theID;
+  }
+}
+
+//=======================================================================
+//function : SetID
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetID()
+{
+  Backup();
+  myID = GetID();
+}
+
+//=======================================================================
+//function : ID
+//purpose  : 
+//=======================================================================
+const Standard_GUID& TDataXtd_SurfacicMesh::ID () const 
+{ 
+  return myID; 
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose  : 
+//=======================================================================
+Handle(TDF_Attribute) TDataXtd_SurfacicMesh::NewEmpty () const
+{  
+  return new TDataXtd_SurfacicMesh(); 
+}
+
+//=======================================================================
+//function : Restore
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::Restore (const Handle(TDF_Attribute)& theWithMesh) 
+{
+  myMesh.Nullify();
+  Handle(TDataXtd_SurfacicMesh) withMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theWithMesh);
+  if (!withMesh->myMesh.IsNull()) {
+    Handle(Poly_Triangulation) withTris = withMesh->myMesh->Copy();
+    if (!withTris.IsNull())
+      myMesh = Handle(Poly_Mesh)::DownCast (withTris);
+  }
+}
+
+//=======================================================================
+//function : Paste
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::Paste (const Handle(TDF_Attribute)& theIntoMesh,
+                           const Handle(TDF_RelocationTable)& ) const
+{
+  Handle(TDataXtd_SurfacicMesh) intoMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theIntoMesh);
+  intoMesh->myMesh.Nullify();
+  if (!myMesh.IsNull()) {
+    Handle(Poly_Triangulation) aTris = myMesh->Copy();
+    if (!aTris.IsNull())
+      intoMesh->myMesh = Handle(Poly_Mesh)::DownCast (aTris);
+  }
+}
+
+//=======================================================================
+//function : Dump
+//purpose  : 
+//=======================================================================
+Standard_OStream& TDataXtd_SurfacicMesh::Dump (Standard_OStream& theOS) const
+{  
+  theOS << "Mesh: ";
+
+  Standard_Character aStrID[Standard_GUID_SIZE_ALLOC];
+  myID.ToCString (aStrID);
+  theOS << aStrID;
+
+  if (!myMesh.IsNull()) {
+    theOS << "\n\tDeflection: " << myMesh->Deflection();
+    theOS << "\n\tNodes: " << myMesh->NbNodes();
+    theOS << "\n\tTriangles: " << myMesh->NbTriangles();
+    if (myMesh->HasUVNodes())
+      theOS << "\n\tHas UV-Nodes";
+    else
+      theOS << "\n\tNo UV-Nodes";
+    if (myMesh->HasNormals())
+      theOS << "\n\tHas normals";
+    else
+      theOS << "\n\tNo normals";
+  }
+
+  theOS << "\nAttribute fields: ";
+  TDF_Attribute::Dump (theOS);
+  return theOS;
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose  : 
+//=======================================================================
+void TDataXtd_SurfacicMesh::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
+  OCCT_DUMP_BASE_CLASS(theOStream, theDepth, TDF_Attribute)
+  if (!myMesh.IsNull())
+    myMesh->DumpJson (theOStream, theDepth);
+}
diff --git a/src/TDataXtd/TDataXtd_SurfacicMesh.hxx b/src/TDataXtd/TDataXtd_SurfacicMesh.hxx
new file mode 100644 (file)
index 0000000..055b033
--- /dev/null
@@ -0,0 +1,236 @@
+// Created on: 2015-12-10
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _TDataXtd_SurfacicMesh_HeaderFile
+#define _TDataXtd_SurfacicMesh_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <Poly_Mesh.hxx>
+#include <TDF_Attribute.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard_Integer.hxx>
+#include <Standard_OStream.hxx>
+#include <Standard_GUID.hxx>
+
+class TDF_Label;
+class TDF_RelocationTable;
+
+class TDataXtd_SurfacicMesh;
+DEFINE_STANDARD_HANDLE(TDataXtd_SurfacicMesh, TDF_Attribute)
+
+//! An Ocaf attribute containing a mesh (Poly_Mesh).
+//! It duplicates all methods from Poly_Mesh (and Poly_Triangulation).
+//! It is highly recommended to modify the mesh through the methods of this attribute,
+//! but not directly via the underlying Poly_Mesh object.
+//! In this case Undo/Redo will work fine and robust.
+class TDataXtd_SurfacicMesh : public TDF_Attribute
+{
+public:
+  
+  //! Static methods
+  //  ==============
+
+  //! Returns the ID of the mesh attribute.
+  Standard_EXPORT static const Standard_GUID& GetID();
+  
+  //! Finds or creates a mesh attribute.
+  Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel);
+
+  //! Finds or creates a mesh attribute with specified ID.
+  //! It allows setting several mesh-attributes at the same label.
+  Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+                                                    const Standard_GUID& theID);
+
+  //! Finds or creates a mesh attribute.
+  //! Initializes the attribute by a mesh (Poly_Mesh) object.
+  //! If the mesh consists of only triangles,
+  //! you may put Poly_Triangulation object as a 2nd parameter of this method.
+  Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+                                                    const Handle(Poly_Mesh)& theMesh);
+
+  //! Finds or creates a mesh attribute (the same method as above).
+  //! Additionally, it allows setting several mesh-attributes at the same label.
+  Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+                                                    const Standard_GUID& theID,
+                                                    const Handle(Poly_Mesh)& theMesh);
+
+  //! Object methods
+  //  ==============
+
+  //! A constructor.
+  //! Don't use it directly, 
+  //! use please the static method Set(),
+  //! which returns the attribute attached to a label.
+  Standard_EXPORT TDataXtd_SurfacicMesh();
+
+  //! Sets the explicit ID (user defined) for the attribute.
+  Standard_EXPORT void SetID (const Standard_GUID& theID) Standard_OVERRIDE;
+
+  //! Sets default ID for the attribute.
+  Standard_EXPORT void SetID() Standard_OVERRIDE;
+
+  //! Sets the mesh.
+  //! If the mesh consists of only triangles,
+  //! you may put Poly_Triangulation object.
+  Standard_EXPORT void Set (const Handle(Poly_Mesh)& theMesh);
+
+  //! Returns the underlying mesh.
+  Standard_EXPORT const Handle(Poly_Mesh)& Get() const;
+
+
+  //! Poly_Mesh methods
+  //  =================
+
+  //! The methods are "covered" by this attribute to prevent direct modification of the mesh.
+  //! There is no performance problem to call Poly_Mesh method through this attribute.
+  //! The most of the methods are considered as "inline" by the compiler in release mode.
+
+  //! Returns the deflection of this triangulation.
+  Standard_EXPORT Standard_Real Deflection() const;
+
+  //! Sets the deflection of this triangulation to theDeflection.
+  //! See more on deflection in Polygon2D
+  Standard_EXPORT void Deflection (const Standard_Real theDeflection);
+
+  //! Deallocates the UV nodes.
+  Standard_EXPORT void RemoveUVNodes();
+
+  //! @return the number of nodes for this triangulation.
+  Standard_EXPORT Standard_Integer NbNodes() const;
+
+  //! @return the number of triangles for this triangulation.
+  Standard_EXPORT Standard_Integer NbTriangles() const;
+
+  //! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+  Standard_EXPORT Standard_Boolean HasUVNodes() const;
+
+  //! Adds Node to the triangulation. If triangulation has UVNodes or Normals
+  //! they will be expanded and set to zero values to match the new number of nodes.
+  //! @return index of the added Node.
+  Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
+
+  //! @return node at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+  Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
+
+  //! The method differs from Poly_Mesh!
+  //! Sets a node at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+  Standard_EXPORT void SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode);
+
+  //! @return UVNode at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+  Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
+
+  //! The method differs from Poly_Mesh!
+  //! Sets a UVNode at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+  Standard_EXPORT void SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode);
+
+  //! Adds triangle to the triangulation.
+  //! @return index of the added triangle.
+  Standard_EXPORT Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
+
+  //! @return triangle at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
+  Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
+
+  //! The method differs from Poly_Mesh!
+  //! Sets a triangle at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
+  Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
+
+  //! Changes normal at the given index.
+  //! Raises Standard_OutOfRange exception.
+  Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
+                                  const gp_Dir&          theNormal);
+
+  //! Returns Standard_True if nodal normals are defined.
+  Standard_EXPORT Standard_Boolean HasNormals() const;
+
+  //! @return normal at the given index.
+  //! Raises Standard_OutOfRange exception.
+  Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
+
+  //! 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 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.
+  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_EXPORT Standard_Integer NbElements() const;
+
+  //! @return the number of quads for this mesh.
+  Standard_EXPORT Standard_Integer NbQuads() const;
+
+  //! @return element at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
+  Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const;
+
+  //! @return nodes of the element at the given index.
+  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
+  Standard_EXPORT void Element (const Standard_Integer theIndex,
+                                Standard_Integer& theN1,
+                                Standard_Integer& theN2,
+                                Standard_Integer& theN3,
+                                Standard_Integer& theN4) const;
+
+  //! Sets an element at the given index.
+  //! 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);
+
+  //! Dumps the content of me into the stream
+  Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+
+  //! Inherited attribute methods
+  //  ===========================
+
+  Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+  
+  Standard_EXPORT void Restore (const Handle(TDF_Attribute)& theWithMesh) Standard_OVERRIDE;
+  
+  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+  
+  Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theIntoMesh, const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
+  
+  Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& theOS) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTI_INLINE(TDataXtd_SurfacicMesh,TDF_Attribute)
+
+private:
+
+  Handle(Poly_Mesh) myMesh;
+  Standard_GUID     myID;
+};
+
+#endif // _TDataXtd_SurfacicMesh_HeaderFile
index 48b34dab211935e0abd9a40f8eee18599815fcb5..d65c6702e5cb3f32b52dd3379a985000d944d946 100644 (file)
@@ -2826,14 +2826,12 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
   }
 
   Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
-  TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
-  Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
 
   if (  mStartPhi <= 0.0 ){
       x[0] =  mCenter[0];
       x[1] =  mCenter[1];
       x[2] =  mCenter[2] +  mRadius;
-      PointsOfArray.SetValue(1,gp_Pnt(x[0],x[1],x[2]));
+      polyTriangulation->ChangeNode (1) = gp_Pnt (x[0],x[1],x[2]);
   }
 
   // Create south pole if needed
@@ -2841,7 +2839,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
       x[0] =  mCenter[0];
       x[1] =  mCenter[1];
       x[2] =  mCenter[2] -  mRadius;
-      PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
+      polyTriangulation->ChangeNode (2) = gp_Pnt (x[0],x[1],x[2]);
   }
 
   number_point = 3;
@@ -2856,7 +2854,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         x[0] = n[0] +  mCenter[0];
         x[1] = n[1] +  mCenter[1];
         x[2] = n[2] +  mCenter[2];
-        PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
+        polyTriangulation->ChangeNode (number_point) = gp_Pnt (x[0],x[1],x[2]);
         number_point++;
       }
     }
@@ -2868,7 +2866,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         pts[0] = phiResolution*i + numPoles;
         pts[1] = (phiResolution*(i+1) % base) + numPoles;
         pts[2] = 1;
-        pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+        polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
         number_triangle++;
       }
     }
@@ -2879,7 +2877,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         pts[0] = phiResolution*i + numOffset;
         pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
         pts[1] = numPoles - 1;
-        pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+        polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
         number_triangle++;
       }
     }
@@ -2891,11 +2889,11 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         pts[0] = phiResolution*i + j + numPoles;
         pts[1] = pts[0] + 1;
         pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
-        pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+        polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
         number_triangle++;
         pts[1] = pts[2];
         pts[2] = pts[1] - 1;
-        pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+        polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
         number_triangle++;
       }
     }
@@ -2908,12 +2906,12 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
   Standard_Real Tol = Precision::Confusion();
 
   gp_Dir Nor;
-  for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
+  for (i = 1; i <= polyTriangulation->NbNodes(); i++) {
       gp_XYZ eqPlan(0, 0, 0);
       for ( pc->Initialize(i); pc->More(); pc->Next()) {
-        pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
-        gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
-        gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
+        polyTriangulation->Triangle (pc->Value()).Get (index[0], index[1], index[2]);
+        gp_XYZ v1 (polyTriangulation->Node (index[1]).Coord() - polyTriangulation->Node (index[0]).Coord());
+        gp_XYZ v2 (polyTriangulation->Node (index[2]).Coord() - polyTriangulation->Node (index[1]).Coord());
         gp_XYZ vv = v1^v2;
         Standard_Real mod = vv.Modulus();
         if(mod < Tol) continue;
@@ -2926,11 +2924,11 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         Nor = gp_Dir(eqPlan);
       else
         Nor = gp_Dir(0., 0., 1.);
-      
-      Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
-      Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
-      Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
-      Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
+
+      Standard_Integer j = (i - 1) * 3;
+      Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
+      Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
+      Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
   }
 
   delete pc;
@@ -2979,8 +2977,8 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
     = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
                                                   aResolution,
                                                   aRadius));
-  Standard_Integer aNumberPoints    = aShape->GetTriangulation()->Nodes().Length();
-  Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
+  Standard_Integer aNumberPoints    = aShape->GetTriangulation()->NbNodes();
+  Standard_Integer aNumberTriangles = aShape->GetTriangulation()->NbTriangles();
 
   // stupid initialization of Green color in RGBA space as integer
   // probably wrong for big-endian CPUs
@@ -6410,20 +6408,19 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
         continue;
       }
 
-      const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
       const gp_Trsf&            aTrsf  = aLocation.Transformation();
 
       // extract normals from nodes
-      TColgp_Array1OfDir aNormals (aNodes.Lower(), hasNormals ? aNodes.Upper() : aNodes.Lower());
+      TColgp_Array1OfDir aNormals (1, hasNormals ? aTriangulation->NbNodes() : 1);
       if (hasNormals)
       {
         Poly_Connect aPolyConnect (aTriangulation);
         StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
       }
 
-      for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+      for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
       {
-        gp_Pnt aPoint = aNodes (aNodeIter);
+        gp_Pnt aPoint = aTriangulation->Node (aNodeIter);
         if (!aLocation.IsIdentity())
         {
           aPoint.Transform (aTrsf);
index aec83e96194ec2244c4130e973d0a4a179c2b688..79500f61cf538b1ab2ed6b539d9cc407fe07e00d 100644 (file)
@@ -84,22 +84,18 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
       // number of triangles:
     if (T.IsNull()) continue; //smh 
       nnn = T->NbTriangles();            
-    
-    const TColgp_Array1OfPnt& Nodes = T->Nodes(); 
-    // getting a triangle. It is  a triplet of indices in the node table:      
-    const Poly_Array1OfTriangle& triangles = T->Triangles(); 
-    
+
     // Taking the nodes of the triangle, taking into account the orientation
     // of the triangle.
     for (nt = 1; nt <= nnn; nt++) {
       if (F.Orientation() == TopAbs_REVERSED) 
-       triangles(nt).Get(n1,n3,n2);
+           T->Triangle (nt).Get (n1,n3,n2);
       else 
-       triangles(nt).Get(n1,n2,n3);
+           T->Triangle (nt).Get (n1,n2,n3);
       
-      const gp_Pnt& P1 = Nodes(n1);
-      const gp_Pnt& P2 = Nodes(n2);
-      const gp_Pnt& P3 = Nodes(n3);
+      const gp_Pnt& P1 = T->Node (n1);
+      const gp_Pnt& P2 = T->Node (n2);
+      const gp_Pnt& P3 = T->Node (n3);
       // controlling whether the triangle correct from a 3d point of 
       // view: (the triangle may exist in the UV space but the
       // in the 3d space a dimension is null for example)
@@ -160,13 +156,12 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
        // 1 -  Building HAV1 -  array of all XYZ of nodes for Vrml_Coordinate3 from the triangles
        //            and HAV2 - array of all normals of nodes for Vrml_Normal
        
-       const TColgp_Array1OfPnt& Nodes = T->Nodes();
-       TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
+       TColgp_Array1OfDir NORMAL(1, T->NbNodes());
 
          decal = nnv-1;
        
-       for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
-         p = Nodes(j).Transformed(theLocation.Transformation());
+       for (j= 1; j<= T->NbNodes(); j++) {
+         p = T->Node (j).Transformed (theLocation.Transformation());
 
           V.SetX(p.X()); V.SetY(p.Y()); V.SetZ(p.Z());
           HAV1->SetValue(nnv,V);
@@ -185,16 +180,15 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
        // 2 -   Building HAI1 - array of indexes of all triangles and
        //        HAI3 - array of indexes of all normales  for Vrml_IndexedFaceSet
         nbTriangles = T->NbTriangles();
-       const Poly_Array1OfTriangle& triangles = T->Triangles();        
         for (i = 1; i <= nbTriangles; i++) {
           pc.Triangles(i,t[0],t[1],t[2]);
           if (F.Orientation() == TopAbs_REVERSED) 
-            triangles(i).Get(n[0],n[2],n[1]);
+            T->Triangle (i).Get (n[0],n[2],n[1]);
           else 
-            triangles(i).Get(n[0],n[1],n[2]);
-          const gp_Pnt& P1 = Nodes(n[0]);
-          const gp_Pnt& P2 = Nodes(n[1]);
-          const gp_Pnt& P3 = Nodes(n[2]);
+            T->Triangle (i).Get (n[0],n[1],n[2]);
+          const gp_Pnt& P1 = T->Node (n[0]);
+          const gp_Pnt& P2 = T->Node (n[1]);
+          const gp_Pnt& P3 = T->Node (n[2]);
           gp_Vec V1(P1,P2);
           if (V1.SquareMagnitude() > 1.e-10) {
             gp_Vec V2(P2,P3);
@@ -389,10 +383,9 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace,
     CSLib_DerivativeStatus aStatus;
     CSLib_NormalStatus NStat;
     S.Initialize(aFace);
-    const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
-    for (i = UVNodes.Lower(); i <= UVNodes.Upper(); i++) {
-      U = UVNodes(i).X();
-      V = UVNodes(i).Y();
+    for (i = 1; i <= T->NbNodes(); i++) {
+      U = T->UVNode (i).X();
+      V = T->UVNode (i).Y();
       S.D1(U,V,P,D1U,D1V);
       CSLib::Normal(D1U,D1V,Precision::Angular(),aStatus,Nor(i));
       if (aStatus != CSLib_Done) {
@@ -403,16 +396,14 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace,
     }
   }
   else {
-    const TColgp_Array1OfPnt& Nodes = T->Nodes();
     Standard_Integer n[3];
-    const Poly_Array1OfTriangle& triangles = T->Triangles();
 
-    for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
+    for (i = 1; i <= T->NbNodes(); i++) {
       gp_XYZ eqPlan(0, 0, 0);
       for (pc.Initialize(i);  pc.More(); pc.Next()) {
-       triangles(pc.Value()).Get(n[0], n[1], n[2]);
-       gp_XYZ v1(Nodes(n[1]).Coord()-Nodes(n[0]).Coord());
-       gp_XYZ v2(Nodes(n[2]).Coord()-Nodes(n[1]).Coord());
+       T->Triangle (pc.Value()).Get (n[0], n[1], n[2]);
+       gp_XYZ v1 (T->Node (n[1]).Coord() - T->Node (n[0]).Coord());
+       gp_XYZ v2 (T->Node (n[2]).Coord() - T->Node (n[1]).Coord());
        eqPlan += (v1^v2).Normalized();
       }
       Nor(i) = gp_Dir(eqPlan);
index a513281edb02761fcb38d4e0fe06b975630c1c8c..5194e8e94529b29011954e0b1f5c805fe0910ffa 100644 (file)
@@ -208,17 +208,15 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
   Handle(Poly_Triangulation) aTriangulation =
     new Poly_Triangulation(aNodes.Length(), aTriangles.Extent(), Standard_False);
   // Copy the triangulation vertices
-  TColgp_Array1OfPnt& aTNodes = aTriangulation->ChangeNodes();
   for (i = 0; i < aNodes.Length(); i++)
   {
-    aTNodes.SetValue(i + 1, gp_Pnt(aNodes(i)));
+    aTriangulation->ChangeNode (i + 1) = gp_Pnt (aNodes (i));
   }
   // Copy the triangles.
-  Poly_Array1OfTriangle& aTTriangles = aTriangulation->ChangeTriangles();
   NCollection_List<Poly_Triangle>::Iterator itT(aTriangles);
   for (i = 1; itT.More(); itT.Next(), i++)
   {
-    aTTriangles.SetValue(i, itT.Value());
+    aTriangulation->ChangeTriangle (i) = itT.Value();
   }
 
   Handle(BRep_TFace) aFace = new BRep_TFace();
index ae627986e608fdf071f67a2d9e32c0cdacf91bca..df3302049993a136c792da117d4a249970262b16 100644 (file)
@@ -330,21 +330,19 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
   Standard_Integer i;
   const Standard_Integer nNodes         (theTri->NbNodes());
   const Standard_Integer nTriangles     (theTri->NbTriangles());
-  const TColgp_Array1OfPnt&    arrPolyNodes = theTri->Nodes();
-  const Poly_Array1OfTriangle& arrTriangles = theTri->Triangles();
 
   // protection against creation degenerative triangles
   Standard_Integer nbTri = 0;
   Poly_Array1OfTriangle aTriangles(1, nTriangles);
   for (i = 0; i < nTriangles; i++) {
     Standard_Integer idx[3];
-    arrTriangles(i + 1).Get(idx[0], idx[1], idx[2]);
+    theTri->Triangle (i + 1).Get (idx[0], idx[1], idx[2]);
     if (idx[0] == idx[1] || idx[0] == idx[2] || idx[1] == idx[2])
     {
       continue;
     }
     nbTri++;
-    aTriangles.SetValue(nbTri, arrTriangles(i + 1));
+    aTriangles.SetValue (nbTri, theTri->Triangle (i + 1));
   }
   aTriangles.Resize(1, nbTri, Standard_True);
 
@@ -387,7 +385,7 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
     gp_XYZ * arrNodes = static_cast <gp_XYZ *>
       (anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
     for  (i = 0; i < nNodes; i++)
-      arrNodes[i] = arrPolyNodes(i+1).XYZ() * myScale;
+      arrNodes[i] = theTri->Node (i+1).XYZ() * myScale;
 
     const Handle(VrmlData_Coordinate) aCoordNode =
       new VrmlData_Coordinate (myScene, 0L, nNodes, arrNodes);
@@ -399,11 +397,10 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
   if(theTri->HasNormals()) {
     gp_XYZ * arrVec = static_cast <gp_XYZ *>
       (anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
-    const TShort_Array1OfShortReal& Norm = theTri->Normals();
     Standard_Integer j;
     for  (i = 0, j = 1; i < nNodes; i++, j += 3)
     {
-      gp_XYZ aNormal(Norm(j), Norm(j+1), Norm(j+2));
+      gp_XYZ aNormal = theTri->Normal (i + 1).XYZ();
       if (isReverse)
       {
         aNormal.Reverse();
@@ -429,14 +426,13 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
       Handle(TShort_HArray1OfShortReal) Normals = 
         new TShort_HArray1OfShortReal(1, nbNormVal);
 
-      const TColgp_Array1OfPnt2d& arrUV = theTri->UVNodes();
       gp_XYZ * arrVec = static_cast <gp_XYZ *>
         (anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
 
       // Compute the normal vectors
       Standard_Real Tol = Sqrt(aConf2);
       for  (i = 0; i < nNodes; i++) {
-        const gp_Pnt2d& aUV = arrUV(i+1);
+        const gp_Pnt2d& aUV = theTri->UVNode (i+1);
         
         gp_Dir aNormal;
         
@@ -447,8 +443,8 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
           gp_XYZ eqPlan(0., 0., 0.);
           for (PC.Initialize(i+1);  PC.More(); PC.Next()) {
             aTriangles(PC.Value()).Get(n[0], n[1], n[2]);
-            gp_XYZ v1(arrPolyNodes(n[1]).Coord()-arrPolyNodes(n[0]).Coord());
-            gp_XYZ v2(arrPolyNodes(n[2]).Coord()-arrPolyNodes(n[1]).Coord());
+            gp_XYZ v1 (theTri->Node (n[1]).Coord()-theTri->Node (n[0]).Coord());
+            gp_XYZ v2 (theTri->Node (n[2]).Coord()-theTri->Node (n[1]).Coord());
             gp_XYZ vv = v1^v2;
 
             Standard_Real mod = vv.Modulus();
index 38f078390a9bd1998bd25e70dec98d7d5aa7b085..d0434c78851635ef5b78bba840ae0c28c84de6dc 100644 (file)
@@ -146,24 +146,22 @@ static Standard_Real CalculVolume(const TopoDS_Shape& So,
          facing = BRep_Tool::Triangulation(F,L);
        }
 
-      TColgp_Array1OfPnt tab(1,(facing->NbNodes()));
-      tab = facing->Nodes();
-      Poly_Array1OfTriangle tri(1,facing->NbTriangles());
-      tri = facing->Triangles();
       for (Standard_Integer i=1;i<=(facing->NbTriangles());i++)
        {
          
-         Poly_Triangle trian = tri.Value(i);
+         Poly_Triangle trian = facing->Triangle (i);
          Standard_Integer index1,index2,index3;//M,N;
          if( F.Orientation() == TopAbs_REVERSED )
            trian.Get(index1,index3,index2);
          else
            trian.Get(index1,index2,index3);
-         curVolume = TetraVol(aRefPoint, tab.Value(index1),
-                              tab.Value(index2), tab.Value(index3));
+         curVolume = TetraVol (aRefPoint, facing->Node (index1),
+                                                  facing->Node (index2),
+                                       facing->Node (index3));
          myVolume += curVolume;
-         curCentroid = TetraCen(aRefPoint, tab.Value(index1),
-                                tab.Value(index2), tab.Value(index3));
+         curCentroid = TetraCen (aRefPoint, facing->Node (index1),
+                                                        facing->Node (index2),
+                                         facing->Node (index3));
          
          localCentroid = localCentroid + curCentroid*curVolume;
        }
index 0d65e198322fc32422a0c2c233afe4979619e707..07ccd3e23f40e2801c309478a192b97a7c26335b 100644 (file)
@@ -783,7 +783,7 @@ static Standard_Integer createmesh
 
   // Hide all nodes by default
   Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
-  Standard_Integer aLen = aSTLMesh->Nodes().Length();
+  Standard_Integer aLen = aSTLMesh->NbNodes();
   for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
     aNodes->ChangeMap().Add( anIndex );
   aMesh->SetHiddenNodes( aNodes );
index f6cc4e1bbb6ec7702c49f0a237bdad7bf1496bd9..4528ba81f1922dbfc0202c12b10a7bb8c6773c35 100644 (file)
@@ -33,8 +33,7 @@ XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulat
 
   if( !myMesh.IsNull() )
   {
-    const TColgp_Array1OfPnt& aCoords = myMesh->Nodes();
-    Standard_Integer len = aCoords.Length(), i, j;
+    Standard_Integer len = myMesh->NbNodes(), i, j;
     myNodeCoords = new TColStd_HArray2OfReal(1, len, 1, 3);
     std::cout << "Nodes : " << len << std::endl;
 
@@ -43,15 +42,14 @@ XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulat
     for( i = 1; i <= len; i++ )
     {
       myNodes.Add( i );
-      xyz = aCoords(i).XYZ();
+      xyz = myMesh->Node (i).XYZ();
 
       myNodeCoords->SetValue(i, 1, xyz.X());
       myNodeCoords->SetValue(i, 2, xyz.Y());
       myNodeCoords->SetValue(i, 3, xyz.Z());
     }
 
-    const Poly_Array1OfTriangle& aSeq = myMesh->Triangles();
-    len = aSeq.Length();
+    len = myMesh->NbTriangles();
     myElemNormals = new TColStd_HArray2OfReal(1, len, 1, 3);
     myElemNodes = new TColStd_HArray2OfInteger(1, len, 1, 3);
 
@@ -61,14 +59,14 @@ XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulat
     {
       myElements.Add( i );
 
-      const Poly_Triangle& aTri = aSeq(i);
+      const Poly_Triangle& aTri = myMesh->Triangle (i);
 
       Standard_Integer V[3];
       aTri.Get (V[0], V[1], V[2]);
 
-      const gp_Pnt aP1 = aCoords (V[0]);
-      const gp_Pnt aP2 = aCoords (V[1]);
-      const gp_Pnt aP3 = aCoords (V[2]);
+      const gp_Pnt& aP1 = myMesh->Node (V[0]);
+      const gp_Pnt& aP2 = myMesh->Node (V[1]);
+      const gp_Pnt& aP3 = myMesh->Node (V[2]);
 
       gp_Vec aV1(aP1, aP2);
       gp_Vec aV2(aP2, aP3);
index 6cd788d3448ac4a7b1feef40048d044194223516..fa46cf59dd286cddde4f61c2d1916e0bcb490ccf 100644 (file)
@@ -12,3 +12,5 @@ XmlMDataXtd_PresentationDriver.hxx
 XmlMDataXtd_PresentationDriver.cxx
 XmlMDataXtd_TriangulationDriver.cxx
 XmlMDataXtd_TriangulationDriver.hxx
+XmlMDataXtd_SurfacicMeshDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.hxx
index 9a63cbc18f0a307eb9685a3856d483a60b49393c..744d6a0c6435f1406b967d74130fee54952ee837 100644 (file)
@@ -21,6 +21,7 @@
 #include <XmlMDataXtd_GeometryDriver.hxx>
 #include <XmlMDataXtd_PatternStdDriver.hxx>
 #include <XmlMDataXtd_TriangulationDriver.hxx>
+#include <XmlMDataXtd_SurfacicMeshDriver.hxx>
 #include <XmlMDF_ADriverTable.hxx>
 
 #include <XmlMDataXtd_PresentationDriver.hxx>
@@ -34,13 +35,14 @@ static Standard_Integer myDocumentVersion = -1;
 void XmlMDataXtd::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
                               const Handle(Message_Messenger)&   anMsgDrv)
 {
-  aDriverTable->AddDriver(new XmlMDataXtd_GeometryDriver      (anMsgDrv));
-  aDriverTable->AddDriver(new XmlMDataXtd_ConstraintDriver    (anMsgDrv));
-  aDriverTable->AddDriver(new XmlMDataXtd_PatternStdDriver    (anMsgDrv));
-  aDriverTable->AddDriver(new XmlMDataXtd_TriangulationDriver (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_GeometryDriver      (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_ConstraintDriver    (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_PatternStdDriver    (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_TriangulationDriver (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_SurfacicMeshDriver  (anMsgDrv));
 
-  aDriverTable->AddDriver(new XmlMDataXtd_PresentationDriver  (anMsgDrv));
-  aDriverTable->AddDriver(new XmlMDataXtd_PositionDriver      (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_PresentationDriver  (anMsgDrv));
+  aDriverTable->AddDriver (new XmlMDataXtd_PositionDriver      (anMsgDrv));
 }
 
 //=======================================================================
diff --git a/src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.cxx b/src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.cxx
new file mode 100644 (file)
index 0000000..069242b
--- /dev/null
@@ -0,0 +1,132 @@
+// Created on: 2015-12-15
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XmlMDataXtd_SurfacicMeshDriver.hxx>
+#include <Message_Messenger.hxx>
+#include <NCollection_LocalArray.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XmlObjMgt.hxx>
+#include <XmlObjMgt_Persistent.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <LDOM_OSStream.hxx>
+#include <BRepTools_ShapeSet.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XmlMDataXtd_SurfacicMeshDriver,XmlMDF_ADriver)
+IMPLEMENT_DOMSTRING (MeshString, "mesh")
+IMPLEMENT_DOMSTRING (NullString, "null")
+IMPLEMENT_DOMSTRING (ExistString, "exists")
+
+//=======================================================================
+//function : XmlMDataXtd_SurfacicMeshDriver
+//purpose  : Constructor
+//=======================================================================
+XmlMDataXtd_SurfacicMeshDriver::XmlMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMsgDriver)
+     : XmlMDF_ADriver (theMsgDriver, NULL)
+{
+
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose  : 
+//=======================================================================
+Handle(TDF_Attribute) XmlMDataXtd_SurfacicMeshDriver::NewEmpty() const
+{
+  return new TDataXtd_SurfacicMesh();
+}
+
+//=======================================================================
+//function : Paste
+//purpose  : persistent -> transient (retrieve)
+//=======================================================================
+Standard_Boolean XmlMDataXtd_SurfacicMeshDriver::Paste (const XmlObjMgt_Persistent&  theSource,
+                                                const Handle(TDF_Attribute)& theTarget,
+                                                XmlObjMgt_RRelocationTable&  ) const
+{
+  const XmlObjMgt_Element& anElement = theSource;
+  Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theTarget);
+
+  // Read the FirstIndex; if the attribute is absent initialize to 1
+  XmlObjMgt_DOMString aMeshStatus = anElement.getAttribute (::MeshString());
+  if (aMeshStatus == NULL ||
+      aMeshStatus.Type() != LDOMBasicString::LDOM_AsciiDoc ||
+      strcmp (aMeshStatus.GetString(), ::ExistString().GetString())) 
+  {
+    // No mesh.
+    return Standard_True;
+  }
+
+  // Get mesh as a string.
+  const XmlObjMgt_DOMString& aData = XmlObjMgt::GetStringValue (anElement);
+  std::stringstream aStream (std::string (aData.GetString()));
+
+  // Read the mesh.
+  BRepTools_ShapeSet aShapeSet;
+  TColStd_IndexedMapOfTransient aMeshes;
+  aShapeSet.ReadMeshes (aStream, aMeshes);
+
+  // Set mesh.
+  if (!aMeshes.IsEmpty()) {
+    // We expect only one mesh.
+    Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (aMeshes (1));
+    if (!aMesh.IsNull())
+      attrMesh->Set (aMesh);
+  }
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose  : transient -> persistent (store)
+//=======================================================================
+void XmlMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSource,
+                                    XmlObjMgt_Persistent&        theTarget,
+                                    XmlObjMgt_SRelocationTable&  ) const
+{
+  const Handle(TDataXtd_SurfacicMesh) meshAttr = Handle(TDataXtd_SurfacicMesh)::DownCast (theSource);
+  if (meshAttr->Get().IsNull())
+    theTarget.Element().setAttribute (::MeshString(), ::NullString());
+  else
+  {
+    theTarget.Element().setAttribute (::MeshString(), ::ExistString());
+    
+    // Analyse the size of the mesh
+    // (to allocate properly the string array).
+    const Handle(Poly_Mesh)& aMesh = meshAttr->Get();
+    Standard_Integer aSize = aMesh->NbNodes();
+    aSize *= 3; // 3 coordinates for a node
+    aSize *= 8; // 8 characters are used to represent a coordinate (double) in XML
+    aSize += 4 * 5 * aMesh->NbElements(); // space for elements (triangles and quadrangles)
+    aSize *= 2; // just in case :-)
+    if (!aSize)
+      aSize = 1;
+
+    // Allocate a string stream.
+    LDOM_OSStream aStream (aSize);
+
+    // Write the mesh.
+    BRepTools_ShapeSet aShapeSet;
+    TColStd_IndexedMapOfTransient aMeshes;
+    aMeshes.Add (aMesh);
+    aShapeSet.WriteMeshes (aStream, aMeshes, Standard_True/*compact*/);
+    aStream << std::ends;
+
+    Standard_Character* aDump = (Standard_Character*) aStream.str(); // copying! Don't forget to delete it.
+    XmlObjMgt::SetStringValue (theTarget, aDump, Standard_True);
+    delete[] aDump;
+  }
+}
diff --git a/src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.hxx b/src/XmlMDataXtd/XmlMDataXtd_SurfacicMeshDriver.hxx
new file mode 100644 (file)
index 0000000..ba55476
--- /dev/null
@@ -0,0 +1,50 @@
+// Created on: 2015-12-15
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
+#define _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <XmlMDF_ADriver.hxx>
+#include <XmlObjMgt_RRelocationTable.hxx>
+#include <XmlObjMgt_SRelocationTable.hxx>
+
+class Message_Messenger;
+class TDF_Attribute;
+class XmlObjMgt_Persistent;
+
+DEFINE_STANDARD_HANDLE(XmlMDataXtd_SurfacicMeshDriver, XmlMDF_ADriver)
+
+//! TDataXtd_SurfacicMesh attribute XML-driver.
+class XmlMDataXtd_SurfacicMeshDriver : public XmlMDF_ADriver
+{
+
+public:
+  
+  Standard_EXPORT XmlMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMessageDriver);
+  
+  Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+  
+  Standard_EXPORT Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource, 
+                                          const Handle(TDF_Attribute)& theTarget, 
+                                          XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+  
+  Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource, XmlObjMgt_Persistent& theTarget, 
+                              XmlObjMgt_SRelocationTable& RelocTable) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTIEXT(XmlMDataXtd_SurfacicMeshDriver, XmlMDF_ADriver)
+};
+
+#endif // _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
index 6b162e276f2abb70146891b8e349c78b7bbf9c11..02039bee9c4291a214a3a2ed3b58976c1359fc57 100644 (file)
@@ -158,28 +158,25 @@ void XmlMDataXtd_TriangulationDriver::Paste(const Handle(TDF_Attribute)& theSour
     stream << PT->Deflection() << "\n";
 
     // write the 3d nodes
-    const TColgp_Array1OfPnt& Nodes = PT->Nodes();
     for (i = 1; i <= nbNodes; i++)
     {
-      stream << Nodes(i).X() << " "
-             << Nodes(i).Y() << " "
-             << Nodes(i).Z() << " ";
+      stream << PT->Node (i).X() << " "
+             << PT->Node (i).Y() << " "
+             << PT->Node (i).Z() << " ";
     }
 
     if (PT->HasUVNodes())
     {
-      const TColgp_Array1OfPnt2d& UVNodes = PT->UVNodes();
       for (i = 1; i <= nbNodes; i++)
       {
-        stream << UVNodes(i).X() << " "
-               << UVNodes(i).Y() << " ";
+        stream << PT->UVNode (i).X() << " "
+               << PT->UVNode (i).Y() << " ";
       }
     }
 
-    const Poly_Array1OfTriangle& Triangles = PT->Triangles();
     for (i = 1; i <= nbTriangles; i++)
     {
-      Triangles(i).Get(n1, n2, n3);
+      PT->Triangle (i).Get (n1, n2, n3);
       stream << n1 << " "
              << n2 << " "
              << n3 << " ";
diff --git a/tests/caf/basic/Z1 b/tests/caf/basic/Z1
new file mode 100644 (file)
index 0000000..1da3540
--- /dev/null
@@ -0,0 +1,47 @@
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: TDataStd_Mesh
+#
+# Testing command:   SetMesh
+# Testing command:   DumpMesh
+#
+puts "caf001-Z1"
+set QA_DUP 0
+
+# Make a sphere and produce triangulation
+box s 100 200 300
+explode s f
+incmesh s_1 0.1
+
+# Set mesh from the spherical face
+NewCommand D
+SetMesh D 0:1 s_1
+NewCommand D
+
+# Test Undo/Redo.
+Undo D
+Redo D
+
+# Print the mesh data
+set dump1 [DumpMesh D 0:1]
+
+# Save document on disk.
+set filename ${imagedir}/${casename}.cbf
+SaveAs D ${filename}
+
+# Close and open the document again.
+Close D
+Open ${filename} DD
+
+# Print mesh data
+set dump2 [DumpMesh DD 0:1]
+
+Close DD
+
+# Check data
+if { ${dump1}!=${dump2} } {
+       puts "TDataStd_Mesh(XML) attribute: Error"
+       return
+}
+puts "TDataStd_Mesh(XML) attribute: OK"