From: vro Date: Mon, 8 Feb 2021 15:03:28 +0000 (+0300) Subject: 0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=f2384f0ca8f37db6a1eef20a7fc222003acbd563;p=occt-copy.git 0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal mesh) // Added skipped changes in samples --- diff --git a/samples/OCCTOverview/code/TriangulationSamples.cxx b/samples/OCCTOverview/code/TriangulationSamples.cxx index eff114e831..a3684639ad 100644 --- a/samples/OCCTOverview/code/TriangulationSamples.cxx +++ b/samples/OCCTOverview/code/TriangulationSamples.cxx @@ -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()); diff --git a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp index 497f5244ed..8ea5b4b6e0 100755 --- a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp +++ b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp @@ -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); } diff --git a/samples/mfc/standard/07_Triangulation/src/Tesselate_Presentation.cpp b/samples/mfc/standard/07_Triangulation/src/Tesselate_Presentation.cpp index 77eeb4c530..b34e562e29 100755 --- a/samples/mfc/standard/07_Triangulation/src/Tesselate_Presentation.cpp +++ b/samples/mfc/standard/07_Triangulation/src/Tesselate_Presentation.cpp @@ -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]; diff --git a/samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp b/samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp index d25bf8924d..58555a457e 100755 --- a/samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp +++ b/samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp @@ -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\ diff --git a/samples/mfc/standard/Common/User_Cylinder.cxx b/samples/mfc/standard/Common/User_Cylinder.cxx index c427005c2c..c5e8467b74 100755 --- a/samples/mfc/standard/Common/User_Cylinder.cxx +++ b/samples/mfc/standard/Common/User_Cylinder.cxx @@ -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