]> OCCT Git - occt-copy.git/commitdiff
0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal...
authorvro <vladislav.romashko@opencascade.com>
Sun, 14 Feb 2021 05:55:02 +0000 (08:55 +0300)
committervro <vladislav.romashko@opencascade.com>
Sun, 14 Feb 2021 05:55:02 +0000 (08:55 +0300)
Extension of triangular mesh of Open CASCADE to support quadrangular elements.
A Poly_Mesh class inherits Poly_Triangulation and manipulates quadrangles.
A TDataXtd_SurfacicMesh OCAF attribute is added to support a new surface mesh in OCAF operations.

// Porting of old development (for OCCT 7.1.0) to the current version of Open CASCADE.
// All remarks are checked, regressions are fixed.
// A new test-case is added : caf basic Z1

88 files changed:
dox/upgrade/upgrade.md
samples/OCCTOverview/code/TriangulationSamples.cxx
samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp
samples/mfc/standard/07_Triangulation/src/Tesselate_Presentation.cpp
samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp
samples/mfc/standard/Common/User_Cylinder.cxx
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_Mesh.cxx [new file with mode: 0644]
src/Poly/Poly_Mesh.hxx [new file with mode: 0644]
src/Poly/Poly_PolygonOnTriangulation.cxx
src/Poly/Poly_PolygonOnTriangulation.hxx
src/Poly/Poly_Quad.hxx [new file with mode: 0644]
src/Poly/Poly_Triangle.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/RWObj/RWObj_TriangulationReader.cxx
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_Triangulation.cxx
src/TDataXtd/TDataXtd_Triangulation.hxx
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 87d73022b3e1493146ba56eed5f9f4c08cae2245..875e39990f81b2d5275ab1890407d345fa99034a 100644 (file)
@@ -2210,3 +2210,12 @@ BRep and Binary BRep Shape formats (only in case of triangulation-only Faces, wi
 
 Versions of formats have been changed (11 for BinOCAF, 10 for XmlOCAF, 4 for BRep Shape and 3 for Binary BRep Shape).
 Files written with the new version will not be readable by applications of old versions.
+
+@subsection upgrade_occt760_poly Changes in *Poly* package and *Poly_Triangulation* class:
+
+* Poly_Triangulation: Replaced all arrays with NCollection_Vector.
+* Poly_Triangulation: Old fashion of data access via getting collection reference is not more allowed for safety reasons.
+  Instead of old API, data access is organized via getters of single element by index.
+* New class Poly_Element that allows to store triangles or quads (quad consists of two triangles).
+* New class Poly_Mesh is extension of Poly_Triangulation that allows to store mesh with quad polygons as table of Poly_Element.
+* New OCAF attribute TDataXtd_SurfacicMesh that allows to store Poly_Mesh in OCAF documents.
index eff114e83160df5325566b1883cbea96fafcb9cd..a3684639ad2c77f82158d4916e8fb735a68fe707 100644 (file)
@@ -70,14 +70,9 @@ void TriangulationSamples::Triangulation3dSample()
     TopLoc_Location aLocation;
     Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLocation);
 
-    TColgp_Array1OfPnt aTriangNodes(1, (aTriangulation->NbNodes()));
-    aTriangNodes = aTriangulation->Nodes();
-    Poly_Array1OfTriangle aTriangles(1, aTriangulation->NbTriangles());
-    aTriangles = aTriangulation->Triangles();
-
     for (Standard_Integer i = 1; i <= (aTriangulation->NbTriangles()); i++)
     {
-      Poly_Triangle trian = aTriangles.Value(i);
+      const Poly_Triangle& trian = aTriangulation->Triangle (i);
       Standard_Integer index1, index2, index3, M = 0, N = 0;
       trian.Get(index1, index2, index3);
 
@@ -96,7 +91,7 @@ void TriangulationSamples::Triangulation3dSample()
             M = index2;
         }
 
-        BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangNodes.Value(M), aTriangNodes.Value(N));
+        BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangulation->Node (M), aTriangulation->Node (N));
         if (anEdgeMaker.IsDone())
         {
           aBuilder.Add(aCompound, anEdgeMaker.Edge());
index 497f5244ed53c07f3779793d2126ab6b6a87da6d..8ea5b4b6e0bd8538bf88929b9e490ce945a06ce6 100755 (executable)
@@ -1217,14 +1217,12 @@ void CGeometryDoc::simplify(const TopoDS_Shape& aShape)
     "\n"
     "    if(!aTr.IsNull())\n"
     "    { \n"
-    "      // takes the array of nodes for this triangulation\n"
-    "      const TColgp_Array1OfPnt& aNodes = aTr->Nodes();    \n"
-    "      nbNodes = aNodes.Length();\n"
+    "      nbNodes = aTr->NbNodes();\n"
     "\n"
     "      for( Standard_Integer i = 1; i <= nbNodes; i++)\n"
     "      {\n"
     "        // create seguence of node points in absolute coordinate system\n"
-    "        gp_Pnt aPnt = aNodes(i).Transformed(aLocation);\n"
+    "        gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);\n"
     "        aPoints.Append(aPnt);\n"
     "        \n"
     "      }\n"
@@ -1371,13 +1369,12 @@ void CGeometryDoc::simplify(const TopoDS_Shape& aShape)
       if(!aTr.IsNull())
       { 
         // takes the array of nodes for this triangulation
-        const TColgp_Array1OfPnt& aNodes = aTr->Nodes();    
-        nbNodes = aNodes.Length();
+        nbNodes = aTr->NbNodes();
 
         for( Standard_Integer i = 1; i <= nbNodes; i++)
         {
           // create seguence of node points in absolute coordinate system
-          gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
+          gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
           aPoints.Append(aPnt);
 
         }
index 77eeb4c5307a138a6b89624a28d8f513afa76290..b34e562e295a7235212276ade944ded5fd418d98 100755 (executable)
@@ -126,15 +126,10 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
     
     "  if(!aTr.IsNull()) // if this triangulation is not NULL" EOL
     "  { " EOL
-    "    // takes the array of nodes for this triangulation:" EOL
-    "    const TColgp_Array1OfPnt& aNodes = aTr->Nodes();" EOL
-    "    // takes the array of triangles for this triangulation:" EOL
-    "    const Poly_Array1OfTriangle& triangles = aTr->Triangles();" EOL EOL
-    
     "    // create array of node points in absolute coordinate system" EOL
-    "    TColgp_Array1OfPnt aPoints(1, aNodes.Length());" EOL
-    "    for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)" EOL
-    "      aPoints(i) = aNodes(i).Transformed(aLocation);" EOL EOL
+    "    TColgp_Array1OfPnt aPoints(1, aTr->NbNodes());" EOL
+    "    for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)" EOL
+    "      aPoints(i) = aTr->Node (i).Transformed (aLocation);" EOL EOL
 
     "    // Takes the node points of each triangle of this triangulation." EOL
     "    // takes a number of triangles:" EOL
@@ -143,7 +138,7 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
     "    for( nt = 1 ; nt < nnn+1 ; nt++)" EOL
     "    {" EOL
     "      // takes the node indices of each triangle in n1,n2,n3:" EOL
-    "      triangles(nt).Get(n1,n2,n3);" EOL
+    "      aTr->Triangle (nt).Get (n1,n2,n3);" EOL
     "      // takes the node points:" EOL
     "      gp_Pnt aPnt1 = aPoints(n1);" EOL
     "      gp_Pnt aPnt2 = aPoints(n2);" EOL
@@ -211,11 +206,9 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
 
     if(!aTr.IsNull())
     { 
-      const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
       aNumOfNodes += aTr->NbNodes();
       //Standard_Integer aLower = aNodes.Lower();
       //Standard_Integer anUpper = aNodes.Upper();
-      const Poly_Array1OfTriangle& triangles = aTr->Triangles();
       aNumOfTriangles += aTr->NbTriangles();
 
       if(aCount == aNumOfFace)
@@ -251,8 +244,8 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
             Standard_Integer aLower = aNodesOfPol.Lower(), anUpper = aNodesOfPol.Upper();
             for( int i = aLower; i < anUpper ; i++)
             {
-              gp_Pnt aPnt1 = aNodes(aNodesOfPol(i)).Transformed(aLocation);
-              gp_Pnt aPnt2 = aNodes(aNodesOfPol(i+1)).Transformed(aLocation);
+              gp_Pnt aPnt1 = aTr->Node (aNodesOfPol (i)).Transformed (aLocation);
+              gp_Pnt aPnt2 = aTr->Node (aNodesOfPol (i+1)).Transformed (aLocation);
               TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex (aPnt1);
               TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex (aPnt2);
 
@@ -283,9 +276,9 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
       TopTools_DataMapOfIntegerShape aEdges;
       TopTools_SequenceOfShape aVertices;
 
-      for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)
+      for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)
       {
-        gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
+        gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
         TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(aPnt);
 
         if(!aVertex.IsNull())
@@ -302,7 +295,7 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
 
       for( nt = 1 ; nt < nnn+1 ; nt++)
       {     
-        triangles(nt).Get(n1,n2,n3);
+        aTr->Triangle (nt).Get (n1,n2,n3);
 
         Standard_Integer key[3];
         
index d25bf8924d3fb7e75bdfbc9a963e84e2245da2c5..58555a457e9ecb6099a358e3f1f1c41861dc431f 100755 (executable)
@@ -157,13 +157,9 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {
        TopoDS_Face F =TopoDS::Face(ex.Current());
     TopLoc_Location L;
        Handle (Poly_Triangulation) 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);
+               const Poly_Triangle& trian = facing->Triangle (i);
                Standard_Integer index1,index2,index3,M = 0, N = 0;
                trian.Get(index1,index2,index3);
        
@@ -180,7 +176,7 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {
                                M = index2;
                        }
                        
-                       BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N));
+                       BRepBuilderAPI_MakeEdge ME(facing->Node (M), facing->Node (N));
                        if (ME.IsDone()) {
                                builder.Add(Comp,ME.Edge());
                        }
@@ -210,13 +206,9 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {  \n\
        TopoDS_Face F =TopoDS::Face(ex.Current());      \n\
        TopLoc_Location L;      \n\
        Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);     \n\
-       TColgp_Array1OfPnt tab(1,(facing->NbNodes()));  \n\
-       tab = facing->Nodes();  \n\
-       Poly_Array1OfTriangle tri(1,facing->NbTriangles());     \n\
-       tri = facing->Triangles();      \n\
-       \n\
+    \n\
        for (Standard_Integer i=1;i<=(facing->NbTriangles());i++) {     \n\
-               Poly_Triangle trian = tri.Value(i);     \n\
+               Poly_Triangle trian = facing->Triangle (i);     \n\
                Standard_Integer index1,index2,index3,M,N;      \n\
                trian.Get(index1,index2,index3);        \n\
                \n\
@@ -233,7 +225,7 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {   \n\
                                M = index2;     \n\
                        }       \n\
                                \n\
-                       BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N));  \n\
+                       BRepBuilderAPI_MakeEdge ME(facing->Node (M),facing->Node (N));  \n\
                        if (ME.IsDone()) {      \n\
                                builder.Add(Comp,ME.Edge());    \n\
                        }       \n\
index c427005c2caa2d70229923b23cbef8607d9a3f9f..c5e8467b74c3c637ebe60d6ea705a13a9064f31b 100755 (executable)
@@ -158,10 +158,6 @@ case 6: //color
         return;
       }
 
