mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025936: Modeling Data - reusable data structure for 2D tesselation (3- and 4-nodal mesh)
// NCollection_Array1 replaced NCollection_Vector in Poly_Triangulation for nodes, triangles, ...
This commit is contained in:
@@ -142,7 +142,8 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
|
|||||||
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
|
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
|
||||||
{
|
{
|
||||||
anArray->AddVertex (myTriangulation->Node (i), attenuateColor (colors (i), ambient));
|
anArray->AddVertex (myTriangulation->Node (i), attenuateColor (colors (i), ambient));
|
||||||
anArray->SetVertexNormal(i, myTriangulation->Normal (i));
|
const Vec3f& aNormal = myTriangulation->Normal (i);
|
||||||
|
anArray->SetVertexNormal (i, aNormal.x(), aNormal.y(), aNormal.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // !hasVColors
|
else // !hasVColors
|
||||||
@@ -150,7 +151,8 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
|
|||||||
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
|
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
|
||||||
{
|
{
|
||||||
anArray->AddVertex(myTriangulation->Node (i));
|
anArray->AddVertex(myTriangulation->Node (i));
|
||||||
anArray->SetVertexNormal(i, myTriangulation->Normal (i));
|
const Vec3f& aNormal = myTriangulation->Normal(i);
|
||||||
|
anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2343,9 +2343,6 @@ Standard_Boolean BRepLib::
|
|||||||
}
|
}
|
||||||
|
|
||||||
GeomLProp_SLProps aSLP(aSurf, 2, Precision::Confusion());
|
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 = 1; i <= aPT->NbNodes(); i++)
|
for(Standard_Integer i = 1; i <= aPT->NbNodes(); i++)
|
||||||
{
|
{
|
||||||
const gp_Pnt2d &aP2d = aPT->UVNode (i);
|
const gp_Pnt2d &aP2d = aPT->UVNode (i);
|
||||||
@@ -2364,14 +2361,13 @@ Standard_Boolean BRepLib::
|
|||||||
if (aFace.Orientation() == TopAbs_REVERSED)
|
if (aFace.Orientation() == TopAbs_REVERSED)
|
||||||
aNorm.Reverse();
|
aNorm.Reverse();
|
||||||
}
|
}
|
||||||
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.X());
|
aPT->SetNormal (i, static_cast<Standard_ShortReal>(aNorm.X()),
|
||||||
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Y());
|
static_cast<Standard_ShortReal>(aNorm.Y()),
|
||||||
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Z());
|
static_cast<Standard_ShortReal>(aNorm.Z()));
|
||||||
}
|
}
|
||||||
|
|
||||||
aRetVal = Standard_True;
|
aRetVal = Standard_True;
|
||||||
isNormalsFound = Standard_True;
|
isNormalsFound = Standard_True;
|
||||||
aPT->SetNormals(aNormArr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isNormalsFound)
|
if(!isNormalsFound)
|
||||||
@@ -2418,8 +2414,9 @@ Standard_Boolean BRepLib::
|
|||||||
const Standard_Integer aFNodF1 = aPTEF1->Nodes().Value(anEdgNode);
|
const Standard_Integer aFNodF1 = aPTEF1->Nodes().Value(anEdgNode);
|
||||||
const Standard_Integer aFNodF2 = aPTEF2->Nodes().Value(anEdgNode);
|
const Standard_Integer aFNodF2 = aPTEF2->Nodes().Value(anEdgNode);
|
||||||
|
|
||||||
gp_XYZ aNorm1 (aPT1->Normal (aFNodF1).XYZ());
|
gp_XYZ aNorm1, aNorm2;
|
||||||
gp_XYZ aNorm2 (aPT2->Normal (aFNodF2).XYZ());
|
aPT1->Normal (aFNodF1, aNorm1);
|
||||||
|
aPT1->Normal (aFNodF2, aNorm2);
|
||||||
const Standard_Real aDot = aNorm1 * aNorm2;
|
const Standard_Real aDot = aNorm1 * aNorm2;
|
||||||
|
|
||||||
if(aDot > aThresDot)
|
if(aDot > aThresDot)
|
||||||
|
@@ -1522,7 +1522,7 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
|
|||||||
}
|
}
|
||||||
for (k = 1; k <= 3; k++)
|
for (k = 1; k <= 3; k++)
|
||||||
{
|
{
|
||||||
OS << T->Normal (j).Coord (k) << " ";
|
OS << T->Normal (j).GetData() [k - 1] << " ";
|
||||||
if (!Compact)
|
if (!Compact)
|
||||||
{
|
{
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
@@ -1558,10 +1558,9 @@ void BRepTools_ShapeSet::DumpTriangulation(Standard_OStream& OS)const
|
|||||||
void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_ProgressRange& theProgress)
|
void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_ProgressRange& theProgress)
|
||||||
{
|
{
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
// Standard_Integer i, j, val, nbtri;
|
|
||||||
Standard_Integer i, j, nbtri =0;
|
Standard_Integer i, j, nbtri =0;
|
||||||
Standard_Real d, x, y, z;
|
Standard_Real d, x, y, z;
|
||||||
Standard_Real normal;
|
Standard_Real normalX, normalY, normalZ;
|
||||||
Standard_Integer nbNodes =0, nbTriangles=0;
|
Standard_Integer nbNodes =0, nbTriangles=0;
|
||||||
Standard_Boolean hasUV= Standard_False;
|
Standard_Boolean hasUV= Standard_False;
|
||||||
Standard_Boolean hasNormals= Standard_False;
|
Standard_Boolean hasNormals= Standard_False;
|
||||||
@@ -1583,53 +1582,44 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
|
|||||||
}
|
}
|
||||||
GeomTools::GetReal(IS, d);
|
GeomTools::GetReal(IS, d);
|
||||||
|
|
||||||
TColgp_Array1OfPnt Nodes(1, nbNodes);
|
T = new Poly_Triangulation (nbNodes, nbTriangles, hasUV, hasNormals);
|
||||||
TColgp_Array1OfPnt2d UVNodes(1, nbNodes);
|
|
||||||
Handle(TShort_HArray1OfShortReal) Normals;
|
|
||||||
if (hasNormals)
|
|
||||||
{
|
|
||||||
Normals = new TShort_HArray1OfShortReal(1, nbNodes * 3);
|
|
||||||
}
|
|
||||||
for (j = 1; j <= nbNodes; j++) {
|
for (j = 1; j <= nbNodes; j++) {
|
||||||
GeomTools::GetReal(IS, x);
|
GeomTools::GetReal(IS, x);
|
||||||
GeomTools::GetReal(IS, y);
|
GeomTools::GetReal(IS, y);
|
||||||
GeomTools::GetReal(IS, z);
|
GeomTools::GetReal(IS, z);
|
||||||
Nodes(j).SetCoord(x,y,z);
|
T->ChangeNode (j).SetCoord (x,y,z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasUV) {
|
if (hasUV) {
|
||||||
for (j = 1; j <= nbNodes; j++) {
|
for (j = 1; j <= nbNodes; j++) {
|
||||||
GeomTools::GetReal(IS, x);
|
GeomTools::GetReal(IS, x);
|
||||||
GeomTools::GetReal(IS, y);
|
GeomTools::GetReal(IS, y);
|
||||||
UVNodes(j).SetCoord(x,y);
|
T->ChangeUVNode (j).SetCoord (x,y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the triangles
|
// read the triangles
|
||||||
Standard_Integer n1,n2,n3;
|
Standard_Integer n1,n2,n3;
|
||||||
Poly_Array1OfTriangle Triangles(1, nbTriangles);
|
|
||||||
for (j = 1; j <= nbTriangles; j++) {
|
for (j = 1; j <= nbTriangles; j++) {
|
||||||
IS >> n1 >> n2 >> n3;
|
IS >> n1 >> n2 >> n3;
|
||||||
Triangles(j).Set(n1,n2,n3);
|
T->ChangeTriangle (j).Set (n1,n2,n3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNormals)
|
if (hasNormals)
|
||||||
{
|
{
|
||||||
for (j = 1; j <= nbNodes * 3; j++)
|
for (j = 1; j <= nbNodes; j++)
|
||||||
{
|
{
|
||||||
GeomTools::GetReal(IS, normal);
|
GeomTools::GetReal (IS, normalX);
|
||||||
Normals->SetValue(j, static_cast<Standard_ShortReal>(normal));
|
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);
|
T->Deflection(d);
|
||||||
if (hasNormals)
|
|
||||||
{
|
|
||||||
T->SetNormals(Normals);
|
|
||||||
}
|
|
||||||
myTriangulations.Add(T, hasNormals);
|
myTriangulations.Add(T, hasNormals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1654,17 +1644,18 @@ void BRepTools_ShapeSet::WriteMeshes (Standard_OStream& theOS,
|
|||||||
{
|
{
|
||||||
const Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (theMeshes (i));
|
const Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (theMeshes (i));
|
||||||
const Standard_Integer nbNodes = aMesh->NbNodes();
|
const Standard_Integer nbNodes = aMesh->NbNodes();
|
||||||
const Standard_Integer nbElements = aMesh->NbElements();
|
const Standard_Integer nbTriangles = aMesh->NbTriangles();
|
||||||
|
const Standard_Integer nbQuads = aMesh->NbQuads();
|
||||||
const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
|
const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
|
||||||
|
|
||||||
if (theCompact)
|
if (theCompact)
|
||||||
{
|
{
|
||||||
theOS << nbNodes << " " << nbElements << " ";
|
theOS << nbNodes << " " << nbTriangles << " " << nbQuads << " ";
|
||||||
theOS << (hasUVNodes ? "1" : "0") << " ";
|
theOS << (hasUVNodes ? "1" : "0") << " ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theOS << " "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbElements <<" Triangles and Quadrangles\n";
|
theOS << " "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbTriangles << " Triangles, " << nbQuads << " Quadrangles\n";
|
||||||
theOS << " "<<(hasUVNodes ? "with" : "without") << " UV nodes\n";
|
theOS << " "<<(hasUVNodes ? "with" : "without") << " UV nodes\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1707,28 +1698,38 @@ void BRepTools_ShapeSet::WriteMeshes (Standard_OStream& theOS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write triangles and quadrangles
|
// write triangles
|
||||||
if (!theCompact) theOS << "\nElements :\n";
|
if (!theCompact) theOS << "\nTriangles :\n";
|
||||||
Standard_Integer n, n1, n2, n3, n4;
|
Standard_Integer n1, n2, n3;
|
||||||
for (j = 1; j <= nbElements; j++)
|
for (j = 1; j <= nbTriangles; j++)
|
||||||
{
|
{
|
||||||
if (!theCompact) theOS << std::setw (10) << j << " : ";
|
if (!theCompact) theOS << std::setw (10) << j << " : ";
|
||||||
aMesh->Element (j, n1, n2, n3, n4);
|
aMesh->Triangle (j).Get (n1, n2, n3);
|
||||||
n = (n4 > 0) ? 4 : 3;
|
|
||||||
if (!theCompact) theOS << std::setw (10);
|
|
||||||
theOS << n << " ";
|
|
||||||
if (!theCompact) theOS << std::setw (10);
|
if (!theCompact) theOS << std::setw (10);
|
||||||
theOS << n1 << " ";
|
theOS << n1 << " ";
|
||||||
if (!theCompact) theOS << std::setw (10);
|
if (!theCompact) theOS << std::setw (10);
|
||||||
theOS << n2 << " ";
|
theOS << n2 << " ";
|
||||||
if (!theCompact) theOS << std::setw (10);
|
if (!theCompact) theOS << std::setw (10);
|
||||||
theOS << n3;
|
theOS << n3;
|
||||||
if (n4 > 0)
|
if (!theCompact) theOS << "\n";
|
||||||
|
else theOS << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// write quadrangles
|
||||||
|
if (!theCompact) theOS << "\nQuadrangles :\n";
|
||||||
|
Standard_Integer n4;
|
||||||
|
for (j = 1; j <= nbQuads; j++)
|
||||||
{
|
{
|
||||||
theOS << " ";
|
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);
|
if (!theCompact) theOS << std::setw(10);
|
||||||
theOS << n4;
|
theOS << n4;
|
||||||
}
|
|
||||||
if (!theCompact) theOS << "\n";
|
if (!theCompact) theOS << "\n";
|
||||||
else theOS << " ";
|
else theOS << " ";
|
||||||
}
|
}
|
||||||
@@ -1742,9 +1743,9 @@ void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
|
|||||||
{
|
{
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
Standard_Integer i, j;
|
Standard_Integer i, j;
|
||||||
Standard_Integer n, n1(0), n2(0), n3(0), n4(0);
|
Standard_Integer n1 (0), n2 (0), n3 (0), n4 (0);
|
||||||
Standard_Real deflection, x, y, z;
|
Standard_Real deflection, x, y, z;
|
||||||
Standard_Integer nbMeshes(0), nbNodes(0), nbElements(0);
|
Standard_Integer nbMeshes (0), nbNodes (0), nbTriangles (0), nbQuads (0);
|
||||||
Standard_Boolean hasUV (Standard_False);
|
Standard_Boolean hasUV (Standard_False);
|
||||||
gp_Pnt p;
|
gp_Pnt p;
|
||||||
|
|
||||||
@@ -1758,11 +1759,11 @@ void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
|
|||||||
|
|
||||||
for (i = 1; i <= nbMeshes; i++)
|
for (i = 1; i <= nbMeshes; i++)
|
||||||
{
|
{
|
||||||
theIS >> nbNodes >> nbElements >> hasUV;
|
theIS >> nbNodes >> nbTriangles >> nbQuads >> hasUV;
|
||||||
GeomTools::GetReal (theIS, deflection);
|
GeomTools::GetReal (theIS, deflection);
|
||||||
|
|
||||||
// Allocate the mesh.
|
// Allocate the mesh.
|
||||||
Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
|
Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, hasUV);
|
||||||
aMesh->Deflection (deflection);
|
aMesh->Deflection (deflection);
|
||||||
|
|
||||||
// Read nodes.
|
// Read nodes.
|
||||||
@@ -1772,7 +1773,7 @@ void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
|
|||||||
GeomTools::GetReal (theIS, y);
|
GeomTools::GetReal (theIS, y);
|
||||||
GeomTools::GetReal (theIS, z);
|
GeomTools::GetReal (theIS, z);
|
||||||
p.SetCoord (x, y, z);
|
p.SetCoord (x, y, z);
|
||||||
aMesh->AddNode (p);
|
aMesh->ChangeNode (j) = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads 2d-nodes.
|
// Reads 2d-nodes.
|
||||||
@@ -1786,21 +1787,24 @@ void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads the triangles and quadrangles.
|
// Reads the triangles.
|
||||||
for (j = 1; j <= nbElements; j++)
|
for (j = 1; j <= nbTriangles; j++)
|
||||||
{
|
{
|
||||||
// Read the element.
|
// Read the indices.
|
||||||
theIS >> n;
|
|
||||||
if (n == 3)
|
|
||||||
theIS >> n1 >> n2 >> n3;
|
theIS >> n1 >> n2 >> n3;
|
||||||
else if (n == 4)
|
|
||||||
|
// 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;
|
theIS >> n1 >> n2 >> n3 >> n4;
|
||||||
|
|
||||||
// Set the element to the mesh.
|
// Set the quadrangle to the mesh.
|
||||||
if (n == 3)
|
aMesh->ChangeQuad (j) = Poly_Quad (n1, n2, n3, n4);
|
||||||
aMesh->AddElement (n1, n2, n3);
|
|
||||||
else if (n == 4)
|
|
||||||
aMesh->AddElement (n1, n2, n3, n4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theMeshes.Add (aMesh);
|
theMeshes.Add (aMesh);
|
||||||
|
@@ -52,18 +52,19 @@ Standard_Boolean BinMDataXtd_SurfacicMeshDriver::Paste (const BinObjMgt_Persiste
|
|||||||
|
|
||||||
Standard_Integer i;
|
Standard_Integer i;
|
||||||
Standard_Real deflection, x, y, z;
|
Standard_Real deflection, x, y, z;
|
||||||
Standard_Integer n, n1, n2, n3, n4;
|
Standard_Integer n1, n2, n3, n4;
|
||||||
Standard_Integer nbNodes(0), nbElements(0);
|
Standard_Integer nbNodes (0), nbTriangles (0), nbQuads (0);
|
||||||
Standard_Boolean hasUV (Standard_False);
|
Standard_Boolean hasUV (Standard_False);
|
||||||
gp_Pnt p;
|
gp_Pnt p;
|
||||||
|
|
||||||
theSource >> nbNodes;
|
theSource >> nbNodes;
|
||||||
theSource >> nbElements;
|
theSource >> nbTriangles;
|
||||||
|
theSource >> nbQuads;
|
||||||
theSource >> hasUV;
|
theSource >> hasUV;
|
||||||
theSource >> deflection;
|
theSource >> deflection;
|
||||||
|
|
||||||
// allocate the mesh
|
// allocate the mesh
|
||||||
Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
|
Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, hasUV);
|
||||||
|
|
||||||
// deflection
|
// deflection
|
||||||
aMesh->Deflection (deflection);
|
aMesh->Deflection (deflection);
|
||||||
@@ -75,7 +76,7 @@ Standard_Boolean BinMDataXtd_SurfacicMeshDriver::Paste (const BinObjMgt_Persiste
|
|||||||
theSource >> y;
|
theSource >> y;
|
||||||
theSource >> z;
|
theSource >> z;
|
||||||
p.SetCoord (x, y, z);
|
p.SetCoord (x, y, z);
|
||||||
aMesh->AddNode (p);
|
aMesh->ChangeNode (i) = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read 2d nodes
|
// read 2d nodes
|
||||||
@@ -89,20 +90,23 @@ Standard_Boolean BinMDataXtd_SurfacicMeshDriver::Paste (const BinObjMgt_Persiste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read triangles and quadrangles
|
// read triangles
|
||||||
for (i = 1; i <= nbElements; i++)
|
for (i = 1; i <= nbTriangles; i++)
|
||||||
{
|
{
|
||||||
theSource >> n;
|
|
||||||
theSource >> n1;
|
theSource >> n1;
|
||||||
theSource >> n2;
|
theSource >> n2;
|
||||||
theSource >> n3;
|
theSource >> n3;
|
||||||
if (n == 3)
|
aMesh->ChangeTriangle (i).Set (n1, n2, n3);
|
||||||
aMesh->AddElement (n1, n2, n3);
|
|
||||||
else if (n == 4)
|
|
||||||
{
|
|
||||||
theSource >> n4;
|
|
||||||
aMesh->AddElement (n1, n2, n3, n4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Set mesh to Ocaf attribute
|
||||||
@@ -123,11 +127,13 @@ void BinMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSour
|
|||||||
if (!aMesh.IsNull())
|
if (!aMesh.IsNull())
|
||||||
{
|
{
|
||||||
Standard_Integer nbNodes = aMesh->NbNodes();
|
Standard_Integer nbNodes = aMesh->NbNodes();
|
||||||
Standard_Integer nbElements = aMesh->NbElements();
|
Standard_Integer nbTriangles = aMesh->NbTriangles();
|
||||||
|
Standard_Integer nbQuads = aMesh->NbQuads();
|
||||||
|
|
||||||
// write number of elements
|
// write number of elements
|
||||||
theTarget << nbNodes;
|
theTarget << nbNodes;
|
||||||
theTarget << nbElements;
|
theTarget << nbTriangles;
|
||||||
|
theTarget << nbQuads;
|
||||||
theTarget << (aMesh->HasUVNodes() ? 1 : 0);
|
theTarget << (aMesh->HasUVNodes() ? 1 : 0);
|
||||||
// write the deflection
|
// write the deflection
|
||||||
theTarget << aMesh->Deflection();
|
theTarget << aMesh->Deflection();
|
||||||
@@ -153,17 +159,24 @@ void BinMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write triangles and quadrangles
|
// write triangles
|
||||||
Standard_Integer n, n1, n2, n3, n4;
|
Standard_Integer n1, n2, n3;
|
||||||
for (i = 1; i <= nbElements; i++)
|
for (i = 1; i <= nbTriangles; i++)
|
||||||
{
|
{
|
||||||
aMesh->Element (i, n1, n2, n3, n4);
|
aMesh->Triangle (i).Get (n1, n2, n3);
|
||||||
n = (n4 > 0) ? 4 : 3;
|
theTarget << n1;
|
||||||
theTarget << n;
|
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 << n1;
|
||||||
theTarget << n2;
|
theTarget << n2;
|
||||||
theTarget << n3;
|
theTarget << n3;
|
||||||
if (n4 > 0)
|
|
||||||
theTarget << n4;
|
theTarget << n4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1532,10 +1532,10 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
|
|||||||
{
|
{
|
||||||
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
|
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
|
||||||
{
|
{
|
||||||
const gp_Dir aNormal = aTriangulation->Normal (aNormalIter);
|
const Vec3f& aNormal = aTriangulation->Normal (aNormalIter);
|
||||||
BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.X());
|
BinTools::PutShortReal (OS, aNormal.x());
|
||||||
BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Y());
|
BinTools::PutShortReal (OS, aNormal.y());
|
||||||
BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Z());
|
BinTools::PutShortReal (OS, aNormal.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1620,8 +1620,7 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
|
|||||||
BinTools::GetShortReal(IS, aNormalX);
|
BinTools::GetShortReal(IS, aNormalX);
|
||||||
BinTools::GetShortReal(IS, aNormalY);
|
BinTools::GetShortReal(IS, aNormalY);
|
||||||
BinTools::GetShortReal(IS, aNormalZ);
|
BinTools::GetShortReal(IS, aNormalZ);
|
||||||
gp_Dir aNormal(aNormalX, aNormalY, aNormalZ);
|
aTriangulation->SetNormal (aNormalIter, aNormalX, aNormalY, aNormalZ);
|
||||||
aTriangulation->SetNormal (aNormalIter, aNormal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1148,7 +1148,9 @@ Standard_Boolean DBRep_DrawableShape::addMeshNormals (NCollection_Vector<std::pa
|
|||||||
gp_Vec aNormal;
|
gp_Vec aNormal;
|
||||||
if (hasNormals)
|
if (hasNormals)
|
||||||
{
|
{
|
||||||
aNormal = aTriangulation->Normal (aNodeIter);
|
gp_XYZ anXYZ;
|
||||||
|
aTriangulation->Normal (aNodeIter, anXYZ);
|
||||||
|
aNormal.SetXYZ (anXYZ);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -13,8 +13,7 @@ Poly_CoherentTriPtr.cxx
|
|||||||
Poly_CoherentTriPtr.hxx
|
Poly_CoherentTriPtr.hxx
|
||||||
Poly_Connect.cxx
|
Poly_Connect.cxx
|
||||||
Poly_Connect.hxx
|
Poly_Connect.hxx
|
||||||
Poly_Element.cxx
|
Poly_Quad.hxx
|
||||||
Poly_Element.hxx
|
|
||||||
Poly_HArray1OfTriangle.hxx
|
Poly_HArray1OfTriangle.hxx
|
||||||
Poly_ListOfTriangulation.hxx
|
Poly_ListOfTriangulation.hxx
|
||||||
Poly_MakeLoops.cxx
|
Poly_MakeLoops.cxx
|
||||||
|
@@ -480,28 +480,21 @@ void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize all vectors
|
// Normalize all vectors
|
||||||
|
gp_Dir aNormal;
|
||||||
gp_XYZ aNormXYZ;
|
gp_XYZ aNormXYZ;
|
||||||
for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
|
for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
|
||||||
{
|
{
|
||||||
const Standard_Size anIndex = aNodeIter * 3;
|
const Standard_Size anIndex = aNodeIter * 3;
|
||||||
aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
|
aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
|
||||||
const Standard_Real aMod2 = aNormXYZ.SquareModulus();
|
const Standard_Real aMod2 = aNormXYZ.SquareModulus();
|
||||||
if (aMod2 < anEps2)
|
if (aMod2 > anEps2)
|
||||||
{
|
aNormal = aNormXYZ;
|
||||||
aNormArr[anIndex + 0] = 0.0f;
|
|
||||||
aNormArr[anIndex + 1] = 0.0f;
|
|
||||||
aNormArr[anIndex + 2] = 1.0f;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
aNormal = gp::DZ();
|
||||||
aNormXYZ /= Sqrt (aMod2);
|
|
||||||
aNormArr[anIndex + 0] = Standard_ShortReal(aNormXYZ.X());
|
|
||||||
aNormArr[anIndex + 1] = Standard_ShortReal(aNormXYZ.Y());
|
|
||||||
aNormArr[anIndex + 2] = Standard_ShortReal(aNormXYZ.Z());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theTri->SetNormals (aNormals);
|
// Set normal.
|
||||||
|
theTri->SetNormal (aNodeIter + 1, aNormXYZ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -81,7 +81,8 @@ Poly_CoherentTriangulation::Poly_CoherentTriangulation
|
|||||||
// Copy the normals at nodes
|
// Copy the normals at nodes
|
||||||
if (theTriangulation->HasNormals()) {
|
if (theTriangulation->HasNormals()) {
|
||||||
for (i = 0; i < nNodes; i++) {
|
for (i = 0; i < nNodes; i++) {
|
||||||
const gp_XYZ aNormal = theTriangulation->Normal (i + 1).XYZ();
|
const Vec3f& anXYZ = theTriangulation->Normal (i + 1);
|
||||||
|
gp_XYZ aNormal (anXYZ.x(), anXYZ.y(), anXYZ.z());
|
||||||
myNodes (i).SetNormal (aNormal);
|
myNodes (i).SetNormal (aNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,14 +115,10 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
|
|||||||
const Standard_Integer nTriangles = NTriangles();
|
const Standard_Integer nTriangles = NTriangles();
|
||||||
if (nNodes > 0 && nTriangles > 0) {
|
if (nNodes > 0 && nTriangles > 0) {
|
||||||
aResult = new Poly_Triangulation(nNodes, nTriangles, Standard_True);
|
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);
|
|
||||||
|
|
||||||
NCollection_Vector<Standard_Integer> vecNodeId;
|
NCollection_Vector<Standard_Integer> vecNodeId;
|
||||||
Standard_Integer i, aCount(0);
|
Standard_Integer i, aCount(0);
|
||||||
Standard_Boolean hasUV (Standard_False);
|
Standard_Boolean hasUV (Standard_False);
|
||||||
Standard_Boolean hasNormals (Standard_False);
|
|
||||||
|
|
||||||
// Copy the nodes (3D and 2D coordinates)
|
// Copy the nodes (3D and 2D coordinates)
|
||||||
for (i = 0; i < myNodes.Length(); i++) {
|
for (i = 0; i < myNodes.Length(); i++) {
|
||||||
@@ -130,9 +127,11 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
|
|||||||
vecNodeId.SetValue(i, 0);
|
vecNodeId.SetValue(i, 0);
|
||||||
else {
|
else {
|
||||||
const gp_XYZ aNormal = aNode.GetNormal();
|
const gp_XYZ aNormal = aNode.GetNormal();
|
||||||
arrNormal[3 * aCount + 0] = static_cast<Standard_ShortReal>(aNormal.X());
|
if (aNormal.SquareModulus() > Precision::Confusion()) {
|
||||||
arrNormal[3 * aCount + 1] = static_cast<Standard_ShortReal>(aNormal.Y());
|
aResult->SetNormal (aCount, static_cast<Standard_ShortReal>(aNormal.X()),
|
||||||
arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
|
static_cast<Standard_ShortReal>(aNormal.Y()),
|
||||||
|
static_cast<Standard_ShortReal>(aNormal.Z()));
|
||||||
|
}
|
||||||
|
|
||||||
vecNodeId.SetValue(i, ++aCount);
|
vecNodeId.SetValue(i, ++aCount);
|
||||||
aResult->ChangeNode (aCount) = aNode;
|
aResult->ChangeNode (aCount) = aNode;
|
||||||
@@ -141,8 +140,6 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
|
|||||||
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
|
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
|
||||||
Precision::Confusion())
|
Precision::Confusion())
|
||||||
hasUV = Standard_True;
|
hasUV = Standard_True;
|
||||||
if (aNormal.SquareModulus() > Precision::Confusion())
|
|
||||||
hasNormals = Standard_True;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasUV == Standard_False)
|
if (hasUV == Standard_False)
|
||||||
@@ -159,8 +156,6 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
|
|||||||
vecNodeId (aTri.Node (2)));;
|
vecNodeId (aTri.Node (2)));;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasNormals)
|
|
||||||
aResult->SetNormals (harrNormal);
|
|
||||||
|
|
||||||
aResult->Deflection(myDeflection);
|
aResult->Deflection(myDeflection);
|
||||||
}
|
}
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
// 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_Element.hxx>
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Poly_Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Poly_Element::Poly_Element()
|
|
||||||
{
|
|
||||||
myTriangles[0] = myTriangles[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Poly_Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Poly_Element::Poly_Element (const Standard_Integer theTriangle1,
|
|
||||||
const Standard_Integer theTriangle2)
|
|
||||||
{
|
|
||||||
myTriangles[0] = theTriangle1;
|
|
||||||
myTriangles[1] = theTriangle2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Set
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Poly_Element::Set (const Standard_Integer theTriangle1,
|
|
||||||
const Standard_Integer theTriangle2)
|
|
||||||
{
|
|
||||||
myTriangles[0] = theTriangle1;
|
|
||||||
myTriangles[1] = theTriangle2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Get
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Poly_Element::Get (Standard_Integer& theTriangle1,
|
|
||||||
Standard_Integer& theTriangle2) const
|
|
||||||
{
|
|
||||||
theTriangle1 = myTriangles[0];
|
|
||||||
theTriangle2 = myTriangles[1];
|
|
||||||
}
|
|
@@ -1,84 +0,0 @@
|
|||||||
// 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_Element_HeaderFile
|
|
||||||
#define _Poly_Element_HeaderFile
|
|
||||||
|
|
||||||
#include <Standard_DefineAlloc.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
#include <Standard_OutOfRange.hxx>
|
|
||||||
|
|
||||||
//! Describes an element on mesh.
|
|
||||||
//! It can be defined as triangle index (in this case second index will be 0)
|
|
||||||
//! or as a pair of triangles indices that make up the quad.
|
|
||||||
class Poly_Element
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
|
||||||
|
|
||||||
//! Constructs an element and sets all indices to zero.
|
|
||||||
Standard_EXPORT Poly_Element();
|
|
||||||
|
|
||||||
//! Constructs an element and sets it indices.
|
|
||||||
Standard_EXPORT Poly_Element (const Standard_Integer theTriangle1,
|
|
||||||
const Standard_Integer theTriangle2);
|
|
||||||
|
|
||||||
//! Sets the value of triangles indices.
|
|
||||||
Standard_EXPORT void Set (const Standard_Integer theTriangle1,
|
|
||||||
const Standard_Integer theTriangle2);
|
|
||||||
|
|
||||||
//! Returns the triangles indices of this element in theTriangle1, theTriangle2.
|
|
||||||
Standard_EXPORT void Get (Standard_Integer& theTriangle1,
|
|
||||||
Standard_Integer& theTriangle2) const;
|
|
||||||
|
|
||||||
//! @return the triangle index of given element theIndex.
|
|
||||||
//! Raises OutOfRange from Standard if theIndex is not in 1,2.
|
|
||||||
Standard_Integer Value (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > 2, NULL);
|
|
||||||
return myTriangles[theIndex - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer operator() (const Standard_Integer theIndex) const { return Value (theIndex); }
|
|
||||||
|
|
||||||
//! @return the triangle index of given element theIndex.
|
|
||||||
//! Raises OutOfRange from Standard if theIndex is not in 1,2.
|
|
||||||
Standard_Integer& ChangeValue (const Standard_Integer theIndex)
|
|
||||||
{
|
|
||||||
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > 2, NULL);
|
|
||||||
return myTriangles[theIndex - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer& operator() (const Standard_Integer theIndex) { return ChangeValue (theIndex); }
|
|
||||||
|
|
||||||
//! @return Standard_True if the first element index > 0 and the second index == 0.
|
|
||||||
Standard_Boolean IsTriangle() const
|
|
||||||
{
|
|
||||||
return (myTriangles[0] > 0 && myTriangles[1] == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! @return Standard_True if the first and the second element indices > 0.
|
|
||||||
Standard_Boolean IsQuad() const
|
|
||||||
{
|
|
||||||
return (myTriangles[0] > 0 && myTriangles[1] > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Standard_Integer myTriangles[2];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _Poly_Element_HeaderFile
|
|
@@ -12,7 +12,6 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <Poly_Mesh.hxx>
|
#include <Poly_Mesh.hxx>
|
||||||
|
|
||||||
#include <Standard_DefineHandle.hxx>
|
#include <Standard_DefineHandle.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
|
IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
|
||||||
@@ -22,10 +21,25 @@ IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Poly_Mesh::Poly_Mesh (const Standard_Boolean theHasUVNodes)
|
Poly_Mesh::Poly_Mesh () : Poly_Triangulation (0, 0, Standard_False)
|
||||||
: Poly_Triangulation (0, 0, theHasUVNodes),
|
{
|
||||||
myNbQuads (0)
|
}
|
||||||
{}
|
|
||||||
|
//=======================================================================
|
||||||
|
//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
|
//function : Poly_Mesh
|
||||||
@@ -33,20 +47,9 @@ Poly_Mesh::Poly_Mesh (const Standard_Boolean theHasUVNodes)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
|
Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
|
||||||
: Poly_Triangulation ( theTriangulation ),
|
: Poly_Triangulation ( theTriangulation )
|
||||||
myNbQuads (0)
|
|
||||||
{
|
{
|
||||||
const Standard_Integer aNbTris = theTriangulation->NbTriangles();
|
// No quadrangles.
|
||||||
|
|
||||||
// Fill collection of elements
|
|
||||||
if ( aNbTris )
|
|
||||||
myElements.SetValue( aNbTris - 1, Poly_Element() );
|
|
||||||
|
|
||||||
// Populate elements with triangles
|
|
||||||
for ( Standard_Integer i = 1; i <= aNbTris; ++i )
|
|
||||||
{
|
|
||||||
myElements(i - 1).Set(i, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -56,144 +59,8 @@ Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
|
|||||||
|
|
||||||
Handle(Poly_Triangulation) Poly_Mesh::Copy() const
|
Handle(Poly_Triangulation) Poly_Mesh::Copy() const
|
||||||
{
|
{
|
||||||
const Standard_Boolean hasUV = HasUVNodes();
|
Handle(Poly_Triangulation) aCopiedTriangulation = Poly_Triangulation::Copy();
|
||||||
Handle(Poly_Mesh) aCopy = new Poly_Mesh(hasUV);
|
Handle(Poly_Mesh) aCopiedMesh = new Poly_Mesh (aCopiedTriangulation);
|
||||||
// Copy nodes
|
aCopiedMesh->myQuads = myQuads;
|
||||||
Standard_Integer aNbNodes = NbNodes();
|
return aCopiedMesh;
|
||||||
for ( Standard_Integer i = 1; i <= aNbNodes; ++i )
|
|
||||||
{
|
|
||||||
aCopy->AddNode(Node(i));
|
|
||||||
if ( hasUV )
|
|
||||||
aCopy->ChangeUVNode(i) = UVNode(i);
|
|
||||||
}
|
|
||||||
// Copy triangles
|
|
||||||
Standard_Integer aNbTriangles = NbTriangles();
|
|
||||||
const Standard_Boolean hasNormals = HasNormals();
|
|
||||||
for ( Standard_Integer i = 1; i <= aNbTriangles; ++i )
|
|
||||||
{
|
|
||||||
aCopy->AddTriangle(Triangle(i));
|
|
||||||
// Pass normal vector (if any)
|
|
||||||
if ( hasNormals )
|
|
||||||
aCopy->SetNormal(i, Normal(i));
|
|
||||||
}
|
|
||||||
// Copy quads
|
|
||||||
aCopy->myNbQuads = myNbQuads;
|
|
||||||
aCopy->myElements = myElements;
|
|
||||||
return aCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AddElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3)
|
|
||||||
{
|
|
||||||
Standard_Integer anIndex = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN2, theN3) );
|
|
||||||
return addElement( Poly_Element(anIndex, 0) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AddElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3,
|
|
||||||
const Standard_Integer theN4)
|
|
||||||
{
|
|
||||||
Standard_Integer anIndex1 = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN2, theN3) );
|
|
||||||
Standard_Integer anIndex2 = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN3, theN4) );
|
|
||||||
return addElement( Poly_Element(anIndex1, anIndex2) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
const Poly_Element& Poly_Mesh::Element (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
if ( theIndex < 1 || theIndex > myElements.Size() )
|
|
||||||
{
|
|
||||||
Standard_OutOfRange::Raise("Poly_Mesh::Element : index out of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
return myElements.Value(theIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Poly_Mesh::Element (const Standard_Integer theIndex,
|
|
||||||
Standard_Integer& theN1,
|
|
||||||
Standard_Integer& theN2,
|
|
||||||
Standard_Integer& theN3,
|
|
||||||
Standard_Integer& theN4) const
|
|
||||||
{
|
|
||||||
if ( theIndex < 1 || theIndex > myElements.Size() )
|
|
||||||
{
|
|
||||||
Standard_OutOfRange::Raise("Poly_Mesh::Element : index out of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
const Poly_Element& anElem = Element(theIndex);
|
|
||||||
Standard_Integer aTriIdx1, aTriIdx2;
|
|
||||||
anElem.Get(aTriIdx1, aTriIdx2);
|
|
||||||
|
|
||||||
// Get node indices for the first triangle
|
|
||||||
const Poly_Triangle& aTri1 = Poly_Triangulation::Triangle(aTriIdx1);
|
|
||||||
aTri1.Get(theN1, theN2, theN3);
|
|
||||||
|
|
||||||
// If the second triangle exists, take its node indices for quad
|
|
||||||
if ( aTriIdx2 )
|
|
||||||
{
|
|
||||||
const Poly_Triangle& aTri2 = Poly_Triangulation::Triangle(aTriIdx2);
|
|
||||||
aTri2.Get(theN1, theN3, theN4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
theN4 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
void Poly_Mesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
|
|
||||||
{
|
|
||||||
if ( theIndex < 1 || theIndex > myElements.Size() )
|
|
||||||
{
|
|
||||||
Standard_OutOfRange::Raise("Poly_Mesh::SetElement : index out of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( myElements.Value(theIndex - 1).Value(2) == 0 && theElement.Value(2) != 0 )
|
|
||||||
{
|
|
||||||
myNbQuads++;
|
|
||||||
}
|
|
||||||
else if ( myElements.Value(theIndex - 1).Value(2) != 0 && theElement.Value(2) == 0 )
|
|
||||||
{
|
|
||||||
myNbQuads--;
|
|
||||||
}
|
|
||||||
|
|
||||||
myElements.SetValue(theIndex - 1, theElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : addElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Standard_Integer Poly_Mesh::addElement(const Poly_Element& theElement)
|
|
||||||
{
|
|
||||||
myElements.Append(theElement);
|
|
||||||
if ( theElement.Value(2) != 0 )
|
|
||||||
{
|
|
||||||
myNbQuads++;
|
|
||||||
}
|
|
||||||
return myElements.Size();
|
|
||||||
}
|
}
|
||||||
|
@@ -14,23 +14,31 @@
|
|||||||
#ifndef _Poly_Mesh_HeaderFile
|
#ifndef _Poly_Mesh_HeaderFile
|
||||||
#define _Poly_Mesh_HeaderFile
|
#define _Poly_Mesh_HeaderFile
|
||||||
|
|
||||||
#include <Poly_Element.hxx>
|
#include <Poly_Quad.hxx>
|
||||||
#include <Poly_Triangulation.hxx>
|
#include <Poly_Triangulation.hxx>
|
||||||
|
|
||||||
//! This class is extension for Poly_Triangulation.
|
//! This class is extension for Poly_Triangulation.
|
||||||
//! It allows to store mesh with quad polygons as table of Poly_Element.
|
//! It allows to store mesh with quad polygons.
|
||||||
//! Keep in mind that when you add a triangle, it is also added to the table of elements
|
|
||||||
//! as Poly_Element. And it will have first index set to triangle index from Poly_Triangulation
|
|
||||||
//! and second index will be set to 0.
|
|
||||||
class Poly_Mesh : public Poly_Triangulation
|
class Poly_Mesh : public Poly_Triangulation
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructs an empty mesh.
|
//! 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
|
//! @param theHasUVNodes indicates whether 2D nodes will be associated with
|
||||||
//! 3D ones, (i.e. to enable a 2D representation).
|
//! 3D ones, (i.e. to enable a 2D representation).
|
||||||
Standard_EXPORT Poly_Mesh (const Standard_Boolean theHasUVNodes = Standard_False);
|
//! @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.
|
//! Constructs a mesh from existing triangulation.
|
||||||
//! @param theTriangulation source triangulation.
|
//! @param theTriangulation source triangulation.
|
||||||
@@ -39,59 +47,39 @@ public:
|
|||||||
//! Creates full copy of current mesh
|
//! Creates full copy of current mesh
|
||||||
Standard_EXPORT virtual Handle(Poly_Triangulation) Copy() const;
|
Standard_EXPORT virtual Handle(Poly_Triangulation) Copy() const;
|
||||||
|
|
||||||
//! Adds element to the mesh.
|
//! Sets a quadrangle to the mesh.
|
||||||
//! @param theN1 index of the first node.
|
//! @param theIndex is an index of the quadrangle.
|
||||||
//! @param theN2 index of the second node.
|
|
||||||
//! @param theN3 index of the third node.
|
|
||||||
//! @return index of the added element.
|
|
||||||
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3);
|
|
||||||
|
|
||||||
//! Adds element to the mesh.
|
|
||||||
//! @param theN1 index of the first node.
|
//! @param theN1 index of the first node.
|
||||||
//! @param theN2 index of the second node.
|
//! @param theN2 index of the second node.
|
||||||
//! @param theN3 index of the third node.
|
//! @param theN3 index of the third node.
|
||||||
//! @param theN4 index of the fourth node.
|
//! @param theN4 index of the fourth node.
|
||||||
//! @return index of the added element.
|
void SetQuad (const Standard_Integer theIndex,
|
||||||
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
|
const Standard_Integer theN1,
|
||||||
const Standard_Integer theN2,
|
const Standard_Integer theN2,
|
||||||
const Standard_Integer theN3,
|
const Standard_Integer theN3,
|
||||||
const Standard_Integer theN4);
|
const Standard_Integer theN4)
|
||||||
|
{
|
||||||
|
myQuads.SetValue (theIndex, Poly_Quad (theN1, theN2, theN3, theN4));
|
||||||
|
}
|
||||||
|
|
||||||
//! @return the number of elements for this mesh.
|
//! @return the number of quadrangles in the mesh.
|
||||||
Standard_Integer NbElements() const { return myElements.Size(); }
|
Standard_Integer NbQuads() const {
|
||||||
|
return myQuads.Size();
|
||||||
|
}
|
||||||
|
|
||||||
//! @return the number of quads for this mesh.
|
//! @return a quadrangle at the given index.
|
||||||
Standard_Integer NbQuads() const { return myNbQuads; }
|
const Poly_Quad& Quad (const Standard_Integer theIndex) const {
|
||||||
|
return myQuads.Value (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//! @return element at the given index.
|
//! @return a reference to a quadrangle at the given index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
Poly_Quad& ChangeQuad (const Standard_Integer theIndex) {
|
||||||
Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const;
|
return myQuads.ChangeValue (theIndex);
|
||||||
|
}
|
||||||
//! @return nodes of the element at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
|
||||||
Standard_EXPORT void Element (const Standard_Integer theIndex,
|
|
||||||
Standard_Integer& theN1,
|
|
||||||
Standard_Integer& theN2,
|
|
||||||
Standard_Integer& theN3,
|
|
||||||
Standard_Integer& theN4) const;
|
|
||||||
|
|
||||||
//! Sets the element at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
|
||||||
Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Adds element to the mesh.
|
NCollection_Array1<Poly_Quad> myQuads;
|
||||||
//! @param theElement element to add.
|
|
||||||
//! @return index of the added element.
|
|
||||||
Standard_EXPORT Standard_Integer addElement (const Poly_Element& theElement);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
NCollection_Vector<Poly_Element> myElements;
|
|
||||||
Standard_Integer myNbQuads;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
|
Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
Standard_Integer myNodes[3];
|
Standard_Integer myNodes[3];
|
||||||
|
|
||||||
|
@@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <Poly_Triangle.hxx>
|
#include <Poly_Triangle.hxx>
|
||||||
#include <Standard_DomainError.hxx>
|
|
||||||
#include <Standard_Dump.hxx>
|
#include <Standard_Dump.hxx>
|
||||||
#include <Standard_NullObject.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
|
||||||
@@ -49,15 +47,15 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
|
|||||||
{
|
{
|
||||||
if (theNbNodes > 0)
|
if (theNbNodes > 0)
|
||||||
{
|
{
|
||||||
myNodes.SetValue (theNbNodes - 1, gp_Pnt());
|
myNodes.Resize (1, theNbNodes, Standard_False);
|
||||||
if (myHasUVNodes)
|
if (myHasUVNodes)
|
||||||
{
|
{
|
||||||
myUVNodes.SetValue (theNbNodes - 1, gp_Pnt2d());
|
myUVNodes.Resize (1, theNbNodes, Standard_False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (theNbTriangles > 0)
|
if (theNbTriangles > 0)
|
||||||
{
|
{
|
||||||
myTriangles.SetValue (theNbTriangles - 1, Poly_Triangle());
|
myTriangles.Resize (1, theNbTriangles, Standard_False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +71,7 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
|
|||||||
{
|
{
|
||||||
if (theHasNormals)
|
if (theHasNormals)
|
||||||
{
|
{
|
||||||
myNormals.SetValue (theNbNodes - 1, gp_Dir());
|
myNormals.Resize (1, theNbNodes, Standard_False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,14 +85,11 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
|
|||||||
myDeflection (0),
|
myDeflection (0),
|
||||||
myHasUVNodes (Standard_False)
|
myHasUVNodes (Standard_False)
|
||||||
{
|
{
|
||||||
for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
|
myNodes.Resize (1, theNodes.Length(), Standard_False);
|
||||||
{
|
myNodes = theNodes;
|
||||||
myNodes.SetValue (anIndex - 1, theNodes (anIndex));
|
|
||||||
}
|
myTriangles.Resize (1, theTriangles.Length(), Standard_False);
|
||||||
for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
|
myTriangles = theTriangles;
|
||||||
{
|
|
||||||
myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -109,20 +104,15 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
|
|||||||
myDeflection (0),
|
myDeflection (0),
|
||||||
myHasUVNodes (theNodes.Length() == theUVNodes.Length())
|
myHasUVNodes (theNodes.Length() == theUVNodes.Length())
|
||||||
{
|
{
|
||||||
for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
|
myNodes.Resize (1, theNodes.Length(), Standard_False);
|
||||||
{
|
myNodes = theNodes;
|
||||||
myNodes.SetValue (anIndex - 1, theNodes (anIndex));
|
|
||||||
}
|
myTriangles.Resize (1, theTriangles.Length(), Standard_False);
|
||||||
if (myHasUVNodes)
|
myTriangles = theTriangles;
|
||||||
{
|
|
||||||
for (Standard_Integer anIndex = theUVNodes.Upper(); anIndex >= theUVNodes.Lower(); anIndex--)
|
if (myHasUVNodes) {
|
||||||
{
|
myUVNodes.Resize (1, theNodes.Length(), Standard_False);
|
||||||
myUVNodes.SetValue (anIndex - 1, theUVNodes (anIndex));
|
myUVNodes = theUVNodes;
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
|
|
||||||
{
|
|
||||||
myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,9 +135,16 @@ Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
|
|||||||
Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (NbNodes(), NbTriangles(), HasUVNodes());
|
Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (NbNodes(), NbTriangles(), HasUVNodes());
|
||||||
aCopy->myNodes = myNodes;
|
aCopy->myNodes = myNodes;
|
||||||
aCopy->myTriangles = myTriangles;
|
aCopy->myTriangles = myTriangles;
|
||||||
aCopy->myUVNodes = myUVNodes;
|
|
||||||
aCopy->myDeflection = myDeflection;
|
aCopy->myDeflection = myDeflection;
|
||||||
|
|
||||||
|
if (HasUVNodes())
|
||||||
|
aCopy->myUVNodes = myUVNodes;
|
||||||
|
|
||||||
|
if (HasNormals()) {
|
||||||
|
aCopy->myNormals.Resize (1, myNodes.Size(), Standard_False);
|
||||||
aCopy->myNormals = myNormals;
|
aCopy->myNormals = myNormals;
|
||||||
|
}
|
||||||
|
|
||||||
return aCopy;
|
return aCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,23 +159,22 @@ Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTri
|
|||||||
myHasUVNodes (theTriangulation->myHasUVNodes)
|
myHasUVNodes (theTriangulation->myHasUVNodes)
|
||||||
{
|
{
|
||||||
SetCachedMinMax (theTriangulation->CachedMinMax());
|
SetCachedMinMax (theTriangulation->CachedMinMax());
|
||||||
myNodes.Assign(theTriangulation->myNodes);
|
|
||||||
|
// Re-allocate the arrays.
|
||||||
|
myNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
|
||||||
if (myHasUVNodes)
|
if (myHasUVNodes)
|
||||||
{
|
myUVNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
|
||||||
myUVNodes.Assign(theTriangulation->myUVNodes);
|
myTriangles.Resize (1, theTriangulation->NbTriangles(), Standard_False);
|
||||||
}
|
if (theTriangulation->HasNormals())
|
||||||
myTriangles.Assign(theTriangulation->myTriangles);
|
myNormals.Resize (1, theTriangulation->NbNodes(), Standard_False);
|
||||||
myNormals.Assign(theTriangulation->myNormals);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
// Copy data.
|
||||||
//function : Deflection
|
myNodes = theTriangulation->myNodes;
|
||||||
//purpose :
|
if (myHasUVNodes)
|
||||||
//=======================================================================
|
myUVNodes = theTriangulation->myUVNodes;
|
||||||
|
myTriangles = theTriangulation->myTriangles;
|
||||||
void Poly_Triangulation::Deflection (const Standard_Real theDeflection)
|
if (theTriangulation->HasNormals())
|
||||||
{
|
myNormals = theTriangulation->myNormals;
|
||||||
myDeflection = theDeflection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -188,127 +184,10 @@ void Poly_Triangulation::Deflection (const Standard_Real theDeflection)
|
|||||||
|
|
||||||
void Poly_Triangulation::RemoveUVNodes()
|
void Poly_Triangulation::RemoveUVNodes()
|
||||||
{
|
{
|
||||||
myUVNodes.Clear();
|
myUVNodes = TColgp_Array1OfPnt2d();
|
||||||
myHasUVNodes = Standard_False;
|
myHasUVNodes = Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AddNode
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Integer Poly_Triangulation::AddNode (const gp_Pnt& theNode)
|
|
||||||
{
|
|
||||||
myNodes.Append (theNode);
|
|
||||||
|
|
||||||
if (myHasUVNodes)
|
|
||||||
{
|
|
||||||
myUVNodes.Append (gp_Pnt2d());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!myNormals.IsEmpty())
|
|
||||||
{
|
|
||||||
Standard_Integer aNbNormals = myNodes.Size();
|
|
||||||
myNormals.SetValue (aNbNormals, gp_Dir());
|
|
||||||
}
|
|
||||||
|
|
||||||
return myNodes.Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//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 - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//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 - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : UVNode
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
|
|
||||||
{
|
|
||||||
throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
|
|
||||||
}
|
|
||||||
return myUVNodes.Value (theIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : ChangeUVNode
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
|
|
||||||
{
|
|
||||||
if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
|
|
||||||
{
|
|
||||||
throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
|
|
||||||
}
|
|
||||||
return myUVNodes.ChangeValue (theIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Triangle
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
Standard_Integer Poly_Triangulation::AddTriangle (const Poly_Triangle& theTriangle)
|
|
||||||
{
|
|
||||||
myTriangles.Append (theTriangle);
|
|
||||||
return myTriangles.Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//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 - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//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 - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetNormals
|
//function : SetNormals
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -322,64 +201,47 @@ void Poly_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& th
|
|||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer anArrayLower = theNormals->Lower();
|
Standard_Integer anArrayLower = theNormals->Lower();
|
||||||
Standard_Integer anArrayInd;
|
for (Standard_Integer anIndex = 1; anIndex >= NbNodes(); anIndex--)
|
||||||
for (Standard_Integer anIndex = NbNodes() - 1; anIndex >= 0; anIndex--)
|
|
||||||
{
|
{
|
||||||
anArrayInd = anArrayLower + anIndex * 3;
|
Standard_Integer anArrayInd = anArrayLower + (anIndex - 1) * 3;
|
||||||
gp_Dir aNormal(theNormals->Value(anArrayInd),
|
SetNormal (anIndex, theNormals->Value(anArrayInd),
|
||||||
theNormals->Value(anArrayInd),
|
theNormals->Value(anArrayInd + 1),
|
||||||
theNormals->Value(anArrayInd));
|
theNormals->Value(anArrayInd + 2));
|
||||||
myNormals.SetValue (anIndex, aNormal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
//function : SetNormal
|
// function : ResizeNodes
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
|
||||||
void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
|
void Poly_Triangulation::ResizeNodes (const Standard_Integer theNbNodes)
|
||||||
{
|
{
|
||||||
|
if (theNbNodes > 0) {
|
||||||
if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size()) {
|
myNodes.Resize (1, theNbNodes, Standard_True);
|
||||||
throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
|
if (myHasUVNodes)
|
||||||
"wrong length or null array");
|
myUVNodes.Resize (1, theNbNodes, Standard_True);
|
||||||
|
if (HasNormals())
|
||||||
|
myNormals.Resize (1, theNbNodes, Standard_True);
|
||||||
}
|
}
|
||||||
|
|
||||||
myNormals.ChangeValue (theIndex - 1) = theNormal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
//function : HasNormals
|
// function : ResizeTriangles
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
|
||||||
Standard_Boolean Poly_Triangulation::HasNormals() const
|
void Poly_Triangulation::ResizeTriangles (const Standard_Integer theNbTriangles)
|
||||||
{
|
{
|
||||||
if (myNormals.IsEmpty() || myNormals.Length() != NbNodes()) {
|
if (theNbTriangles > 0)
|
||||||
return Standard_False;
|
myTriangles.Resize (1, theNbTriangles, Standard_True);
|
||||||
}
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Normal
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
const gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size())
|
|
||||||
{
|
|
||||||
throw Standard_NullObject ("Poly_Triangulation::Normal : empty array or index out of range");
|
|
||||||
}
|
|
||||||
return myNormals (theIndex - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : DumpJson
|
// function : DumpJson
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
|
||||||
void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
|
||||||
{
|
{
|
||||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||||
|
@@ -20,19 +20,12 @@
|
|||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_DefineHandle.hxx>
|
#include <Standard_DefineHandle.hxx>
|
||||||
#include <Standard_Real.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
#include <TColgp_Array1OfPnt.hxx>
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
#include <TColgp_HArray1OfPnt2d.hxx>
|
#include <TColgp_HArray1OfPnt2d.hxx>
|
||||||
#include <Poly_Array1OfTriangle.hxx>
|
#include <Poly_Array1OfTriangle.hxx>
|
||||||
#include <TShort_HArray1OfShortReal.hxx>
|
#include <TShort_HArray1OfShortReal.hxx>
|
||||||
#include <Standard_Transient.hxx>
|
|
||||||
#include <Standard_Boolean.hxx>
|
typedef NCollection_Vec3 <Standard_ShortReal> Vec3f;
|
||||||
#include <TColgp_Array1OfPnt2d.hxx>
|
|
||||||
#include <TShort_Array1OfShortReal.hxx>
|
|
||||||
#include <NCollection_Vector.hxx>
|
|
||||||
class Standard_DomainError;
|
|
||||||
class Standard_NullObject;
|
|
||||||
|
|
||||||
//! Provides a triangulation for a surface, a set of surfaces, or more generally a shape.
|
//! 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.
|
//! A triangulation consists of an approximate representation of the actual shape, using a collection of points and triangles.
|
||||||
@@ -63,7 +56,7 @@ public:
|
|||||||
//! triangles. Here the UVNodes flag indicates whether
|
//! triangles. Here the UVNodes flag indicates whether
|
||||||
//! 2D nodes will be associated with 3D ones, (i.e. to
|
//! 2D nodes will be associated with 3D ones, (i.e. to
|
||||||
//! enable a 2D representation).
|
//! 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.
|
//! Constructs a triangulation from a set of triangles.
|
||||||
//! The triangulation is initialized without a triangle or a node,
|
//! The triangulation is initialized without a triangle or a node,
|
||||||
@@ -73,7 +66,7 @@ public:
|
|||||||
//! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
|
//! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
|
||||||
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
|
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
|
||||||
const Standard_Integer nbTriangles,
|
const Standard_Integer nbTriangles,
|
||||||
const Standard_Boolean UVNodes,
|
const Standard_Boolean hasUVNodes,
|
||||||
const Standard_Boolean hasNormals);
|
const Standard_Boolean hasNormals);
|
||||||
|
|
||||||
//! Constructs a triangulation from a set of triangles. The
|
//! Constructs a triangulation from a set of triangles. The
|
||||||
@@ -100,59 +93,138 @@ public:
|
|||||||
Standard_EXPORT Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation);
|
Standard_EXPORT Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation);
|
||||||
|
|
||||||
//! Returns the deflection of this triangulation.
|
//! 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.
|
//! Sets the deflection of this triangulation to theDeflection.
|
||||||
//! See more on deflection in Polygon2D
|
//! 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.
|
//! Deallocates the UV nodes.
|
||||||
Standard_EXPORT void RemoveUVNodes();
|
Standard_EXPORT void RemoveUVNodes();
|
||||||
|
|
||||||
//! Returns TRUE if triangulation has some geometry.
|
//! 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();
|
||||||
|
}
|
||||||
|
|
||||||
//! @return the number of nodes for this triangulation.
|
//! Returns the number of nodes for this triangulation.
|
||||||
Standard_Integer NbNodes() const { return myNodes.Size(); }
|
Standard_Integer NbNodes() const {
|
||||||
|
return myNodes.Size();
|
||||||
|
}
|
||||||
|
|
||||||
//! @return the number of triangles for this triangulation.
|
//! Returns the number of triangles for this triangulation.
|
||||||
Standard_Integer NbTriangles() const { return myTriangles.Size(); }
|
Standard_Integer NbTriangles() const {
|
||||||
|
return myTriangles.Size();
|
||||||
|
}
|
||||||
|
|
||||||
//! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
|
//! Sets a node coordinates.
|
||||||
Standard_Boolean HasUVNodes() const { return myHasUVNodes; }
|
void SetNode (const Standard_Integer theIndex,
|
||||||
|
const gp_Pnt& thePnt)
|
||||||
|
{
|
||||||
|
myNodes.SetValue (theIndex, thePnt);
|
||||||
|
}
|
||||||
|
|
||||||
//! Adds Node to the triangulation. If triangulation has UVNodes or Normals
|
//! Returns a node at the given index.
|
||||||
//! they will be expanded and set to zero values to match the new number of nodes.
|
const gp_Pnt& Node (const Standard_Integer theIndex) const {
|
||||||
//! @return index of the added Node.
|
return myNodes.Value (theIndex);
|
||||||
Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
|
}
|
||||||
|
|
||||||
//! @return node at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
|
||||||
Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
|
|
||||||
|
|
||||||
//! Give access to the node at the given index.
|
//! Give access to the node at the given index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
gp_Pnt& ChangeNode (const Standard_Integer theIndex) {
|
||||||
Standard_EXPORT gp_Pnt& ChangeNode (const Standard_Integer theIndex);
|
return myNodes.ChangeValue (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//! @return UVNode at the given index.
|
//! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
Standard_Boolean HasUVNodes() const {
|
||||||
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
|
return myHasUVNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sets an UV-node coordinates.
|
||||||
|
void SetUVNode (const Standard_Integer theIndex,
|
||||||
|
const gp_Pnt2d& thePnt)
|
||||||
|
{
|
||||||
|
myUVNodes.SetValue (theIndex, thePnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! 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.
|
//! Give access to the UVNode at the given index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex) {
|
||||||
Standard_EXPORT gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex);
|
return myUVNodes.ChangeValue (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//! Adds triangle to the triangulation.
|
//! Sets a triangle.
|
||||||
//! @return index of the added triangle.
|
void SetTriangle (const Standard_Integer theIndex,
|
||||||
Standard_EXPORT virtual Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
|
const Poly_Triangle& theTriangle)
|
||||||
|
{
|
||||||
|
myTriangles.SetValue (theIndex, theTriangle);
|
||||||
|
}
|
||||||
|
|
||||||
//! @return triangle at the given index.
|
//! Returns triangle at the given index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
|
const Poly_Triangle& Triangle (const Standard_Integer theIndex) const {
|
||||||
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
|
return myTriangles.Value (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//! Give access to the triangle at the given index.
|
//! Give access to the triangle at the given index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
|
//! Raises an exception if theIndex is less than 1 or greater than number of triangles.
|
||||||
Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
|
Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex) {
|
||||||
|
return myTriangles.ChangeValue (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns Standard_True if nodal normals are defined.
|
||||||
|
Standard_Boolean HasNormals() const {
|
||||||
|
return !myNormals.IsEmpty() && myNormals.Length() == NbNodes();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! 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);
|
||||||
|
|
||||||
|
// Set a normal.
|
||||||
|
myNormals.ChangeValue (theIndex) = theNormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! 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.
|
||||||
|
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.
|
//! Sets the table of node normals.
|
||||||
//! Raises exception if length of theNormals != 3 * NbNodes
|
//! Raises exception if length of theNormals != 3 * NbNodes
|
||||||
@@ -161,17 +233,14 @@ public:
|
|||||||
Array of floats should be replaced by vector of normals")
|
Array of floats should be replaced by vector of normals")
|
||||||
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
|
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
|
||||||
|
|
||||||
//! Changes normal at the given index.
|
//! An advanced method resizing an internal array of nodes.
|
||||||
//! Raises Standard_OutOfRange exception.
|
//! The old nodes are copied into the new array.
|
||||||
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
//! UV-nodes as well as normals, if exist are extended and copied too.
|
||||||
const gp_Dir& theNormal);
|
Standard_EXPORT void ResizeNodes (const Standard_Integer theNbNodes);
|
||||||
|
|
||||||
//! Returns Standard_True if nodal normals are defined.
|
//! An advanced method resizing an internal array of triangles.
|
||||||
Standard_EXPORT Standard_Boolean HasNormals() const;
|
//! The old triangles are copied into the new array.
|
||||||
|
Standard_EXPORT void ResizeTriangles (const Standard_Integer theNbTriangles);
|
||||||
//! @return normal at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception.
|
|
||||||
Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
|
|
||||||
|
|
||||||
//! Returns cached min - max range of triangulation data,
|
//! Returns cached min - max range of triangulation data,
|
||||||
//! which is VOID by default (e.g, no cached information).
|
//! which is VOID by default (e.g, no cached information).
|
||||||
@@ -223,11 +292,10 @@ protected:
|
|||||||
Bnd_Box* myCachedMinMax;
|
Bnd_Box* myCachedMinMax;
|
||||||
Standard_Real myDeflection;
|
Standard_Real myDeflection;
|
||||||
Standard_Boolean myHasUVNodes;
|
Standard_Boolean myHasUVNodes;
|
||||||
NCollection_Vector<gp_Pnt> myNodes;
|
TColgp_Array1OfPnt myNodes;
|
||||||
NCollection_Vector<gp_Pnt2d> myUVNodes;
|
TColgp_Array1OfPnt2d myUVNodes;
|
||||||
NCollection_Vector<Poly_Triangle> myTriangles;
|
Poly_Array1OfTriangle myTriangles;
|
||||||
NCollection_Vector<gp_Dir> myNormals;
|
NCollection_Array1<Vec3f> myNormals;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _Poly_Triangulation_HeaderFile
|
#endif // _Poly_Triangulation_HeaderFile
|
||||||
|
@@ -4038,7 +4038,8 @@ static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theA
|
|||||||
for( int i=0; i < aVertexNb; i++ )
|
for( int i=0; i < aVertexNb; i++ )
|
||||||
{
|
{
|
||||||
gp_Pnt aPoint = aT->Node ( i+1 );
|
gp_Pnt aPoint = aT->Node ( i+1 );
|
||||||
gp_Dir aNormal = aT->Normal ( 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)
|
if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
|
||||||
{
|
{
|
||||||
|
@@ -333,11 +333,11 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
|
|||||||
if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
|
if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
|
||||||
{
|
{
|
||||||
myCoordSysConverter.TransformNormal (*aVec3);
|
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
|
else
|
||||||
{
|
{
|
||||||
setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
|
setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,11 +353,11 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
|
|||||||
}
|
}
|
||||||
if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
|
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
|
else
|
||||||
{
|
{
|
||||||
setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
|
setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,14 +52,8 @@ protected: //! @name interface for filling triangulation data
|
|||||||
//! Resize array of position nodes to specified size.
|
//! Resize array of position nodes to specified size.
|
||||||
virtual bool setNbPositionNodes (Standard_Integer theNbNodes)
|
virtual bool setNbPositionNodes (Standard_Integer theNbNodes)
|
||||||
{
|
{
|
||||||
if (theNbNodes <= 0)
|
myTriangulation->ResizeNodes (theNbNodes);
|
||||||
{
|
return theNbNodes > 0;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Standard_Integer i = myTriangulation->NbNodes();
|
|
||||||
while (++i <= theNbNodes)
|
|
||||||
myTriangulation->AddNode (gp::Origin());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set node position.
|
//! Set node position.
|
||||||
@@ -72,15 +66,9 @@ protected: //! @name interface for filling triangulation data
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Resize array of UV nodes to specified size.
|
//! Resize array of UV nodes to specified size.
|
||||||
virtual bool setNbUVNodes (Standard_Integer theNbNodes)
|
virtual bool setNbUVNodes (Standard_Integer /*theNbNodes*/)
|
||||||
{
|
{
|
||||||
if (theNbNodes <= 0
|
// Resizing of the array of nodes extends an array of UV-nodes too.
|
||||||
|| myTriangulation->NbNodes() != theNbNodes)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resizing of the array of nodes extends the array of UV-nodes too.
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +82,9 @@ protected: //! @name interface for filling triangulation data
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Resize array of nodes normals to specified size.
|
//! Resize array of nodes normals to specified size.
|
||||||
virtual bool setNbNormalNodes (Standard_Integer theNbNodes)
|
virtual bool setNbNormalNodes (Standard_Integer /*theNbNodes*/)
|
||||||
{
|
{
|
||||||
if (theNbNodes <= 0
|
// Resizing of the array of nodes extends an array of normals too.
|
||||||
|| myTriangulation->NbNodes() != theNbNodes)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
myTriangulation->SetNormals (new TShort_HArray1OfShortReal (1, theNbNodes * 3));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +92,7 @@ protected: //! @name interface for filling triangulation data
|
|||||||
//! @param theIndex node index starting from 1
|
//! @param theIndex node index starting from 1
|
||||||
//! @param theNormal node normal
|
//! @param theNormal node normal
|
||||||
virtual void setNodeNormal (Standard_Integer theIndex,
|
virtual void setNodeNormal (Standard_Integer theIndex,
|
||||||
const gp_Dir& theNormal)
|
const gp_XYZ& theNormal)
|
||||||
{
|
{
|
||||||
myTriangulation->SetNormal (theIndex, theNormal);
|
myTriangulation->SetNormal (theIndex, theNormal);
|
||||||
}
|
}
|
||||||
@@ -117,15 +100,8 @@ protected: //! @name interface for filling triangulation data
|
|||||||
//! Resize array of triangles to specified size.
|
//! Resize array of triangles to specified size.
|
||||||
virtual bool setNbTriangles (Standard_Integer theNbTris)
|
virtual bool setNbTriangles (Standard_Integer theNbTris)
|
||||||
{
|
{
|
||||||
if (theNbTris >= 1)
|
myTriangulation->ResizeTriangles (theNbTris);
|
||||||
{
|
return theNbTris > 0;
|
||||||
Poly_Triangle emptyTri (0, 0, 0);
|
|
||||||
Standard_Integer i = myTriangulation->NbTriangles();
|
|
||||||
while (++i <= theNbTris)
|
|
||||||
myTriangulation->AddTriangle (emptyTri);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Add triangle element.
|
//! Add triangle element.
|
||||||
|
@@ -132,7 +132,8 @@ gp_Dir RWMesh_FaceIterator::normal (Standard_Integer theNode)
|
|||||||
gp_Dir aNormal (gp::DZ());
|
gp_Dir aNormal (gp::DZ());
|
||||||
if (myPolyTriang->HasNormals())
|
if (myPolyTriang->HasNormals())
|
||||||
{
|
{
|
||||||
aNormal = myPolyTriang->Normal (theNode);
|
const Vec3f& aVec = myPolyTriang->Normal (theNode);
|
||||||
|
aNormal.SetCoord (aVec.x(), aVec.y(), aVec.z());
|
||||||
if (aNormal.XYZ().Modulus() < Precision::Confusion())
|
if (aNormal.XYZ().Modulus() < Precision::Confusion())
|
||||||
aNormal = gp::DZ();
|
aNormal = gp::DZ();
|
||||||
}
|
}
|
||||||
|
@@ -167,30 +167,19 @@ Handle(Poly_Triangulation) RWObj_TriangulationReader::GetTriangulation()
|
|||||||
}
|
}
|
||||||
if (hasNormals)
|
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)
|
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
|
||||||
{
|
{
|
||||||
const Graphic3d_Vec3& aNorm = myNormals.Value (aNodeIter);
|
const Graphic3d_Vec3& aNorm = myNormals.Value (aNodeIter);
|
||||||
const float aMod2 = aNorm.SquareModulus();
|
const float aMod2 = aNorm.SquareModulus();
|
||||||
if (aMod2 > 0.001f)
|
if (aMod2 > 0.001f)
|
||||||
{
|
{
|
||||||
aNormArr[aNodeIter * 3 + 0] = aNorm.x();
|
aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
|
||||||
aNormArr[aNodeIter * 3 + 1] = aNorm.y();
|
|
||||||
aNormArr[aNodeIter * 3 + 2] = aNorm.z();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++aNbInvalid;
|
aPoly->SetNormal (aNodeIter + 1, 0.0f, 0.0f, 1.0f);
|
||||||
aNormArr[aNodeIter * 3 + 0] = 0.0f;
|
|
||||||
aNormArr[aNodeIter * 3 + 1] = 0.0f;
|
|
||||||
aNormArr[aNodeIter * 3 + 2] = 1.0f;
|
|
||||||
}
|
}
|
||||||
}
|
aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
|
||||||
if (aNbInvalid != myNodes.Length())
|
|
||||||
{
|
|
||||||
aPoly->SetNormals (aNormals);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -157,7 +157,6 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Standard_Real aTol = Precision::Confusion();
|
const Standard_Real aTol = Precision::Confusion();
|
||||||
Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, theTris->NbNodes() * 3);
|
|
||||||
Standard_Integer aTri[3];
|
Standard_Integer aTri[3];
|
||||||
gp_Dir aNorm;
|
gp_Dir aNorm;
|
||||||
for (Standard_Integer aNodeIter = 1; aNodeIter <= theTris->NbNodes(); ++aNodeIter)
|
for (Standard_Integer aNodeIter = 1; aNodeIter <= theTris->NbNodes(); ++aNodeIter)
|
||||||
@@ -187,13 +186,10 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
|
|||||||
const Standard_Real aModMax = eqPlan.Modulus();
|
const Standard_Real aModMax = eqPlan.Modulus();
|
||||||
aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
|
aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
|
||||||
}
|
}
|
||||||
|
theTris->SetNormal (aNodeIter, static_cast<Standard_ShortReal>(aNorm.X()),
|
||||||
const Standard_Integer anId = (aNodeIter - 1) * 3;
|
static_cast<Standard_ShortReal>(aNorm.Y()),
|
||||||
aNormals->SetValue (anId + 1, (Standard_ShortReal )aNorm.X());
|
static_cast<Standard_ShortReal>(aNorm.Z()));
|
||||||
aNormals->SetValue (anId + 2, (Standard_ShortReal )aNorm.Y());
|
|
||||||
aNormals->SetValue (anId + 3, (Standard_ShortReal )aNorm.Z());
|
|
||||||
}
|
}
|
||||||
theTris->SetNormals (aNormals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -212,7 +208,8 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace,
|
|||||||
|
|
||||||
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
|
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
|
||||||
{
|
{
|
||||||
theNormals.ChangeValue (aNodeIter) = aPolyTri->Normal (aNodeIter);
|
const Vec3f& aNormal = aPolyTri->Normal (aNodeIter);
|
||||||
|
theNormals.ChangeValue (aNodeIter).SetCoord (aNormal.x(), aNormal.y(), aNormal.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theFace.Orientation() == TopAbs_REVERSED)
|
if (theFace.Orientation() == TopAbs_REVERSED)
|
||||||
|
@@ -167,6 +167,15 @@ Standard_Integer TDataXtd_SurfacicMesh::NbTriangles() const
|
|||||||
return myMesh->NbTriangles();
|
return myMesh->NbTriangles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbQuads
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer TDataXtd_SurfacicMesh::NbQuads() const
|
||||||
|
{
|
||||||
|
return myMesh->NbQuads();
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : HasUVNodes
|
//function : HasUVNodes
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -177,13 +186,13 @@ Standard_Boolean TDataXtd_SurfacicMesh::HasUVNodes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AddNode
|
//function : SetNode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::AddNode (const gp_Pnt& theNode)
|
void TDataXtd_SurfacicMesh::SetNode (const Standard_Integer& theIndex, const gp_Pnt& theNode)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
return myMesh->AddNode (theNode);
|
myMesh->ChangeNode (theIndex) = theNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -195,25 +204,6 @@ const gp_Pnt& TDataXtd_SurfacicMesh::Node (const Standard_Integer theIndex) cons
|
|||||||
return myMesh->Node (theIndex);
|
return myMesh->Node (theIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetNode
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void TDataXtd_SurfacicMesh::SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode)
|
|
||||||
{
|
|
||||||
Backup();
|
|
||||||
myMesh->ChangeNode (theIndex) = theNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : UVNode
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const gp_Pnt2d& TDataXtd_SurfacicMesh::UVNode (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
return myMesh->UVNode (theIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetUVNode
|
//function : SetUVNode
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -225,22 +215,12 @@ void TDataXtd_SurfacicMesh::SetUVNode (const Standard_Integer theIndex, const gp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AddTriangle
|
//function : UVNode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::AddTriangle (const Poly_Triangle& theTriangle)
|
const gp_Pnt2d& TDataXtd_SurfacicMesh::UVNode (const Standard_Integer theIndex) const
|
||||||
{
|
{
|
||||||
Backup();
|
return myMesh->UVNode (theIndex);
|
||||||
return myMesh->AddTriangle (theTriangle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Triangle
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const Poly_Triangle& TDataXtd_SurfacicMesh::Triangle (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
return myMesh->Triangle (theIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -254,14 +234,31 @@ void TDataXtd_SurfacicMesh::SetTriangle (const Standard_Integer theIndex, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetNormal
|
//function : Triangle
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TDataXtd_SurfacicMesh::SetNormal (const Standard_Integer theIndex,
|
const Poly_Triangle& TDataXtd_SurfacicMesh::Triangle(const Standard_Integer theIndex) const
|
||||||
const gp_Dir& theNormal)
|
{
|
||||||
|
return myMesh->Triangle (theIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetQuad
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void TDataXtd_SurfacicMesh::SetQuad (const Standard_Integer theIndex, const Poly_Quad& theQuad)
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myMesh->SetNormal (theIndex, theNormal);
|
myMesh->ChangeQuad (theIndex) = theQuad;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Quad
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Poly_Quad& TDataXtd_SurfacicMesh::Quad (const Standard_Integer theIndex) const
|
||||||
|
{
|
||||||
|
return myMesh->Quad (theIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -273,90 +270,39 @@ Standard_Boolean TDataXtd_SurfacicMesh::HasNormals() const
|
|||||||
return myMesh->HasNormals();
|
return myMesh->HasNormals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNormal
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void TDataXtd_SurfacicMesh::SetNormal (const Standard_Integer theIndex,
|
||||||
|
const gp_XYZ& theNormal)
|
||||||
|
{
|
||||||
|
Backup();
|
||||||
|
myMesh->SetNormal (theIndex, theNormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNormal
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void TDataXtd_SurfacicMesh::SetNormal (const Standard_Integer theIndex,
|
||||||
|
const Standard_ShortReal theNormalX,
|
||||||
|
const Standard_ShortReal theNormalY,
|
||||||
|
const Standard_ShortReal theNormalZ)
|
||||||
|
{
|
||||||
|
Backup();
|
||||||
|
myMesh->SetNormal (theIndex, theNormalX, theNormalY, theNormalZ);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Normal
|
//function : Normal
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
const gp_Dir TDataXtd_SurfacicMesh::Normal (const Standard_Integer theIndex) const
|
const Vec3f& TDataXtd_SurfacicMesh::Normal (const Standard_Integer theIndex) const
|
||||||
{
|
{
|
||||||
return myMesh->Normal (theIndex);
|
return myMesh->Normal (theIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AddElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3)
|
|
||||||
{
|
|
||||||
Backup();
|
|
||||||
return myMesh->AddElement (theN1, theN2, theN3);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AddElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3,
|
|
||||||
const Standard_Integer theN4)
|
|
||||||
{
|
|
||||||
Backup();
|
|
||||||
return myMesh->AddElement (theN1, theN2, theN3, theN4);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : NbElements
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::NbElements() const
|
|
||||||
{
|
|
||||||
return myMesh->NbElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : NbQuads
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Integer TDataXtd_SurfacicMesh::NbQuads() const
|
|
||||||
{
|
|
||||||
return myMesh->NbQuads();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const Poly_Element& TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
return myMesh->Element (theIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Element
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex,
|
|
||||||
Standard_Integer& theN1,
|
|
||||||
Standard_Integer& theN2,
|
|
||||||
Standard_Integer& theN3,
|
|
||||||
Standard_Integer& theN4) const
|
|
||||||
{
|
|
||||||
myMesh->Element (theIndex, theN1, theN2, theN3, theN4);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetElement
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void TDataXtd_SurfacicMesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
|
|
||||||
{
|
|
||||||
Backup();
|
|
||||||
myMesh->SetElement (theIndex, theElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetID
|
//function : SetID
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -444,6 +390,7 @@ Standard_OStream& TDataXtd_SurfacicMesh::Dump (Standard_OStream& theOS) const
|
|||||||
theOS << "\n\tDeflection: " << myMesh->Deflection();
|
theOS << "\n\tDeflection: " << myMesh->Deflection();
|
||||||
theOS << "\n\tNodes: " << myMesh->NbNodes();
|
theOS << "\n\tNodes: " << myMesh->NbNodes();
|
||||||
theOS << "\n\tTriangles: " << myMesh->NbTriangles();
|
theOS << "\n\tTriangles: " << myMesh->NbTriangles();
|
||||||
|
theOS << "\n\tQuadrangles: " << myMesh->NbQuads();
|
||||||
if (myMesh->HasUVNodes())
|
if (myMesh->HasUVNodes())
|
||||||
theOS << "\n\tHas UV-Nodes";
|
theOS << "\n\tHas UV-Nodes";
|
||||||
else
|
else
|
||||||
|
@@ -33,10 +33,7 @@ class TDataXtd_SurfacicMesh;
|
|||||||
DEFINE_STANDARD_HANDLE(TDataXtd_SurfacicMesh, TDF_Attribute)
|
DEFINE_STANDARD_HANDLE(TDataXtd_SurfacicMesh, TDF_Attribute)
|
||||||
|
|
||||||
//! An Ocaf attribute containing a mesh (Poly_Mesh).
|
//! An Ocaf attribute containing a mesh (Poly_Mesh).
|
||||||
//! It duplicates all methods from Poly_Mesh (and Poly_Triangulation).
|
//! It includes all methods of Poly_Mesh (and Poly_Triangulation).
|
||||||
//! It is highly recommended to modify the mesh through the methods of this attribute,
|
|
||||||
//! but not directly via the underlying Poly_Mesh object.
|
|
||||||
//! In this case Undo/Redo will work fine and robust.
|
|
||||||
class TDataXtd_SurfacicMesh : public TDF_Attribute
|
class TDataXtd_SurfacicMesh : public TDF_Attribute
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -96,117 +93,70 @@ public:
|
|||||||
// =================
|
// =================
|
||||||
|
|
||||||
//! The methods are "covered" by this attribute to prevent direct modification of the mesh.
|
//! The methods are "covered" by this attribute to prevent direct modification of the mesh.
|
||||||
//! There is no performance problem to call Poly_Mesh method through this attribute.
|
|
||||||
//! The most of the methods are considered as "inline" by the compiler in release mode.
|
|
||||||
|
|
||||||
//! Returns the deflection of this triangulation.
|
//! Returns the deflection of this triangulation.
|
||||||
Standard_EXPORT Standard_Real Deflection() const;
|
Standard_EXPORT Standard_Real Deflection() const;
|
||||||
|
|
||||||
//! Sets the deflection of this triangulation to theDeflection.
|
//! Sets the deflection of this mesh to theDeflection.
|
||||||
//! See more on deflection in Polygon2D
|
|
||||||
Standard_EXPORT void Deflection (const Standard_Real theDeflection);
|
Standard_EXPORT void Deflection (const Standard_Real theDeflection);
|
||||||
|
|
||||||
//! Deallocates the UV nodes.
|
//! Deallocates the UV nodes.
|
||||||
Standard_EXPORT void RemoveUVNodes();
|
Standard_EXPORT void RemoveUVNodes();
|
||||||
|
|
||||||
//! @return the number of nodes for this triangulation.
|
//! @return the number of nodes for this mesh.
|
||||||
Standard_EXPORT Standard_Integer NbNodes() const;
|
Standard_EXPORT Standard_Integer NbNodes() const;
|
||||||
|
|
||||||
//! @return the number of triangles for this triangulation.
|
//! @return the number of triangles for this mesh.
|
||||||
Standard_EXPORT Standard_Integer NbTriangles() const;
|
Standard_EXPORT Standard_Integer NbTriangles() const;
|
||||||
|
|
||||||
//! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
|
//! @return the number of quadrangles for this mesh.
|
||||||
|
Standard_EXPORT Standard_Integer NbQuads() const;
|
||||||
|
|
||||||
|
//! @return Standard_True if 2D nodes are associated with 3D nodes for this mesh.
|
||||||
Standard_EXPORT Standard_Boolean HasUVNodes() const;
|
Standard_EXPORT Standard_Boolean HasUVNodes() const;
|
||||||
|
|
||||||
//! Adds Node to the triangulation. If triangulation has UVNodes or Normals
|
//! Sets a node by index.
|
||||||
//! they will be expanded and set to zero values to match the new number of nodes.
|
Standard_EXPORT void SetNode (const Standard_Integer& theIndex, const gp_Pnt& theNode);
|
||||||
//! @return index of the added Node.
|
|
||||||
Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
|
|
||||||
|
|
||||||
//! @return node at the given index.
|
//! Returns a node by 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;
|
Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
|
||||||
|
|
||||||
//! The method differs from Poly_Mesh!
|
//! Sets a UV-node by index.
|
||||||
//! Sets a node at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
|
||||||
Standard_EXPORT void SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode);
|
|
||||||
|
|
||||||
//! @return UVNode at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
|
||||||
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
|
|
||||||
|
|
||||||
//! The method differs from Poly_Mesh!
|
|
||||||
//! Sets a UVNode at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
|
|
||||||
Standard_EXPORT void SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode);
|
Standard_EXPORT void SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode);
|
||||||
|
|
||||||
//! Adds triangle to the triangulation.
|
//! Returns an UV-node by index.
|
||||||
//! @return index of the added triangle.
|
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
|
||||||
Standard_EXPORT Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
|
|
||||||
|
|
||||||
//! @return triangle at the given index.
|
//! Sets a triangle by index.
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
|
|
||||||
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
|
|
||||||
|
|
||||||
//! The method differs from Poly_Mesh!
|
|
||||||
//! Sets a triangle at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
|
|
||||||
Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
|
Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
|
||||||
|
|
||||||
//! Changes normal at the given index.
|
//! Returns a triangle by index.
|
||||||
//! Raises Standard_OutOfRange exception.
|
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
|
||||||
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
|
||||||
const gp_Dir& theNormal);
|
//! Sets a quadrangle by index.
|
||||||
|
Standard_EXPORT void SetQuad (const Standard_Integer theIndex, const Poly_Quad& theQuad);
|
||||||
|
|
||||||
|
//! Returns a quadrangle by index.
|
||||||
|
Standard_EXPORT const Poly_Quad& Quad (const Standard_Integer theIndex) const;
|
||||||
|
|
||||||
//! Returns Standard_True if nodal normals are defined.
|
//! Returns Standard_True if nodal normals are defined.
|
||||||
Standard_EXPORT Standard_Boolean HasNormals() const;
|
Standard_EXPORT Standard_Boolean HasNormals() const;
|
||||||
|
|
||||||
//! @return normal at the given index.
|
//! Sets normal by index.
|
||||||
//! Raises Standard_OutOfRange exception.
|
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
||||||
Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
|
const gp_XYZ& theNormal);
|
||||||
|
|
||||||
//! Adds element to the mesh.
|
//! Sets normal by index.
|
||||||
//! @param theN1 index of the first node.
|
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
||||||
//! @param theN2 index of the second node.
|
const Standard_ShortReal theNormalX,
|
||||||
//! @param theN3 index of the third node.
|
const Standard_ShortReal theNormalY,
|
||||||
//! @return index of the added element.
|
const Standard_ShortReal theNormalZ);
|
||||||
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3);
|
|
||||||
|
|
||||||
//! Adds element to the mesh.
|
//! Returns normal by index.
|
||||||
//! @param theN1 index of the first node.
|
Standard_EXPORT const Vec3f& Normal(const Standard_Integer theIndex) const;
|
||||||
//! @param theN2 index of the second node.
|
|
||||||
//! @param theN3 index of the third node.
|
|
||||||
//! @param theN4 index of the fourth node.
|
|
||||||
//! @return index of the added element.
|
|
||||||
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
|
|
||||||
const Standard_Integer theN2,
|
|
||||||
const Standard_Integer theN3,
|
|
||||||
const Standard_Integer theN4);
|
|
||||||
|
|
||||||
//! @return the number of elements for this mesh.
|
//! Returns normal by index.
|
||||||
Standard_EXPORT Standard_Integer NbElements() const;
|
Standard_EXPORT void Normal(const Standard_Integer theIndex, gp_XYZ& theNormal) const;
|
||||||
|
|
||||||
//! @return the number of quads for this mesh.
|
|
||||||
Standard_EXPORT Standard_Integer NbQuads() const;
|
|
||||||
|
|
||||||
//! @return element at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
|
||||||
Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const;
|
|
||||||
|
|
||||||
//! @return nodes of the element at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
|
||||||
Standard_EXPORT void Element (const Standard_Integer theIndex,
|
|
||||||
Standard_Integer& theN1,
|
|
||||||
Standard_Integer& theN2,
|
|
||||||
Standard_Integer& theN3,
|
|
||||||
Standard_Integer& theN4) const;
|
|
||||||
|
|
||||||
//! Sets an element at the given index.
|
|
||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
|
|
||||||
Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement);
|
|
||||||
|
|
||||||
//! Dumps the content of me into the stream
|
//! Dumps the content of me into the stream
|
||||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||||
|
@@ -217,17 +217,6 @@ void TDataXtd_Triangulation::SetTriangle (const Standard_Integer theIndex, const
|
|||||||
myTriangulation->ChangeTriangle(theIndex) = theTriangle;
|
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
|
//function : SetNormal
|
||||||
//purpose : Changes normal at the given index.
|
//purpose : Changes normal at the given index.
|
||||||
@@ -237,7 +226,7 @@ void TDataXtd_Triangulation::SetNormal (const Standard_Integer theIndex,
|
|||||||
const gp_Dir& theNormal)
|
const gp_Dir& theNormal)
|
||||||
{
|
{
|
||||||
Backup();
|
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
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -123,10 +123,6 @@ public:
|
|||||||
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
|
//! 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);
|
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.
|
//! Changes normal at the given index.
|
||||||
//! Raises Standard_OutOfRange exception.
|
//! Raises Standard_OutOfRange exception.
|
||||||
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
|
||||||
|
@@ -2900,8 +2900,6 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
|
|||||||
|
|
||||||
Poly_Connect* pc = new Poly_Connect(polyTriangulation);
|
Poly_Connect* pc = new Poly_Connect(polyTriangulation);
|
||||||
|
|
||||||
Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
|
|
||||||
|
|
||||||
Standard_Integer index[3];
|
Standard_Integer index[3];
|
||||||
Standard_Real Tol = Precision::Confusion();
|
Standard_Real Tol = Precision::Confusion();
|
||||||
|
|
||||||
@@ -2925,15 +2923,10 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
|
|||||||
else
|
else
|
||||||
Nor = gp_Dir(0., 0., 1.);
|
Nor = gp_Dir(0., 0., 1.);
|
||||||
|
|
||||||
Standard_Integer j = (i - 1) * 3;
|
polyTriangulation->SetNormal (i, Nor.XYZ());
|
||||||
Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
|
|
||||||
Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
|
|
||||||
Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pc;
|
delete pc;
|
||||||
polyTriangulation->SetNormals(Normals);
|
|
||||||
|
|
||||||
return polyTriangulation;
|
return polyTriangulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -400,7 +400,8 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
|
|||||||
Standard_Integer j;
|
Standard_Integer j;
|
||||||
for (i = 0, j = 1; i < nNodes; i++, j += 3)
|
for (i = 0, j = 1; i < nNodes; i++, j += 3)
|
||||||
{
|
{
|
||||||
gp_XYZ aNormal = theTri->Normal (i + 1).XYZ();
|
const Vec3f& aVec = theTri->Normal (i + 1);
|
||||||
|
gp_XYZ aNormal (aVec.x(), aVec.y(), aVec.z());
|
||||||
if (isReverse)
|
if (isReverse)
|
||||||
{
|
{
|
||||||
aNormal.Reverse();
|
aNormal.Reverse();
|
||||||
@@ -466,17 +467,11 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
|
|||||||
aNormal.SetY(0.);
|
aNormal.SetY(0.);
|
||||||
if (aNormal.Z()*aNormal.Z() < aConf2)
|
if (aNormal.Z()*aNormal.Z() < aConf2)
|
||||||
aNormal.SetZ(0.);
|
aNormal.SetZ(0.);
|
||||||
|
|
||||||
arrVec[i] = aNormal.XYZ();
|
arrVec[i] = aNormal.XYZ();
|
||||||
|
theTri->SetNormal (i + 1, 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());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theTri->SetNormals(Normals);
|
|
||||||
|
|
||||||
const Handle(VrmlData_Normal) aNormalNode =
|
const Handle(VrmlData_Normal) aNormalNode =
|
||||||
new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
|
new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
|
||||||
myScene.AddNode (aNormalNode, Standard_False);
|
myScene.AddNode (aNormalNode, Standard_False);
|
||||||
|
@@ -110,7 +110,8 @@ void XmlMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSour
|
|||||||
Standard_Integer aSize = aMesh->NbNodes();
|
Standard_Integer aSize = aMesh->NbNodes();
|
||||||
aSize *= 3; // 3 coordinates for a node
|
aSize *= 3; // 3 coordinates for a node
|
||||||
aSize *= 8; // 8 characters are used to represent a coordinate (double) in XML
|
aSize *= 8; // 8 characters are used to represent a coordinate (double) in XML
|
||||||
aSize += 4 * 5 * aMesh->NbElements(); // space for elements (triangles and quadrangles)
|
aSize += 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 :-)
|
aSize *= 2; // just in case :-)
|
||||||
if (!aSize)
|
if (!aSize)
|
||||||
aSize = 1;
|
aSize = 1;
|
||||||
|
Reference in New Issue
Block a user