-      const TColgp_Array1OfPnt& Nodes= myT->Nodes();
-
-      const Poly_Array1OfTriangle& triangles = myT->Triangles();
-
       Standard_Integer nnn = myT->NbTriangles(); // nnn : nombre de triangles
       Standard_Integer nt, n1, n2, n3 = 0;// nt : triangle courant
       // ni : sommet i du triangle courant
@@ -171,15 +167,15 @@ case 6: //color
         // triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
 
         if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
-          triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+          myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
         else
-          triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+          myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
 
-        if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
+        if (TriangleIsValid (myT->Node (n1), myT->Node (n2), myT->Node (n3)) )
         { // Associates a vertexNT to each node
-          gp_Pnt p = Nodes(n1).Transformed(myLocation.Transformation());
-          gp_Pnt q = Nodes(n2).Transformed(myLocation.Transformation());
-          gp_Pnt r = Nodes(n3).Transformed(myLocation.Transformation());
+          gp_Pnt p = myT->Node (n1).Transformed (myLocation.Transformation());
+          gp_Pnt q = myT->Node (n2).Transformed (myLocation.Transformation());
+          gp_Pnt r = myT->Node (n3).Transformed (myLocation.Transformation());
 
           if (p.Z() > H.Z()) H=p;
           if (q.Z() > H.Z()) H=q;
@@ -213,14 +209,12 @@ case 6: //color
         return;
       }
       Poly_Connect pc(myT);
-      const TColgp_Array1OfPnt& Nodes= myT->Nodes();
+      TColgp_Array1OfPnt Nodes (1, myT->NbNodes());
+      for (Standard_Integer in = 1; in <= myT->NbNodes(); in++)
+        Nodes.SetValue(in, myT->Node (in));
       BAR = GProp_PGProps::Barycentre(Nodes);
 
-
-      //const TColgp_Array1OfPnt2d& UVNodes = myT->UVNodes();
-      const Poly_Array1OfTriangle& triangles = myT->Triangles();
       TColgp_Array1OfDir myNormal(Nodes.Lower(), Nodes.Upper());
-
       StdPrs_ToolTriangulatedShape::Normal(myFace, pc, myNormal);
       BRepTools::UVBounds(myFace,Umin, Umax, Vmin, Vmax);
       dUmax = (Umax - Umin);
@@ -238,9 +232,9 @@ case 6: //color
       {
         // triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
         if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
-          triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+          myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
         else
-          triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+          myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
 
         if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
         { // Associates a vertexNT to each node
@@ -258,9 +252,9 @@ case 6: //color
         std::cout << "On traite actuellement le triangle : "<< nt <<"\n";
 #endif
         if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
-          triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+          myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
         else
-          triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+          myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
 
         if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
         { // Associates a vertexNT to each node
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..1b72f9d70a8f9d40ad9629e9771440a0942a8df7 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,27 @@ 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));
+            const Vec3f& aNormal = myTriangulation->Normal (i);
+            anArray->SetVertexNormal (i, aNormal.x(), aNormal.y(), aNormal.z());
           }
         }
         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));
+            const Vec3f& aNormal = myTriangulation->Normal(i);
+            anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());
           }
         }
       }
@@ -166,23 +161,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..7a268f09f7a6dff93170f4540d86c273d3184243 100644 (file)
@@ -2343,12 +2343,9 @@ Standard_Boolean BRepLib::
     }
 
     GeomLProp_SLProps aSLP(aSurf, 2, Precision::Confusion());
-    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.);
@@ -2364,14 +2361,13 @@ Standard_Boolean BRepLib::
         if (aFace.Orientation() == TopAbs_REVERSED)
           aNorm.Reverse();
       }
-      aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.X());
-      aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Y());
-      aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Z());
+      aPT->SetNormal (i, static_cast<Standard_ShortReal>(aNorm.X()),
+                         static_cast<Standard_ShortReal>(aNorm.Y()),
+                         static_cast<Standard_ShortReal>(aNorm.Z()));
     }
 
     aRetVal = Standard_True;
     isNormalsFound = Standard_True;
-    aPT->SetNormals(aNormArr);
   }
 
   if(!isNormalsFound)
@@ -2407,9 +2403,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 +2414,16 @@ 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, aNorm2;
+      aPT1->Normal (aFNodF1, aNorm1);
+      aPT1->Normal (aFNodF2, aNorm2);
       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..404da9b706eba3c68e6fce1e1fec7d37a3de0992 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..a2638334808d9b5ce4614801bdb3ce63c6f79f54 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).GetData() [k - 1] << " ";
+            if (!Compact)
+            {
+              OS << "\n";
+            }
+            else
+            {
+              OS << " ";
+            }
           }
         }
       }
@@ -1558,10 +1558,9 @@ void BRepTools_ShapeSet::DumpTriangulation(Standard_OStream& OS)const
 void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_ProgressRange& theProgress)
 {
   char buffer[255];
-  //  Standard_Integer i, j, val, nbtri;
   Standard_Integer i, j, nbtri =0;
   Standard_Real d, x, y, z;
-  Standard_Real normal;
+  Standard_Real normalX, normalY, normalZ;
   Standard_Integer nbNodes =0, nbTriangles=0;
   Standard_Boolean hasUV= Standard_False;
   Standard_Boolean hasNormals= Standard_False;
@@ -1583,53 +1582,231 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
     }
     GeomTools::GetReal(IS, d);
 
-    TColgp_Array1OfPnt Nodes(1, nbNodes);
-    TColgp_Array1OfPnt2d UVNodes(1, nbNodes);
-    Handle(TShort_HArray1OfShortReal) Normals;
-    if (hasNormals)
-    {
-      Normals = new TShort_HArray1OfShortReal(1, nbNodes * 3);
-    }
+    T = new Poly_Triangulation (nbNodes, nbTriangles, hasUV, hasNormals);
+
     for (j = 1; j <= nbNodes; j++) {
       GeomTools::GetReal(IS, x);
       GeomTools::GetReal(IS, y);
       GeomTools::GetReal(IS, z);
-      Nodes(j).SetCoord(x,y,z);
+      T->ChangeNode (j).SetCoord (x,y,z);
     }
 
     if (hasUV) {
       for (j = 1; j <= nbNodes; j++) {
         GeomTools::GetReal(IS, x);
         GeomTools::GetReal(IS, y);
-        UVNodes(j).SetCoord(x,y);
+        T->ChangeUVNode (j).SetCoord (x,y);
       }
     }
       
     // read the triangles
     Standard_Integer n1,n2,n3;
-    Poly_Array1OfTriangle Triangles(1, nbTriangles);
     for (j = 1; j <= nbTriangles; j++) {
       IS >> n1 >> n2 >> n3;
-      Triangles(j).Set(n1,n2,n3);
+      T->ChangeTriangle (j).Set (n1,n2,n3);
     }
 
     if (hasNormals)
     {
-      for (j = 1; j <= nbNodes * 3; j++)
+      for (j = 1; j <= nbNodes; j++)
       {
-        GeomTools::GetReal(IS, normal);
-        Normals->SetValue(j, static_cast<Standard_ShortReal>(normal));
+        GeomTools::GetReal (IS, normalX);
+        GeomTools::GetReal (IS, normalY);
+        GeomTools::GetReal (IS, normalZ);
+        T->SetNormal (j, static_cast<Standard_ShortReal>(normalX),
+                         static_cast<Standard_ShortReal>(normalY),
+                         static_cast<Standard_ShortReal>(normalZ));
       }
     }
-
-    if (hasUV) T =  new Poly_Triangulation(Nodes,UVNodes,Triangles);
-    else T = new Poly_Triangulation(Nodes,Triangles);
       
     T->Deflection(d);
-    if (hasNormals)
+    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 nbTriangles = aMesh->NbTriangles();
+    const Standard_Integer nbQuads = aMesh->NbQuads();
+    const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
+
+    if (theCompact)
     {
-      T->SetNormals(Normals);
+      theOS << nbNodes << " " << nbTriangles << " " << nbQuads << " ";
+      theOS << (hasUVNodes ? "1" : "0") << " ";
     }
-    myTriangulations.Add(T, hasNormals);
+    else
+    {
+      theOS << "  "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbTriangles << " Triangles, " << nbQuads << " 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
+    if (!theCompact) theOS << "\nTriangles :\n";
+    Standard_Integer n1, n2, n3;
+    for (j = 1; j <= nbTriangles; j++)
+    {
+      if (!theCompact) theOS << std::setw (10) << j << " : ";
+      aMesh->Triangle (j).Get (n1, n2, n3);
+      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 (!theCompact) theOS << "\n";
+      else theOS << " ";
+    }
+
+    // write quadrangles
+    if (!theCompact) theOS << "\nQuadrangles :\n";
+    Standard_Integer n4;
+    for (j = 1; j <= nbQuads; j++)
+    {
+        if (!theCompact) theOS << std::setw(10) << j << " : ";
+        aMesh->Quad (j).Get (n1, n2, n3, n4);
+        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 (!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 n1 (0), n2 (0), n3 (0), n4 (0);
+  Standard_Real deflection, x, y, z;
+  Standard_Integer nbMeshes (0), nbNodes (0), nbTriangles (0), nbQuads (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 >> nbTriangles >> nbQuads >> hasUV;
+    GeomTools::GetReal (theIS, deflection);
+
+    // Allocate the mesh.
+    Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, 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->ChangeNode (j) = 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.
+    for (j = 1; j <= nbTriangles; j++)
+    {
+        // Read the indices.
+        theIS >> n1 >> n2 >> n3;
+
+        // Set the triangle to the mesh.
+        aMesh->ChangeTriangle (j) = Poly_Triangle (n1, n2, n3);
+    }
+
+    // Reads the quadrangles.
+    for (j = 1; j <= nbQuads; j++)
+    {
+        // Read the indices.
+        theIS >> n1 >> n2 >> n3 >> n4;
+
+        // Set the quadrangle to the mesh.
+        aMesh->ChangeQuad (j) = Poly_Quad (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..b988036
--- /dev/null
@@ -0,0 +1,183 @@
+// 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 n1, n2, n3, n4;
+  Standard_Integer nbNodes (0), nbTriangles (0), nbQuads (0);
+  Standard_Boolean hasUV (Standard_False);
+  gp_Pnt p;
+
+  theSource >> nbNodes;
+  theSource >> nbTriangles;
+  theSource >> nbQuads;
+  theSource >> hasUV;
+  theSource >> deflection;
+
+  // allocate the mesh
+  Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, 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->ChangeNode (i) = p;
+  }
+      
+  // read 2d nodes
+  if (hasUV)
+  {
+    for (i = 1; i <= nbNodes; i++)
+    {
+      theSource >> x;
+      theSource >> y;
+      aMesh->ChangeUVNode (i).SetCoord (x,y);
+    }
+  }
+
+  // read triangles
+  for (i = 1; i <= nbTriangles; i++)
+  {
+      theSource >> n1;
+      theSource >> n2;
+      theSource >> n3;
+      aMesh->ChangeTriangle (i).Set (n1, n2, n3);
+  }
+
+  // read quadrangles
+  for (i = 1; i <= nbQuads; i++)
+  {
+      theSource >> n1;
+      theSource >> n2;
+      theSource >> n3;
+      theSource >> n4;
+      aMesh->ChangeQuad (i).Set (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 nbTriangles = aMesh->NbTriangles();
+    Standard_Integer nbQuads = aMesh->NbQuads();
+
+    // write number of elements
+    theTarget << nbNodes;
+    theTarget << nbTriangles;
+    theTarget << nbQuads;
+    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
+    Standard_Integer n1, n2, n3;
+    for (i = 1; i <= nbTriangles; i++)
+    {
+      aMesh->Triangle (i).Get (n1, n2, n3);
+      theTarget << n1;
+      theTarget << n2;
+      theTarget << n3;
+    }
+
+    // write quadrangles
+    Standard_Integer n4;
+    for (i = 1; i <= nbQuads; i++)
+    {
+      aMesh->Quad (i).Get (n1, n2, n3, n4);
+      theTarget << n1;
+      theTarget << n2;
+      theTarget << n3;
+      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..3b455eb89e5e372dbe928cd8f4c2ebb004dbad96 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 Vec3f& aNormal = aTriangulation->Normal (aNormalIter);
+            BinTools::PutShortReal (OS, aNormal.x());
+            BinTools::PutShortReal (OS, aNormal.y());
+            BinTools::PutShortReal (OS, aNormal.z());
           }
         }
       }
@@ -1589,45 +1588,39 @@ 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);
+          aTriangulation->SetNormal (aNormalIter, aNormalX, aNormalY, aNormalZ);
         }
       }
 
index a68f49f7e4a8307b3e95ce716ea1b55a92419692..6a69553bc4cbad9dd958cec9fbbd4fe8b5ac2a70 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());
@@ -1152,7 +1148,9 @@ Standard_Boolean DBRep_DrawableShape::addMeshNormals (NCollection_Vector<std::pa
     gp_Vec aNormal;
     if (hasNormals)
     {
-      aNormal = aTriangulation->Normal (aNodeIter);
+      gp_XYZ anXYZ;
+      aTriangulation->Normal (aNodeIter, anXYZ);
+      aNormal.SetXYZ (anXYZ);
     }
     else
     {
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..d4dd8633652252667b0330abbb676910d73c6e56 100755 (executable)
@@ -17,12 +17,15 @@ 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
 Poly_Polygon3D.hxx
 Poly_PolygonOnTriangulation.cxx
 Poly_PolygonOnTriangulation.hxx
+Poly_Quad.hxx
 Poly_Triangle.hxx
 Poly_Triangulation.cxx
 Poly_Triangulation.hxx
index 179a657446fa0811d01e660e9fb878c45bb8c6f8..c163683aeeb1cb499e71acb5a0c83ca201a309de 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();
@@ -489,28 +480,21 @@ void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
   }
 
   // Normalize all vectors
+  gp_Dir aNormal;
   gp_XYZ aNormXYZ;
   for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
   {
     const Standard_Size anIndex = aNodeIter * 3;
     aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
     const Standard_Real aMod2 = aNormXYZ.SquareModulus();
-    if (aMod2 < anEps2)
-    {
-      aNormArr[anIndex + 0] = 0.0f;
-      aNormArr[anIndex + 1] = 0.0f;
-      aNormArr[anIndex + 2] = 1.0f;
-    }
+    if (aMod2 > anEps2)
+      aNormal = aNormXYZ;
     else
-    {
-      aNormXYZ /= Sqrt (aMod2);
-      aNormArr[anIndex + 0] = Standard_ShortReal(aNormXYZ.X());
-      aNormArr[anIndex + 1] = Standard_ShortReal(aNormXYZ.Y());
-      aNormArr[anIndex + 2] = Standard_ShortReal(aNormXYZ.Z());
-    }
-  }
+      aNormal = gp::DZ();
 
-  theTri->SetNormals (aNormals);
+    // Set normal.
+    theTri->SetNormal (aNodeIter + 1, aNormXYZ);
+  }
 }
 
 //=======================================================================
index 772ee8183ece144566534c6774776ff7dc8f4030..82cf42f4b466882b7b08f28ac5f009434510811a 100644 (file)
@@ -51,45 +51,39 @@ 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()));
-        myNodes(i).SetNormal(aNormal);
+        const Vec3f& anXYZ = theTriangulation->Normal (i + 1);
+        gp_XYZ aNormal (anXYZ.x(), anXYZ.y(), anXYZ.z());
+        myNodes (i).SetNormal (aNormal);
       }
     }
     myDeflection = theTriangulation->Deflection();
@@ -121,17 +115,10 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
   const Standard_Integer nTriangles = NTriangles();
   if (nNodes > 0 && nTriangles > 0) {
     aResult = new Poly_Triangulation(nNodes, nTriangles, Standard_True);
-    const Handle(TShort_HArray1OfShortReal) harrNormal =
-      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);
-    Standard_Boolean hasNormals (Standard_False);
 
     // Copy the nodes (3D and 2D coordinates)
     for (i = 0; i < myNodes.Length(); i++) {
@@ -140,19 +127,19 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
         vecNodeId.SetValue(i, 0);
       else {
         const gp_XYZ aNormal = aNode.GetNormal();
-        arrNormal[3 * aCount + 0] = static_cast<Standard_ShortReal>(aNormal.X());
-        arrNormal[3 * aCount + 1] = static_cast<Standard_ShortReal>(aNormal.Y());
-        arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
+        if (aNormal.SquareModulus() > Precision::Confusion()) {
+          aResult->SetNormal (aCount, static_cast<Standard_ShortReal>(aNormal.X()),
+                                      static_cast<Standard_ShortReal>(aNormal.Y()),
+                                      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;
-        if (aNormal.SquareModulus() >  Precision::Confusion())
-          hasNormals = Standard_True;
       }
     }
     if (hasUV == Standard_False)
@@ -164,14 +151,11 @@ 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)
-      aResult->SetNormals (harrNormal);
 
     aResult->Deflection(myDeflection);
   }
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];
diff --git a/src/Poly/Poly_Mesh.cxx b/src/Poly/Poly_Mesh.cxx
new file mode 100644 (file)
index 0000000..3a23808
--- /dev/null
@@ -0,0 +1,66 @@
+// 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 <Poly_Mesh.hxx>
+#include <Standard_DefineHandle.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose  :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh () : Poly_Triangulation (0, 0, Standard_False)
+{
+}
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose  :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh (const Standard_Integer theNbNodes,
+                      const Standard_Integer theNbTriangles,
+                      const Standard_Integer theNbQuads,
+                      const Standard_Boolean theHasUVNodes,
+                      const Standard_Boolean theHasNormals)
+: Poly_Triangulation (theNbNodes, theNbTriangles, theHasUVNodes, theHasNormals)
+{
+  if (theNbQuads > 0)
+    myQuads.Resize (1, theNbQuads, Standard_False);
+}
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose  :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
+: Poly_Triangulation ( theTriangulation )
+{
+  // No quadrangles.
+}
+
+//=======================================================================
+//function : Copy
+//purpose  :
+//=======================================================================
+
+Handle(Poly_Triangulation) Poly_Mesh::Copy() const
+{
+  Handle(Poly_Triangulation) aCopiedTriangulation = Poly_Triangulation::Copy();
+  Handle(Poly_Mesh) aCopiedMesh = new Poly_Mesh (aCopiedTriangulation);
+  aCopiedMesh->myQuads = myQuads;
+  return aCopiedMesh;
+}
diff --git a/src/Poly/Poly_Mesh.hxx b/src/Poly/Poly_Mesh.hxx
new file mode 100644 (file)
index 0000000..70db45f
--- /dev/null
@@ -0,0 +1,92 @@
+// 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 _Poly_Mesh_HeaderFile
+#define _Poly_Mesh_HeaderFile
+
+#include <Poly_Quad.hxx>
+#include <Poly_Triangulation.hxx>
+
+//! This class is extension for Poly_Triangulation.
+//! It allows to store mesh with quad polygons.
+class Poly_Mesh : public Poly_Triangulation
+{
+
+public:
+
+  //! Constructs an empty mesh.
+  Standard_EXPORT Poly_Mesh();
+
+  //! Constructs a mesh.
+  //! @param theNbNodes defines the number of nodes.
+  //! @param theNbTriangles defines the number of triangles.
+  //! @param theNbQuads defines the number of quadrangles.
+  //! @param theHasUVNodes indicates whether 2D nodes will be associated with
+  //!        3D ones, (i.e. to enable a 2D representation).
+  //! @param theHasNormals defines allocation of normals for the nodes.
+  Standard_EXPORT Poly_Mesh(const Standard_Integer theNbNodes,
+                            const Standard_Integer theNbTriangles,
+                            const Standard_Integer theNbQuads,
+                            const Standard_Boolean theHasUVNodes = Standard_False,
+                            const Standard_Boolean theHasNormals = Standard_False);
+
+  //! Constructs a mesh from existing triangulation.
+  //! @param theTriangulation source triangulation.
+  Standard_EXPORT Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation);
+
+  //! Creates full copy of current mesh
+  Standard_EXPORT virtual Handle(Poly_Triangulation) Copy() const Standard_OVERRIDE;
+
+  //! Sets a quadrangle to the mesh.
+  //! @param theIndex is an index of the quadrangle.
+  //! @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.
+  void SetQuad (const Standard_Integer theIndex,
+                const Standard_Integer theN1,
+                const Standard_Integer theN2,
+                const Standard_Integer theN3,
+                const Standard_Integer theN4)
+  {
+    myQuads.SetValue (theIndex, Poly_Quad (theN1, theN2, theN3, theN4));
+  }
+
+  //! @return the number of quadrangles in the mesh.
+  Standard_Integer NbQuads() const {
+    return myQuads.Size();
+  }
+
+  //! @return a quadrangle at the given index.
+  const Poly_Quad& Quad (const Standard_Integer theIndex) const {
+    return myQuads.Value (theIndex);
+  }
+
+  //! @return a reference to a quadrangle at the given index.
+  Poly_Quad& ChangeQuad (const Standard_Integer theIndex) {
+    return myQuads.ChangeValue (theIndex);
+  }
+
+protected:
+
+  NCollection_Array1<Poly_Quad> myQuads;
+
+public:
+
+  DEFINE_STANDARD_RTTIEXT(Poly_Mesh, Poly_Triangulation)
+
+};
+
+DEFINE_STANDARD_HANDLE(Poly_Mesh, Poly_Triangulation)
+
+#endif // _Poly_Mesh_HeaderFile
index 19a0052372c1beb00ff07a1b2d7a9c52b8298314..c087894555e249366dc366f19608cb2da8ee8020 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,58 @@ Handle(Poly_PolygonOnTriangulation) Poly_PolygonOnTriangulation::Copy() const
   return aCopy;
 }
 
+//=======================================================================
+//function : Node
+//purpose  : 
+//=======================================================================
+
+Standard_Integer Poly_PolygonOnTriangulation::Node (const Standard_Integer theIndex) const
+{
+  Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myNodes.Length()),
+                                "Poly_PolygonOnTriangulation::Node : index out of range");
+  return myNodes.Value (theIndex);
+}
+
+//=======================================================================
+//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..8b2c1d2384173859f2fcb35431d864de1ff219e0 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.
diff --git a/src/Poly/Poly_Quad.hxx b/src/Poly/Poly_Quad.hxx
new file mode 100644 (file)
index 0000000..644fcfd
--- /dev/null
@@ -0,0 +1,73 @@
+// 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 _Poly_Quad_HeaderFile
+#define _Poly_Quad_HeaderFile
+
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Integer.hxx>
+#include <Poly_Triangle.hxx>
+
+//! Describes a quadric element of a mesh.
+class Poly_Quad : public Poly_Triangle
+{
+
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  //! Constructs an empty Quad object.
+  Poly_Quad():myNode4 (0) {
+    myNodes[0] = myNodes[1] = myNodes[2] = 0;
+  }
+
+  //! Constructs a quadric element.
+  Poly_Quad (const Standard_Integer theNode1,
+             const Standard_Integer theNode2,
+             const Standard_Integer theNode3,
+             const Standard_Integer theNode4)
+  {
+    Set (theNode1, theNode2, theNode3, theNode4);
+  }
+
+  //! Sets indices of nodes.
+  void Set (const Standard_Integer theNode1,
+            const Standard_Integer theNode2,
+            const Standard_Integer theNode3,
+            const Standard_Integer theNode4)
+  {
+    myNodes[0] = theNode1;
+    myNodes[1] = theNode2;
+    myNodes[2] = theNode3;
+    myNode4 = theNode4;
+  }
+
+  //! Returns indices of nodes of the quadric element.
+  void Get (Standard_Integer& theNode1,
+            Standard_Integer& theNode2,
+            Standard_Integer& theNode3,
+            Standard_Integer& theNode4) const
+  {
+    theNode1 = myNodes[0];
+    theNode2 = myNodes[1];
+    theNode3 = myNodes[2];
+    theNode4 = myNode4;
+  }
+
+protected:
+
+  Standard_Integer myNode4;
+
+};
+
+#endif // _Poly_Quad_HeaderFile
index b00ff5f0a5dc9d272bcf83817df5ec2a3b72dd8b..76e6592eca148f6a66e8047040e6e3f37e4e76d4 100644 (file)
@@ -89,7 +89,7 @@ public:
 
   Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
 
-private:
+protected:
 
   Standard_Integer myNodes[3];
 
index ae7ed0df2e73ad7ddfb9c703fad3d319ced2a3da..1083227339f7cf0b6d4b31d741fb127d50d2b31c 100644 (file)
@@ -18,9 +18,7 @@
 
 #include <gp_Pnt.hxx>
 #include <Poly_Triangle.hxx>
-#include <Standard_DomainError.hxx>
 #include <Standard_Dump.hxx>
-#include <Standard_NullObject.hxx>
 #include <Standard_Type.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
@@ -31,7 +29,8 @@ IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
 //=======================================================================
 Poly_Triangulation::Poly_Triangulation()
 : myCachedMinMax (NULL),
-  myDeflection   (0)
+  myDeflection   (0),
+  myHasUVNodes   (Standard_False)
 {
 }
 
@@ -39,36 +38,40 @@ Poly_Triangulation::Poly_Triangulation()
 //function : Poly_Triangulation
 //purpose  : 
 //=======================================================================
-Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
-                                       const Standard_Integer theNbTriangles,
-                                       const Standard_Boolean theHasUVNodes)
+Poly_Triangulation::Poly_Triangulation (const Standard_Integer theNbNodes,
+                                        const Standard_Integer theNbTriangles,
+                                        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.Resize (1, theNbNodes, Standard_False);
+    if (myHasUVNodes)
+    {
+      myUVNodes.Resize (1, theNbNodes, Standard_False);
+    }
+  }
+  if (theNbTriangles > 0)
+  {
+    myTriangles.Resize (1, theNbTriangles, Standard_False);
+  }
 }
 
 //=======================================================================
 //function : Poly_Triangulation
 //purpose  :
 //=======================================================================
-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::Poly_Triangulation (const Standard_Integer theNbNodes,
+                                        const Standard_Integer theNbTriangles,
+                                        const Standard_Boolean theHasUVNodes,
+                                        const Standard_Boolean theHasNormals)
+: Poly_Triangulation(theNbNodes, theNbTriangles, theHasUVNodes)
 {
-  if (theHasUVNodes)
-  {
-    myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
-  }
   if (theHasNormals)
   {
-    myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
+    myNormals.Resize (1, theNbNodes, Standard_False);
   }
 }
 
@@ -76,14 +79,16 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
 //function : Poly_Triangulation
 //purpose  :
 //=======================================================================
-Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt&    theNodes,
-                                       const Poly_Array1OfTriangle& theTriangles)
+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.Resize (1, theNodes.Length(), Standard_False);
   myNodes = theNodes;
+
+  myTriangles.Resize (1, theTriangles.Length(), Standard_False);
   myTriangles = theTriangles;
 }
 
@@ -92,18 +97,23 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt&    theNodes,
 //purpose  : 
 //=======================================================================
 
-Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt&    theNodes,
-                                       const TColgp_Array1OfPnt2d&  theUVNodes,
-                                       const Poly_Array1OfTriangle& theTriangles)
+Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt&    theNodes,
+                                        const TColgp_Array1OfPnt2d&  theUVNodes,
+                                        const Poly_Array1OfTriangle& theTriangles)
 : myCachedMinMax (NULL),
   myDeflection   (0),
-  myNodes        (1, theNodes.Length()),
-  myTriangles    (1, theTriangles.Length())
+  myHasUVNodes   (theNodes.Length() == theUVNodes.Length())
 {
+  myNodes.Resize (1, theNodes.Length(), Standard_False);
   myNodes = theNodes;
+  
+  myTriangles.Resize (1, theTriangles.Length(), Standard_False);
   myTriangles = theTriangles;
-  myUVNodes = new TColgp_HArray1OfPnt2d (1, theNodes.Length());
-  myUVNodes->ChangeArray1() = theUVNodes;
+  
+  if (myHasUVNodes) {
+    myUVNodes.Resize (1, theNodes.Length(), Standard_False);
+    myUVNodes = theUVNodes;
+  }
 }
 
 //=======================================================================
@@ -122,7 +132,20 @@ 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->myDeflection = myDeflection;
+
+  if (HasUVNodes())
+    aCopy->myUVNodes = myUVNodes;
+
+  if (HasNormals()) {
+    aCopy->myNormals.Resize (1, myNodes.Size(), Standard_False);
+    aCopy->myNormals = myNormals;
+  }
+
+  return aCopy;
 }
 
 //=======================================================================
@@ -132,29 +155,26 @@ 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())
-  {
-    myNormals = new TShort_HArray1OfShortReal(theTriangulation->myNormals->Array1());
-  }
-}
 
-//=======================================================================
-//function : Deflection
-//purpose  : 
-//=======================================================================
+  // Re-allocate the arrays.
+  myNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
+  if (myHasUVNodes)
+    myUVNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
+  myTriangles.Resize (1, theTriangulation->NbTriangles(), Standard_False);
+  if (theTriangulation->HasNormals())
+    myNormals.Resize (1, theTriangulation->NbNodes(), Standard_False);
 
-void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
-{
-  myDeflection = theDeflection;
+  // Copy data.
+  myNodes = theTriangulation->myNodes;
+  if (myHasUVNodes)
+    myUVNodes = theTriangulation->myUVNodes;
+  myTriangles = theTriangulation->myTriangles;
+  if (theTriangulation->HasNormals())
+    myNormals = theTriangulation->myNormals;
 }
 
 //=======================================================================
@@ -164,91 +184,8 @@ void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
 
 void Poly_Triangulation::RemoveUVNodes()
 {
-  myUVNodes.Nullify();
-}
-
-//=======================================================================
-//function : Node
-//purpose  : 
-//=======================================================================
-
-const gp_Pnt& Poly_Triangulation::Node (const Standard_Integer theIndex) const
-{
-  if (theIndex < 1 || theIndex > myNodes.Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::Node : index out of range");
-  }
-  return myNodes.Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeNode
-//purpose  : 
-//=======================================================================
-
-gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
-{
-  if (theIndex < 1 || theIndex > myNodes.Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::ChangeNode : index out of range");
-  }
-  return myNodes.ChangeValue (theIndex);
-}
-
-//=======================================================================
-//function : UVNode
-//purpose  : 
-//=======================================================================
-
-const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
-{
-  if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
-  }
-  return myUVNodes->Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeUVNode
-//purpose  : 
-//=======================================================================
-
-gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
-{
-  if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
-  }
-  return myUVNodes->ChangeValue (theIndex);
-}
-
-//=======================================================================
-//function : Triangle
-//purpose  : 
-//=======================================================================
-
-const Poly_Triangle& Poly_Triangulation::Triangle (const Standard_Integer theIndex) const
-{
-  if (theIndex < 1 || theIndex > myTriangles.Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::Triangle : index out of range");
-  }
-  return myTriangles.Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeTriangle
-//purpose  : 
-//=======================================================================
-
-Poly_Triangle& Poly_Triangulation::ChangeTriangle (const Standard_Integer theIndex)
-{
-  if (theIndex < 1 || theIndex > myTriangles.Size())
-  {
-    throw Standard_OutOfRange ("Poly_Triangulation::ChangeTriangle : index out of range");
-  }
-  return myTriangles.ChangeValue (theIndex);
+  myUVNodes = TColgp_Array1OfPnt2d();
+  myHasUVNodes = Standard_False;
 }
 
 //=======================================================================
@@ -263,94 +200,48 @@ 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");
-  }
-
-  return myNormals->Array1();
-}
-
-//=======================================================================
-//function : ChangeNormals
-//purpose  : 
-//=======================================================================
-
-TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
-{
-
-  if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
-    throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
-                              "wrong length or null array");
-  }
-
-  return myNormals->ChangeArray1();
-}
-
-//=======================================================================
-//function : HasNormals
-//purpose  : 
-//=======================================================================
-
-Standard_Boolean Poly_Triangulation::HasNormals() const
-{
-  if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
-    return Standard_False;
+  Standard_Integer anArrayLower = theNormals->Lower();
+  for (Standard_Integer anIndex = 1; anIndex >= NbNodes(); anIndex--)
+  {
+    Standard_Integer anArrayInd = anArrayLower + (anIndex - 1) * 3;
+    SetNormal (anIndex, theNormals->Value(anArrayInd),
+                        theNormals->Value(anArrayInd + 1),
+                        theNormals->Value(anArrayInd + 2));
   }
-  return Standard_True;
 }
 
-//=======================================================================
-//function : SetNormal
-//purpose  : 
-//=======================================================================
+// =======================================================================
+// function : ResizeNodes
+// purpose  :
+// =======================================================================
 
-void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
+void Poly_Triangulation::ResizeNodes (const Standard_Integer theNbNodes)
 {
-  if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
-  {
-    throw Standard_NullObject ("Poly_Triangulation::SetNormal : empty array or index out of range");
+  if (theNbNodes > 0) {
+    myNodes.Resize (1, theNbNodes, Standard_True);
+    if (myHasUVNodes)
+      myUVNodes.Resize (1, theNbNodes, Standard_True);
+    if (HasNormals())
+      myNormals.Resize (1, theNbNodes, Standard_True);
   }
-
-  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  : 
-//=======================================================================
+// =======================================================================
+// function : ResizeTriangles
+// purpose  :
+// =======================================================================
 
-gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
+void Poly_Triangulation::ResizeTriangles (const Standard_Integer theNbTriangles)
 {
-  if (myNormals.IsNull() || 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;
+  if (theNbTriangles > 0)
+    myTriangles.Resize (1, theNbTriangles, Standard_True);
 }
 
 // =======================================================================
 // function : DumpJson
 // purpose  :
 // =======================================================================
+
 void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
 {
   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
@@ -358,10 +249,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..7b0c8eb2d2c143c25488f25b193bf3e43ecbaac5 100644 (file)
 #include <Bnd_Box.hxx>
 #include <Standard.hxx>
 #include <Standard_DefineHandle.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Integer.hxx>
 #include <TColgp_Array1OfPnt.hxx>
 #include <TColgp_HArray1OfPnt2d.hxx>
 #include <Poly_Array1OfTriangle.hxx>
 #include <TShort_HArray1OfShortReal.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TShort_Array1OfShortReal.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
+
+typedef NCollection_Vec3 <Standard_ShortReal> Vec3f;
+
+//! 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
 {
 
@@ -78,7 +56,7 @@ public:
   //! triangles. Here the UVNodes flag indicates whether
   //! 2D nodes will be associated with 3D ones, (i.e. to
   //! enable a 2D representation).
-  Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean UVNodes);
+  Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean hasUVNodes);
 
   //! Constructs a triangulation from a set of triangles.
   //! The triangulation is initialized without a triangle or a node,
@@ -88,7 +66,7 @@ public:
   //! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
   Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
                                      const Standard_Integer nbTriangles,
-                                     const Standard_Boolean UVNodes,
+                                     const Standard_Boolean hasUVNodes,
                                      const Standard_Boolean hasNormals);
 
   //! Constructs a triangulation from a set of triangles. The
@@ -115,107 +93,154 @@ public:
   Standard_EXPORT Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation);
 
   //! Returns the deflection of this triangulation.
-  Standard_Real Deflection() const { return myDeflection; }
+  Standard_Real Deflection() const { 
+    return myDeflection;
+  }
 
   //! Sets the deflection of this triangulation to theDeflection.
   //! See more on deflection in Polygon2D
-  Standard_EXPORT void Deflection (const Standard_Real theDeflection);
+  void Deflection (const Standard_Real theDeflection) {
+    myDeflection = theDeflection;
+  }
 
   //! Deallocates the UV nodes.
   Standard_EXPORT void RemoveUVNodes();
 
   //! Returns TRUE if triangulation has some geometry.
-  virtual Standard_Boolean HasGeometry() const { return !myNodes.IsEmpty() && !myTriangles.IsEmpty(); }
+  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(); }
+  Standard_Integer NbNodes() const {
+    return myNodes.Size();
+  }
 
   //! Returns the number of triangles for this triangulation.
-  Standard_Integer NbTriangles() const { return myTriangles.Length(); }
+  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(); }
+  //! Sets a node coordinates.
+  void SetNode (const Standard_Integer theIndex,
+                const gp_Pnt&          thePnt)
+  {
+    myNodes.SetValue (theIndex, thePnt);
+  }
 
-  //! Returns the table of 3D nodes (3D points) for this triangulation.
-  const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
+  //! Returns a node at the given index.
+  const gp_Pnt& Node (const Standard_Integer theIndex) const {
+    return myNodes.Value (theIndex);
+  }
+
+  //! Give access to the node at the given index.
+  gp_Pnt& ChangeNode (const Standard_Integer theIndex) {
+    return myNodes.ChangeValue (theIndex);
+  }
 
-  //! 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 Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+  Standard_Boolean HasUVNodes() const {
+    return myHasUVNodes;
+  }
 
-  //! Returns 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;
+  //! Sets an UV-node coordinates.
+  void SetUVNode (const Standard_Integer theIndex,
+                  const gp_Pnt2d&        thePnt)
+  {
+    myUVNodes.SetValue (theIndex, thePnt);
+  }
 
-  //! Give access to the node at the given index.
-  //! 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.
-  //! 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;
+  //! Returns UV-node at the given index.
+  const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const {
+    return myUVNodes.Value (theIndex);
+  }
 
   //! Give access to the UVNode at the given index.
-  //! 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; }
+  gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex) {
+    return myUVNodes.ChangeValue (theIndex);
+  }
 
-  //! 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; }
+  //! Sets a triangle.
+  void SetTriangle (const Standard_Integer theIndex,
+                    const Poly_Triangle&   theTriangle)
+  {
+    myTriangles.SetValue (theIndex, theTriangle);
+  }
 
   //! Returns 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;
+  const Poly_Triangle& Triangle (const Standard_Integer theIndex) const {
+    return myTriangles.Value (theIndex);
+  }
 
   //! Give access to the triangle at the given index.
-  //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
-  Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
-
-  //! Sets the table of node normals.
-  //! raises exception if length of theNormals != 3*NbNodes
-  Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
+  //! Raises an exception if theIndex is less than 1 or greater than number of triangles.
+  Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex) {
+    return myTriangles.ChangeValue (theIndex);
+  }
 
-  //! Returns the table of node normals.
-  Standard_EXPORT const TShort_Array1OfShortReal& Normals() const;
+  //! Returns Standard_True if nodal normals are defined.
+  Standard_Boolean HasNormals() const {
+    return !myNormals.IsEmpty() && myNormals.Length() == NbNodes();
+  }
 
-  //! Gives access to the table of node normals.
-  Standard_EXPORT TShort_Array1OfShortReal& ChangeNormals();
+  //! Changes normal at the given index.
+  void SetNormal (const Standard_Integer theIndex,
+                  const Vec3f&           theNormal)
+  {
+    // If an array for normals is not allocated yet, do it now.
+    if (myNormals.IsEmpty())
+      myNormals.Resize (1, myNodes.Size(), Standard_False);
 
-  //! Returns Standard_True if nodal normals are defined.
-  Standard_EXPORT Standard_Boolean HasNormals() const;
+    // Set a normal.
+    myNormals.ChangeValue (theIndex) = theNormal;
+  }
 
-  //! @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.
+  void SetNormal (const Standard_Integer theIndex,
+                  const gp_XYZ&          theNormal)
+  {
+    SetNormal (theIndex, static_cast<Standard_ShortReal>(theNormal.X()),
+                         static_cast<Standard_ShortReal>(theNormal.Y()),
+                         static_cast<Standard_ShortReal>(theNormal.Z()));
+  }
 
   //! Changes normal at the given index.
-  //! Raises Standard_OutOfRange exception.
-  Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
-                                  const gp_Dir&          theNormal);
+  void SetNormal (const Standard_Integer theIndex,
+                  const Standard_ShortReal theNormalX,
+                  const Standard_ShortReal theNormalY,
+                  const Standard_ShortReal theNormalZ)
+  {
+    SetNormal (theIndex, Vec3f (theNormalX, theNormalY, theNormalZ));
+  }
+
+  //! Returns normal at the given index.
+  const Vec3f& Normal (const Standard_Integer theIndex) const {
+    return myNormals (theIndex);
+  }
+
+  //! Returns normal at the given index.
+  void Normal (const Standard_Integer theIndex,
+               gp_XYZ&                theNormal) const
+  {
+    const Vec3f& aCoords = Normal (theIndex);
+    theNormal.SetCoord (aCoords.x(), aCoords.y(), aCoords.z());
+  }
+
+  //! Sets the table of node normals.
+  //! 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);
+
+  //! An advanced method resizing an internal array of nodes.
+  //! The old nodes are copied into the new array.
+  //! UV-nodes as well as normals, if exist are extended and copied too.
+  Standard_EXPORT void ResizeNodes (const Standard_Integer theNbNodes);
+
+  //! An advanced method resizing an internal array of triangles.
+  //! The old triangles are copied into the new array.
+  Standard_EXPORT void ResizeTriangles (const Standard_Integer theNbTriangles);
 
   //! Returns cached min - max range of triangulation data,
   //! which is VOID by default (e.g, no cached information).
@@ -264,13 +289,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;
+  TColgp_Array1OfPnt        myNodes;
+  TColgp_Array1OfPnt2d      myUVNodes;
+  Poly_Array1OfTriangle     myTriangles;
+  NCollection_Array1<Vec3f> myNormals;
 };
 
 #endif // _Poly_Triangulation_HeaderFile
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..c84f78af764ddbe4e50628cfa5d94dfe62e7b4ed 100644 (file)
@@ -4030,25 +4030,16 @@ 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 );
+      const Vec3f& aVec = aT->Normal ( i+1 );
+      gp_Dir aNormal (aVec.x(), aVec.y(), aVec.z());
 
       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..92cec103f6a0114d724021fd4d4c9ee63ce6fba8 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
@@ -350,11 +333,11 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
           if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
           {
             myCoordSysConverter.TransformNormal (*aVec3);
-            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (aVec3->x(), aVec3->y(), aVec3->z()));
+            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_XYZ (aVec3->x(), aVec3->y(), aVec3->z()));
           }
           else
           {
-            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
+            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
           }
         }
       }
@@ -370,11 +353,11 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
           }
           if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
           {
-            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (aVec3->x(), aVec3->y(), aVec3->z()));
+            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_XYZ (aVec3->x(), aVec3->y(), aVec3->z()));
           }
           else
           {
-            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
+            setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
           }
         }
       }
index 37bf9bc8efc943702876c9e4101718fb7dc1c56f..b36b06a2c87c603a2ff06587a721f1c57f7120a6 100644 (file)
@@ -52,12 +52,8 @@ protected: //! @name interface for filling triangulation data
   //! Resize array of position nodes to specified size.
   virtual bool setNbPositionNodes (Standard_Integer theNbNodes)
   {
-    if (theNbNodes <= 0)
-    {
-      return false;
-    }
-    myTriangulation->ChangeNodes().Resize (1, theNbNodes, false);
-    return true;
+    myTriangulation->ResizeNodes (theNbNodes);
+    return theNbNodes > 0;
   }
 
   //! Set node position.
@@ -70,14 +66,9 @@ protected: //! @name interface for filling triangulation data
   }
 
   //! Resize array of UV nodes to specified size.
-  virtual bool setNbUVNodes (Standard_Integer theNbNodes)
+  virtual bool setNbUVNodes (Standard_Integer /*theNbNodes*/)
   {
-    if (theNbNodes <= 0
-     || myTriangulation->NbNodes() != theNbNodes)
-    {
-      return false;
-    }
-    myTriangulation->ChangeUVNodes().Resize (1, theNbNodes, false);
+    // Resizing of the array of nodes extends an array of UV-nodes too.
     return true;
   }
 
@@ -91,14 +82,9 @@ protected: //! @name interface for filling triangulation data
   }
 
   //! Resize array of nodes normals to specified size.
-  virtual bool setNbNormalNodes (Standard_Integer theNbNodes)
+  virtual bool setNbNormalNodes (Standard_Integer /*theNbNodes*/)
   {
-    if (theNbNodes <= 0
-     || myTriangulation->NbNodes() != theNbNodes)
-    {
-      return false;
-    }
-    myTriangulation->SetNormals (new TShort_HArray1OfShortReal (1, theNbNodes * 3));
+    // Resizing of the array of nodes extends an array of normals too.
     return true;
   }
 
@@ -106,7 +92,7 @@ protected: //! @name interface for filling triangulation data
   //! @param theIndex  node index starting from 1
   //! @param theNormal node normal
   virtual void setNodeNormal (Standard_Integer theIndex,
-                              const gp_Dir& theNormal)
+                              const gp_XYZ& theNormal)
   {
     myTriangulation->SetNormal (theIndex, theNormal);
   }
@@ -114,12 +100,8 @@ protected: //! @name interface for filling triangulation data
   //! Resize array of triangles to specified size.
   virtual bool setNbTriangles (Standard_Integer theNbTris)
   {
-    if (theNbTris >= 1)
-    {
-      myTriangulation->ChangeTriangles().Resize (1, theNbTris, false);
-      return true;
-    }
-    return false;
+    myTriangulation->ResizeTriangles (theNbTris);
+    return theNbTris > 0;
   }
 
   //! Add triangle element.
@@ -129,9 +111,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..65a86becf9c1430d877d6c6fbdcb0b72421e9102 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,17 @@ 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());
-    }
-  }
+    const Vec3f& aVec = myPolyTriang->Normal (theNode);
+    aNormal.SetCoord (aVec.x(), aVec.y(), aVec.z());
+    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 +162,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 +185,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 1299643b2641fb77e8f679d3dd1a28a44397fdad..912dce87fea34cfee28327d754969e1c69f01398 100644 (file)
@@ -167,30 +167,19 @@ Handle(Poly_Triangulation) RWObj_TriangulationReader::GetTriangulation()
   }
   if (hasNormals)
   {
-    const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, myNodes.Length() * 3);
-    Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
-    Standard_Integer aNbInvalid = 0;
     for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
     {
       const Graphic3d_Vec3& aNorm = myNormals.Value (aNodeIter);
       const float aMod2 = aNorm.SquareModulus();
       if (aMod2 > 0.001f)
       {
-        aNormArr[aNodeIter * 3 + 0] = aNorm.x();
-        aNormArr[aNodeIter * 3 + 1] = aNorm.y();
-        aNormArr[aNodeIter * 3 + 2] = aNorm.z();
+        aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
       }
       else
       {
-        ++aNbInvalid;
-        aNormArr[aNodeIter * 3 + 0] = 0.0f;
-        aNormArr[aNodeIter * 3 + 1] = 0.0f;
-        aNormArr[aNodeIter * 3 + 2] = 1.0f;
+        aPoly->SetNormal (aNodeIter + 1, 0.0f, 0.0f, 1.0f);
       }
-    }
-    if (aNbInvalid != myNodes.Length())
-    {
-      aPoly->SetNormals (aNormals);
+      aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
     }
   }
 
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..6ae87b152e50e890145c15efa1a46e7fb86c2171 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
@@ -158,15 +157,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 +173,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)
@@ -190,13 +186,10 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
       const Standard_Real aModMax = eqPlan.Modulus();
       aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
     }
-
-    const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 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());
+    theTris->SetNormal (aNodeIter, static_cast<Standard_ShortReal>(aNorm.X()),
+                                   static_cast<Standard_ShortReal>(aNorm.Y()),
+                                   static_cast<Standard_ShortReal>(aNorm.Z()));
   }
-  theTris->SetNormals (aNormals);
 }
 
 //=======================================================================
@@ -213,21 +206,15 @@ 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;
+    const Vec3f& aNormal = aPolyTri->Normal (aNodeIter);
+    theNormals.ChangeValue (aNodeIter).SetCoord (aNormal.x(), aNormal.y(), aNormal.z());
   }
 
   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..6d8bb02c334fc5d85f37972e418bf737e0f522bd 100644 (file)
@@ -27,5 +27,7 @@ TDataXtd_Presentation.hxx
 TDataXtd_Presentation.cxx
 TDataXtd_Shape.cxx
 TDataXtd_Shape.hxx
+TDataXtd_SurfacicMesh.cxx
+TDataXtd_SurfacicMesh.hxx
 TDataXtd_Triangulation.cxx
 TDataXtd_Triangulation.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());
 }
 
 //=======================================================================
index 60d0249626fd8f1f40e8bb89f6241c6f0f0e8761..aad1cb9c85b2f9d7084a52fb0fb0cd616c98028e 100644 (file)
@@ -217,27 +217,16 @@ void TDataXtd_Triangulation::SetTriangle (const Standard_Integer theIndex, const
   myTriangulation->ChangeTriangle(theIndex) = theTriangle;
 }
 
-//=======================================================================
-//function : SetNormals
-//purpose  : Sets the table of node normals.
-//           Raises exception if length of theNormals = 3 * NbNodes
-//=======================================================================
-void TDataXtd_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals)
-{
-  Backup();
-  myTriangulation->SetNormals(theNormals);
-}
-
 //=======================================================================
 //function : SetNormal
 //purpose  : Changes normal at the given index.
 //           Raises Standard_OutOfRange exception.
 //=======================================================================
 void TDataXtd_Triangulation::SetNormal (const Standard_Integer theIndex,
-                               const gp_Dir&          theNormal)
+                                        const gp_Dir&          theNormal)
 {
   Backup();
-  myTriangulation->SetNormal(theIndex, theNormal);
+  myTriangulation->SetNormal (theIndex, theNormal.XYZ());
 }
 
 //=======================================================================
@@ -256,7 +245,9 @@ Standard_Boolean TDataXtd_Triangulation::HasNormals() const
 //=======================================================================
 const gp_Dir TDataXtd_Triangulation::Normal (const Standard_Integer theIndex) const
 {
-  return myTriangulation->Normal(theIndex);
+  const Vec3f& aVec = myTriangulation->Normal (theIndex);
+  gp_Dir aDir (aVec.x(), aVec.y(), aVec.z());
+  return aDir;
 }
 
 //=======================================================================
index b127dd8c4aea3940e2a25cf432a2754114883332..1c52fa465212bc275eb05c54c2c5dcb6aec76ed4 100644 (file)
@@ -123,10 +123,6 @@ public:
   //! 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);
 
-  //! Sets the table of node normals.
-  //! Raises exception if length of theNormals != 3 * NbNodes
-  Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
-
   //! Changes normal at the given index.
   //! Raises Standard_OutOfRange exception.
   Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
index 48b34dab211935e0abd9a40f8eee18599815fcb5..67ca7cf77cad0598c10ba120c9883768884d9518 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,29 +2889,27 @@ 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++;
       }
     }
 
   Poly_Connect* pc = new Poly_Connect(polyTriangulation);
 
-  Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
-
   Standard_Integer index[3];
   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,16 +2922,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());
+
+      polyTriangulation->SetNormal (i, Nor.XYZ());
   }
 
   delete pc;
-  polyTriangulation->SetNormals(Normals);
-
   return polyTriangulation;
 }
 
@@ -2979,8 +2970,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 +6401,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..9af2efd55a08227347e14eabfeb363fc29f24b55 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();
@@ -231,17 +229,12 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
   }
   else {
     // Copy the normals. Currently only normals-per-vertex are supported.
-    Handle(TShort_HArray1OfShortReal) Normals =
-      new TShort_HArray1OfShortReal(1, 3 * nbNodes);
     if (myNormalPerVertex) {
       if (myArrNormalInd == 0L) {
         for (i = 0; i < nbNodes; i++)
         {
-          Standard_Integer anIdx = i * 3 + 1;
-          const gp_XYZ& aNormal = myNormals->Normal(i);
-          Normals->SetValue(anIdx + 0, Standard_ShortReal(aNormal.X()));
-          Normals->SetValue(anIdx + 1, Standard_ShortReal(aNormal.Y()));
-          Normals->SetValue(anIdx + 2, Standard_ShortReal(aNormal.Z()));
+          const gp_XYZ& aNormal = myNormals->Normal (i);
+          aTriangulation->SetNormal (i + 1, aNormal);
         }
       }
       else
@@ -256,10 +249,7 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
             int nbn = IndiceNormals(i, arrIndice);
             for (Standard_Integer j = 0; j < nbn; j++) {
               const gp_XYZ& aNormal = myNormals->Normal(arrIndice[j]);
-              Standard_Integer anInd = mapIdId(anArrNodes[j]) * 3 + 1;
-              Normals->SetValue(anInd + 0, Standard_ShortReal(aNormal.X()));
-              Normals->SetValue(anInd + 1, Standard_ShortReal(aNormal.Y()));
-              Normals->SetValue(anInd + 2, Standard_ShortReal(aNormal.Z()));
+              aTriangulation->SetNormal (mapIdId (anArrNodes[j]) + 1, aNormal);
             }
           }
         }
@@ -268,7 +258,6 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
     else {
       //TODO ..
     }
-    aTriangulation->SetNormals(Normals);
   }
 
   myIsModified = Standard_False;
index ae627986e608fdf071f67a2d9e32c0cdacf91bca..63091ccdce60f2b10b87a5748225f28b81dfa02d 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,11 @@ 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));
+      const Vec3f& aVec = theTri->Normal (i + 1);
+      gp_XYZ aNormal (aVec.x(), aVec.y(), aVec.z());
       if (isReverse)
       {
         aNormal.Reverse();
@@ -429,14 +427,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 +444,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();
@@ -470,16 +467,10 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
           aNormal.SetY(0.);
         if (aNormal.Z()*aNormal.Z() < aConf2)
           aNormal.SetZ(0.);
-        arrVec[i] = aNormal.XYZ();
-
-        Standard_Integer j = i * 3;
-        Normals->SetValue(j + 1, (Standard_ShortReal)aNormal.X());
-        Normals->SetValue(j + 2, (Standard_ShortReal)aNormal.Y());
-        Normals->SetValue(j + 3, (Standard_ShortReal)aNormal.Z());
 
+        arrVec[i] = aNormal.XYZ();
+        theTri->SetNormal (i + 1, aNormal.XYZ());
       }
-
-      theTri->SetNormals(Normals);  
   
       const Handle(VrmlData_Normal) aNormalNode =
         new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
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..0e3e8f72268a2afd8c6b33dbbc9e3b582c95ef7a 100644 (file)
@@ -10,5 +10,7 @@ XmlMDataXtd_PositionDriver.hxx
 XmlMDataXtd_PositionDriver.cxx
 XmlMDataXtd_PresentationDriver.hxx
 XmlMDataXtd_PresentationDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.hxx
 XmlMDataXtd_TriangulationDriver.cxx
 XmlMDataXtd_TriangulationDriver.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..b88fb04
--- /dev/null
@@ -0,0 +1,133 @@
+// 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 += 3 * 5 * aMesh->NbTriangles(); // space for triangles   (3 integers of 5 symbols)
+    aSize += 4 * 5 * aMesh->NbQuads();     // space for quadrangles (4 integers of 5 symbols)
+    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"