1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0032133: Modeling Data - Restriction of access to internal arrays for Poly_Triangulation, revision of API

Removed methods from Poly_Triangulation/Poly_PolygonOnTriangulation giving access to internal arrays of 2d and 3d nodes, triangles and normals.
This commit is contained in:
vro 2021-02-16 14:24:15 +03:00 committed by bugmaster
parent 008210c3e2
commit a8b605eb5e
73 changed files with 1235 additions and 1445 deletions

View File

@ -2210,3 +2210,9 @@ BRep and Binary BRep Shape formats (only in case of triangulation-only Faces, wi
Versions of formats have been changed (11 for BinOCAF, 10 for XmlOCAF, 4 for BRep Shape and 3 for Binary BRep Shape).
Files written with the new version will not be readable by applications of old versions.
@subsection upgrade_occt760_poly Changes in *Poly* package and *Poly_Triangulation* class:
*Poly_Triangulation* does no more provide access to internal array structures: methods Nodes(), ChangeNode(), Triangles(), ChangeTriangle(), UVNodes(), ChangeUVNode(), Normals() have been removed.
Methods of *Poly_Triangulation* for accessing individual nodal properties / triangles by index and implementing copy semantics should be used instead.
The same is applicable to *Poly_PolygonOnTriangulation* interface.

View File

@ -70,14 +70,9 @@ void TriangulationSamples::Triangulation3dSample()
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLocation);
TColgp_Array1OfPnt aTriangNodes(1, (aTriangulation->NbNodes()));
aTriangNodes = aTriangulation->Nodes();
Poly_Array1OfTriangle aTriangles(1, aTriangulation->NbTriangles());
aTriangles = aTriangulation->Triangles();
for (Standard_Integer i = 1; i <= (aTriangulation->NbTriangles()); i++)
for (Standard_Integer i = 1; i <= aTriangulation->NbTriangles(); i++)
{
Poly_Triangle trian = aTriangles.Value(i);
const Poly_Triangle trian = aTriangulation->Triangle (i);
Standard_Integer index1, index2, index3, M = 0, N = 0;
trian.Get(index1, index2, index3);
@ -96,7 +91,7 @@ void TriangulationSamples::Triangulation3dSample()
M = index2;
}
BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangNodes.Value(M), aTriangNodes.Value(N));
BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangulation->Node (M), aTriangulation->Node (N));
if (anEdgeMaker.IsDone())
{
aBuilder.Add(aCompound, anEdgeMaker.Edge());

View File

@ -1217,14 +1217,12 @@ void CGeometryDoc::simplify(const TopoDS_Shape& aShape)
"\n"
" if(!aTr.IsNull())\n"
" { \n"
" // takes the array of nodes for this triangulation\n"
" const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); \n"
" nbNodes = aNodes.Length();\n"
" nbNodes = aTr->NbNodes();\n"
"\n"
" for( Standard_Integer i = 1; i <= nbNodes; i++)\n"
" {\n"
" // create seguence of node points in absolute coordinate system\n"
" gp_Pnt aPnt = aNodes(i).Transformed(aLocation);\n"
" gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);\n"
" aPoints.Append(aPnt);\n"
" \n"
" }\n"
@ -1371,13 +1369,12 @@ void CGeometryDoc::simplify(const TopoDS_Shape& aShape)
if(!aTr.IsNull())
{
// takes the array of nodes for this triangulation
const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
nbNodes = aNodes.Length();
nbNodes = aTr->NbNodes();
for( Standard_Integer i = 1; i <= nbNodes; i++)
{
// create seguence of node points in absolute coordinate system
gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
aPoints.Append(aPnt);
}

View File

@ -126,15 +126,10 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
" if(!aTr.IsNull()) // if this triangulation is not NULL" EOL
" { " EOL
" // takes the array of nodes for this triangulation:" EOL
" const TColgp_Array1OfPnt& aNodes = aTr->Nodes();" EOL
" // takes the array of triangles for this triangulation:" EOL
" const Poly_Array1OfTriangle& triangles = aTr->Triangles();" EOL EOL
" // create array of node points in absolute coordinate system" EOL
" TColgp_Array1OfPnt aPoints(1, aNodes.Length());" EOL
" for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)" EOL
" aPoints(i) = aNodes(i).Transformed(aLocation);" EOL EOL
" TColgp_Array1OfPnt aPoints(1, aTr->NbNodes());" EOL
" for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)" EOL
" aPoints(i) = aTr->Node (i).Transformed (aLocation);" EOL EOL
" // Takes the node points of each triangle of this triangulation." EOL
" // takes a number of triangles:" EOL
@ -143,7 +138,7 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
" for( nt = 1 ; nt < nnn+1 ; nt++)" EOL
" {" EOL
" // takes the node indices of each triangle in n1,n2,n3:" EOL
" triangles(nt).Get(n1,n2,n3);" EOL
" aTr->Triangle (nt).Get (n1,n2,n3);" EOL
" // takes the node points:" EOL
" gp_Pnt aPnt1 = aPoints(n1);" EOL
" gp_Pnt aPnt2 = aPoints(n2);" EOL
@ -211,11 +206,9 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
if(!aTr.IsNull())
{
const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
aNumOfNodes += aTr->NbNodes();
//Standard_Integer aLower = aNodes.Lower();
//Standard_Integer anUpper = aNodes.Upper();
const Poly_Array1OfTriangle& triangles = aTr->Triangles();
aNumOfTriangles += aTr->NbTriangles();
if(aCount == aNumOfFace)
@ -251,8 +244,8 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
Standard_Integer aLower = aNodesOfPol.Lower(), anUpper = aNodesOfPol.Upper();
for( int i = aLower; i < anUpper ; i++)
{
gp_Pnt aPnt1 = aNodes(aNodesOfPol(i)).Transformed(aLocation);
gp_Pnt aPnt2 = aNodes(aNodesOfPol(i+1)).Transformed(aLocation);
gp_Pnt aPnt1 = aTr->Node (aNodesOfPol (i)).Transformed (aLocation);
gp_Pnt aPnt2 = aTr->Node (aNodesOfPol (i+1)).Transformed (aLocation);
TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex (aPnt1);
TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex (aPnt2);
@ -283,9 +276,9 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
TopTools_DataMapOfIntegerShape aEdges;
TopTools_SequenceOfShape aVertices;
for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)
for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)
{
gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(aPnt);
if(!aVertex.IsNull())
@ -302,7 +295,7 @@ void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape)
for( nt = 1 ; nt < nnn+1 ; nt++)
{
triangles(nt).Get(n1,n2,n3);
aTr->Triangle (nt).Get (n1,n2,n3);
Standard_Integer key[3];

View File

@ -157,13 +157,9 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {
TopoDS_Face F =TopoDS::Face(ex.Current());
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
TColgp_Array1OfPnt tab(1,(facing->NbNodes()));
tab = facing->Nodes();
Poly_Array1OfTriangle tri(1,facing->NbTriangles());
tri = facing->Triangles();
for (Standard_Integer i=1;i<=(facing->NbTriangles());i++) {
Poly_Triangle trian = tri.Value(i);
const Poly_Triangle trian = facing->Triangle (i);
Standard_Integer index1,index2,index3,M = 0, N = 0;
trian.Get(index1,index2,index3);
@ -180,7 +176,7 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) {
M = index2;
}
BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N));
BRepBuilderAPI_MakeEdge ME(facing->Node (M), facing->Node (N));
if (ME.IsDone()) {
builder.Add(Comp,ME.Edge());
}
@ -210,13 +206,9 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) { \n\
TopoDS_Face F =TopoDS::Face(ex.Current()); \n\
TopLoc_Location L; \n\
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L); \n\
TColgp_Array1OfPnt tab(1,(facing->NbNodes())); \n\
tab = facing->Nodes(); \n\
Poly_Array1OfTriangle tri(1,facing->NbTriangles()); \n\
tri = facing->Triangles(); \n\
\n\
\n\
for (Standard_Integer i=1;i<=(facing->NbTriangles());i++) { \n\
Poly_Triangle trian = tri.Value(i); \n\
Poly_Triangle trian = facing->Triangle (i); \n\
Standard_Integer index1,index2,index3,M,N; \n\
trian.Get(index1,index2,index3); \n\
\n\
@ -233,7 +225,7 @@ for (TopExp_Explorer ex(ShapeFused,TopAbs_FACE) ; ex.More(); ex.Next()) { \n\
M = index2; \n\
} \n\
\n\
BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N)); \n\
BRepBuilderAPI_MakeEdge ME(facing->Node (M),facing->Node (N)); \n\
if (ME.IsDone()) { \n\
builder.Add(Comp,ME.Edge()); \n\
} \n\

View File

@ -158,10 +158,6 @@ case 6: //color
return;
}
const TColgp_Array1OfPnt& Nodes= myT->Nodes();
const Poly_Array1OfTriangle& triangles = myT->Triangles();
Standard_Integer nnn = myT->NbTriangles(); // nnn : nombre de triangles
Standard_Integer nt, n1, n2, n3 = 0;// nt : triangle courant
// ni : sommet i du triangle courant
@ -171,15 +167,15 @@ case 6: //color
// triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
if (TriangleIsValid (myT->Node (n1), myT->Node (n2), myT->Node (n3)) )
{ // Associates a vertexNT to each node
gp_Pnt p = Nodes(n1).Transformed(myLocation.Transformation());
gp_Pnt q = Nodes(n2).Transformed(myLocation.Transformation());
gp_Pnt r = Nodes(n3).Transformed(myLocation.Transformation());
gp_Pnt p = myT->Node (n1).Transformed (myLocation.Transformation());
gp_Pnt q = myT->Node (n2).Transformed (myLocation.Transformation());
gp_Pnt r = myT->Node (n3).Transformed (myLocation.Transformation());
if (p.Z() > H.Z()) H=p;
if (q.Z() > H.Z()) H=q;
@ -213,12 +209,13 @@ case 6: //color
return;
}
Poly_Connect pc(myT);
const TColgp_Array1OfPnt& Nodes= myT->Nodes();
TColgp_Array1OfPnt Nodes (1, myT->NbNodes());
for (Standard_Integer in = 1; in <= myT->NbNodes(); in++)
{
Nodes.SetValue(in, myT->Node (in));
}
BAR = GProp_PGProps::Barycentre(Nodes);
//const TColgp_Array1OfPnt2d& UVNodes = myT->UVNodes();
const Poly_Array1OfTriangle& triangles = myT->Triangles();
TColgp_Array1OfDir myNormal(Nodes.Lower(), Nodes.Upper());
StdPrs_ToolTriangulatedShape::Normal(myFace, pc, myNormal);
@ -238,15 +235,15 @@ case 6: //color
{
// triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
{ // Associates a vertexNT to each node
gp_Pnt p = Nodes(n1).Transformed(myLocation.Transformation());
gp_Pnt q = Nodes(n2).Transformed(myLocation.Transformation());
gp_Pnt r = Nodes(n3).Transformed(myLocation.Transformation());
gp_Pnt p = myT->Node(n1).Transformed(myLocation.Transformation());
gp_Pnt q = myT->Node(n2).Transformed(myLocation.Transformation());
gp_Pnt r = myT->Node(n3).Transformed(myLocation.Transformation());
}
}
@ -258,18 +255,18 @@ case 6: //color
std::cout << "On traite actuellement le triangle : "<< nt <<"\n";
#endif
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
{ // Associates a vertexNT to each node
TColgp_Array1OfPnt Points(1,3);
gp_Pnt p = Nodes(n1).Transformed(myLocation.Transformation());
gp_Pnt q = Nodes(n2).Transformed(myLocation.Transformation());
gp_Pnt r = Nodes(n3).Transformed(myLocation.Transformation());
gp_Pnt p = myT->Node(n1).Transformed(myLocation.Transformation());
gp_Pnt q = myT->Node(n2).Transformed(myLocation.Transformation());
gp_Pnt r = myT->Node(n3).Transformed(myLocation.Transformation());
Points(1).SetCoord(p.X(), p.Y(), p.Z());
Points(2).SetCoord(q.X(), q.Y(), q.Z());

View File

@ -1336,11 +1336,11 @@ void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
const gp_Dir& theNormal)
{
myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 1, theP1);
myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 2, theP2);
myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 3, theP3);
myTriangulation->SetNode (theIndex * 3 + 1, theP1);
myTriangulation->SetNode (theIndex * 3 + 2, theP2);
myTriangulation->SetNode (theIndex * 3 + 3, theP3);
myTriangulation->ChangeTriangles().SetValue (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
myTriangulation->SetTriangle (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
myArray->AddVertex (theP1, theNormal);
myArray->AddVertex (theP2, theNormal);
myArray->AddVertex (theP3, theNormal);

View File

@ -123,9 +123,6 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
switch (aMode)
{
case 0:
const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes(); //Nodes
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles(); //Triangle
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
Standard_Boolean hasVColors = HasVertexColors();
@ -135,29 +132,28 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
Standard_Integer i;
Standard_Integer j;
const Standard_Real ambient = 0.2;
if (hasVNormals)
{
const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
gp_Vec3f aNormal;
if (hasVColors)
{
const TColStd_Array1OfInteger& colors = myColor->Array1();
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
j = (i - nodes.Lower()) * 3;
anArray->AddVertex(nodes(i), attenuateColor(colors(i), ambient));
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
anArray->AddVertex (myTriangulation->Node (i), attenuateColor (colors[i], ambient));
myTriangulation->Normal (i, aNormal);
anArray->SetVertexNormal (i, aNormal.x(), aNormal.y(), aNormal.z());
}
}
else // !hasVColors
{
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
j = (i - nodes.Lower()) * 3;
anArray->AddVertex(nodes(i));
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
anArray->AddVertex (myTriangulation->Node (i));
myTriangulation->Normal (i, aNormal);
anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());
}
}
}
@ -166,23 +162,24 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
if (hasVColors)
{
const TColStd_Array1OfInteger& colors = myColor->Array1();
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
anArray->AddVertex(nodes(i), attenuateColor(colors(i), ambient));
anArray->AddVertex (myTriangulation->Node (i), attenuateColor(colors(i), ambient));
}
}
else // !hasVColors
{
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
anArray->AddVertex(nodes(i));
anArray->AddVertex (myTriangulation->Node (i));
}
}
}
Standard_Integer indexTriangle[3] = {0,0,0};
for ( i = triangles.Lower(); i<= triangles.Upper(); i++ ) {
triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
for ( i = 1; i<= myTriangulation->NbTriangles(); i++ )
{
myTriangulation->Triangle (i).Get (indexTriangle[0], indexTriangle[1], indexTriangle[2]);
anArray->AddEdge(indexTriangle[0]);
anArray->AddEdge(indexTriangle[1]);
anArray->AddEdge(indexTriangle[2]);

View File

@ -149,20 +149,19 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
if (l.IsIdentity())
{
for (i = 1; i <= nbNodes; i++)
{
B.Add(Nodes(Indices[i]));
B.Add (T->Node (Indices[i]));
}
}
else
{
for (i = 1; i <= nbNodes; i++)
{
B.Add(Nodes(Indices[i]).Transformed(l));
B.Add (T->Node (Indices[i]).Transformed (l));
}
}
// B.Enlarge(T->Deflection());
@ -341,12 +340,17 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B,
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
for (i = 1; i <= nbNodes; i++)
{
if (l.IsIdentity()) aLocBox.Add(Nodes(Indices[i]));
else aLocBox.Add(Nodes(Indices[i]).Transformed(l));
if (l.IsIdentity())
{
aLocBox.Add (T->Node (Indices[i]));
}
else
{
aLocBox.Add (T->Node (Indices[i]).Transformed (l));
}
}
Standard_Real Tol = useShapeTolerance? BRep_Tool::Tolerance(E) : 0.;
aLocBox.Enlarge(Poly->Deflection() + Tol);

View File

@ -185,23 +185,26 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS,
}
// Use triangulation of the face
const Handle(Poly_Triangulation) &aTrng = BRep_Tool::Triangulation(aF, aLoc);
const Handle(Poly_Triangulation)& aTrng = BRep_Tool::Triangulation (aF, aLoc);
if (aTrng.IsNull())
{
// no triangulation on the face
return 0;
}
const Standard_Integer aCNode = aTrng->NbNodes();
const TColgp_Array1OfPnt& aNodesArr = aTrng->Nodes();
const gp_Trsf aTrsf = aLoc;
for (Standard_Integer i = 1; i <= aCNode; i++)
{
if (thePts)
if (thePts != NULL)
{
const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr[i] :
aNodesArr[i].Transformed(aLoc);
const gp_Pnt aP = aTrsf.Form() == gp_Identity
? aTrng->Node (i)
: aTrng->Node (i).Transformed (aTrsf);
(*thePts)(aRetVal) = aP;
}
if (theArrOfToler)
if (theArrOfToler != NULL)
{
(*theArrOfToler) (aRetVal) = aTrng->Deflection();
}

View File

@ -697,6 +697,7 @@ BRepCheck_Status BRepCheck_Edge::
Handle(BRep_PolygonOnTriangulation) aPT (Handle(BRep_PolygonOnTriangulation)::DownCast(aCR));
const TopLoc_Location aLL = theEdge.Location() * aPT->Location();
const gp_Trsf aTrsf = aLL;
const Handle(Poly_Triangulation) aTriang = aCR->Triangulation();
const Handle(Poly_PolygonOnTriangulation) aPOnTriag =
@ -704,7 +705,6 @@ BRepCheck_Status BRepCheck_Edge::
aCR->PolygonOnTriangulation2() :
aCR->PolygonOnTriangulation();
const TColStd_Array1OfInteger& anIndices = aPOnTriag->Nodes();
const TColgp_Array1OfPnt& Nodes = aTriang->Nodes();
const Standard_Integer aNbNodes = anIndices.Length();
const Standard_Real aTol = aPOnTriag->Deflection() +
@ -716,8 +716,8 @@ BRepCheck_Status BRepCheck_Edge::
i <= aPOnTriag->Parameters()->Upper(); i++)
{
const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
const gp_Pnt aPE(aBC.Value(aParam)),
aPnt(Nodes(anIndices(i)).Transformed(aLL));
const gp_Pnt aPE (aBC.Value (aParam));
const gp_Pnt aPnt (aTriang->Node (anIndices (i)).Transformed (aTrsf));
const Standard_Real aSQDist = aPE.SquareDistance(aPnt);
if(aSQDist > aTol*aTol)
@ -735,10 +735,14 @@ BRepCheck_Status BRepCheck_Edge::
for (Standard_Integer i = 1; i <= aNbNodes; i++)
{
if (aLL.IsIdentity())
aB.Add(Nodes(anIndices(i)));
if (aTrsf.Form() == gp_Identity)
{
aB.Add (aTriang->Node (anIndices(i)));
}
else
aB.Add(Nodes(anIndices(i)).Transformed(aLL));
{
aB.Add (aTriang->Node (anIndices(i)).Transformed(aTrsf));
}
}
aB.Enlarge(aTol);

View File

@ -75,12 +75,12 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
const gp_Trsf aTrsf = L;
n = Tr->NbNodes();
for (i = 1; i <= n; i++)
{
nbn1++;
TP1.SetValue(nbn1,Nod(i).Transformed(L));
TP1.SetValue (nbn1, Tr->Node (i).Transformed (aTrsf));
}
}
}
@ -96,12 +96,12 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
const gp_Trsf aTrsf = L;
n = Tr->NbNodes();
for (i = 1; i <= n; i++)
{
nbn2++;
TP2.SetValue(nbn2,Nod(i).Transformed(L));
TP2.SetValue (nbn2, Tr->Node (i).Transformed (aTrsf));
}
}
}

View File

@ -179,25 +179,15 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
for (Standard_Integer aVertIdx = 1; aVertIdx <= aTriangulation->NbNodes(); ++aVertIdx)
{
gp_Pnt aVertex = aTriangulation->Nodes().Value (aVertIdx);
gp_Pnt aVertex = aTriangulation->Node (aVertIdx);
aVertex.Transform (aLocation.Transformation());
myVertexArray.push_back (BVH_Vec3d (aVertex.X(),
aVertex.Y(),
aVertex.Z()));
myVertexArray.push_back (BVH_Vec3d (aVertex.X(), aVertex.Y(), aVertex.Z()));
}
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)
{
Standard_Integer aVertex1;
Standard_Integer aVertex2;
Standard_Integer aVertex3;
aTriangulation->Triangles().Value (aTriIdx).Get (aVertex1,
aVertex2,
aVertex3);
Standard_Integer aVertex1, aVertex2, aVertex3;
aTriangulation->Triangle (aTriIdx).Get (aVertex1, aVertex2, aVertex3);
myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
aVertex2 + aVertOffset,
aVertex3 + aVertOffset,

View File

@ -180,13 +180,12 @@ void BRepGProp_MeshCinert::PreparePolygon(const TopoDS_Edge& theE,
Standard_Integer aNbNodes = aPOnTri->NbNodes();
thePolyg = new TColgp_HArray1OfPnt(1, aNbNodes);
const TColStd_Array1OfInteger& aNodeInds = aPOnTri->Nodes();
const TColgp_Array1OfPnt& aNodes = aTri->Nodes();
Standard_Integer i;
if (aLoc.IsIdentity())
{
for (i = 1; i <= aNbNodes; ++i)
{
thePolyg->SetValue(i, aNodes(aNodeInds(i)));
thePolyg->SetValue (i, aTri->Node (aNodeInds (i)));
}
}
else
@ -194,7 +193,7 @@ void BRepGProp_MeshCinert::PreparePolygon(const TopoDS_Edge& theE,
const gp_Trsf& aTr = aLoc.Transformation();
for (i = 1; i <= aNbNodes; ++i)
{
thePolyg->SetValue(i, aNodes.Value(aNodeInds(i)).Transformed(aTr));
thePolyg->SetValue (i, aTri->Node (aNodeInds (i)).Transformed (aTr));
}
}
return;

View File

@ -171,7 +171,7 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
}
if (theLoc.IsIdentity())
{
Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
Perform (theMesh, theOri);
}
else
{
@ -181,21 +181,24 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
Abs(Abs(aTr.ScaleFactor()) - 1.) > gp::Resolution();
if (isToCopy)
{
TColgp_Array1OfPnt aNodes(1, theMesh->NbNodes());
const TColgp_Array1OfPnt& aMeshNodes = theMesh->Nodes();
Standard_Integer i;
for (i = 1; i <= aMeshNodes.Length(); ++i)
Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (theMesh->NbNodes(), theMesh->NbTriangles(), false);
TColgp_Array1OfPnt aNodes (1, theMesh->NbNodes());
for (Standard_Integer i = 1; i <= theMesh->NbNodes(); ++i)
{
aNodes(i) = aMeshNodes.Value(i).Transformed(aTr);
aCopy->SetNode (i, theMesh->Node (i).Transformed (aTr));
}
Perform(aNodes, theMesh->Triangles(), theOri);
for (Standard_Integer i = 1; i <= theMesh->NbTriangles(); ++i)
{
aCopy->SetTriangle (i, theMesh->Triangle (i));
}
Perform (aCopy, theOri);
return;
}
//
gp_Trsf aTrInv = aTr.Inverted();
gp_Pnt loc_save = loc;
loc.Transform(aTrInv);
Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
Perform (theMesh, theOri);
//Computes the inertia tensor at mesh gravity center
gp_Mat HMat, inertia0;
gp_Pnt g0 = g;
@ -229,11 +232,12 @@ void BRepGProp_MeshProps::Perform(const Handle(Poly_Triangulation)& theMesh,
//function : Perform
//purpose :
//=======================================================================
void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles,
void BRepGProp_MeshProps::Perform (const Handle(Poly_Triangulation)& theMesh,
const TopAbs_Orientation theOri)
{
if (theNodes.IsEmpty() || theTriangles.IsEmpty())
if (theMesh.IsNull()
|| theMesh->NbNodes() == 0
|| theMesh->NbTriangles() == 0)
{
return;
}
@ -256,23 +260,20 @@ void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
//aGProps[7] = Ixy, aGProps[8] = Ixz, aGProps[9] = Iyz,
Standard_Boolean isVolume = myType == Vinert;
Standard_Integer i;
Standard_Integer n1, n2, n3; //node indices
for (i = theTriangles.Lower(); i <= theTriangles.Upper(); ++i)
for (Standard_Integer i = 1; i <= theMesh->NbTriangles(); ++i)
{
const Poly_Triangle& aTri = theTriangles(i);
aTri.Get(n1, n2, n3);
const Poly_Triangle aTri = theMesh->Triangle (i);
aTri.Get (n1, n2, n3);
if (theOri == TopAbs_REVERSED)
{
Standard_Integer nn = n2;
n2 = n3;
n3 = nn;
std::swap (n2, n3);
}
// Calculate properties of a pyramid built on face and apex
const gp_Pnt& p1 = theNodes(n1);
const gp_Pnt& p2 = theNodes(n2);
const gp_Pnt& p3 = theNodes(n3);
CalculateProps(p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
const gp_Pnt p1 = theMesh->Node (n1);
const gp_Pnt p2 = theMesh->Node (n2);
const gp_Pnt p3 = theMesh->Node (n3);
CalculateProps (p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
}
dim = aGProps[0];

View File

@ -55,8 +55,7 @@ public:
const TopLoc_Location& theLoc,
const TopAbs_Orientation theOri);
Standard_EXPORT void Perform(const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles,
Standard_EXPORT void Perform(const Handle(Poly_Triangulation)& theMesh,
const TopAbs_Orientation theOri);
//! Computes the global properties of triangle {p1, p2, p3} relatively

View File

@ -2342,36 +2342,33 @@ Standard_Boolean BRepLib::
continue;
}
aPT->AddNormals();
GeomLProp_SLProps aSLP(aSurf, 2, Precision::Confusion());
const Standard_Integer anArrDim = 3*aPT->NbNodes();
Handle(TShort_HArray1OfShortReal) aNormArr = new TShort_HArray1OfShortReal(1, anArrDim);
Standard_Integer anNormInd = aNormArr->Lower();
for(Standard_Integer i = aPT->UVNodes().Lower(); i <= aPT->UVNodes().Upper(); i++)
for (Standard_Integer i = 1; i <= aPT->NbNodes(); i++)
{
const gp_Pnt2d &aP2d = aPT->UVNodes().Value(i);
const gp_Pnt2d aP2d = aPT->UVNode (i);
aSLP.SetParameters(aP2d.X(), aP2d.Y());
gp_XYZ aNorm(0.,0.,0.);
if(!aSLP.IsNormalDefined())
{
#ifdef OCCT_DEBUG
std::cout << "BRepLib::EnsureNormalConsistency(): Cannot find normal!" << std::endl;
#endif
aPT->SetNormal (i, gp_Vec3f (0.0f));
}
else
{
aNorm = aSLP.Normal().XYZ();
gp_Dir aNorm = aSLP.Normal();
if (aFace.Orientation() == TopAbs_REVERSED)
{
aNorm.Reverse();
}
aPT->SetNormal (i, aNorm);
}
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.X());
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Y());
aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Z());
}
aRetVal = Standard_True;
isNormalsFound = Standard_True;
aPT->SetNormals(aNormArr);
}
if(!isNormalsFound)
@ -2407,9 +2404,6 @@ Standard_Boolean BRepLib::
const Handle(Poly_PolygonOnTriangulation)& aPTEF2 =
BRep_Tool::PolygonOnTriangulation(anEdg, aPT2, aLoc2);
TShort_Array1OfShortReal& aNormArr1 = aPT1->ChangeNormals();
TShort_Array1OfShortReal& aNormArr2 = aPT2->ChangeNormals();
if (aPTEF1->Nodes().Lower() != aPTEF2->Nodes().Lower() ||
aPTEF1->Nodes().Upper() != aPTEF2->Nodes().Upper())
continue;
@ -2421,31 +2415,17 @@ Standard_Boolean BRepLib::
const Standard_Integer aFNodF1 = aPTEF1->Nodes().Value(anEdgNode);
const Standard_Integer aFNodF2 = aPTEF2->Nodes().Value(anEdgNode);
const Standard_Integer aFNorm1FirstIndex = aNormArr1.Lower() + 3*
(aFNodF1 - aPT1->Nodes().Lower());
const Standard_Integer aFNorm2FirstIndex = aNormArr2.Lower() + 3*
(aFNodF2 - aPT2->Nodes().Lower());
gp_XYZ aNorm1(aNormArr1.Value(aFNorm1FirstIndex),
aNormArr1.Value(aFNorm1FirstIndex+1),
aNormArr1.Value(aFNorm1FirstIndex+2));
gp_XYZ aNorm2(aNormArr2.Value(aFNorm2FirstIndex),
aNormArr2.Value(aFNorm2FirstIndex+1),
aNormArr2.Value(aFNorm2FirstIndex+2));
gp_Vec3f aNorm1f, aNorm2f;
aPT1->Normal (aFNodF1, aNorm1f);
aPT1->Normal (aFNodF2, aNorm2f);
const gp_XYZ aNorm1 (aNorm1f.x(), aNorm1f.y(), aNorm1f.z());
const gp_XYZ aNorm2 (aNorm2f.x(), aNorm2f.y(), aNorm2f.z());
const Standard_Real aDot = aNorm1 * aNorm2;
if(aDot > aThresDot)
if (aDot > aThresDot)
{
gp_XYZ aNewNorm = (aNorm1 + aNorm2).Normalized();
aNormArr1.ChangeValue(aFNorm1FirstIndex) =
aNormArr2.ChangeValue(aFNorm2FirstIndex) =
static_cast<Standard_ShortReal>(aNewNorm.X());
aNormArr1.ChangeValue(aFNorm1FirstIndex+1) =
aNormArr2.ChangeValue(aFNorm2FirstIndex+1) =
static_cast<Standard_ShortReal>(aNewNorm.Y());
aNormArr1.ChangeValue(aFNorm1FirstIndex+2) =
aNormArr2.ChangeValue(aFNorm2FirstIndex+2) =
static_cast<Standard_ShortReal>(aNewNorm.Z());
aPT1->SetNormal (aFNodF1, aNewNorm);
aPT2->SetNormal (aFNodF2, aNewNorm);
aRetVal = Standard_True;
}
}

View File

@ -259,7 +259,8 @@ Handle(Poly_Triangulation) BRepMesh_BaseMeshAlgo::collectTriangles()
return Handle(Poly_Triangulation)();
}
Poly_Array1OfTriangle aPolyTrianges(1, aTriangles.Extent());
Handle(Poly_Triangulation) aRes = new Poly_Triangulation();
aRes->ResizeTriangles (aTriangles.Extent(), false);
IMeshData::IteratorOfMapOfInteger aTriIt(aTriangles);
for (Standard_Integer aTriangeId = 1; aTriIt.More(); aTriIt.Next(), ++aTriangeId)
{
@ -278,14 +279,11 @@ Handle(Poly_Triangulation) BRepMesh_BaseMeshAlgo::collectTriangles()
aNode[i] = myUsedNodes->Find(aNode[i]);
}
aPolyTrianges(aTriangeId).Set(aNode[0], aNode[1], aNode[2]);
aRes->SetTriangle (aTriangeId, Poly_Triangle (aNode[0], aNode[1], aNode[2]));
}
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation(
myUsedNodes->Extent(), aTriangles.Extent(), Standard_True);
aTriangulation->ChangeTriangles() = aPolyTrianges;
return aTriangulation;
aRes->ResizeNodes (myUsedNodes->Extent(), false);
aRes->AddUVNodes();
return aRes;
}
//=======================================================================
@ -295,10 +293,6 @@ Handle(Poly_Triangulation) BRepMesh_BaseMeshAlgo::collectTriangles()
void BRepMesh_BaseMeshAlgo::collectNodes(
const Handle(Poly_Triangulation)& theTriangulation)
{
// Store mesh nodes
TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
TColgp_Array1OfPnt2d& aNodes2d = theTriangulation->ChangeUVNodes();
for (Standard_Integer i = 1; i <= myNodesMap->Size(); ++i)
{
if (myUsedNodes->IsBound(i))
@ -306,8 +300,8 @@ void BRepMesh_BaseMeshAlgo::collectNodes(
const BRepMesh_Vertex& aVertex = myStructure->GetNode(i);
const Standard_Integer aNodeIndex = myUsedNodes->Find(i);
aNodes(aNodeIndex) = myNodesMap->Value(aVertex.Location3d());
aNodes2d(aNodeIndex) = getNodePoint2d(aVertex);
theTriangulation->SetNode (aNodeIndex, myNodesMap->Value (aVertex.Location3d()));
theTriangulation->SetUVNode(aNodeIndex, getNodePoint2d (aVertex));
}
}
}

View File

@ -14,11 +14,13 @@
// commercial license or contractual agreement.
#include <BRepMesh_EdgeTessellationExtractor.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
#include <IMeshData_Face.hxx>
#include <gp_Pnt.hxx>
#include <IMeshData_Edge.hxx>
#include <IMeshData_Face.hxx>
#include <Poly_Triangulation.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_EdgeTessellationExtractor, IMeshTools_CurveTessellator)
@ -36,7 +38,7 @@ BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor (
Handle (Poly_PolygonOnTriangulation) aPolygon =
BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc);
myNodes = &aTriangulation->Nodes ();
myTriangulation = aTriangulation.get();
myIndices = &aPolygon->Nodes ();
myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
}
@ -67,8 +69,8 @@ Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value (
gp_Pnt& thePoint,
Standard_Real& theParameter) const
{
const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex));
thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc);
const gp_Pnt aRefPnt = myTriangulation->Node (myIndices->Value (theIndex));
thePoint = BRepMesh_ShapeTool::UseLocation (aRefPnt, myLoc);
theParameter = myProvider.Parameter (theIndex, thePoint);
return Standard_True;

View File

@ -55,9 +55,9 @@ public:
private:
BRepMesh_EdgeParameterProvider<Handle(TColStd_HArray1OfReal)> myProvider;
const TColgp_Array1OfPnt* myNodes;
const Poly_Triangulation* myTriangulation;
const TColStd_Array1OfInteger* myIndices;
TopLoc_Location myLoc;
};
#endif
#endif

View File

@ -63,19 +63,15 @@ namespace
if (isTriangulationConsistent)
{
// #25080: check that indices of links forming triangles are in range.
const Standard_Integer aNodesNb = aTriangulation->NbNodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
Standard_Integer i = aTriangles.Lower();
for (; i <= aTriangles.Upper() && isTriangulationConsistent; ++i)
for (Standard_Integer i = 1; i <= aTriangulation->NbTriangles() && isTriangulationConsistent; ++i)
{
const Poly_Triangle& aTriangle = aTriangles(i);
const Poly_Triangle aTriangle = aTriangulation->Triangle (i);
Standard_Integer aNode[3];
aTriangle.Get(aNode[0], aNode[1], aNode[2]);
for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j)
{
isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aNodesNb);
isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aTriangulation->NbNodes());
}
}
}

View File

@ -208,10 +208,12 @@ void BRepMesh_ShapeTool::AddInFace(
{
gp_Trsf aTrsf = aLoc.Transformation();
aTrsf.Invert();
TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i)
aNodes(i).Transform(aTrsf);
for (Standard_Integer aNodeIter = 1; aNodeIter <= theTriangulation->NbNodes(); ++aNodeIter)
{
gp_Pnt aNode = theTriangulation->Node (aNodeIter);
aNode.Transform (aTrsf);
theTriangulation->SetNode (aNodeIter, aNode);
}
}
BRep_Builder aBuilder;

View File

@ -14,19 +14,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepTools_Modification.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Type.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TopoDS_Face.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_Modification,Standard_Transient)

View File

@ -1467,28 +1467,31 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (!Compact) OS << "\n3D Nodes :\n";
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (j = 1; j <= nbNodes; j++) {
for (j = 1; j <= nbNodes; j++)
{
const gp_Pnt aNode = T->Node (j);
if (!Compact) OS << std::setw(10) << j << " : ";
if (!Compact) OS << std::setw(17);
OS << Nodes(j).X() << " ";
OS << aNode.X() << " ";
if (!Compact) OS << std::setw(17);
OS << Nodes(j).Y() << " ";
OS << aNode.Y() << " ";
if (!Compact) OS << std::setw(17);
OS << Nodes(j).Z();
OS << aNode.Z();
if (!Compact) OS << "\n";
else OS << " ";
}
if (T->HasUVNodes()) {
if (T->HasUVNodes())
{
if (!Compact) OS << "\nUV Nodes :\n";
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (j = 1; j <= nbNodes; j++) {
for (j = 1; j <= nbNodes; j++)
{
const gp_Pnt2d aNode2d = T->UVNode (j);
if (!Compact) OS << std::setw(10) << j << " : ";
if (!Compact) OS << std::setw(17);
OS << UVNodes(j).X() << " ";
OS << aNode2d.X() << " ";
if (!Compact) OS << std::setw(17);
OS << UVNodes(j).Y();
OS << aNode2d.Y();
if (!Compact) OS << "\n";
else OS << " ";
}
@ -1496,10 +1499,9 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (!Compact) OS << "\nTriangles :\n";
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& Triangles = T->Triangles();
for (j = 1; j <= nbTriangles; j++) {
if (!Compact) OS << std::setw(10) << j << " : ";
Triangles(j).Get(n1, n2, n3);
T->Triangle (j).Get (n1, n2, n3);
if (!Compact) OS << std::setw(10);
OS << n1 << " ";
if (!Compact) OS << std::setw(10);
@ -1515,22 +1517,19 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (T->HasNormals() && toWriteNormals)
{
if (!Compact) OS << "\nNormals :\n";
const TShort_Array1OfShortReal& Normals = T->Normals();
for (j = 1; j <= nbNodes * 3; j++)
for (j = 1; j <= nbNodes; j++)
{
if (!Compact)
{
OS << std::setw(10) << j << " : ";
OS << std::setw(17);
}
OS << Normals(j) << " ";
if (!Compact)
gp_Vec3f aNorm;
for (Standard_Integer k = 0; k < 3; ++k)
{
OS << "\n";
}
else
{
OS << " ";
T->Normal (j, aNorm);
OS << aNorm[k];
OS << (!Compact ? "\n" : " ");
}
}
}
@ -1558,10 +1557,8 @@ void BRepTools_ShapeSet::DumpTriangulation(Standard_OStream& OS)const
void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_ProgressRange& theProgress)
{
char buffer[255];
// Standard_Integer i, j, val, nbtri;
Standard_Integer i, j, nbtri =0;
Standard_Real d, x, y, z;
Standard_Real normal;
Standard_Integer nbNodes =0, nbTriangles=0;
Standard_Boolean hasUV= Standard_False;
Standard_Boolean hasNormals= Standard_False;
@ -1583,53 +1580,43 @@ void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_P
}
GeomTools::GetReal(IS, d);
TColgp_Array1OfPnt Nodes(1, nbNodes);
TColgp_Array1OfPnt2d UVNodes(1, nbNodes);
Handle(TShort_HArray1OfShortReal) Normals;
if (hasNormals)
{
Normals = new TShort_HArray1OfShortReal(1, nbNodes * 3);
}
T = new Poly_Triangulation (nbNodes, nbTriangles, hasUV, hasNormals);
for (j = 1; j <= nbNodes; j++) {
GeomTools::GetReal(IS, x);
GeomTools::GetReal(IS, y);
GeomTools::GetReal(IS, z);
Nodes(j).SetCoord(x,y,z);
T->SetNode (j, gp_Pnt (x, y, z));
}
if (hasUV) {
for (j = 1; j <= nbNodes; j++) {
GeomTools::GetReal(IS, x);
GeomTools::GetReal(IS, y);
UVNodes(j).SetCoord(x,y);
T->SetUVNode (j, gp_Pnt2d (x,y));
}
}
// read the triangles
Standard_Integer n1,n2,n3;
Poly_Array1OfTriangle Triangles(1, nbTriangles);
for (j = 1; j <= nbTriangles; j++) {
IS >> n1 >> n2 >> n3;
Triangles(j).Set(n1,n2,n3);
T->SetTriangle (j, Poly_Triangle (n1, n2, n3));
}
if (hasNormals)
{
for (j = 1; j <= nbNodes * 3; j++)
NCollection_Vec3<Standard_Real> aNorm;
for (j = 1; j <= nbNodes; j++)
{
GeomTools::GetReal(IS, normal);
Normals->SetValue(j, static_cast<Standard_ShortReal>(normal));
GeomTools::GetReal (IS, aNorm.x());
GeomTools::GetReal (IS, aNorm.y());
GeomTools::GetReal (IS, aNorm.z());
T->SetNormal (j, gp_Vec3f (aNorm));
}
}
if (hasUV) T = new Poly_Triangulation(Nodes,UVNodes,Triangles);
else T = new Poly_Triangulation(Nodes,Triangles);
T->Deflection(d);
if (hasNormals)
{
T->SetNormals(Normals);
}
myTriangulations.Add(T, hasNormals);
}
}

View File

@ -80,7 +80,7 @@ Standard_Boolean BinMDataXtd_TriangulationDriver::Paste(const BinObjMgt_Persiste
theSource >> x;
theSource >> y;
theSource >> z;
PT->ChangeNode(i).SetCoord(x, y, z);
PT->SetNode (i, gp_Pnt (x, y, z));
}
// read 2d nodes
@ -90,7 +90,7 @@ Standard_Boolean BinMDataXtd_TriangulationDriver::Paste(const BinObjMgt_Persiste
{
theSource >> x;
theSource >> y;
PT->ChangeUVNode(i).SetCoord(x,y);
PT->SetUVNode (i, gp_Pnt2d (x, y));
}
}
@ -100,7 +100,7 @@ Standard_Boolean BinMDataXtd_TriangulationDriver::Paste(const BinObjMgt_Persiste
theSource >> n1;
theSource >> n2;
theSource >> n3;
PT->ChangeTriangle(i).Set(n1, n2, n3);
PT->SetTriangle (i, Poly_Triangle (n1, n2, n3));
}
// set triangulation to Ocaf attribute
@ -132,29 +132,29 @@ void BinMDataXtd_TriangulationDriver::Paste(const Handle(TDF_Attribute)& theSour
theTarget << PT->Deflection();
// write 3d nodes
Standard_Integer i;
for (i = 1; i <= nbNodes; i++)
for (Standard_Integer i = 1; i <= nbNodes; i++)
{
theTarget << PT->Node(i).X();
theTarget << PT->Node(i).Y();
theTarget << PT->Node(i).Z();
const gp_Pnt aNode = PT->Node (i);
theTarget << aNode.X();
theTarget << aNode.Y();
theTarget << aNode.Z();
}
// write 2d nodes
if (PT->HasUVNodes())
{
for (i = 1; i <= nbNodes; i++)
for (Standard_Integer i = 1; i <= nbNodes; i++)
{
theTarget << PT->UVNode(i).X();
theTarget << PT->UVNode(i).Y();
const gp_Pnt2d aNode2d = PT->UVNode (i);
theTarget << aNode2d.X();
theTarget << aNode2d.Y();
}
}
// Write triangles
const Poly_Array1OfTriangle& Triangles = PT->Triangles();
for (i = 1; i <= nbTriangles; i++)
for (Standard_Integer i = 1; i <= nbTriangles; i++)
{
Triangles(i).Get(n1, n2, n3);
PT->Triangle (i).Get (n1, n2, n3);
theTarget << n1;
theTarget << n2;
theTarget << n3;

View File

@ -1321,10 +1321,11 @@ void BinTools_ShapeSet::ReadPolygonOnTriangulation
Standard_Integer aNbNodes = 0;
BinTools::GetInteger(IS, aNbNodes);
Handle(Poly_PolygonOnTriangulation) aPoly = new Poly_PolygonOnTriangulation (aNbNodes, Standard_False);
TColStd_Array1OfInteger& aNodes = aPoly->ChangeNodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
BinTools::GetInteger(IS, aNodes.ChangeValue (aNodeIter));
Standard_Integer aNode = 0;
BinTools::GetInteger (IS, aNode);
aPoly->SetNode (aNodeIter, aNode);
}
Standard_Real aDefl = 0.0;
@ -1498,10 +1499,9 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
BinTools::PutReal(OS, aTriangulation->Deflection());
// write the 3d nodes
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
const gp_Pnt& aPnt = aNodes.Value (aNodeIter);
const gp_Pnt aPnt = aTriangulation->Node (aNodeIter);
BinTools::PutReal(OS, aPnt.X());
BinTools::PutReal(OS, aPnt.Y());
BinTools::PutReal(OS, aPnt.Z());
@ -1509,19 +1509,17 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
if (aTriangulation->HasUVNodes())
{
const TColgp_Array1OfPnt2d& aUVNodes = aTriangulation->UVNodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
const gp_Pnt2d aUV = aUVNodes.Value (aNodeIter);
const gp_Pnt2d aUV = aTriangulation->UVNode (aNodeIter);
BinTools::PutReal(OS, aUV.X());
BinTools::PutReal(OS, aUV.Y());
}
}
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
{
const Poly_Triangle& aTri = aTriangles.Value (aTriIter);
const Poly_Triangle aTri = aTriangulation->Triangle (aTriIter);
BinTools::PutInteger(OS, aTri.Value (1));
BinTools::PutInteger(OS, aTri.Value (2));
BinTools::PutInteger(OS, aTri.Value (3));
@ -1532,11 +1530,13 @@ void BinTools_ShapeSet::WriteTriangulation (Standard_OStream& OS,
{
if (aTriangulation->HasNormals() && NeedToWriteNormals)
{
const TShort_Array1OfShortReal& aNormals = aTriangulation->Normals();
for (Standard_Integer aNormalIter = 1; aNormalIter <= 3 * aNbNodes; ++aNormalIter)
gp_Vec3f aNormal;
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
{
const Standard_ShortReal& aNormal = aNormals.Value(aNormalIter);
BinTools::PutShortReal(OS, aNormal);
aTriangulation->Normal (aNormalIter, aNormal);
BinTools::PutShortReal (OS, aNormal.x());
BinTools::PutShortReal (OS, aNormal.y());
BinTools::PutShortReal (OS, aNormal.z());
}
}
}
@ -1589,45 +1589,45 @@ void BinTools_ShapeSet::ReadTriangulation (Standard_IStream& IS,
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (aNbNodes, aNbTriangles, hasUV, hasNormals);
aTriangulation->Deflection (aDefl);
TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
gp_Pnt aNode;
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
Standard_Real* anXYZ = aNodes.ChangeValue (aNodeIter).ChangeCoord().ChangeData();
BinTools::GetReal(IS, anXYZ[0]);
BinTools::GetReal(IS, anXYZ[1]);
BinTools::GetReal(IS, anXYZ[2]);
BinTools::GetReal(IS, aNode.ChangeCoord().ChangeCoord (1));
BinTools::GetReal(IS, aNode.ChangeCoord().ChangeCoord (2));
BinTools::GetReal(IS, aNode.ChangeCoord().ChangeCoord (3));
aTriangulation->SetNode (aNodeIter, aNode);
}
if (hasUV)
{
TColgp_Array1OfPnt2d& aUVNodes = aTriangulation->ChangeUVNodes();
gp_Pnt2d aNode2d;
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
gp_XY& anUV = aUVNodes.ChangeValue (aNodeIter).ChangeCoord();
BinTools::GetReal(IS, anUV.ChangeCoord (1));
BinTools::GetReal(IS, anUV.ChangeCoord (2));
BinTools::GetReal(IS, aNode2d.ChangeCoord().ChangeCoord (1));
BinTools::GetReal(IS, aNode2d.ChangeCoord().ChangeCoord (2));
aTriangulation->SetUVNode (aNodeIter, aNode2d);
}
}
// read the triangles
Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
Standard_Integer aTriNodes[3] = {};
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
{
Poly_Triangle& aTri = aTriangles.ChangeValue (aTriIter);
BinTools::GetInteger(IS, aTri.ChangeValue (1));
BinTools::GetInteger(IS, aTri.ChangeValue (2));
BinTools::GetInteger(IS, aTri.ChangeValue (3));
BinTools::GetInteger(IS, aTriNodes[0]);
BinTools::GetInteger(IS, aTriNodes[1]);
BinTools::GetInteger(IS, aTriNodes[2]);
aTriangulation->SetTriangle (aTriIter, Poly_Triangle (aTriNodes[0], aTriNodes[1], aTriNodes[2]));
}
if (hasNormals)
{
TShort_Array1OfShortReal& aNormals = aTriangulation->ChangeNormals();
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes*3; ++aNormalIter)
gp_Vec3f aNormal;
for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
{
Standard_ShortReal aNormalFromFile;
BinTools::GetShortReal(IS, aNormalFromFile);
Standard_ShortReal& aNormalCoordinate = aNormals.ChangeValue(aNormalIter);
aNormalCoordinate = aNormalFromFile;
BinTools::GetShortReal(IS, aNormal.x());
BinTools::GetShortReal(IS, aNormal.y());
BinTools::GetShortReal(IS, aNormal.z());
aTriangulation->SetNormal (aNormalIter, aNormal);
}
}

View File

@ -777,13 +777,15 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
Handle(Poly_Triangulation) PolyTr;
Handle(Poly_PolygonOnTriangulation) Poly;
BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, PolyTr, loc);
if (!Poly.IsNull()) {
if (!Poly.IsNull())
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = PolyTr->Nodes();
for (i=Indices.Lower()+1; i<=Indices.Upper(); i++) {
dis.Draw(Nodes(Indices(i-1)).Transformed(loc),
Nodes(Indices(i)).Transformed(loc));
if (dis.HasPicked()) {
for (i=Indices.Lower()+1; i<=Indices.Upper(); i++)
{
dis.Draw (PolyTr->Node (Indices (i-1)).Transformed (loc),
PolyTr->Node (Indices (i )).Transformed (loc));
if (dis.HasPicked())
{
pickshape = E->Edge();
upick = 0;
vpick = 0;
@ -1079,11 +1081,11 @@ void DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
NCollection_Vector< NCollection_Vec2<Standard_Integer> > anInternal;
Standard_Integer fr = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer n[3];
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
T->Triangle (i).Get (n[0],n[1],n[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
@ -1099,16 +1101,14 @@ void DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
}
// Display the edges
const TColgp_Array1OfPnt& Nodes = T->Nodes();
// std::cout<<"nb nodes = "<<Nodes.Length()<<std::endl;
// free edges
Standard_Integer nn;
dis.SetColor(Draw_rouge);
nn = Free.Length() / 2;
for (i = 1; i <= nn; i++) {
dis.Draw(Nodes(Free(2*i-1)).Transformed(tr),
Nodes(Free(2*i)).Transformed(tr));
dis.Draw (T->Node (Free[2*i-1]).Transformed (tr),
T->Node (Free[2*i]).Transformed (tr));
}
// internal edges
@ -1118,7 +1118,7 @@ void DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
{
const Standard_Integer n1 = anInterIter.Value()[0];
const Standard_Integer n2 = anInterIter.Value()[1];
dis.Draw (Nodes(n1).Transformed(tr), Nodes(n2).Transformed(tr));
dis.Draw (T->Node (n1).Transformed (tr), T->Node (n2).Transformed (tr));
}
}
@ -1139,11 +1139,10 @@ Standard_Boolean DBRep_DrawableShape::addMeshNormals (NCollection_Vector<std::pa
return Standard_False;
}
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
BRepAdaptor_Surface aSurface (theFace);
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
{
gp_Pnt aP1 = aNodes (aNodeIter);
gp_Pnt aP1 = aTriangulation->Node (aNodeIter);
if (!aLoc.IsIdentity())
{
aP1.Transform (aLoc.Transformation());

View File

@ -64,11 +64,10 @@ DrawTrSurf_Triangulation::DrawTrSurf_Triangulation
TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer n[3];
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
T->Triangle (i).Get (n[0],n[1],n[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
@ -146,15 +145,14 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
// Display the edges
Standard_Integer i,n;
const TColgp_Array1OfPnt& Nodes = myTriangulation->Nodes();
// free edges
dis.SetColor(Draw_rouge);
const TColStd_Array1OfInteger& Free = myFree->Array1();
n = Free.Length() / 2;
for (i = 1; i <= n; i++) {
dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
dis.Draw (myTriangulation->Node (Free[2*i-1]),
myTriangulation->Node (Free[2*i]));
}
// internal edges
@ -163,7 +161,8 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
n = Internal.Length() / 2;
for (i = 1; i <= n; i++) {
dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
dis.Draw (myTriangulation->Node (Internal[2*i-1]),
myTriangulation->Node (Internal[2*i]));
}
// texts
@ -173,7 +172,7 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
n = myTriangulation->NbNodes();
for (i = 1; i <= n; i++) {
Sprintf(text,"%d",i);
dis.DrawString(Nodes(i),text);
dis.DrawString (myTriangulation->Node (i), text);
}
}
@ -181,13 +180,12 @@ void DrawTrSurf_Triangulation::DrawOn(Draw_Display& dis) const
dis.SetColor(Draw_vert);
n = myTriangulation->NbTriangles();
Standard_Integer t[3],j;
const Poly_Array1OfTriangle& triangle = myTriangulation->Triangles();
for (i = 1; i <= n; i++) {
triangle(i).Get(t[0],t[1],t[2]);
myTriangulation->Triangle (i).Get (t[0],t[1],t[2]);
gp_Pnt P(0,0,0);
gp_XYZ& bary = P.ChangeCoord();
for (j = 0; j < 3; j++)
bary.Add(Nodes(t[j]).Coord());
bary.Add (myTriangulation->Node (t[j]).Coord());
bary.Multiply(1./3.);
Sprintf(text,"%d",i);

View File

@ -67,11 +67,10 @@ DrawTrSurf_Triangulation2D::DrawTrSurf_Triangulation2D
TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer n[3];
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
T->Triangle(i).Get (n[0],n[1],n[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
@ -108,28 +107,27 @@ void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
{
// Display the edges
Standard_Integer i,n;
if (myTriangulation->HasUVNodes()) {
const TColgp_Array1OfPnt2d& Nodes = myTriangulation->UVNodes();
if (myTriangulation->HasUVNodes())
{
// free edges
dis.SetColor(Draw_rouge);
const TColStd_Array1OfInteger& Free = myFree->Array1();
n = Free.Length() / 2;
for (i = 1; i <= n; i++) {
dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
for (i = 1; i <= n; i++)
{
dis.Draw (myTriangulation->UVNode (Free[2*i-1]),
myTriangulation->UVNode (Free[2*i]));
}
// internal edges
dis.SetColor(Draw_bleu);
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
n = Internal.Length() / 2;
for (i = 1; i <= n; i++) {
dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
for (i = 1; i <= n; i++)
{
dis.Draw (myTriangulation->UVNode (Internal[2*i-1]),
myTriangulation->UVNode (Internal[2*i]));
}
}
}

View File

@ -428,10 +428,8 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
TTMa[2][0] = ttma.Value(3,1);
TTMa[2][1] = ttma.Value(3,2);
TTMa[2][2] = ttma.Value(3,3);
Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
Standard_Integer nbN = Nod.Upper();
Standard_Integer nbT = Tri.Upper();
const Standard_Integer nbN = Tr->NbNodes();
const Standard_Integer nbT = Tr->NbTriangles();
PD (f) = new HLRAlgo_PolyData();
psd->PolyData().ChangeValue(iFace) = PD(f);
PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
@ -452,22 +450,20 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
HLRAlgo_Array1OfTData* TData = &pid->TData();
HLRAlgo_Array1OfPISeg* PISeg = &pid->PISeg();
HLRAlgo_Array1OfPINod* PINod = &pid->PINod();
Poly_Triangle * OT = &(Tri.ChangeValue(1));
HLRAlgo_TriangleData* NT = &TData->ChangeValue(1);
for (i = 1; i <= nbT; i++) {
OT->Get(NT->Node1, NT->Node2, NT->Node3);
for (i = 1; i <= nbT; i++)
{
Tr->Triangle (i).Get (NT->Node1, NT->Node2, NT->Node3);
NT->Flags = 0;
if (reversed) {
j = NT->Node1;
NT->Node1 = NT->Node3;
NT->Node3 = j;
}
OT++;
NT++;
}
gp_Pnt * ON = &(Nod.ChangeValue(1));
Handle(HLRAlgo_PolyInternalNode)* NN = &PINod->ChangeValue(1);
for (i = 1; i <= nbN; i++) {
@ -475,23 +471,20 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
HLRAlgo_PolyInternalNode::NodeIndices& aNodIndices = (*NN)->Indices();
aNodIndices.NdSg = 0;
aNodIndices.Flag = 0;
Nod1RValues.Point = ON->Coord();
Nod1RValues.Point = Tr->Node (i).Coord();
TTMultiply(Nod1RValues.Point);
ON++;
NN++;
}
pid->UpdateLinks(TData,PISeg,PINod);
if (Tr->HasUVNodes()) {
myBSurf.Initialize(F,Standard_False);
TColgp_Array1OfPnt2d & UVN = Tr->ChangeUVNodes();
gp_Pnt2d* OUVN = &(UVN.ChangeValue(1));
NN = &(((HLRAlgo_Array1OfPINod*)PINod)->
ChangeValue(1));
for (i = 1; i <= nbN; i++) {
HLRAlgo_PolyInternalNode::NodeIndices& aNodIndices = (*NN)->Indices();
HLRAlgo_PolyInternalNode::NodeData& Nod1RValues = (*NN)->Data();
Nod1RValues.UV = OUVN->Coord();
Nod1RValues.UV = Tr->UVNode (i).Coord();
if (Normal(i,aNodIndices,Nod1RValues,
TData,PISeg,PINod,Standard_False))
aNodIndices.Flag |= NMsk_Norm;
@ -499,7 +492,6 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
aNodIndices.Flag &= ~NMsk_Norm;
Nod1RValues.Scal = 0;
}
OUVN++;
NN++;
}
}

View File

@ -382,19 +382,20 @@ void IVtkOCC_ShapeMesher::addEdge (const TopoDS_Edge& theEdge,
anEdgeTransf,
theMeshType);
}
else
else if (aPolyOnTriangulation->NbNodes() >= 2)
{
Standard_Integer aNbNodes = aPolyOnTriangulation->NbNodes();
const TColStd_Array1OfInteger& aPointIds = aPolyOnTriangulation->Nodes();
const TColgp_Array1OfPnt& aPoints = aTriangulation->Nodes();
IVtk_PointIdList aPolyPointIds;
const Standard_Integer aNbNodes = aPolyOnTriangulation->NbNodes();
for (Standard_Integer aJ = 0; aJ < aNbNodes; aJ++)
{
const Standard_Integer aPntId = aPolyOnTriangulation->Node (aJ + 1);
gp_Pnt aPoint = aTriangulation->Node (aPntId);
if (!noTransform) { aPoint.Transform (anEdgeTransf); }
processPolyline (aNbNodes,
aPoints,
aPointIds,
theShapeId,
noTransform,
anEdgeTransf,
theMeshType);
IVtk_PointId anId = myShapeData->InsertCoordinate (aPoint.X(), aPoint.Y(), aPoint.Z());
aPolyPointIds.Append (anId);
}
myShapeData->InsertLine (theShapeId, &aPolyPointIds, theMeshType);
}
}
@ -493,7 +494,6 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
}
// Get triangulation points.
const TColgp_Array1OfPnt& aPoints = anOcctTriangulation->Nodes();
Standard_Integer aNbPoints = anOcctTriangulation->NbNodes();
// Keep inserted points id's of triangulation in an array.
@ -503,7 +503,7 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
Standard_Integer anI;
for (anI = 1; anI <= aNbPoints; anI++)
{
gp_Pnt aPoint = aPoints (anI);
gp_Pnt aPoint = anOcctTriangulation->Node (anI);
if (!noTransform)
{
@ -516,12 +516,11 @@ void IVtkOCC_ShapeMesher::addShadedFace (const TopoDS_Face& theFace,
}
// Create triangles on the created triangulation points.
const Poly_Array1OfTriangle& aTriangles = anOcctTriangulation->Triangles();
Standard_Integer aNbTriangles = anOcctTriangulation->NbTriangles();
Standard_Integer aN1, aN2, aN3;
for (anI = 1; anI <= aNbTriangles; anI++)
{
aTriangles(anI).Get (aN1, aN2, aN3); // get indexes of triangle's points
anOcctTriangulation->Triangle (anI).Get (aN1, aN2, aN3); // get indexes of triangle's points
// Insert new triangle on these points into output shape data.
myShapeData->InsertTriangle (
theShapeId, aPointIds(aN1), aPointIds(aN2), aPointIds(aN3), MT_ShadedFace);

View File

@ -334,7 +334,6 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
new Poly_Triangulation (aNbNodes, aNbTriangles, Standard_False);
// fill nodes
TColgp_Array1OfPnt &aNodes = aTriangulation->ChangeNodes();
GeomAdaptor_Surface anAdSurf (aSurf);
double aDU = (aUMax - aUMin) / aNbU;
double aDV = (aVMax - aVMin) / aNbV;
@ -345,12 +344,11 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
{
double aV = aVMin + iV * aDV;
gp_Pnt aP = anAdSurf.Value (aU, aV);
aNodes.SetValue (iShift + iV, aP);
aTriangulation->SetNode (iShift + iV, aP);
}
}
// fill triangles
Poly_Array1OfTriangle &aTriangles = aTriangulation->ChangeTriangles();
for (int iU = 0, iShift = 1, iTri = 0; iU < aNbU; iU++, iShift += aNbV + 1)
{
for (int iV = 0; iV < aNbV; iV++)
@ -358,8 +356,8 @@ static Standard_Integer tessellate (Draw_Interpretor& /*di*/, Standard_Integer n
int iBase = iShift + iV;
Poly_Triangle aTri1 (iBase, iBase + aNbV + 2, iBase + 1);
Poly_Triangle aTri2 (iBase, iBase + aNbV + 1, iBase + aNbV + 2);
aTriangles.SetValue (++iTri, aTri1);
aTriangles.SetValue (++iTri, aTri2);
aTriangulation->SetTriangle (++iTri, aTri1);
aTriangulation->SetTriangle (++iTri, aTri2);
}
}
@ -574,21 +572,18 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
Standard_Real deflemax = 0, deflemin = 1.e100;
if (!T.IsNull()) {
Standard_Real defstock = T->Deflection();
const Poly_Array1OfTriangle& triangles = T->Triangles();
const TColgp_Array1OfPnt2d& Nodes2d = T->UVNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
S = BRep_Tool::Surface(F, L);
for(i = 1; i <= triangles.Length(); i++) {
for(i = 1; i <= T->NbTriangles(); i++) {
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(n1,n3,n2);
T->Triangle (i).Get (n1,n3,n2);
else
triangles(i).Get(n1,n2,n3);
T->Triangle (i).Get (n1,n2,n3);
const gp_XY& xy1 = Nodes2d(n1).XY();
const gp_XY& xy2 = Nodes2d(n2).XY();
const gp_XY& xy3 = Nodes2d(n3).XY();
const gp_XY& xy1 = T->UVNode (n1).XY();
const gp_XY& xy2 = T->UVNode (n2).XY();
const gp_XY& xy3 = T->UVNode (n3).XY();
mi2d1.SetCoord((xy2.X()+xy3.X())*0.5,
(xy2.Y()+xy3.Y())*0.5);
@ -597,9 +592,9 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
mi2d3.SetCoord((xy1.X()+xy2.X())*0.5,
(xy1.Y()+xy2.Y())*0.5);
gp_XYZ p1 = Nodes(n1).Transformed(L.Transformation()).XYZ();
gp_XYZ p2 = Nodes(n2).Transformed(L.Transformation()).XYZ();
gp_XYZ p3 = Nodes(n3).Transformed(L.Transformation()).XYZ();
gp_XYZ p1 = T->Node (n1).Transformed (L.Transformation()).XYZ();
gp_XYZ p2 = T->Node (n2).Transformed (L.Transformation()).XYZ();
gp_XYZ p3 = T->Node (n3).Transformed (L.Transformation()).XYZ();
vecEd1=p2-p1;
vecEd2=p3-p2;
@ -721,11 +716,10 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
TColStd_Array1OfInteger Internal(0,2*nInternal);
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer nodes[3];
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(nodes[0],nodes[1],nodes[2]);
T->Triangle (i).Get (nodes[0],nodes[1],nodes[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
@ -744,17 +738,15 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
// Display the edges
if (T->HasUVNodes()) {
const TColgp_Array1OfPnt2d& Nodes2d = T->UVNodes();
Handle(Draw_Segment2D) Seg;
// free edges
Standard_Integer nn;
nn = Free.Length() / 2;
for (i = 1; i <= nn; i++) {
Seg = new Draw_Segment2D(Nodes2d(Free(2*i-1)),
Nodes2d(Free(2*i)),
Draw_rouge);
Seg = new Draw_Segment2D (T->UVNode (Free[2*i-1]),
T->UVNode (Free[2*i]),
Draw_rouge);
dout << Seg;
}
@ -762,9 +754,9 @@ static Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char*
nn = nInternal;
for (i = 1; i <= nn; i++) {
Seg = new Draw_Segment2D(Nodes2d(Internal(2*i-1)),
Nodes2d(Internal(2*i)),
Draw_bleu);
Seg = new Draw_Segment2D (T->UVNode (Internal[2*i-1]),
T->UVNode (Internal[2*i]),
Draw_bleu);
dout << Seg;
}
}
@ -833,11 +825,10 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
if (!Tr.IsNull()) {
nbNodes = Tr->NbNodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
// les noeuds.
for (i = 1; i <= nbNodes; i++) {
gp_Pnt Pnt = Nodes(i).Transformed(L.Transformation());
gp_Pnt Pnt = Tr->Node (i).Transformed (L.Transformation());
x = Pnt.X();
y = Pnt.Y();
z = Pnt.Z();
@ -850,12 +841,11 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
// les normales.
if (Tr->HasUVNodes()) {
const TColgp_Array1OfPnt2d& UVNodes = Tr->UVNodes();
BRepAdaptor_Surface BS(F, Standard_False);
for (i = 1; i <= nbNodes; i++) {
U = UVNodes(i).X();
V = UVNodes(i).Y();
U = Tr->UVNode (i).X();
V = Tr->UVNode (i).Y();
BS.D1(U,V,P,D1U,D1V);
CSLib::Normal (D1U, D1V, Precision::Angular(), aStatus, Nor);
@ -875,14 +865,12 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
// les triangles.
Standard_Integer nbTriangles = Tr->NbTriangles();
const Poly_Array1OfTriangle& triangles = Tr->Triangles();
for (i = 1; i <= nbTriangles; i++) {
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(n1, n3, n2);
Tr->Triangle (i).Get (n1, n3, n2);
else
triangles(i).Get(n1, n2, n3);
Tr->Triangle (i).Get (n1, n2, n3);
k1 = n1+totalnodes;
k2 = n2+totalnodes;
k3 = n3+totalnodes;
@ -950,14 +938,13 @@ static Standard_Integer triedgepoints(Draw_Interpretor& di, Standard_Integer nba
BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(it.Key()), aPoly, aT, aLoc);
if ( aT.IsNull() || aPoly.IsNull() )
continue;
const TColgp_Array1OfPnt& Nodes = aT->Nodes();
const TColStd_Array1OfInteger& Indices = aPoly->Nodes();
const Standard_Integer nbnodes = Indices.Length();
for( Standard_Integer j = 1; j <= nbnodes; j++ )
{
gp_Pnt P3d = Nodes(Indices(j));
gp_Pnt P3d = aT->Node (Indices[j]);
if( !aLoc.IsIdentity() )
P3d.Transform(aLoc.Transformation());

View File

@ -112,8 +112,6 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// check distances between corresponding points
Standard_Real aSqDefle = BRep_Tool::Tolerance(aEdge);
aSqDefle *= aSqDefle;
const TColgp_Array1OfPnt& aPoints1 = aT1->Nodes();
const TColgp_Array1OfPnt& aPoints2 = aT2->Nodes();
Standard_Integer iF1 = aMapF.FindIndex(aFace1);
Standard_Integer iF2 = aMapF.FindIndex(aFace2);
Standard_Integer i1 = aNodes1.Lower();
@ -121,17 +119,17 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
const gp_Trsf &aTrsf1 = aFace1.Location().Transformation();
const gp_Trsf &aTrsf2 = aFace2.Location().Transformation();
for (; i1 <= aNodes1.Upper(); i1++, i2++) {
const gp_Pnt aP1 = aPoints1(aNodes1(i1)).Transformed(aTrsf1);
const gp_Pnt aP2 = aPoints2(aNodes2(i2)).Transformed(aTrsf2);
const Standard_Real aSqDist = aP1.SquareDistance(aP2);
const gp_Pnt aP1 = aT1->Node (aNodes1[i1]).Transformed (aTrsf1);
const gp_Pnt aP2 = aT2->Node (aNodes2[i2]).Transformed (aTrsf2);
const Standard_Real aSqDist = aP1.SquareDistance(aP2);
if (aSqDist > aSqDefle)
{
myErrors.Append(iF1);
myErrors.Append(i1);
myErrors.Append(iF2);
myErrors.Append(i2);
myErrors.Append(iF1);
myErrors.Append(i1);
myErrors.Append(iF2);
myErrors.Append(i2);
myErrorsVal.Append(Sqrt(aSqDist));
}
}
}
}
}
@ -167,10 +165,9 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// check of free links and nodes
Poly_Connect aConn(aT);
const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
Standard_Integer nbTri = aT->NbTriangles(), i, j, n[3], t[3];
for (i = 1; i <= nbTri; i++) {
aTriangles(i).Get(n[0], n[1], n[2]);
aT->Triangle (i).Get (n[0], n[1], n[2]);
aUsedNodes.Add (n[0]);
aUsedNodes.Add (n[1]);

View File

@ -303,15 +303,14 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
std::cout << "face "<<i<<" has no triangulation"<<std::endl;
continue;
}
const Poly_Array1OfTriangle& triangles = aPoly->Triangles();
const TColgp_Array1OfPnt& nodes = aPoly->Nodes();
for (int j=triangles.Lower(); j <= triangles.Upper(); j++) {
const Poly_Triangle& tri = triangles(j);
for (int j = 1; j <= aPoly->NbTriangles(); j++)
{
const Poly_Triangle tri = aPoly->Triangle (j);
int n1, n2, n3;
tri.Get (n1, n2, n3);
const gp_Pnt& p1 = nodes(n1);
const gp_Pnt& p2 = nodes(n2);
const gp_Pnt& p3 = nodes(n3);
const gp_Pnt p1 = aPoly->Node (n1);
const gp_Pnt p2 = aPoly->Node (n2);
const gp_Pnt p3 = aPoly->Node (n3);
gp_Vec v1(p1, p2);
gp_Vec v2(p1, p3);
double ar = v1.CrossMagnitude(v2);
@ -370,7 +369,6 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
const TopoDS_Face& aFace = TopoDS::Face(aShape);
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
const gp_Trsf& trsf = aLoc.Transformation();
TColgp_Array1OfPnt pnts(1,2);
@ -379,17 +377,16 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
Standard_Integer n1, n2;
aCheck.GetFreeLink(k, i, n1, n2);
di << "{" << n1 << " " << n2 << "} ";
pnts(1) = aPoints(n1).Transformed(trsf);
pnts(2) = aPoints(n2).Transformed(trsf);
pnts (1) = aT->Node (n1).Transformed (trsf);
pnts (2) = aT->Node (n2).Transformed (trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
DrawTrSurf::Set (name, poly);
DrawTrSurf::Set (name, pnts(1));
DrawTrSurf::Set (name, pnts(2));
if (aT->HasUVNodes())
{
const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
pnts2d(1) = aPoints2d(n1);
pnts2d(2) = aPoints2d(n2);
pnts2d (1) = aT->UVNode (n1);
pnts2d (2) = aT->UVNode (n2);
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
DrawTrSurf::Set (name, poly2d);
DrawTrSurf::Set (name, pnts2d(1));
@ -435,12 +432,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
const TopoDS_Face& aFace = TopoDS::Face(aMapF.FindKey(iface));
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
const gp_Trsf& trsf = aLoc.Transformation();
DrawTrSurf::Set (name, aPoints(inode).Transformed(trsf));
DrawTrSurf::Set (name, aT->Node (inode).Transformed (trsf));
if (aT->HasUVNodes())
{
DrawTrSurf::Set (name, aT->UVNodes()(inode));
DrawTrSurf::Set (name, aT->UVNode (inode));
}
di << "{" << iface << " " << inode << "} ";
@ -464,12 +460,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
const Poly_Triangle &aTri = aT->Triangle(aTriID);
Standard_Integer aN1, aN2, aN3;
aTri.Get(aN1, aN2, aN3);
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
TColgp_Array1OfPnt aPoles(1, 4);
aPoles(1) = aPoles(4) = aPoints(aN1).Transformed(aTrsf);
aPoles(2) = aPoints(aN2).Transformed(aTrsf);
aPoles(3) = aPoints(aN3).Transformed(aTrsf);
aPoles (1) = aPoles (4) = aT->Node (aN1).Transformed (aTrsf);
aPoles (2) = aT->Node (aN2).Transformed (aTrsf);
aPoles (3) = aT->Node (aN3).Transformed (aTrsf);
TColStd_Array1OfInteger aMults(1, 4);
aMults(1) = aMults(4) = 2;
@ -488,9 +483,9 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
if (aT->HasUVNodes())
{
TColgp_Array1OfPnt2d aPoles2d(1, 4);
aPoles2d(1) = aPoles2d(4) = aT->UVNodes()(aN1);
aPoles2d(2) = aT->UVNodes()(aN2);
aPoles2d(3) = aT->UVNodes()(aN3);
aPoles2d (1) = aPoles2d (4) = aT->UVNode (aN1);
aPoles2d (2) = aT->UVNode (aN2);
aPoles2d (3) = aT->UVNode (aN3);
Handle(Geom2d_BSplineCurve) aBS2d = new Geom2d_BSplineCurve(aPoles2d, aKnots, aMults, 1);
@ -562,12 +557,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
break;
}
const Poly_Array1OfTriangle& aTris = aT->Triangles();
NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
Standard_Integer aTriNum = aTris.Length();
const Standard_Integer aTriNum = aT->NbTriangles();
for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
{
const Poly_Triangle& aTri = aTris(aTriIndx);
const Poly_Triangle aTri = aT->Triangle (aTriIndx);
Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
for (Standard_Integer j = 1; j <= 3; ++j)
@ -590,7 +584,6 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
{
di << "Not connected mesh inside face " << aFaceId << "\n";
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
const gp_Trsf& trsf = aLoc.Transformation();
TColgp_Array1OfPnt pnts(1,2);
@ -600,17 +593,16 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
{
const BRepMesh_Edge& aLink = aMapIt.Key();
di << "{" << aLink.FirstNode() << " " << aLink.LastNode() << "} ";
pnts(1) = aPoints(aLink.FirstNode()).Transformed(trsf);
pnts(2) = aPoints(aLink.LastNode()).Transformed(trsf);
pnts (1) = aT->Node (aLink.FirstNode()).Transformed (trsf);
pnts (2) = aT->Node (aLink.LastNode()).Transformed (trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
DrawTrSurf::Set (name, poly);
DrawTrSurf::Set (name, pnts(1));
DrawTrSurf::Set (name, pnts(2));
if (aT->HasUVNodes())
{
const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
pnts2d(1) = aPoints2d(aLink.FirstNode());
pnts2d(2) = aPoints2d(aLink.LastNode());
pnts2d (1) = aT->UVNode (aLink.FirstNode());
pnts2d (2) = aT->UVNode (aLink.LastNode());
Handle(Poly_Polygon2D) poly2d = new Poly_Polygon2D (pnts2d);
DrawTrSurf::Set (name, poly2d);
DrawTrSurf::Set (name, pnts2d(1));

View File

@ -43,42 +43,48 @@ Handle(Poly_Triangulation) Poly::Catenate (const Poly_ListOfTriangulation& lstTr
// Sum up the total number of nodes.
Poly_ListOfTriangulation::Iterator anIter(lstTri);
for (; anIter.More(); anIter.Next()) {
for (; anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTri = anIter.Value();
if (aTri.IsNull() == Standard_False) {
if (!aTri.IsNull())
{
nNodes += aTri->NbNodes();
nTrian += aTri->NbTriangles();
}
}
Handle(Poly_Triangulation) aResult;
if (nNodes > 0) {
aResult = new Poly_Triangulation(nNodes, nTrian, Standard_False);
Standard_Integer i, iNode[3];
nNodes = 0;
nTrian = 0;
TColgp_Array1OfPnt& arrNode = aResult->ChangeNodes();
Poly_Array1OfTriangle& arrTrian = aResult->ChangeTriangles();
for (anIter.Init(lstTri); anIter.More(); anIter.Next()) {
const Handle(Poly_Triangulation)& aTri = anIter.Value();
if (aTri.IsNull() == Standard_False) {
const TColgp_Array1OfPnt& srcNode = aTri->Nodes();
const Poly_Array1OfTriangle& srcTrian = aTri->Triangles();
const Standard_Integer nbNodes = aTri->NbNodes();
const Standard_Integer nbTrian = aTri->NbTriangles();
for (i = 1; i <= nbNodes; i++) {
arrNode.SetValue(i + nNodes, srcNode(i));
}
for (i = 1; i <= nbTrian; i++) {
srcTrian(i).Get(iNode[0], iNode[1], iNode[2]);
arrTrian.SetValue(i + nTrian, Poly_Triangle(iNode[0] + nNodes,
iNode[1] + nNodes,
iNode[2] + nNodes));
}
nNodes += nbNodes;
nTrian += nbTrian;
}
if (nNodes == 0)
{
return Handle(Poly_Triangulation)();
}
Handle(Poly_Triangulation) aResult = new Poly_Triangulation(nNodes, nTrian, Standard_False);
Standard_Integer iNode[3] = {};
nNodes = 0;
nTrian = 0;
for (anIter.Init(lstTri); anIter.More(); anIter.Next())
{
const Handle(Poly_Triangulation)& aTri = anIter.Value();
if (aTri.IsNull())
{
continue;
}
const Standard_Integer nbNodes = aTri->NbNodes();
const Standard_Integer nbTrian = aTri->NbTriangles();
for (Standard_Integer i = 1; i <= nbNodes; i++)
{
aResult->SetNode (i + nNodes, aTri->Node (i));
}
for (Standard_Integer i = 1; i <= nbTrian; i++)
{
aTri->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
aResult->SetTriangle (i + nTrian, Poly_Triangle (iNode[0] + nNodes,
iNode[1] + nNodes,
iNode[2] + nNodes));
}
nNodes += nbNodes;
nTrian += nbTrian;
}
return aResult;
}
@ -113,36 +119,39 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
if (!Compact) OS << "\n3D Nodes :\n";
Standard_Integer i, nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
for (i = 1; i <= nbNodes; i++)
{
const gp_Pnt aNode = T->Node (i);
if (!Compact) OS << std::setw(10) << i << " : ";
if (!Compact) OS << std::setw(17);
OS << Nodes(i).X() << " ";
OS << aNode.X() << " ";
if (!Compact) OS << std::setw(17);
OS << Nodes(i).Y() << " ";
OS << aNode.Y() << " ";
if (!Compact) OS << std::setw(17);
OS << Nodes(i).Z() << "\n";
OS << aNode.Z() << "\n";
}
if (T->HasUVNodes()) {
if (T->HasUVNodes())
{
if (!Compact) OS << "\nUV Nodes :\n";
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (i = 1; i <= nbNodes; i++) {
for (i = 1; i <= nbNodes; i++)
{
const gp_Pnt2d aNode2d = T->UVNode (i);
if (!Compact) OS << std::setw(10) << i << " : ";
if (!Compact) OS << std::setw(17);
OS << UVNodes(i).X() << " ";
if (!Compact) OS << std::setw(17);
OS << UVNodes(i).Y() << "\n";
if (!Compact) OS << std::setw(17);
OS << aNode2d.X() << " ";
if (!Compact) OS << std::setw(17);
OS << aNode2d.Y() << "\n";
}
}
if (!Compact) OS << "\nTriangles :\n";
Standard_Integer nbTriangles = T->NbTriangles();
Standard_Integer n1, n2, n3;
const Poly_Array1OfTriangle& Triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
for (i = 1; i <= nbTriangles; i++)
{
if (!Compact) OS << std::setw(10) << i << " : ";
Triangles(i).Get(n1, n2, n3);
T->Triangle (i).Get (n1, n2, n3);
if (!Compact) OS << std::setw(10);
OS << n1 << " ";
if (!Compact) OS << std::setw(10);
@ -447,70 +456,7 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
//=======================================================================
void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
{
const TColgp_Array1OfPnt& aNodes = theTri->Nodes();
const Standard_Integer aNbNodes = aNodes.Size();
const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, aNbNodes * 3);
aNormals->Init (0.0f);
Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
Standard_Integer anElem[3] = {0, 0, 0};
const Standard_Real anEps2 = gp::Resolution();
for (Poly_Array1OfTriangle::Iterator aTriIter (theTri->Triangles()); aTriIter.More(); aTriIter.Next())
{
aTriIter.Value().Get (anElem[0], anElem[1], anElem[2]);
const gp_Pnt& aNode0 = aNodes.Value (anElem[0]);
const gp_Pnt& aNode1 = aNodes.Value (anElem[1]);
const gp_Pnt& aNode2 = aNodes.Value (anElem[2]);
const gp_XYZ aVec01 = aNode1.XYZ() - aNode0.XYZ();
const gp_XYZ aVec02 = aNode2.XYZ() - aNode0.XYZ();
gp_XYZ aTriNorm = aVec01 ^ aVec02;
/*if (theToIgnoreTriangleSize)
{
const Standard_Real aMod = aTriNorm.SquareModulus();
if (aMod > anEps2)
{
aTriNorm /= Sqrt (aMod);
}
else
{
continue;
}
}*/
for (Standard_Integer aNodeIter = 0; aNodeIter < 3; ++aNodeIter)
{
const Standard_Size anIndex = (anElem[aNodeIter] - 1) * 3;
aNormArr[anIndex + 0] += Standard_ShortReal(aTriNorm.X());
aNormArr[anIndex + 1] += Standard_ShortReal(aTriNorm.Y());
aNormArr[anIndex + 2] += Standard_ShortReal(aTriNorm.Z());
}
}
// Normalize all vectors
gp_XYZ aNormXYZ;
for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
{
const Standard_Size anIndex = aNodeIter * 3;
aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
const Standard_Real aMod2 = aNormXYZ.SquareModulus();
if (aMod2 < anEps2)
{
aNormArr[anIndex + 0] = 0.0f;
aNormArr[anIndex + 1] = 0.0f;
aNormArr[anIndex + 2] = 1.0f;
}
else
{
aNormXYZ /= Sqrt (aMod2);
aNormArr[anIndex + 0] = Standard_ShortReal(aNormXYZ.X());
aNormArr[anIndex + 1] = Standard_ShortReal(aNormXYZ.Y());
aNormArr[anIndex + 2] = Standard_ShortReal(aNormXYZ.Z());
}
}
theTri->SetNormals (aNormals);
theTri->ComputeNormals();
}
//=======================================================================

View File

@ -51,45 +51,41 @@ Poly_CoherentTriangulation::Poly_CoherentTriangulation
: theAlloc)
{
if (theTriangulation.IsNull() == Standard_False) {
const TColgp_Array1OfPnt& arrNodes = theTriangulation->Nodes();
const Poly_Array1OfTriangle& arrTriangle = theTriangulation->Triangles();
const Standard_Integer nNodes = theTriangulation->NbNodes();
const Standard_Integer nTri = theTriangulation->NbTriangles();
Standard_Integer i;
// Copy the nodes
for (i = 0; i < nNodes; i++) {
const Standard_Integer anOldInd = i + arrNodes.Lower();
const Standard_Integer aNewInd = SetNode(arrNodes(anOldInd).XYZ(), i);
const Standard_Integer anOldInd = i + 1;
const Standard_Integer aNewInd = SetNode (theTriangulation->Node (anOldInd).XYZ(), i);
Poly_CoherentNode& aCopiedNode = myNodes(aNewInd);
aCopiedNode.SetIndex(anOldInd);
}
// Copy the triangles
for (i = 0; i < nTri; i++) {
for (i = 1; i <= theTriangulation->NbTriangles(); i++) {
Standard_Integer iNode[3];
arrTriangle(i + arrTriangle.Lower()).Get(iNode[0], iNode[1], iNode[2]);
theTriangulation->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0])
AddTriangle (iNode[0]-1, iNode[1]-1, iNode[2]-1);
}
// Copy UV coordinates of nodes
if (theTriangulation->HasUVNodes()) {
const TColgp_Array1OfPnt2d& arrNodes2d = theTriangulation->UVNodes();
for (i = 0; i < nNodes; i++) {
const gp_Pnt2d& anUV = arrNodes2d(i + arrNodes2d.Lower());
const gp_Pnt2d anUV = theTriangulation->UVNode (i + 1);
myNodes(i).SetUV(anUV.X(), anUV.Y());
}
}
// Copy the normals at nodes
if (theTriangulation->HasNormals()) {
const TShort_Array1OfShortReal& arrNorm = theTriangulation->Normals();
for (i = 0; i < nNodes; i++) {
const gp_XYZ aNormal (arrNorm(3 * i + 0 + arrNorm.Lower()),
arrNorm(3 * i + 1 + arrNorm.Lower()),
arrNorm(3 * i + 2 + arrNorm.Lower()));
myNodes(i).SetNormal(aNormal);
if (theTriangulation->HasNormals())
{
gp_Vec3f aNormal;
for (i = 0; i < nNodes; i++)
{
theTriangulation->Normal (i + 1, aNormal);
myNodes (i).SetNormal (gp_XYZ (aNormal.x(), aNormal.y(), aNormal.z()));
}
}
myDeflection = theTriangulation->Deflection();
@ -116,66 +112,59 @@ Poly_CoherentTriangulation::~Poly_CoherentTriangulation ()
Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
{
Handle(Poly_Triangulation) aResult;
const Standard_Integer nNodes = NNodes();
const Standard_Integer nTriangles = NTriangles();
if (nNodes > 0 && nTriangles > 0) {
aResult = new Poly_Triangulation(nNodes, nTriangles, Standard_True);
const Handle(TShort_HArray1OfShortReal) harrNormal =
new TShort_HArray1OfShortReal(1, 3 * nNodes);
Standard_ShortReal * arrNormal = &harrNormal->ChangeValue(1);
TColgp_Array1OfPnt& arrNodes = aResult->ChangeNodes();
TColgp_Array1OfPnt2d& arrNodesUV = aResult->ChangeUVNodes();
Poly_Array1OfTriangle& arrTriangle = aResult->ChangeTriangles();
NCollection_Vector<Standard_Integer> vecNodeId;
Standard_Integer i, aCount(0);
Standard_Boolean hasUV (Standard_False);
Standard_Boolean hasNormals (Standard_False);
// Copy the nodes (3D and 2D coordinates)
for (i = 0; i < myNodes.Length(); i++) {
const Poly_CoherentNode& aNode = myNodes(i);
if (aNode.IsFreeNode())
vecNodeId.SetValue(i, 0);
else {
const gp_XYZ aNormal = aNode.GetNormal();
arrNormal[3 * aCount + 0] = static_cast<Standard_ShortReal>(aNormal.X());
arrNormal[3 * aCount + 1] = static_cast<Standard_ShortReal>(aNormal.Y());
arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
vecNodeId.SetValue(i, ++aCount);
arrNodes.SetValue(aCount, aNode);
arrNodesUV.SetValue(aCount, gp_Pnt2d(aNode.GetU(), aNode.GetV()));
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
Precision::Confusion())
hasUV = Standard_True;
if (aNormal.SquareModulus() > Precision::Confusion())
hasNormals = Standard_True;
}
}
if (hasUV == Standard_False)
aResult->RemoveUVNodes();
// Copy the triangles
aCount = 0;
NCollection_Vector<Poly_CoherentTriangle>::Iterator anIterT (myTriangles);
for (; anIterT.More(); anIterT.Next()) {
const Poly_CoherentTriangle& aTri = anIterT.Value();
if (aTri.IsEmpty() == Standard_False) {
const Poly_Triangle aPolyTriangle (vecNodeId(aTri.Node(0)),
vecNodeId(aTri.Node(1)),
vecNodeId(aTri.Node(2)));
arrTriangle.SetValue(++aCount, aPolyTriangle);
}
}
if (hasNormals)
aResult->SetNormals (harrNormal);
aResult->Deflection(myDeflection);
if (nNodes == 0 || nTriangles == 0)
{
return Handle(Poly_Triangulation)();
}
Handle(Poly_Triangulation) aResult = new Poly_Triangulation(nNodes, nTriangles, false);
NCollection_Vector<Standard_Integer> vecNodeId;
Standard_Integer aCount = 0;
// Copy the nodes (3D and 2D coordinates)
for (Standard_Integer i = 0; i < myNodes.Length(); i++)
{
const Poly_CoherentNode& aNode = myNodes(i);
if (aNode.IsFreeNode())
{
vecNodeId.SetValue (i, 0);
continue;
}
vecNodeId.SetValue (i, ++aCount);
const gp_XYZ aNormal = aNode.GetNormal();
if (aNormal.SquareModulus() > Precision::Confusion())
{
aResult->AddNormals();
aResult->SetNormal (aCount, gp_Dir (aNormal));
}
aResult->SetNode (aCount, aNode);
if (aNode.GetU() * aNode.GetU() + aNode.GetV() * aNode.GetV() > Precision::Confusion())
{
aResult->AddUVNodes();
aResult->SetUVNode (aCount, gp_Pnt2d (aNode.GetU(), aNode.GetV()));
}
}
// Copy the triangles
aCount = 0;
for (NCollection_Vector<Poly_CoherentTriangle>::Iterator anIterT (myTriangles);
anIterT.More(); anIterT.Next())
{
const Poly_CoherentTriangle& aTri = anIterT.Value();
if (!aTri.IsEmpty())
{
aResult->SetTriangle (++aCount, Poly_Triangle (vecNodeId (aTri.Node (0)),
vecNodeId (aTri.Node (1)),
vecNodeId (aTri.Node (2))));
}
}
aResult->Deflection (myDeflection);
return aResult;
}

View File

@ -226,8 +226,7 @@ void Poly_Connect::Initialize(const Standard_Integer N)
if (mymore)
{
Standard_Integer i, no[3];
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
triangles(myfirst).Get(no[0], no[1], no[2]);
myTriangulation->Triangle (myfirst).Get (no[0], no[1], no[2]);
for (i = 0; i < 3; i++)
if (no[i] == mynode) break;
myothernode = no[(i+2)%3];
@ -244,12 +243,11 @@ void Poly_Connect::Next()
Standard_Integer i, j;
Standard_Integer n[3];
Standard_Integer t[3];
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
Triangles(mytr, t[0], t[1], t[2]);
if (mysense) {
for (i = 0; i < 3; i++) {
if (t[i] != 0) {
triangles(t[i]).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
for (j = 0; j < 3; j++) {
if ((n[j] == mynode) && (n[(j+1)%3] == myothernode)) {
mytr = t[i];
@ -261,7 +259,7 @@ void Poly_Connect::Next()
}
}
// sinon, depart vers la gauche.
triangles(myfirst).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (myfirst).Get (n[0], n[1], n[2]);
for (i = 0; i < 3; i++)
if (n[i] == mynode) break;
myothernode = n[(i+1)%3];
@ -272,7 +270,7 @@ void Poly_Connect::Next()
if (!mysense) {
for (i = 0; i < 3; i++) {
if (t[i] != 0) {
triangles(t[i]).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
for (j = 0; j < 3; j++) {
if ((n[j] == mynode) && (n[(j+2)%3] == myothernode)) {
mytr = t[i];

View File

@ -17,7 +17,7 @@
#ifndef _Poly_PolygonOnTriangulation_HeaderFile
#define _Poly_PolygonOnTriangulation_HeaderFile
#include <Standard_NullObject.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
#include <TColStd_Array1OfInteger.hxx>
@ -40,6 +40,7 @@ DEFINE_STANDARD_HANDLE(Poly_PolygonOnTriangulation, Standard_Transient)
//! curve.represents a 3d Polygon
class Poly_PolygonOnTriangulation : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation, Standard_Transient)
public:
//! Constructs a 3D polygon on the triangulation of a shape with specified size of nodes.
@ -79,26 +80,33 @@ public:
//! triangle, the function NbNodes returns 4.
Standard_Integer NbNodes() const { return myNodes.Length(); }
//! Returns the table of nodes for this polygon. A node value
//! is an index in the table of nodes specific to an existing
//! triangulation of a shape.
const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
//! Returns node at the given index.
Standard_Integer Node (Standard_Integer theIndex) const { return myNodes.Value (theIndex); }
//! Returns the table of nodes for this polygon for modification.
TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
//! Sets node at the given index.
void SetNode (Standard_Integer theIndex,
Standard_Integer theNode)
{
myNodes.SetValue (theIndex, theNode);
}
//! Returns true if parameters are associated with the nodes in this polygon.
Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
//! Returns the table of the parameters associated with each node in this polygon.
//! Warning
//! Use the function HasParameters to check if parameters
//! are associated with the nodes in this polygon.
const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
//! Returns parameter at the given index.
Standard_Real Parameter (Standard_Integer theIndex) const
{
Standard_NullObject_Raise_if (myParameters.IsNull(), "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
return myParameters->Value (theIndex);
}
//! Returns the table of the parameters associated with each node in this polygon.
//! Warning! HasParameters() should be called beforehand to check if parameters array is allocated.
TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
//! Sets parameter at the given index.
void SetParameter (Standard_Integer theIndex,
Standard_Real theValue)
{
Standard_NullObject_Raise_if (myParameters.IsNull(), "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
myParameters->SetValue (theIndex, theValue);
}
//! Sets the table of the parameters associated with each node in this polygon.
//! Raises exception if array size doesn't much number of polygon nodes.
@ -107,7 +115,21 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
DEFINE_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation,Standard_Transient)
public:
//! Returns the table of nodes for this polygon.
//! A node value is an index in the table of nodes specific to an existing triangulation of a shape.
const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
//! Returns the table of the parameters associated with each node in this polygon.
//! Warning! Use the function HasParameters to check if parameters are associated with the nodes in this polygon.
const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
Standard_DEPRECATED("Deprecated method, SetNode() should be used instead")
TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
Standard_DEPRECATED("Deprecated method, SetParameter() should be used instead")
TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
private:

View File

@ -89,7 +89,7 @@ public:
Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
private:
protected:
Standard_Integer myNodes[3];

View File

@ -18,9 +18,7 @@
#include <gp_Pnt.hxx>
#include <Poly_Triangle.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Dump.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
@ -35,40 +33,26 @@ Poly_Triangulation::Poly_Triangulation()
{
}
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes)
: myCachedMinMax (NULL),
myDeflection (0),
myNodes (1, theNbNodes),
myTriangles (1, theNbTriangles)
{
if (theHasUVNodes) myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
}
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes,
const Standard_Boolean theHasNormals)
: myDeflection(0),
Poly_Triangulation::Poly_Triangulation (const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes,
const Standard_Boolean theHasNormals)
: myCachedMinMax (NULL),
myDeflection(0),
myNodes (1, theNbNodes),
myTriangles (1, theNbTriangles)
{
if (theHasUVNodes)
{
myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
myUVNodes.Resize (1, theNbNodes, false);
}
if (theHasNormals)
{
myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
myNormals.Resize (1, theNbNodes, false);
}
}
@ -76,8 +60,8 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles)
Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
myNodes (1, theNodes.Length()),
@ -92,18 +76,18 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
const TColgp_Array1OfPnt2d& theUVNodes,
const Poly_Array1OfTriangle& theTriangles)
Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const TColgp_Array1OfPnt2d& theUVNodes,
const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
myNodes (1, theNodes.Length()),
myTriangles (1, theTriangles.Length())
myTriangles (1, theTriangles.Length()),
myUVNodes (1, theNodes.Length())
{
myNodes = theNodes;
myTriangles = theTriangles;
myUVNodes = new TColgp_HArray1OfPnt2d (1, theNodes.Length());
myUVNodes->ChangeArray1() = theUVNodes;
myUVNodes = theUVNodes;
}
//=======================================================================
@ -131,226 +115,190 @@ Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
//=======================================================================
Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation)
: myCachedMinMax(NULL),
: myCachedMinMax (NULL),
myDeflection(theTriangulation->myDeflection),
myNodes(theTriangulation->Nodes()),
myTriangles(theTriangulation->Triangles())
myNodes (theTriangulation->myNodes),
myTriangles (theTriangulation->myTriangles),
myUVNodes (theTriangulation->myUVNodes),
myNormals (theTriangulation->myNormals)
{
SetCachedMinMax (theTriangulation->CachedMinMax());
if (theTriangulation->HasUVNodes())
{
myUVNodes = new TColgp_HArray1OfPnt2d(theTriangulation->myUVNodes->Array1());
}
if (theTriangulation->HasNormals())
{
myNormals = new TShort_HArray1OfShortReal(theTriangulation->myNormals->Array1());
}
}
//=======================================================================
//function : Deflection
//purpose :
//=======================================================================
void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
{
myDeflection = theDeflection;
}
//=======================================================================
//function : RemoveUVNodes
//purpose :
//purpose :
//=======================================================================
void Poly_Triangulation::RemoveUVNodes()
{
myUVNodes.Nullify();
if (!myUVNodes.IsEmpty())
{
TColgp_Array1OfPnt2d anEmpty;
myUVNodes.Move (anEmpty);
}
}
//=======================================================================
//function : Node
//purpose :
//function : RemoveNormals
//purpose :
//=======================================================================
const gp_Pnt& Poly_Triangulation::Node (const Standard_Integer theIndex) const
void Poly_Triangulation::RemoveNormals()
{
if (theIndex < 1 || theIndex > myNodes.Size())
if (!myNormals.IsEmpty())
{
throw Standard_OutOfRange ("Poly_Triangulation::Node : index out of range");
NCollection_Array1<gp_Vec3f> anEmpty;
myNormals.Move (anEmpty);
}
return myNodes.Value (theIndex);
}
//=======================================================================
//function : ChangeNode
//purpose :
//function : MapNodeArray
//purpose :
//=======================================================================
gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
Handle(TColgp_HArray1OfPnt) Poly_Triangulation::MapNodeArray() const
{
if (theIndex < 1 || theIndex > myNodes.Size())
if (myNodes.IsEmpty())
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeNode : index out of range");
return Handle(TColgp_HArray1OfPnt)();
}
return myNodes.ChangeValue (theIndex);
Handle(TColgp_HArray1OfPnt) anHArray = new TColgp_HArray1OfPnt();
TColgp_Array1OfPnt anArray (myNodes.First(), 1, NbNodes());
anHArray->Move (anArray);
return anHArray;
}
//=======================================================================
//function : UVNode
//purpose :
//function : MapTriangleArray
//purpose :
//=======================================================================
const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
Handle(Poly_HArray1OfTriangle) Poly_Triangulation::MapTriangleArray() const
{
if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
if (myTriangles.IsEmpty())
{
throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
return Handle(Poly_HArray1OfTriangle)();
}
return myUVNodes->Value (theIndex);
Handle(Poly_HArray1OfTriangle) anHArray = new Poly_HArray1OfTriangle();
Poly_Array1OfTriangle anArray (myTriangles.First(), 1, NbTriangles());
anHArray->Move (anArray);
return anHArray;
}
//=======================================================================
//function : ChangeUVNode
//purpose :
//function : MapUVNodeArray
//purpose :
//=======================================================================
gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
Handle(TColgp_HArray1OfPnt2d) Poly_Triangulation::MapUVNodeArray() const
{
if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
if (myUVNodes.IsEmpty())
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
return Handle(TColgp_HArray1OfPnt2d)();
}
return myUVNodes->ChangeValue (theIndex);
Handle(TColgp_HArray1OfPnt2d) anHArray = new TColgp_HArray1OfPnt2d();
TColgp_Array1OfPnt2d anArray (myUVNodes.First(), 1, NbNodes());
anHArray->Move (anArray);
return anHArray;
}
//=======================================================================
//function : Triangle
//purpose :
//function : MapNormalArray
//purpose :
//=======================================================================
const Poly_Triangle& Poly_Triangulation::Triangle (const Standard_Integer theIndex) const
Handle(TShort_HArray1OfShortReal) Poly_Triangulation::MapNormalArray() const
{
if (theIndex < 1 || theIndex > myTriangles.Size())
if (myNormals.IsEmpty())
{
throw Standard_OutOfRange ("Poly_Triangulation::Triangle : index out of range");
return Handle(TShort_HArray1OfShortReal)();
}
return myTriangles.Value (theIndex);
}
//=======================================================================
//function : ChangeTriangle
//purpose :
//=======================================================================
Poly_Triangle& Poly_Triangulation::ChangeTriangle (const Standard_Integer theIndex)
{
if (theIndex < 1 || theIndex > myTriangles.Size())
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeTriangle : index out of range");
}
return myTriangles.ChangeValue (theIndex);
Handle(TShort_HArray1OfShortReal) anHArray = new TShort_HArray1OfShortReal();
TShort_Array1OfShortReal anArray (*myNormals.First().GetData(), 1, 3 * NbNodes());
anHArray->Move (anArray);
return anHArray;
}
//=======================================================================
//function : SetNormals
//purpose :
//purpose :
//=======================================================================
void Poly_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals)
{
if(theNormals.IsNull() || theNormals->Length() != 3 * NbNodes()) {
if (theNormals.IsNull() || theNormals->Length() != 3 * NbNodes())
{
throw Standard_DomainError("Poly_Triangulation::SetNormals : wrong length");
}
myNormals = theNormals;
}
//=======================================================================
//function : Normals
//purpose :
//=======================================================================
const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
{
if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
throw Standard_NullObject("Poly_Triangulation::Normals : "
"wrong length or null array");
}
return myNormals->Array1();
}
//=======================================================================
//function : ChangeNormals
//purpose :
//=======================================================================
TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
{
if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
"wrong length or null array");
}
return myNormals->ChangeArray1();
}
//=======================================================================
//function : HasNormals
//purpose :
//=======================================================================
Standard_Boolean Poly_Triangulation::HasNormals() const
{
if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : SetNormal
//purpose :
//=======================================================================
void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
{
if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
AddNormals();
const Standard_Integer anArrayLower = theNormals->Lower();
for (Standard_Integer aNodeIter = 1; aNodeIter <= NbNodes(); ++aNodeIter)
{
throw Standard_NullObject ("Poly_Triangulation::SetNormal : empty array or index out of range");
Standard_Integer anArrayInd = anArrayLower + (aNodeIter - 1) * 3;
gp_Vec3f aNorm (theNormals->Value (anArrayInd + 0),
theNormals->Value (anArrayInd + 1),
theNormals->Value (anArrayInd + 2));
SetNormal (aNodeIter, aNorm);
}
myNormals->ChangeValue (theIndex * 3 - 2) = (Standard_ShortReal) theNormal.X();
myNormals->ChangeValue (theIndex * 3 - 1) = (Standard_ShortReal) theNormal.Y();
myNormals->ChangeValue (theIndex * 3) = (Standard_ShortReal) theNormal.Z();
}
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
// =======================================================================
// function : ResizeNodes
// purpose :
// =======================================================================
void Poly_Triangulation::ResizeNodes (Standard_Integer theNbNodes,
Standard_Boolean theToCopyOld)
{
if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
myNodes.Resize (1, theNbNodes, theToCopyOld);
if (!myUVNodes.IsEmpty())
{
throw Standard_NullObject ("Poly_Triangulation::Normal : empty array or index out of range");
myUVNodes.Resize (1, theNbNodes, theToCopyOld);
}
if (!myNormals.IsEmpty())
{
myNormals.Resize (1, theNbNodes, theToCopyOld);
}
}
gp_Dir N(myNormals->Value(theIndex * 3 - 2),
myNormals->Value(theIndex * 3 - 1),
myNormals->Value(theIndex * 3));
// =======================================================================
// function : ResizeTriangles
// purpose :
// =======================================================================
void Poly_Triangulation::ResizeTriangles (Standard_Integer theNbTriangles,
Standard_Boolean theToCopyOld)
{
myTriangles.Resize (1, theNbTriangles, theToCopyOld);
}
return N;
// =======================================================================
// function : AddUVNodes
// purpose :
// =======================================================================
void Poly_Triangulation::AddUVNodes()
{
if (myUVNodes.IsEmpty() || myUVNodes.Size() != myNodes.Size())
{
myUVNodes.Resize (1, myNodes.Size(), false);
}
}
// =======================================================================
// function : AddNormals
// purpose :
// =======================================================================
void Poly_Triangulation::AddNormals()
{
if (myNormals.IsEmpty() || myNormals.Size() != myNodes.Size())
{
myNormals.Resize (1, myNodes.Size(), false);
}
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
@ -358,10 +306,10 @@ void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Intege
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDeflection)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNodes.Size())
if (!myUVNodes.IsNull())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUVNodes->Size())
if (!myNormals.IsNull())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNormals->Size())
if (!myUVNodes.IsEmpty())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUVNodes.Size())
if (!myNormals.IsEmpty())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNormals.Size())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTriangles.Size())
}
@ -455,3 +403,40 @@ Bnd_Box Poly_Triangulation::computeBoundingBox (const gp_Trsf& theTrsf) const
}
return aBox;
}
//=======================================================================
//function : ComputeNormals
//purpose :
//=======================================================================
void Poly_Triangulation::ComputeNormals()
{
// zero values
AddNormals();
myNormals.Init (gp_Vec3f (0.0f));
Standard_Integer anElem[3] = {0, 0, 0};
for (Poly_Array1OfTriangle::Iterator aTriIter (myTriangles); aTriIter.More(); aTriIter.Next())
{
aTriIter.Value().Get (anElem[0], anElem[1], anElem[2]);
const gp_Pnt aNode0 = myNodes.Value (anElem[0]);
const gp_Pnt aNode1 = myNodes.Value (anElem[1]);
const gp_Pnt aNode2 = myNodes.Value (anElem[2]);
const gp_XYZ aVec01 = aNode1.XYZ() - aNode0.XYZ();
const gp_XYZ aVec02 = aNode2.XYZ() - aNode0.XYZ();
const gp_XYZ aTriNorm = aVec01 ^ aVec02;
const gp_Vec3f aNorm3f = gp_Vec3f (float(aTriNorm.X()), float(aTriNorm.Y()), float(aTriNorm.Z()));
for (Standard_Integer aNodeIter = 0; aNodeIter < 3; ++aNodeIter)
{
myNormals.ChangeValue (anElem[aNodeIter]) += aNorm3f;
}
}
// Normalize all vectors
for (NCollection_Array1<gp_Vec3f>::Iterator aNodeIter (myNormals); aNodeIter.More(); aNodeIter.Next())
{
gp_Vec3f& aNorm3f = aNodeIter.ChangeValue();
const float aMod = aNorm3f.Modulus();
aNorm3f = aMod == 0.0f ? gp_Vec3f (0.0f, 0.0f, 1.0f) : (aNorm3f / aMod);
}
}

View File

@ -18,21 +18,11 @@
#define _Poly_Triangulation_HeaderFile
#include <Bnd_Box.hxx>
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <gp_Vec3f.hxx>
#include <Poly_HArray1OfTriangle.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <TShort_HArray1OfShortReal.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Boolean.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TShort_Array1OfShortReal.hxx>
class Standard_DomainError;
class Standard_NullObject;
class Poly_Triangulation;
DEFINE_STANDARD_HANDLE(Poly_Triangulation, Standard_Transient)
@ -64,32 +54,24 @@ DEFINE_STANDARD_HANDLE(Poly_Triangulation, Standard_Transient)
//! This is a Transient class.
class Poly_Triangulation : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(Poly_Triangulation, Standard_Transient)
public:
//! Constructs an empty triangulation.
Standard_EXPORT Poly_Triangulation();
//! Constructs a triangulation from a set of triangles. The
//! triangulation is initialized without a triangle or a node, but capable of
//! containing nbNodes nodes, and nbTriangles
//! triangles. Here the UVNodes flag indicates whether
//! 2D nodes will be associated with 3D ones, (i.e. to
//! enable a 2D representation).
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean UVNodes);
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized without a triangle or a node,
//! but capable of containing nbNodes nodes, and nbTriangles triangles.
//! Here the UVNodes flag indicates whether 2D nodes will be associated with 3D ones,
//! (i.e. to enable a 2D representation).
//! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
const Standard_Integer nbTriangles,
const Standard_Boolean UVNodes,
const Standard_Boolean hasNormals);
//! but capable of containing specified number of nodes and triangles.
//! @param theNbNodes [in] number of nodes to allocate
//! @param theNbTriangles [in] number of triangles to allocate
//! @param theHasUVNodes [in] indicates whether 2D nodes will be associated with 3D ones,
//! (i.e. to enable a 2D representation)
//! @param theHasNormals [in] indicates whether normals will be given and associated with nodes
Standard_EXPORT Poly_Triangulation (const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes,
const Standard_Boolean theHasNormals = false);
//! Constructs a triangulation from a set of triangles. The
//! triangulation is initialized with 3D points from Nodes and triangles
@ -119,10 +101,7 @@ public:
//! Sets the deflection of this triangulation to theDeflection.
//! See more on deflection in Polygon2D
Standard_EXPORT void Deflection (const Standard_Real theDeflection);
//! Deallocates the UV nodes.
Standard_EXPORT void RemoveUVNodes();
void Deflection (const Standard_Real theDeflection) { myDeflection = theDeflection; }
//! Returns TRUE if triangulation has some geometry.
virtual Standard_Boolean HasGeometry() const { return !myNodes.IsEmpty() && !myTriangles.IsEmpty(); }
@ -134,88 +113,70 @@ public:
Standard_Integer NbTriangles() const { return myTriangles.Length(); }
//! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
Standard_Boolean HasUVNodes() const { return !myUVNodes.IsNull(); }
//! Returns the table of 3D nodes (3D points) for this triangulation.
const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
//! Returns the table of 3D nodes (3D points) for this triangulation.
//! The returned array is
//! shared. Therefore if the table is selected by reference, you
//! can, by simply modifying it, directly modify the data
//! structure of this triangulation.
TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
//! Returns node at the given index.
//! 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.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT gp_Pnt& ChangeNode (const Standard_Integer theIndex);
//! Returns the table of 2D nodes (2D points) associated with
//! each 3D node of this triangulation.
//! The function HasUVNodes checks if 2D nodes
//! are associated with the 3D nodes of this triangulation.
//! Const reference on the 2d nodes values.
const TColgp_Array1OfPnt2d& UVNodes() const { return myUVNodes->Array1(); }
//! Returns the table of 2D nodes (2D points) associated with
//! each 3D node of this triangulation.
//! Function ChangeUVNodes shares the returned array.
//! Therefore if the table is selected by reference,
//! you can, by simply modifying it, directly modify the data
//! structure of this triangulation.
TColgp_Array1OfPnt2d& ChangeUVNodes() { return myUVNodes->ChangeArray1(); }
//! Returns UVNode at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
//! Give access to the UVNode at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex);
//! Returns the table of triangles for this triangulation.
const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
//! Returns the table of triangles for this triangulation.
//! Function ChangeUVNodes shares the returned array.
//! Therefore if the table is selected by reference,
//! you can, by simply modifying it, directly modify the data
//! structure of this triangulation.
Poly_Array1OfTriangle& ChangeTriangles() { return myTriangles; }
//! Returns triangle at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
//! Give access to the triangle at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
//! Sets the table of node normals.
//! raises exception if length of theNormals != 3*NbNodes
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
//! Returns the table of node normals.
Standard_EXPORT const TShort_Array1OfShortReal& Normals() const;
//! Gives access to the table of node normals.
Standard_EXPORT TShort_Array1OfShortReal& ChangeNormals();
Standard_Boolean HasUVNodes() const { return !myUVNodes.IsEmpty(); }
//! Returns Standard_True if nodal normals are defined.
Standard_EXPORT Standard_Boolean HasNormals() const;
Standard_Boolean HasNormals() const { return !myNormals.IsEmpty(); }
//! @return normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
//! Returns a node at the given index.
const gp_Pnt& Node (Standard_Integer theIndex) const { return myNodes.Value (theIndex); }
//! Sets a node coordinates.
void SetNode (Standard_Integer theIndex,
const gp_Pnt& thePnt)
{
myNodes.SetValue (theIndex, thePnt);
}
//! Returns UV-node at the given index.
const gp_Pnt2d& UVNode (Standard_Integer theIndex) const { return myUVNodes.Value (theIndex); }
//! Sets an UV-node coordinates.
void SetUVNode (Standard_Integer theIndex,
const gp_Pnt2d& thePnt)
{
myUVNodes.SetValue (theIndex, thePnt);
}
//! Returns triangle at the given index.
const Poly_Triangle& Triangle (Standard_Integer theIndex) const { return myTriangles.Value (theIndex); }
//! Sets a triangle.
void SetTriangle (Standard_Integer theIndex,
const Poly_Triangle& theTriangle)
{
myTriangles.SetValue (theIndex, theTriangle);
}
//! Returns normal at the given index.
gp_Dir Normal (Standard_Integer theIndex) const
{
const gp_Vec3f& aNorm = myNormals.Value (theIndex);
return gp_Dir (aNorm.x(), aNorm.y(), aNorm.z());
}
//! Returns normal at the given index.
void Normal (Standard_Integer theIndex,
gp_Vec3f& theVec3) const
{
theVec3 = myNormals.Value (theIndex);
}
//! Changes normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
const gp_Dir& theNormal);
void SetNormal (const Standard_Integer theIndex,
const gp_Vec3f& theNormal)
{
myNormals.SetValue (theIndex, theNormal);
}
//! Changes normal at the given index.
void SetNormal (const Standard_Integer theIndex,
const gp_Dir& theNormal)
{
SetNormal (theIndex, gp_Vec3f (float(theNormal.X()),
float(theNormal.Y()),
float(theNormal.Z())));
}
//! Returns cached min - max range of triangulation data,
//! which is VOID by default (e.g, no cached information).
@ -253,6 +214,105 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
public:
//! Method resizing internal arrays of nodes (synchronously for all attributes).
//! @param theNbNodes [in] new number of nodes
//! @param theToCopyOld [in] copy old nodes into the new array
Standard_EXPORT void ResizeNodes (Standard_Integer theNbNodes,
Standard_Boolean theToCopyOld);
//! Method resizing an internal array of triangles.
//! @param theNbTriangles [in] new number of triangles
//! @param theToCopyOld [in] copy old triangles into the new array
Standard_EXPORT void ResizeTriangles (Standard_Integer theNbTriangles,
Standard_Boolean theToCopyOld);
//! If an array for UV coordinates is not allocated yet, do it now.
Standard_EXPORT void AddUVNodes();
//! Deallocates the UV nodes array.
Standard_EXPORT void RemoveUVNodes();
//! If an array for normals is not allocated yet, do it now.
Standard_EXPORT void AddNormals();
//! Deallocates the Normals array.
Standard_EXPORT void RemoveNormals();
//! Compute smooth normals by averaging triangle normals.
Standard_EXPORT void ComputeNormals();
public:
//! Returns the table of 3D points for read-only access or NULL if nodes array is undefined.
//! Poly_Triangulation::Node() should be used instead when possible.
//! Returned object should not be used after Poly_Triangulation destruction.
Standard_EXPORT Handle(TColgp_HArray1OfPnt) MapNodeArray() const;
//! Returns the triangle array for read-only access or NULL if triangle array is undefined.
//! Poly_Triangulation::Triangle() should be used instead when possible.
//! Returned object should not be used after Poly_Triangulation destruction.
Standard_EXPORT Handle(Poly_HArray1OfTriangle) MapTriangleArray() const;
//! Returns the table of 2D nodes for read-only access or NULL if UV nodes array is undefined.
//! Poly_Triangulation::UVNode() should be used instead when possible.
//! Returned object should not be used after Poly_Triangulation destruction.
Standard_EXPORT Handle(TColgp_HArray1OfPnt2d) MapUVNodeArray() const;
//! Returns the table of per-vertex normals for read-only access or NULL if normals array is undefined.
//! Poly_Triangulation::Normal() should be used instead when possible.
//! Returned object should not be used after Poly_Triangulation destruction.
Standard_EXPORT Handle(TShort_HArray1OfShortReal) MapNormalArray() const;
public:
//! Returns an internal array of triangles.
//! Triangle()/SetTriangle() should be used instead in portable code.
Poly_Array1OfTriangle& InternalTriangles() { return myTriangles; }
//! Returns an internal array of nodes.
//! Node()/SetNode() should be used instead in portable code.
TColgp_Array1OfPnt& InternalNodes() { return myNodes; }
//! Returns an internal array of UV nodes.
//! UBNode()/SetUVNode() should be used instead in portable code.
TColgp_Array1OfPnt2d& InternalUVNodes() { return myUVNodes; }
//! Return an internal array of normals.
//! Normal()/SetNormal() should be used instead in portable code.
NCollection_Array1<gp_Vec3f>& InternalNormals() { return myNormals; }
Standard_DEPRECATED("Deprecated method, SetNormal() should be used instead")
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
Standard_DEPRECATED("Deprecated method, Node() should be used instead")
const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
Standard_DEPRECATED("Deprecated method, SetNode() should be used instead")
TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
Standard_DEPRECATED("Deprecated method, SetNode() should be used instead")
gp_Pnt& ChangeNode (const Standard_Integer theIndex) { return myNodes.ChangeValue (theIndex); }
Standard_DEPRECATED("Deprecated method, UVNode() should be used instead")
const TColgp_Array1OfPnt2d& UVNodes() const { return myUVNodes; }
Standard_DEPRECATED("Deprecated method, SetUVNode() should be used instead")
TColgp_Array1OfPnt2d& ChangeUVNodes() { return myUVNodes; }
Standard_DEPRECATED("Deprecated method, SetUVNode() should be used instead")
gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex) { return myUVNodes.ChangeValue (theIndex); }
Standard_DEPRECATED("Deprecated method, Triangle() should be used instead")
const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
Standard_DEPRECATED("Deprecated method, SetTriangle() should be used instead")
Poly_Array1OfTriangle& ChangeTriangles() { return myTriangles; }
Standard_DEPRECATED("Deprecated method, SetTriangle() should be used instead")
Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex) { return myTriangles.ChangeValue (theIndex); }
protected:
//! Clears cached min - max range saved previously.
@ -264,12 +324,12 @@ protected:
protected:
Bnd_Box* myCachedMinMax;
Standard_Real myDeflection;
TColgp_Array1OfPnt myNodes;
Handle(TColgp_HArray1OfPnt2d) myUVNodes;
Poly_Array1OfTriangle myTriangles;
Handle(TShort_HArray1OfShortReal) myNormals;
Bnd_Box* myCachedMinMax;
Standard_Real myDeflection;
TColgp_Array1OfPnt myNodes;
Poly_Array1OfTriangle myTriangles;
TColgp_Array1OfPnt2d myUVNodes;
NCollection_Array1<gp_Vec3f> myNormals;
};

View File

@ -36,11 +36,8 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
return;
}
const TColgp_Array1OfPnt& aNodes = thePolyTri->Nodes();
// Build the connect tool.
Poly_Connect aPolyConnect (thePolyTri);
Standard_Integer aNbTriangles = thePolyTri->NbTriangles();
Standard_Integer aT[3];
Standard_Integer aN[3];
@ -66,11 +63,10 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
Standard_Integer aFreeIndex = 1;
const Poly_Array1OfTriangle& aTriangles = thePolyTri->Triangles();
for (Standard_Integer anI = 1; anI <= aNbTriangles; ++anI)
{
aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
aTriangles (anI).Get (aN[0], aN[1], aN[2]);
thePolyTri->Triangle (anI).Get (aN[0], aN[1], aN[2]);
for (Standard_Integer aJ = 0; aJ < 3; aJ++)
{
Standard_Integer k = (aJ + 1) % 3;
@ -87,8 +83,8 @@ void Prs3d::AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
Standard_Integer aFreeHalfNb = aFree.Length() / 2;
for (Standard_Integer anI = 1; anI <= aFreeHalfNb; ++anI)
{
const gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (theLocation);
const gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (theLocation);
const gp_Pnt aPoint1 = thePolyTri->Node (aFree (2 * anI - 1)).Transformed (theLocation);
const gp_Pnt aPoint2 = thePolyTri->Node (aFree (2 * anI )).Transformed (theLocation);
theSegments.Append (aPoint1);
theSegments.Append (aPoint2);
}

View File

@ -100,9 +100,6 @@ Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolQuadric::CreateTriangulation (const
Handle(Poly_Triangulation) Prs3d_ToolQuadric::CreatePolyTriangulation (const gp_Trsf& theTrsf) const
{
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (VerticesNb(), TrianglesNb(), Standard_False);
TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
Standard_ShortReal aStepU = 1.0f / mySlicesNb;
Standard_ShortReal aStepV = 1.0f / myStacksNb;
@ -116,11 +113,11 @@ Handle(Poly_Triangulation) Prs3d_ToolQuadric::CreatePolyTriangulation (const gp_
const Standard_Integer aVertId = aU * (myStacksNb + 1) + (aV + 1);
gp_Pnt aVertex = Vertex (aParamU, aParamV).Transformed (theTrsf);
aNodes.SetValue (aVertId, aVertex);
aTriangulation->SetNode (aVertId, aVertex);
if (aU != 0 && aV != 0)
{
aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1));
aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1));
aTriangulation->SetTriangle (++anIndex, Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1));
aTriangulation->SetTriangle (++anIndex, Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1));
}
}
}

View File

@ -4030,25 +4030,15 @@ static Standard_Integer OCC26485 (Draw_Interpretor& theDI, Standard_Integer theA
continue;
Poly::ComputeNormals(aT);
const TColgp_Array1OfPnt& aVertices = aT->Nodes();
const TShort_Array1OfShortReal& aNormals = aT->Normals();
// Number of nodes in the triangulation
int aVertexNb = aT->Nodes().Length();
if (aVertexNb*3 != aNormals.Length())
{
theDI << "Failed. Different number of normals vs. vertices\n";
return 1;
}
int aVertexNb = aT->NbNodes();
// Get each vertex index, checking common vertexes between shapes
for( int i=0; i < aVertexNb; i++ )
{
gp_Pnt aPoint = aVertices.Value( i+1 );
gp_Vec aNormal = gp_Vec(
aNormals.Value( i*3 + 1 ),
aNormals.Value( i*3 + 2 ),
aNormals.Value( i*3 + 3 ) );
gp_Pnt aPoint = aT->Node ( i+1 );
const gp_Dir aNormal = aT->Normal (i + 1);
if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
{

View File

@ -648,20 +648,17 @@ static Standard_Integer QABVH_PairDistance (Draw_Interpretor& theDI,
TopLoc_Location aLoc;
const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(aF, aLoc);
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
const int aNbTriangles = aTriangles.Length();
const int aNbTriangles = aTriangulation->NbTriangles();
for (int iT = 1; iT <= aNbTriangles; ++iT)
{
const Poly_Triangle& aTriangle = aTriangles (iT);
const Poly_Triangle aTriangle = aTriangulation->Triangle (iT);
// Nodes indices
Standard_Integer id1, id2, id3;
aTriangle.Get (id1, id2, id3);
const gp_Pnt& aP1 = aNodes(id1).Transformed(aLoc.Transformation());
const gp_Pnt& aP2 = aNodes(id2).Transformed(aLoc.Transformation());
const gp_Pnt& aP3 = aNodes(id3).Transformed(aLoc.Transformation());
const gp_Pnt aP1 = aTriangulation->Node (id1).Transformed (aLoc.Transformation());
const gp_Pnt aP2 = aTriangulation->Node (id2).Transformed (aLoc.Transformation());
const gp_Pnt aP3 = aTriangulation->Node (id3).Transformed (aLoc.Transformation());
BVH_Vec3d aBVHP1 (aP1.X(), aP1.Y(), aP1.Z());
BVH_Vec3d aBVHP2 (aP2.X(), aP2.Y(), aP2.Z());
@ -711,20 +708,17 @@ public:
TopLoc_Location aLoc;
const Handle(Poly_Triangulation)& aTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
const int aNbTriangles = aTriangles.Length();
const int aNbTriangles = aTriangulation->NbTriangles();
for (int iT = 1; iT <= aNbTriangles; ++iT)
{
const Poly_Triangle& aTriangle = aTriangles (iT);
const Poly_Triangle aTriangle = aTriangulation->Triangle (iT);
// Nodes indices
Standard_Integer id1, id2, id3;
aTriangle.Get (id1, id2, id3);
const gp_Pnt& aP1 = aNodes(id1).Transformed(aLoc.Transformation());
const gp_Pnt& aP2 = aNodes(id2).Transformed(aLoc.Transformation());
const gp_Pnt& aP3 = aNodes(id3).Transformed(aLoc.Transformation());
const gp_Pnt aP1 = aTriangulation->Node (id1).Transformed (aLoc.Transformation());
const gp_Pnt aP2 = aTriangulation->Node (id2).Transformed (aLoc.Transformation());
const gp_Pnt aP3 = aTriangulation->Node (id3).Transformed (aLoc.Transformation());
BVH_Vec3d aBVHP1 (aP1.X(), aP1.Y(), aP1.Z());
BVH_Vec3d aBVHP2 (aP2.X(), aP2.Y(), aP2.Z());

View File

@ -48,19 +48,7 @@ RWGltf_TriangulationReader::RWGltf_TriangulationReader()
// =======================================================================
void RWGltf_TriangulationReader::reset()
{
myTriangulation = new Poly_Triangulation (1, 1, true);
{
TColgp_Array1OfPnt anEmpty;
myTriangulation->ChangeNodes().Move (anEmpty);
}
{
TColgp_Array1OfPnt2d anEmpty;
myTriangulation->ChangeUVNodes().Move (anEmpty);
}
{
Poly_Array1OfTriangle anEmpty;
myTriangulation->ChangeTriangles().Move (anEmpty);
}
myTriangulation = new Poly_Triangulation();
}
// =======================================================================
@ -73,10 +61,6 @@ Handle(Poly_Triangulation) RWGltf_TriangulationReader::result()
{
return Handle(Poly_Triangulation)();
}
if (myTriangulation->UVNodes().Size() != myTriangulation->NbNodes())
{
myTriangulation->RemoveUVNodes();
}
if (myTriangulation->NbTriangles() < 1)
{

View File

@ -56,7 +56,7 @@ protected: //! @name interface for filling triangulation data
{
return false;
}
myTriangulation->ChangeNodes().Resize (1, theNbNodes, false);
myTriangulation->ResizeNodes (theNbNodes, false);
return true;
}
@ -66,7 +66,7 @@ protected: //! @name interface for filling triangulation data
virtual void setNodePosition (Standard_Integer theIndex,
const gp_Pnt& thePnt)
{
myTriangulation->ChangeNode (theIndex) = thePnt;
myTriangulation->SetNode (theIndex, thePnt);
}
//! Resize array of UV nodes to specified size.
@ -77,7 +77,7 @@ protected: //! @name interface for filling triangulation data
{
return false;
}
myTriangulation->ChangeUVNodes().Resize (1, theNbNodes, false);
myTriangulation->AddUVNodes();
return true;
}
@ -87,7 +87,7 @@ protected: //! @name interface for filling triangulation data
virtual void setNodeUV (Standard_Integer theIndex,
const gp_Pnt2d& theUV)
{
myTriangulation->ChangeUVNode (theIndex) = theUV;
myTriangulation->SetUVNode (theIndex, theUV);
}
//! Resize array of nodes normals to specified size.
@ -98,7 +98,7 @@ protected: //! @name interface for filling triangulation data
{
return false;
}
myTriangulation->SetNormals (new TShort_HArray1OfShortReal (1, theNbNodes * 3));
myTriangulation->AddNormals();
return true;
}
@ -116,7 +116,7 @@ protected: //! @name interface for filling triangulation data
{
if (theNbTris >= 1)
{
myTriangulation->ChangeTriangles().Resize (1, theNbTris, false);
myTriangulation->ResizeTriangles (theNbTris, false);
return true;
}
return false;
@ -129,13 +129,13 @@ protected: //! @name interface for filling triangulation data
virtual bool setTriangle (Standard_Integer theIndex,
const Poly_Triangle& theTriangle)
{
if (theTriangle.Value (1) < myTriangulation->Nodes().Lower() || theTriangle.Value (1) > myTriangulation->Nodes().Upper()
|| theTriangle.Value (2) < myTriangulation->Nodes().Lower() || theTriangle.Value (2) > myTriangulation->Nodes().Upper()
|| theTriangle.Value (3) < myTriangulation->Nodes().Lower() || theTriangle.Value (3) > myTriangulation->Nodes().Upper())
if (theTriangle.Value (1) < 1 || theTriangle.Value (1) > myTriangulation->NbNodes()
|| theTriangle.Value (2) < 1 || theTriangle.Value (2) > myTriangulation->NbNodes()
|| theTriangle.Value (3) < 1 || theTriangle.Value (3) > myTriangulation->NbNodes())
{
return false;
}
myTriangulation->ChangeTriangle (theIndex) = theTriangle;
myTriangulation->SetTriangle (theIndex, theTriangle);
return true;
}

View File

@ -31,9 +31,6 @@ RWMesh_FaceIterator::RWMesh_FaceIterator (const TDF_Label& theLabel,
: myDefStyle (theStyle),
myToMapColors (theToMapColors),
mySLTool (1, 1e-12),
myNodes (NULL),
myNormals (NULL),
myNodeUVs (NULL),
myHasNormals (false),
myIsMirrored (false),
myHasFaceColor (false)
@ -133,21 +130,19 @@ void RWMesh_FaceIterator::dispatchStyles (const TDF_Label& theLabel,
gp_Dir RWMesh_FaceIterator::normal (Standard_Integer theNode)
{
gp_Dir aNormal (gp::DZ());
if (myNormals != NULL)
if (myPolyTriang->HasNormals())
{
const Standard_Integer aNodeIndex = theNode - myNodes->Lower();
const Graphic3d_Vec3 aNormVec3 (myNormals->Value (myNormals->Lower() + aNodeIndex * 3),
myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 1),
myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 2));
Graphic3d_Vec3 aNormVec3;
myPolyTriang->Normal (theNode, aNormVec3);
if (aNormVec3.Modulus() != 0.0f)
{
aNormal.SetCoord (aNormVec3.x(), aNormVec3.y(), aNormVec3.z());
}
}
else if (myHasNormals
&& myNodeUVs != NULL)
&& myPolyTriang->HasUVNodes())
{
const gp_XY& anUV = myNodeUVs->Value (theNode).XY();
const gp_XY anUV = myPolyTriang->UVNode (theNode).XY();
mySLTool.SetParameters (anUV.X(), anUV.Y());
if (mySLTool.IsNormalDefined())
{
@ -169,7 +164,7 @@ void RWMesh_FaceIterator::Next()
myPolyTriang = BRep_Tool::Triangulation (myFace, myFaceLocation);
myTrsf = myFaceLocation.Transformation();
if (myPolyTriang.IsNull()
|| myPolyTriang->Triangles().Length() == 0)
|| myPolyTriang->NbTriangles() == 0)
{
resetFace();
continue;
@ -192,29 +187,20 @@ void RWMesh_FaceIterator::initFace()
myHasNormals = false;
myHasFaceColor = false;
myIsMirrored = myTrsf.VectorialPart().Determinant() < 0.0;
myNormals = NULL;
myNodeUVs = NULL;
myNodes = &myPolyTriang->Nodes();
if (myPolyTriang->HasNormals())
{
myNormals = &myPolyTriang->Normals();
myHasNormals = true;
}
if (myPolyTriang->HasUVNodes())
if (myPolyTriang->HasUVNodes() && !myHasNormals)
{
myNodeUVs = &myPolyTriang->UVNodes();
if (!myHasNormals)
TopoDS_Face aFaceFwd = TopoDS::Face (myFace.Oriented (TopAbs_FORWARD));
aFaceFwd.Location (TopLoc_Location());
TopLoc_Location aLoc;
if (!BRep_Tool::Surface (aFaceFwd, aLoc).IsNull())
{
TopoDS_Face aFaceFwd = TopoDS::Face (myFace.Oriented (TopAbs_FORWARD));
aFaceFwd.Location (TopLoc_Location());
TopLoc_Location aLoc;
if (!BRep_Tool::Surface (aFaceFwd, aLoc).IsNull())
{
myFaceAdaptor.Initialize (aFaceFwd, false);
mySLTool.SetSurface (myFaceAdaptor);
myHasNormals = true;
}
myFaceAdaptor.Initialize (aFaceFwd, false);
mySLTool.SetSurface (myFaceAdaptor);
myHasNormals = true;
}
}
if (!myToMapColors)

View File

@ -75,10 +75,10 @@ public:
Standard_Integer NbTriangles() const { return myPolyTriang->NbTriangles(); }
//! Lower element index in current triangulation.
Standard_Integer ElemLower() const { return myPolyTriang->Triangles().Lower(); }
Standard_Integer ElemLower() const { return 1; }
//! Upper element index in current triangulation.
Standard_Integer ElemUpper() const { return myPolyTriang->Triangles().Upper(); }
Standard_Integer ElemUpper() const { return myPolyTriang->NbTriangles(); }
//! Return triangle with specified index with applied Face orientation.
Poly_Triangle TriangleOriented (Standard_Integer theElemIndex) const
@ -97,7 +97,7 @@ public:
bool HasNormals() const { return myHasNormals; }
//! Return true if triangulation has defined normals.
bool HasTexCoords() const { return myNodeUVs != NULL; }
bool HasTexCoords() const { return !myPolyTriang.IsNull() && myPolyTriang->HasUVNodes(); }
//! Return normal at specified node index with face transformation applied and face orientation applied.
gp_Dir NormalTransformed (Standard_Integer theNode)
@ -118,15 +118,15 @@ public:
Standard_Integer NbNodes() const
{
return !myPolyTriang.IsNull()
? myPolyTriang->Nodes().Length()
? myPolyTriang->NbNodes()
: 0;
}
//! Lower node index in current triangulation.
Standard_Integer NodeLower() const { return myPolyTriang->Nodes().Lower(); }
Standard_Integer NodeLower() const { return 1; }
//! Upper node index in current triangulation.
Standard_Integer NodeUpper() const { return myPolyTriang->Nodes().Upper(); }
Standard_Integer NodeUpper() const { return myPolyTriang->NbNodes(); }
//! Return the node with specified index with applied transformation.
gp_Pnt NodeTransformed (const Standard_Integer theNode) const
@ -139,19 +139,19 @@ public:
//! Return texture coordinates for the node.
gp_Pnt2d NodeTexCoord (const Standard_Integer theNode) const
{
return myNodeUVs != NULL ? myNodeUVs->Value (theNode) : gp_Pnt2d();
return myPolyTriang->HasUVNodes() ? myPolyTriang->UVNode (theNode) : gp_Pnt2d();
}
public:
//! Return the node with specified index with applied transformation.
gp_Pnt node (const Standard_Integer theNode) const { return myPolyTriang->Nodes().Value (theNode); }
gp_Pnt node (const Standard_Integer theNode) const { return myPolyTriang->Node (theNode); }
//! Return normal at specified node index without face transformation applied.
Standard_EXPORT gp_Dir normal (Standard_Integer theNode);
//! Return triangle with specified index.
Poly_Triangle triangle (Standard_Integer theElemIndex) const { return myPolyTriang->Triangles().Value (theElemIndex); }
Poly_Triangle triangle (Standard_Integer theElemIndex) const { return myPolyTriang->Triangle (theElemIndex); }
private:
@ -165,9 +165,6 @@ private:
{
myPolyTriang.Nullify();
myFace.Nullify();
myNodes = NULL;
myNormals = NULL;
myNodeUVs = NULL;
myHasNormals = false;
myHasFaceColor = false;
myFaceColor = Quantity_ColorRGBA();
@ -190,9 +187,6 @@ private:
TopLoc_Location myFaceLocation; //!< current face location
BRepLProp_SLProps mySLTool; //!< auxiliary tool for fetching normals from surface
BRepAdaptor_Surface myFaceAdaptor; //!< surface adaptor for fetching normals from surface
const TColgp_Array1OfPnt* myNodes; //!< node positions of current face
const TShort_Array1OfShortReal* myNormals; //!< node normals of current face
const TColgp_Array1OfPnt2d* myNodeUVs; //!< node UV coordinates of current face
Standard_Boolean myHasNormals; //!< flag indicating that current face has normals
gp_Trsf myTrsf; //!< current face transformation
Standard_Boolean myIsMirrored; //!< flag indicating that face triangles should be mirrored

View File

@ -155,20 +155,19 @@ Handle(Poly_Triangulation) RWObj_TriangulationReader::GetTriangulation()
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
{
const gp_Pnt& aNode = myNodes.Value (aNodeIter);
aPoly->ChangeNode (aNodeIter + 1) = aNode;
aPoly->SetNode (aNodeIter + 1, aNode);
}
if (hasUV)
{
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
{
const Graphic3d_Vec2& aNode = myNodesUV.Value (aNodeIter);
aPoly->ChangeUVNode (aNodeIter + 1).SetCoord (aNode.x(), aNode.y());
aPoly->SetUVNode (aNodeIter + 1, gp_Pnt2d (aNode.x(), aNode.y()));
}
}
if (hasNormals)
{
const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, myNodes.Length() * 3);
Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
aPoly->AddNormals();
Standard_Integer aNbInvalid = 0;
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
{
@ -176,27 +175,23 @@ Handle(Poly_Triangulation) RWObj_TriangulationReader::GetTriangulation()
const float aMod2 = aNorm.SquareModulus();
if (aMod2 > 0.001f)
{
aNormArr[aNodeIter * 3 + 0] = aNorm.x();
aNormArr[aNodeIter * 3 + 1] = aNorm.y();
aNormArr[aNodeIter * 3 + 2] = aNorm.z();
aPoly->SetNormal (aNodeIter + 1, aNorm);
}
else
{
++aNbInvalid;
aNormArr[aNodeIter * 3 + 0] = 0.0f;
aNormArr[aNodeIter * 3 + 1] = 0.0f;
aNormArr[aNodeIter * 3 + 2] = 1.0f;
aPoly->SetNormal (aNodeIter + 1, Graphic3d_Vec3 (0.0f, 0.0f, 1.0f));
}
}
if (aNbInvalid != myNodes.Length())
if (aNbInvalid == myNodes.Length())
{
aPoly->SetNormals (aNormals);
aPoly->RemoveNormals();
}
}
for (Standard_Integer aTriIter = 0; aTriIter < myTriangles.Size(); ++aTriIter)
{
aPoly->ChangeTriangle (aTriIter + 1) = myTriangles (aTriIter);
aPoly->SetTriangle (aTriIter + 1, myTriangles[aTriIter]);
}
return aPoly;

View File

@ -87,12 +87,12 @@ namespace
Handle(Poly_Triangulation) aPoly = new Poly_Triangulation (myNodes.Length(), myTriangles.Length(), Standard_False);
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
{
aPoly->ChangeNode (aNodeIter + 1) = myNodes (aNodeIter);
aPoly->SetNode (aNodeIter + 1, myNodes[aNodeIter]);
}
for (Standard_Integer aTriIter = 0; aTriIter < myTriangles.Size(); ++aTriIter)
{
aPoly->ChangeTriangle (aTriIter + 1) = myTriangles (aTriIter);
aPoly->SetTriangle (aTriIter + 1, myTriangles[aTriIter]);
}
return aPoly;
@ -284,17 +284,15 @@ Standard_Boolean RWStl::writeASCII (const Handle(Poly_Triangulation)& theMesh,
const Standard_Integer NBTriangles = theMesh->NbTriangles();
Message_ProgressScope aPS (theProgress, "Triangles", NBTriangles);
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
Standard_Integer anElem[3] = {0, 0, 0};
for (Standard_Integer aTriIter = 1; aTriIter <= NBTriangles; ++aTriIter)
{
const Poly_Triangle& aTriangle = aTriangles (aTriIter);
const Poly_Triangle aTriangle = theMesh->Triangle (aTriIter);
aTriangle.Get (anElem[0], anElem[1], anElem[2]);
const gp_Pnt aP1 = aNodes (anElem[0]);
const gp_Pnt aP2 = aNodes (anElem[1]);
const gp_Pnt aP3 = aNodes (anElem[2]);
const gp_Pnt aP1 = theMesh->Node (anElem[0]);
const gp_Pnt aP2 = theMesh->Node (anElem[1]);
const gp_Pnt aP3 = theMesh->Node (anElem[2]);
const gp_Vec aVec1 (aP1, aP2);
const gp_Vec aVec2 (aP1, aP3);
@ -365,9 +363,6 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
NCollection_Array1<Standard_Character> aData (1, aChunkSize);
Standard_Character* aDataChunk = &aData.ChangeFirst();
const TColgp_Array1OfPnt& aNodes = theMesh->Nodes();
const Poly_Array1OfTriangle& aTriangles = theMesh->Triangles();
Standard_Character aConv[4];
convertInteger (aNBTriangles, aConv);
if (fwrite (aConv, 1, 4, theFile) != 4)
@ -379,12 +374,12 @@ Standard_Boolean RWStl::writeBinary (const Handle(Poly_Triangulation)& theMesh,
for (Standard_Integer aTriIter = 1; aTriIter <= aNBTriangles; ++aTriIter)
{
Standard_Integer id[3];
const Poly_Triangle& aTriangle = aTriangles (aTriIter);
const Poly_Triangle aTriangle = theMesh->Triangle (aTriIter);
aTriangle.Get (id[0], id[1], id[2]);
const gp_Pnt aP1 = aNodes (id[0]);
const gp_Pnt aP2 = aNodes (id[1]);
const gp_Pnt aP3 = aNodes (id[2]);
const gp_Pnt aP1 = theMesh->Node (id[0]);
const gp_Pnt aP2 = theMesh->Node (id[1]);
const gp_Pnt aP3 = theMesh->Node (id[2]);
gp_Vec aVec1 (aP1, aP2);
gp_Vec aVec2 (aP1, aP3);

View File

@ -63,8 +63,6 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
{
myInvInitLocation = myInitLocation.Transformation().Inverted();
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
const TColgp_Array1OfPnt& aNodes = myTriangul->Nodes();
Standard_Integer aNbTriangles (myTriangul->NbTriangles());
gp_XYZ aCenter (0.0, 0.0, 0.0);
@ -83,8 +81,9 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= aNbTriangles; aTriangleIdx++)
{
aPoly.Triangles (aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
aTriangles (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
myTriangul->Triangle (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
const gp_Pnt aTriNodes[3] = { myTriangul->Node (aTrNodeIdx[0]), myTriangul->Node (aTrNodeIdx[1]), myTriangul->Node (aTrNodeIdx[2]) };
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ()+ aTriNodes[2].XYZ()) / 3.0;
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; aVertIdx++)
{
Standard_Integer aNextVert = (aVertIdx + 1) % 3;
@ -102,8 +101,9 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
Standard_Integer aTrNodeIdx[3];
for (Standard_Integer aTrIdx = 1; aTrIdx <= aNbTriangles; aTrIdx++)
{
aTriangles (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
myTriangul->Triangle (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
const gp_Pnt aTriNodes[3] = { myTriangul->Node (aTrNodeIdx[0]), myTriangul->Node (aTrNodeIdx[1]), myTriangul->Node (aTrNodeIdx[2]) };
aCenter += (aTriNodes[0].XYZ() + aTriNodes[1].XYZ()+ aTriNodes[2].XYZ()) / 3.0;
}
}
if (aNbTriangles != 0)
@ -113,9 +113,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
myBndBox.Clear();
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
{
myBndBox.Add (SelectMgr_Vec3 (aNodes (aNodeIdx).X(),
aNodes (aNodeIdx).Y(),
aNodes (aNodeIdx).Z()));
const gp_Pnt aNode = myTriangul->Node (aNodeIdx);
myBndBox.Add (SelectMgr_Vec3 (aNode.X(), aNode.Y(), aNode.Z()));
}
if (theIsInterior)
@ -154,7 +153,7 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
{
myInvInitLocation = myInitLocation.Transformation().Inverted();
mySensType = theIsInterior ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
myPrimitivesNb = theIsInterior ? theTrg->Triangles().Length() : theFreeEdges->Length() / 2;
myPrimitivesNb = theIsInterior ? theTrg->NbTriangles() : theFreeEdges->Length() / 2;
myBVHPrimIndexes = new TColStd_HArray1OfInteger(0, myPrimitivesNb - 1);
if (theIsInterior)
{
@ -196,11 +195,11 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
if (mySensType == Select3D_TOS_INTERIOR)
{
Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
myTriangul->Triangle (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
@ -213,8 +212,8 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
{
Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
const gp_Pnt& aNode1 = myTriangul->Nodes().Value (aNodeIdx1);
const gp_Pnt& aNode2 = myTriangul->Nodes().Value (aNodeIdx2);
const gp_Pnt aNode1 = myTriangul->Node (aNodeIdx1);
const gp_Pnt aNode2 = myTriangul->Node (aNodeIdx2);
aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
Min (aNode1.Y(), aNode2.Y()),
@ -281,9 +280,9 @@ bool Select3D_SensitiveTriangulation::LastDetectedTriangle (Poly_Triangle& theTr
return false;
}
theTriNodes[0] = myTriangul->Nodes().Value (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
theTriNodes[1] = myTriangul->Nodes().Value (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
theTriNodes[2] = myTriangul->Nodes().Value (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
theTriNodes[0] = myTriangul->Node (theTriangle.Value (1)).Transformed (myInitLocation.Transformation());;
theTriNodes[1] = myTriangul->Node (theTriangle.Value (2)).Transformed (myInitLocation.Transformation());;
theTriNodes[2] = myTriangul->Node (theTriangle.Value (3)).Transformed (myInitLocation.Transformation());;
return true;
}
@ -310,8 +309,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
const gp_Pnt anEdgePnts[2] =
{
myTriangul->Nodes().Value (aSegmStartIdx),
myTriangul->Nodes().Value (aSegmEndIdx)
myTriangul->Node (aSegmStartIdx),
myTriangul->Node (aSegmEndIdx)
};
TColgp_Array1OfPnt anEdgePntsArr (anEdgePnts[0], 1, 2);
Standard_Boolean isMatched = theMgr.Overlaps (anEdgePntsArr, Select3D_TOS_BOUNDARY, thePickResult);
@ -319,12 +318,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
}
else
{
const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
Standard_Integer aNode1, aNode2, aNode3;
aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, thePickResult);
}
}
@ -345,8 +343,8 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
const Standard_Integer aPrimitiveIdx = myBVHPrimIndexes->Value (theElemIdx);
if (mySensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt& aSegmPnt1 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
const gp_Pnt& aSegmPnt2 = myTriangul->Nodes().Value (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
const gp_Pnt aSegmPnt1 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 1));
const gp_Pnt aSegmPnt2 = myTriangul->Node (myFreeEdges->Value (aPrimitiveIdx * 2 + 2));
if (theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Polyline)
{
SelectBasics_PickResult aDummy;
@ -357,11 +355,11 @@ Standard_Boolean Select3D_SensitiveTriangulation::elementIsInside (SelectBasics_
else
{
Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
const gp_Pnt& aPnt1 = myTriangul->Nodes().Value (aNode1);
const gp_Pnt& aPnt2 = myTriangul->Nodes().Value (aNode2);
const gp_Pnt& aPnt3 = myTriangul->Nodes().Value (aNode3);
const gp_Pnt aPnt1 = myTriangul->Node (aNode1);
const gp_Pnt aPnt2 = myTriangul->Node (aNode2);
const gp_Pnt aPnt3 = myTriangul->Node (aNode3);
if (theMgr.GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Polyline)
{
SelectBasics_PickResult aDummy;
@ -435,12 +433,12 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::BoundingBox()
if (myBndBox.IsValid())
return applyTransformation();
const Standard_Integer aLower = myTriangul->Nodes().Lower();
const Standard_Integer anUpper = myTriangul->Nodes().Upper();
const Standard_Integer aLower = 1;
const Standard_Integer anUpper = myTriangul->NbNodes();
Select3D_BndBox3d aBndBox;
for (Standard_Integer aNodeIdx = aLower; aNodeIdx <= anUpper; ++aNodeIdx)
{
const gp_Pnt& aNode = myTriangul->Nodes().Value (aNodeIdx);
const gp_Pnt aNode = myTriangul->Node (aNodeIdx);
const SelectMgr_Vec3 aNodeTransf = SelectMgr_Vec3 (aNode.X(), aNode.Y(), aNode.Z());
aBndBox.Add (aNodeTransf);
}
@ -466,7 +464,7 @@ gp_Pnt Select3D_SensitiveTriangulation::CenterOfGeometry() const
//=======================================================================
Standard_Integer Select3D_SensitiveTriangulation::NbSubElements() const
{
return myTriangul->Nodes().Length();
return myTriangul->NbNodes();
}
//=======================================================================

View File

@ -198,13 +198,36 @@ ShapePersistent_Poly::Translate(const Handle(Poly_Triangulation)& thePolyTriang,
{
aPT = new Triangulation;
aPT->myPersistent = new pTriangulation;
// Create an array of nodes
TColgp_Array1OfPnt pArrayOfNodes (1, thePolyTriang->NbNodes());
for (Standard_Integer i = 1; i <= thePolyTriang->NbNodes(); i++)
{
pArrayOfNodes.SetValue (i, thePolyTriang->Node (i));
}
// Create an array of triangles
Poly_Array1OfTriangle pArrayOfTriangles (1, thePolyTriang->NbTriangles());
for (Standard_Integer i = 1; i <= thePolyTriang->NbTriangles(); i++)
{
pArrayOfTriangles.SetValue (i, thePolyTriang->Triangle (i));
}
aPT->myPersistent->myNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePolyTriang->Nodes());
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", pArrayOfNodes);
aPT->myPersistent->myTriangles =
StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", thePolyTriang->Triangles());
StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", pArrayOfTriangles);
if (thePolyTriang->HasUVNodes()) {
// Create an array of UV-nodes
TColgp_Array1OfPnt2d pArrayOfUVNodes (1, thePolyTriang->NbNodes());
for (Standard_Integer i = 1; i <= thePolyTriang->NbNodes(); i++)
{
pArrayOfUVNodes.SetValue (i, thePolyTriang->UVNode (i));
}
aPT->myPersistent->myUVNodes =
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePolyTriang->UVNodes());
StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", pArrayOfUVNodes);
}
theMap.Bind(thePolyTriang, aPT);
}

View File

@ -253,9 +253,6 @@ void StdPrs_Isolines::addOnTriangulation (const Handle(Poly_Triangulation)& theT
Prs3d_NListOfSequenceOfPnt& theUPolylines,
Prs3d_NListOfSequenceOfPnt& theVPolylines)
{
const Poly_Array1OfTriangle& aTriangles = theTriangulation->Triangles();
const TColgp_Array1OfPnt& aNodes = theTriangulation->Nodes();
const TColgp_Array1OfPnt2d& aUVNodes = theTriangulation->UVNodes();
for (Standard_Integer anUVIter = 0; anUVIter < 2; ++anUVIter)
{
const Standard_Boolean isUIso = anUVIter == 0;
@ -278,16 +275,16 @@ void StdPrs_Isolines::addOnTriangulation (const Handle(Poly_Triangulation)& theT
anIsoPnts = aPolylines.ChangeValue (anIsoIndexes.Value (anIsoIdx));
}
for (Standard_Integer aTriIter = aTriangles.Lower(); aTriIter <= aTriangles.Upper(); ++aTriIter)
for (Standard_Integer aTriIter = 1; aTriIter <= theTriangulation->NbTriangles(); ++aTriIter)
{
Standard_Integer aNodeIdxs[3];
aTriangles.Value (aTriIter).Get (aNodeIdxs[0], aNodeIdxs[1],aNodeIdxs[2]);
const gp_Pnt aNodesXYZ[3] = { aNodes.Value (aNodeIdxs[0]),
aNodes.Value (aNodeIdxs[1]),
aNodes.Value (aNodeIdxs[2]) };
const gp_Pnt2d aNodesUV[3] = { aUVNodes.Value (aNodeIdxs[0]),
aUVNodes.Value (aNodeIdxs[1]),
aUVNodes.Value (aNodeIdxs[2]) };
theTriangulation->Triangle (aTriIter).Get (aNodeIdxs[0], aNodeIdxs[1],aNodeIdxs[2]);
const gp_Pnt aNodesXYZ[3] = { theTriangulation->Node (aNodeIdxs[0]),
theTriangulation->Node (aNodeIdxs[1]),
theTriangulation->Node (aNodeIdxs[2]) };
const gp_Pnt2d aNodesUV[3] = { theTriangulation->UVNode (aNodeIdxs[0]),
theTriangulation->UVNode (aNodeIdxs[1]),
theTriangulation->UVNode (aNodeIdxs[2]) };
// Find intersections with triangle in uv space and its projection on triangulation.
SegOnIso aSegment;

View File

@ -189,13 +189,7 @@ namespace
Standard_Boolean isMirrored = aTrsf.VectorialPart().Determinant() < 0;
// Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& aNodes = aT->Nodes();
const TColgp_Array1OfPnt2d* aUVNodes = theHasTexels && aT->HasUVNodes() && aT->UVNodes().Upper() == aNodes.Upper()
? &aT->UVNodes()
: NULL;
StdPrs_ToolTriangulatedShape::ComputeNormals (aFace, aT);
const TShort_Array1OfShortReal& aNormals = aT->Normals();
const Standard_ShortReal* aNormArr = &aNormals.First();
if (theHasTexels)
{
@ -205,11 +199,10 @@ namespace
}
const Standard_Integer aDecal = anArray->VertexNumber();
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aT->NbNodes(); ++aNodeIter)
{
aPoint = aNodes (aNodeIter);
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
aPoint = aT->Node (aNodeIter);
gp_Dir aNorm = aT->Normal (aNodeIter);
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aNorm.Reverse();
@ -217,15 +210,16 @@ namespace
if (!aLoc.IsIdentity())
{
aPoint.Transform (aTrsf);
aNorm.Transform (aTrsf);
aNorm .Transform (aTrsf);
}
if (aUVNodes != NULL)
if (theHasTexels && aT->HasUVNodes())
{
const gp_Pnt2d aNode2d = aT->UVNode (aNodeIter);
const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0)
? aUVNodes->Value (aNodeIter)
: gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes->Value (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes->Value (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
? aNode2d
: gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aNode2d.X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aNode2d.Y() - aVmin)) / dVmax) / theUVScale.Y());
anArray->AddVertex (aPoint, aNorm, aTexel);
}
else
@ -235,22 +229,21 @@ namespace
}
// Fill array with vertex and edge visibility info
const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if ((aFace.Orientation() == TopAbs_REVERSED))
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
aT->Triangle (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}
else
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
aT->Triangle (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
}
gp_Pnt aP1 = aNodes (anIndex[0]);
gp_Pnt aP2 = aNodes (anIndex[1]);
gp_Pnt aP3 = aNodes (anIndex[2]);
const gp_Pnt aP1 = aT->Node (anIndex[0]);
const gp_Pnt aP2 = aT->Node (anIndex[1]);
const gp_Pnt aP3 = aT->Node (anIndex[2]);
gp_Vec aV1 (aP1, aP2);
if (aV1.SquareMagnitude() <= aPreci)
@ -415,7 +408,6 @@ namespace
}
// get edge nodes indexes from face triangulation
const TColgp_Array1OfPnt& aTriNodes = aTriangulation->Nodes();
const TColStd_Array1OfInteger& anEdgeNodes = anEdgePoly->Nodes();
// collect the edge nodes
@ -425,7 +417,7 @@ namespace
// node index in face triangulation
// get node and apply location transformation to the node
const Standard_Integer aTriIndex = anEdgeNodes.Value (aNodeIdx);
gp_Pnt aTriNode = aTriNodes.Value (aTriIndex);
gp_Pnt aTriNode = aTriangulation->Node (aTriIndex);
if (!aTrsf.IsIdentity())
{
aTriNode.Transform (aTrsf);

View File

@ -149,7 +149,6 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
// take in face the surface location
const TopoDS_Face aZeroFace = TopoDS::Face (theFace.Located (TopLoc_Location()));
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aZeroFace);
const Poly_Array1OfTriangle& aTriangles = theTris->Triangles();
if (!theTris->HasUVNodes() || aSurf.IsNull())
{
// compute normals by averaging triangulation normals sharing the same vertex
@ -158,15 +157,13 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
}
const Standard_Real aTol = Precision::Confusion();
Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, theTris->NbNodes() * 3);
const TColgp_Array1OfPnt2d& aNodesUV = theTris->UVNodes();
Standard_Integer aTri[3];
const TColgp_Array1OfPnt& aNodes = theTris->Nodes();
gp_Dir aNorm;
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
theTris->AddNormals();
for (Standard_Integer aNodeIter = 1; aNodeIter <= theTris->NbNodes(); ++aNodeIter)
{
// try to retrieve normal from real surface first, when UV coordinates are available
if (GeomLib::NormEstim (aSurf, aNodesUV.Value (aNodeIter), aTol, aNorm) > 1)
if (GeomLib::NormEstim (aSurf, theTris->UVNode (aNodeIter), aTol, aNorm) > 1)
{
if (thePolyConnect.Triangulation() != theTris)
{
@ -177,9 +174,9 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
gp_XYZ eqPlan (0.0, 0.0, 0.0);
for (thePolyConnect.Initialize (aNodeIter); thePolyConnect.More(); thePolyConnect.Next())
{
aTriangles (thePolyConnect.Value()).Get (aTri[0], aTri[1], aTri[2]);
const gp_XYZ v1 (aNodes (aTri[1]).Coord() - aNodes (aTri[0]).Coord());
const gp_XYZ v2 (aNodes (aTri[2]).Coord() - aNodes (aTri[1]).Coord());
theTris->Triangle (thePolyConnect.Value()).Get (aTri[0], aTri[1], aTri[2]);
const gp_XYZ v1 (theTris->Node (aTri[1]).Coord() - theTris->Node (aTri[0]).Coord());
const gp_XYZ v2 (theTris->Node (aTri[2]).Coord() - theTris->Node (aTri[1]).Coord());
const gp_XYZ vv = v1 ^ v2;
const Standard_Real aMod = vv.Modulus();
if (aMod >= aTol)
@ -191,12 +188,8 @@ void StdPrs_ToolTriangulatedShape::ComputeNormals (const TopoDS_Face& theFace,
aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
}
const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 3;
aNormals->SetValue (anId + 1, (Standard_ShortReal )aNorm.X());
aNormals->SetValue (anId + 2, (Standard_ShortReal )aNorm.Y());
aNormals->SetValue (anId + 3, (Standard_ShortReal )aNorm.Z());
theTris->SetNormal (aNodeIter, aNorm);
}
theTris->SetNormals (aNormals);
}
//=======================================================================
@ -213,21 +206,16 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace,
ComputeNormals (theFace, aPolyTri, thePolyConnect);
}
const TColgp_Array1OfPnt& aNodes = aPolyTri->Nodes();
const TShort_Array1OfShortReal& aNormals = aPolyTri->Normals();
const Standard_ShortReal* aNormArr = &aNormals.First();
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
gp_Vec3f aNormal;
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
const gp_Dir aNorm (aNormArr[anId + 0],
aNormArr[anId + 1],
aNormArr[anId + 2]);
theNormals (aNodeIter) = aNorm;
aPolyTri->Normal (aNodeIter, aNormal);
theNormals.ChangeValue (aNodeIter).SetCoord (aNormal.x(), aNormal.y(), aNormal.z());
}
if (theFace.Orientation() == TopAbs_REVERSED)
{
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
theNormals.ChangeValue (aNodeIter).Reverse();
}

View File

@ -332,21 +332,20 @@ void StdPrs_WFShape::addEdges (const TopTools_ListOfShape& theEdges,
{
// Presentation based on triangulation of a face.
const TColStd_Array1OfInteger& anIndices = anEdgeIndicies->Nodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
Standard_Integer anIndex = anIndices.Lower();
if (aLocation.IsIdentity())
{
for (; anIndex <= anIndices.Upper(); ++anIndex)
{
aPoints->Append (aNodes (anIndices (anIndex)));
aPoints->Append (aTriangulation->Node (anIndices[anIndex]));
}
}
else
{
for (; anIndex <= anIndices.Upper(); ++anIndex)
{
aPoints->Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
aPoints->Append (aTriangulation->Node (anIndices[anIndex]).Transformed (aLocation));
}
}
}

View File

@ -350,7 +350,6 @@ static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theE
if (!anHIndices.IsNull())
{
const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
@ -358,14 +357,14 @@ static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theE
{
for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
aResultPoints->SetValue (aPntId, aTriangulation->Node (anIndices[anIndex]));
}
}
else
{
for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
aResultPoints->SetValue (aPntId, aTriangulation->Node (anIndices[anIndex]).Transformed (aLocation));
}
}
return aResultPoints;

View File

@ -52,22 +52,18 @@ Standard_Boolean StlAPI_Reader::Read (TopoDS_Shape& theShape,
BRep_Builder BuildTool;
BuildTool.MakeCompound (aComp);
const TColgp_Array1OfPnt& aNodes = aMesh->Nodes();
const Poly_Array1OfTriangle& aTriangles = aMesh->Triangles();
for (Standard_Integer aTriIdx = aTriangles.Lower();
aTriIdx <= aTriangles.Upper();
++aTriIdx)
for (Standard_Integer aTriIdx = 1; aTriIdx <= aMesh->NbTriangles(); ++aTriIdx)
{
const Poly_Triangle& aTriangle = aTriangles(aTriIdx);
const Poly_Triangle aTriangle = aMesh->Triangle (aTriIdx);
Standard_Integer anId[3];
aTriangle.Get(anId[0], anId[1], anId[2]);
const gp_Pnt& aPnt1 = aNodes (anId[0]);
const gp_Pnt& aPnt2 = aNodes (anId[1]);
const gp_Pnt& aPnt3 = aNodes (anId[2]);
if ((!(aPnt1.IsEqual (aPnt2, 0.0)))
&& (!(aPnt1.IsEqual (aPnt3, 0.0))))
const gp_Pnt aPnt1 = aMesh->Node (anId[0]);
const gp_Pnt aPnt2 = aMesh->Node (anId[1]);
const gp_Pnt aPnt3 = aMesh->Node (anId[2]);
if (!(aPnt1.IsEqual (aPnt2, 0.0))
&& !(aPnt1.IsEqual (aPnt3, 0.0)))
{
aTriVertexes[0] = BRepBuilderAPI_MakeVertex (aPnt1);
aTriVertexes[1] = BRepBuilderAPI_MakeVertex (aPnt2);

View File

@ -83,23 +83,20 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
continue;
}
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
// copy nodes
gp_Trsf aTrsf = aLoc.Transformation();
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
{
gp_Pnt aPnt = aNodes (aNodeIter);
gp_Pnt aPnt = aTriangulation->Node (aNodeIter);
aPnt.Transform (aTrsf);
aMesh->ChangeNode (aNodeIter + aNodeOffset) = aPnt;
aMesh->SetNode (aNodeIter + aNodeOffset, aPnt);
}
// copy triangles
const TopAbs_Orientation anOrientation = anExpSF.Current().Orientation();
for (Standard_Integer aTriIter = aTriangles.Lower(); aTriIter <= aTriangles.Upper(); ++aTriIter)
for (Standard_Integer aTriIter = 1; aTriIter <= aTriangulation->NbTriangles(); ++aTriIter)
{
Poly_Triangle aTri = aTriangles (aTriIter);
Poly_Triangle aTri = aTriangulation->Triangle (aTriIter);
Standard_Integer anId[3];
aTri.Get (anId[0], anId[1], anId[2]);
@ -117,11 +114,11 @@ Standard_Boolean StlAPI_Writer::Write (const TopoDS_Shape& theShape,
anId[2] += aNodeOffset;
aTri.Set (anId[0], anId[1], anId[2]);
aMesh->ChangeTriangle (aTriIter + aTriangleOffet) = aTri;
aMesh->SetTriangle (aTriIter + aTriangleOffet, aTri);
}
aNodeOffset += aNodes.Size();
aTriangleOffet += aTriangles.Size();
aNodeOffset += aTriangulation->NbNodes();
aTriangleOffet += aTriangulation->NbTriangles();
}
OSD_Path aPath (theFileName);

View File

@ -156,7 +156,7 @@ Standard_Boolean TDataXtd_Triangulation::HasUVNodes() const
//purpose : return node at the given index.
// Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
//=======================================================================
const gp_Pnt& TDataXtd_Triangulation::Node (const Standard_Integer theIndex) const
gp_Pnt TDataXtd_Triangulation::Node (const Standard_Integer theIndex) const
{
return myTriangulation->Node(theIndex);
}
@ -170,7 +170,7 @@ const gp_Pnt& TDataXtd_Triangulation::Node (const Standard_Integer theIndex) con
void TDataXtd_Triangulation::SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode)
{
Backup();
myTriangulation->ChangeNode(theIndex) = theNode;
myTriangulation->SetNode (theIndex, theNode);
}
//=======================================================================
@ -178,7 +178,7 @@ void TDataXtd_Triangulation::SetNode (const Standard_Integer theIndex, const gp_
//purpose : return UVNode at the given index.
// Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
//=======================================================================
const gp_Pnt2d& TDataXtd_Triangulation::UVNode (const Standard_Integer theIndex) const
gp_Pnt2d TDataXtd_Triangulation::UVNode (const Standard_Integer theIndex) const
{
return myTriangulation->UVNode(theIndex);
}
@ -192,7 +192,7 @@ const gp_Pnt2d& TDataXtd_Triangulation::UVNode (const Standard_Integer theIndex)
void TDataXtd_Triangulation::SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode)
{
Backup();
myTriangulation->ChangeUVNode(theIndex) = theUVNode;
myTriangulation->SetUVNode (theIndex, theUVNode);
}
//=======================================================================
@ -200,7 +200,7 @@ void TDataXtd_Triangulation::SetUVNode (const Standard_Integer theIndex, const g
//purpose : return triangle at the given index.
// Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
//=======================================================================
const Poly_Triangle& TDataXtd_Triangulation::Triangle (const Standard_Integer theIndex) const
Poly_Triangle TDataXtd_Triangulation::Triangle (const Standard_Integer theIndex) const
{
return myTriangulation->Triangle(theIndex);
}
@ -214,18 +214,7 @@ const Poly_Triangle& TDataXtd_Triangulation::Triangle (const Standard_Integer th
void TDataXtd_Triangulation::SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle)
{
Backup();
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);
myTriangulation->SetTriangle (theIndex, theTriangle);
}
//=======================================================================
@ -234,10 +223,10 @@ void TDataXtd_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)
// Raises Standard_OutOfRange exception.
//=======================================================================
void TDataXtd_Triangulation::SetNormal (const Standard_Integer theIndex,
const gp_Dir& theNormal)
const gp_Dir& theNormal)
{
Backup();
myTriangulation->SetNormal(theIndex, theNormal);
myTriangulation->SetNormal (theIndex, theNormal);
}
//=======================================================================
@ -254,9 +243,9 @@ Standard_Boolean TDataXtd_Triangulation::HasNormals() const
//purpose : return normal at the given index.
// Raises Standard_OutOfRange exception.
//=======================================================================
const gp_Dir TDataXtd_Triangulation::Normal (const Standard_Integer theIndex) const
gp_Dir TDataXtd_Triangulation::Normal (const Standard_Integer theIndex) const
{
return myTriangulation->Normal(theIndex);
return myTriangulation->Normal (theIndex);
}
//=======================================================================

View File

@ -98,7 +98,7 @@ public:
//! @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;
Standard_EXPORT gp_Pnt Node (const Standard_Integer theIndex) const;
//! The method differs from Poly_Triangulation!
//! Sets a node at the given index.
@ -107,7 +107,7 @@ public:
//! @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;
Standard_EXPORT gp_Pnt2d UVNode (const Standard_Integer theIndex) const;
//! The method differs from Poly_Triangulation!
//! Sets a UVNode at the given index.
@ -116,17 +116,13 @@ public:
//! @return triangle at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
Standard_EXPORT Poly_Triangle Triangle (const Standard_Integer theIndex) const;
//! The method differs from Poly_Triangulation!
//! 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);
//! Sets the table of node normals.
//! Raises exception if length of theNormals != 3 * NbNodes
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
//! Changes normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
@ -137,7 +133,7 @@ public:
//! @return normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
//! Inherited attribute methods
// ===========================

View File

@ -2825,15 +2825,13 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
}
}
Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
Handle(Poly_Triangulation) polyTriangulation = new Poly_Triangulation (number_pointArray, number_triangle, false, true);
if ( mStartPhi <= 0.0 ){
x[0] = mCenter[0];
x[1] = mCenter[1];
x[2] = mCenter[2] + mRadius;
PointsOfArray.SetValue(1,gp_Pnt(x[0],x[1],x[2]));
polyTriangulation->SetNode (1, gp_Pnt (x[0],x[1],x[2]));
}
// Create south pole if needed
@ -2841,7 +2839,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
x[0] = mCenter[0];
x[1] = mCenter[1];
x[2] = mCenter[2] - mRadius;
PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
polyTriangulation->SetNode (2, gp_Pnt (x[0],x[1],x[2]));
}
number_point = 3;
@ -2856,7 +2854,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
x[0] = n[0] + mCenter[0];
x[1] = n[1] + mCenter[1];
x[2] = n[2] + mCenter[2];
PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
polyTriangulation->SetNode (number_point, gp_Pnt (x[0],x[1],x[2]));
number_point++;
}
}
@ -2868,7 +2866,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + numPoles;
pts[1] = (phiResolution*(i+1) % base) + numPoles;
pts[2] = 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->SetTriangle (number_triangle, Poly_Triangle (pts[0],pts[1],pts[2]));
number_triangle++;
}
}
@ -2879,7 +2877,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + numOffset;
pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
pts[1] = numPoles - 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->SetTriangle (number_triangle, Poly_Triangle (pts[0],pts[1],pts[2]));
number_triangle++;
}
}
@ -2891,51 +2889,44 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + j + numPoles;
pts[1] = pts[0] + 1;
pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->SetTriangle (number_triangle, Poly_Triangle (pts[0],pts[1],pts[2]));
number_triangle++;
pts[1] = pts[2];
pts[2] = pts[1] - 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->SetTriangle (number_triangle, Poly_Triangle (pts[0],pts[1],pts[2]));
number_triangle++;
}
}
Poly_Connect* pc = new Poly_Connect(polyTriangulation);
Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
Poly_Connect pc (polyTriangulation);
Standard_Integer index[3];
Standard_Real Tol = Precision::Confusion();
gp_Dir Nor;
for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
gp_XYZ eqPlan(0, 0, 0);
for ( pc->Initialize(i); pc->More(); pc->Next()) {
pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
eqPlan += vv/mod;
}
for (i = 1; i <= polyTriangulation->NbNodes(); i++)
{
gp_XYZ eqPlan(0, 0, 0);
for (pc.Initialize (i); pc.More(); pc.Next())
{
polyTriangulation->Triangle (pc.Value()).Get (index[0], index[1], index[2]);
gp_XYZ v1 (polyTriangulation->Node (index[1]).Coord() - polyTriangulation->Node (index[0]).Coord());
gp_XYZ v2 (polyTriangulation->Node (index[2]).Coord() - polyTriangulation->Node (index[1]).Coord());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
eqPlan += vv/mod;
}
Standard_Real modmax = eqPlan.Modulus();
Standard_Real modmax = eqPlan.Modulus();
if(modmax > Tol)
Nor = gp_Dir(eqPlan);
else
Nor = gp_Dir(0., 0., 1.);
if(modmax > Tol)
Nor = gp_Dir(eqPlan);
else
Nor = gp_Dir(0., 0., 1.);
Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
polyTriangulation->SetNormal (i, Nor.XYZ());
}
delete pc;
polyTriangulation->SetNormals(Normals);
return polyTriangulation;
}
@ -2979,8 +2970,8 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
= new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
aResolution,
aRadius));
Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
const Standard_Integer aNumberPoints = aShape->GetTriangulation()->NbNodes();
const Standard_Integer aNumberTriangles = aShape->GetTriangulation()->NbTriangles();
// stupid initialization of Green color in RGBA space as integer
// probably wrong for big-endian CPUs
@ -6410,20 +6401,19 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
continue;
}
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const gp_Trsf& aTrsf = aLocation.Transformation();
// extract normals from nodes
TColgp_Array1OfDir aNormals (aNodes.Lower(), hasNormals ? aNodes.Upper() : aNodes.Lower());
TColgp_Array1OfDir aNormals (1, hasNormals ? aTriangulation->NbNodes() : 1);
if (hasNormals)
{
Poly_Connect aPolyConnect (aTriangulation);
StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
}
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
{
gp_Pnt aPoint = aNodes (aNodeIter);
gp_Pnt aPoint = aTriangulation->Node (aNodeIter);
if (!aLocation.IsIdentity())
{
aPoint.Transform (aTrsf);

View File

@ -84,22 +84,18 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
// number of triangles:
if (T.IsNull()) continue; //smh
nnn = T->NbTriangles();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
// getting a triangle. It is a triplet of indices in the node table:
const Poly_Array1OfTriangle& triangles = T->Triangles();
// Taking the nodes of the triangle, taking into account the orientation
// of the triangle.
for (nt = 1; nt <= nnn; nt++) {
if (F.Orientation() == TopAbs_REVERSED)
triangles(nt).Get(n1,n3,n2);
T->Triangle (nt).Get (n1,n3,n2);
else
triangles(nt).Get(n1,n2,n3);
T->Triangle (nt).Get (n1,n2,n3);
const gp_Pnt& P1 = Nodes(n1);
const gp_Pnt& P2 = Nodes(n2);
const gp_Pnt& P3 = Nodes(n3);
const gp_Pnt P1 = T->Node (n1);
const gp_Pnt P2 = T->Node (n2);
const gp_Pnt P3 = T->Node (n3);
// controlling whether the triangle correct from a 3d point of
// view: (the triangle may exist in the UV space but the
// in the 3d space a dimension is null for example)
@ -160,13 +156,12 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
// 1 - Building HAV1 - array of all XYZ of nodes for Vrml_Coordinate3 from the triangles
// and HAV2 - array of all normals of nodes for Vrml_Normal
const TColgp_Array1OfPnt& Nodes = T->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
TColgp_Array1OfDir NORMAL(1, T->NbNodes());
decal = nnv-1;
for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
p = Nodes(j).Transformed(theLocation.Transformation());
for (j= 1; j<= T->NbNodes(); j++) {
p = T->Node (j).Transformed (theLocation.Transformation());
V.SetX(p.X()); V.SetY(p.Y()); V.SetZ(p.Z());
HAV1->SetValue(nnv,V);
@ -185,16 +180,15 @@ void VrmlConverter_ShadedShape::Add( Standard_OStream& anOStream,
// 2 - Building HAI1 - array of indexes of all triangles and
// HAI3 - array of indexes of all normales for Vrml_IndexedFaceSet
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(n[0],n[2],n[1]);
T->Triangle (i).Get (n[0],n[2],n[1]);
else
triangles(i).Get(n[0],n[1],n[2]);
const gp_Pnt& P1 = Nodes(n[0]);
const gp_Pnt& P2 = Nodes(n[1]);
const gp_Pnt& P3 = Nodes(n[2]);
T->Triangle (i).Get (n[0],n[1],n[2]);
const gp_Pnt P1 = T->Node (n[0]);
const gp_Pnt P2 = T->Node (n[1]);
const gp_Pnt P3 = T->Node (n[2]);
gp_Vec V1(P1,P2);
if (V1.SquareMagnitude() > 1.e-10) {
gp_Vec V2(P2,P3);
@ -389,10 +383,9 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace,
CSLib_DerivativeStatus aStatus;
CSLib_NormalStatus NStat;
S.Initialize(aFace);
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (i = UVNodes.Lower(); i <= UVNodes.Upper(); i++) {
U = UVNodes(i).X();
V = UVNodes(i).Y();
for (i = 1; i <= T->NbNodes(); i++) {
U = T->UVNode (i).X();
V = T->UVNode (i).Y();
S.D1(U,V,P,D1U,D1V);
CSLib::Normal(D1U,D1V,Precision::Angular(),aStatus,Nor(i));
if (aStatus != CSLib_Done) {
@ -403,16 +396,14 @@ void VrmlConverter_ShadedShape::ComputeNormal(const TopoDS_Face& aFace,
}
}
else {
const TColgp_Array1OfPnt& Nodes = T->Nodes();
Standard_Integer n[3];
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
for (i = 1; i <= T->NbNodes(); i++) {
gp_XYZ eqPlan(0, 0, 0);
for (pc.Initialize(i); pc.More(); pc.Next()) {
triangles(pc.Value()).Get(n[0], n[1], n[2]);
gp_XYZ v1(Nodes(n[1]).Coord()-Nodes(n[0]).Coord());
gp_XYZ v2(Nodes(n[2]).Coord()-Nodes(n[1]).Coord());
T->Triangle (pc.Value()).Get (n[0], n[1], n[2]);
gp_XYZ v1 (T->Node (n[1]).Coord() - T->Node (n[0]).Coord());
gp_XYZ v2 (T->Node (n[2]).Coord() - T->Node (n[1]).Coord());
eqPlan += (v1^v2).Normalized();
}
Nor(i) = gp_Dir(eqPlan);

View File

@ -208,17 +208,15 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
Handle(Poly_Triangulation) aTriangulation =
new Poly_Triangulation(aNodes.Length(), aTriangles.Extent(), Standard_False);
// Copy the triangulation vertices
TColgp_Array1OfPnt& aTNodes = aTriangulation->ChangeNodes();
for (i = 0; i < aNodes.Length(); i++)
{
aTNodes.SetValue(i + 1, gp_Pnt(aNodes(i)));
aTriangulation->SetNode (i + 1, gp_Pnt (aNodes (i)));
}
// Copy the triangles.
Poly_Array1OfTriangle& aTTriangles = aTriangulation->ChangeTriangles();
NCollection_List<Poly_Triangle>::Iterator itT(aTriangles);
for (i = 1; itT.More(); itT.Next(), i++)
{
aTTriangles.SetValue(i, itT.Value());
aTriangulation->SetTriangle (i, itT.Value());
}
Handle(BRep_TFace) aFace = new BRep_TFace();
@ -229,19 +227,18 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
if (myNormals.IsNull()) {
Poly::ComputeNormals(aTriangulation);
}
else {
else
{
// Copy the normals. Currently only normals-per-vertex are supported.
Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, 3 * nbNodes);
if (myNormalPerVertex) {
if (myArrNormalInd == 0L) {
if (myNormalPerVertex)
{
aTriangulation->AddNormals();
if (myArrNormalInd == 0L)
{
for (i = 0; i < nbNodes; i++)
{
Standard_Integer anIdx = i * 3 + 1;
const gp_XYZ& aNormal = myNormals->Normal(i);
Normals->SetValue(anIdx + 0, Standard_ShortReal(aNormal.X()));
Normals->SetValue(anIdx + 1, Standard_ShortReal(aNormal.Y()));
Normals->SetValue(anIdx + 2, Standard_ShortReal(aNormal.Z()));
const gp_XYZ& aNormal = myNormals->Normal (i);
aTriangulation->SetNormal (i + 1, aNormal);
}
}
else
@ -254,12 +251,10 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
Polygon(i, anArrNodes);
const Standard_Integer * arrIndice;
int nbn = IndiceNormals(i, arrIndice);
for (Standard_Integer j = 0; j < nbn; j++) {
for (Standard_Integer j = 0; j < nbn; j++)
{
const gp_XYZ& aNormal = myNormals->Normal(arrIndice[j]);
Standard_Integer anInd = mapIdId(anArrNodes[j]) * 3 + 1;
Normals->SetValue(anInd + 0, Standard_ShortReal(aNormal.X()));
Normals->SetValue(anInd + 1, Standard_ShortReal(aNormal.Y()));
Normals->SetValue(anInd + 2, Standard_ShortReal(aNormal.Z()));
aTriangulation->SetNormal (mapIdId (anArrNodes[j]) + 1, aNormal);
}
}
}
@ -268,7 +263,6 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
else {
//TODO ..
}
aTriangulation->SetNormals(Normals);
}
myIsModified = Standard_False;

View File

@ -330,21 +330,19 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
Standard_Integer i;
const Standard_Integer nNodes (theTri->NbNodes());
const Standard_Integer nTriangles (theTri->NbTriangles());
const TColgp_Array1OfPnt& arrPolyNodes = theTri->Nodes();
const Poly_Array1OfTriangle& arrTriangles = theTri->Triangles();
// protection against creation degenerative triangles
Standard_Integer nbTri = 0;
Poly_Array1OfTriangle aTriangles(1, nTriangles);
for (i = 0; i < nTriangles; i++) {
Standard_Integer idx[3];
arrTriangles(i + 1).Get(idx[0], idx[1], idx[2]);
theTri->Triangle (i + 1).Get (idx[0], idx[1], idx[2]);
if (idx[0] == idx[1] || idx[0] == idx[2] || idx[1] == idx[2])
{
continue;
}
nbTri++;
aTriangles.SetValue(nbTri, arrTriangles(i + 1));
aTriangles.SetValue (nbTri, theTri->Triangle (i + 1));
}
aTriangles.Resize(1, nbTri, Standard_True);
@ -387,7 +385,9 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
gp_XYZ * arrNodes = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
for (i = 0; i < nNodes; i++)
arrNodes[i] = arrPolyNodes(i+1).XYZ() * myScale;
{
arrNodes[i] = theTri->Node (i+1).XYZ() * myScale;
}
const Handle(VrmlData_Coordinate) aCoordNode =
new VrmlData_Coordinate (myScene, 0L, nNodes, arrNodes);
@ -396,14 +396,14 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
}
// Create the Normals node if theTri has normals
if(theTri->HasNormals()) {
gp_XYZ * arrVec = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
const TShort_Array1OfShortReal& Norm = theTri->Normals();
Standard_Integer j;
for (i = 0, j = 1; i < nNodes; i++, j += 3)
if (theTri->HasNormals())
{
gp_XYZ* arrVec = static_cast<gp_XYZ*>(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
gp_Vec3f aVec3;
for (i = 0; i < nNodes; i++)
{
gp_XYZ aNormal(Norm(j), Norm(j+1), Norm(j+2));
theTri->Normal (i + 1, aVec3);
gp_XYZ aNormal (aVec3.x(), aVec3.y(), aVec3.z());
if (isReverse)
{
aNormal.Reverse();
@ -422,24 +422,18 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
TopLoc_Location aLoc;
const Standard_Real aConf2 = Precision::SquareConfusion();
const Handle(Geom_Surface) aSurface = BRep_Tool::Surface (theFace, aLoc);
if (theTri->HasUVNodes() && aSurface.IsNull() == Standard_False) {
if (theTri->HasUVNodes() && aSurface.IsNull() == Standard_False)
{
if (aSurface->IsCNu(1) && aSurface->IsCNv(1))
{
Standard_Integer nbNormVal = nNodes * 3;
Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, nbNormVal);
const TColgp_Array1OfPnt2d& arrUV = theTri->UVNodes();
gp_XYZ * arrVec = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
gp_XYZ* arrVec = static_cast<gp_XYZ*> (anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
// Compute the normal vectors
Standard_Real Tol = Sqrt(aConf2);
for (i = 0; i < nNodes; i++) {
const gp_Pnt2d& aUV = arrUV(i+1);
for (i = 0; i < nNodes; i++)
{
const gp_Pnt2d aUV = theTri->UVNode (i+1);
gp_Dir aNormal;
if (GeomLib::NormEstim(aSurface, aUV, Tol, aNormal) > 1) {
//Try to estimate as middle normal of adjacent triangles
Standard_Integer n[3];
@ -447,8 +441,8 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
gp_XYZ eqPlan(0., 0., 0.);
for (PC.Initialize(i+1); PC.More(); PC.Next()) {
aTriangles(PC.Value()).Get(n[0], n[1], n[2]);
gp_XYZ v1(arrPolyNodes(n[1]).Coord()-arrPolyNodes(n[0]).Coord());
gp_XYZ v2(arrPolyNodes(n[2]).Coord()-arrPolyNodes(n[1]).Coord());
gp_XYZ v1 (theTri->Node (n[1]).Coord()-theTri->Node (n[0]).Coord());
gp_XYZ v2 (theTri->Node (n[2]).Coord()-theTri->Node (n[1]).Coord());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
@ -470,17 +464,10 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
aNormal.SetY(0.);
if (aNormal.Z()*aNormal.Z() < aConf2)
aNormal.SetZ(0.);
arrVec[i] = aNormal.XYZ();
Standard_Integer j = i * 3;
Normals->SetValue(j + 1, (Standard_ShortReal)aNormal.X());
Normals->SetValue(j + 2, (Standard_ShortReal)aNormal.Y());
Normals->SetValue(j + 3, (Standard_ShortReal)aNormal.Z());
}
theTri->SetNormals(Normals);
const Handle(VrmlData_Normal) aNormalNode =
new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
myScene.AddNode (aNormalNode, Standard_False);

View File

@ -146,24 +146,20 @@ static Standard_Real CalculVolume(const TopoDS_Shape& So,
facing = BRep_Tool::Triangulation(F,L);
}
TColgp_Array1OfPnt tab(1,(facing->NbNodes()));
tab = facing->Nodes();
Poly_Array1OfTriangle tri(1,facing->NbTriangles());
tri = facing->Triangles();
for (Standard_Integer i=1;i<=(facing->NbTriangles());i++)
{
Poly_Triangle trian = tri.Value(i);
Poly_Triangle trian = facing->Triangle (i);
Standard_Integer index1,index2,index3;//M,N;
if( F.Orientation() == TopAbs_REVERSED )
trian.Get(index1,index3,index2);
else
trian.Get(index1,index2,index3);
curVolume = TetraVol(aRefPoint, tab.Value(index1),
tab.Value(index2), tab.Value(index3));
curVolume = TetraVol (aRefPoint, facing->Node (index1),
facing->Node (index2), facing->Node (index3));
myVolume += curVolume;
curCentroid = TetraCen(aRefPoint, tab.Value(index1),
tab.Value(index2), tab.Value(index3));
curCentroid = TetraCen (aRefPoint, facing->Node (index1),
facing->Node (index2), facing->Node (index3));
localCentroid = localCentroid + curCentroid*curVolume;
}

View File

@ -783,7 +783,7 @@ static Standard_Integer createmesh
// Hide all nodes by default
Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
Standard_Integer aLen = aSTLMesh->Nodes().Length();
const Standard_Integer aLen = aSTLMesh->NbNodes();
for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
aNodes->ChangeMap().Add( anIndex );
aMesh->SetHiddenNodes( aNodes );

View File

@ -33,42 +33,38 @@ XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulat
if( !myMesh.IsNull() )
{
const TColgp_Array1OfPnt& aCoords = myMesh->Nodes();
Standard_Integer len = aCoords.Length(), i, j;
myNodeCoords = new TColStd_HArray2OfReal(1, len, 1, 3);
std::cout << "Nodes : " << len << std::endl;
const Standard_Integer aNbNodes = myMesh->NbNodes();
myNodeCoords = new TColStd_HArray2OfReal (1, aNbNodes, 1, 3);
std::cout << "Nodes : " << aNbNodes << std::endl;
gp_XYZ xyz;
for( i = 1; i <= len; i++ )
for (Standard_Integer i = 1; i <= aNbNodes; i++)
{
myNodes.Add( i );
xyz = aCoords(i).XYZ();
gp_Pnt xyz = myMesh->Node (i);
myNodeCoords->SetValue(i, 1, xyz.X());
myNodeCoords->SetValue(i, 2, xyz.Y());
myNodeCoords->SetValue(i, 3, xyz.Z());
}
const Poly_Array1OfTriangle& aSeq = myMesh->Triangles();
len = aSeq.Length();
myElemNormals = new TColStd_HArray2OfReal(1, len, 1, 3);
myElemNodes = new TColStd_HArray2OfInteger(1, len, 1, 3);
const Standard_Integer aNbTris = myMesh->NbTriangles();
myElemNormals = new TColStd_HArray2OfReal(1, aNbTris, 1, 3);
myElemNodes = new TColStd_HArray2OfInteger(1, aNbTris, 1, 3);
std::cout << "Elements : " << len << std::endl;
std::cout << "Elements : " << aNbTris << std::endl;
for( i = 1; i <= len; i++ )
for (Standard_Integer i = 1; i <= aNbTris; i++)
{
myElements.Add( i );
const Poly_Triangle& aTri = aSeq(i);
const Poly_Triangle aTri = myMesh->Triangle (i);
Standard_Integer V[3];
aTri.Get (V[0], V[1], V[2]);
const gp_Pnt aP1 = aCoords (V[0]);
const gp_Pnt aP2 = aCoords (V[1]);
const gp_Pnt aP3 = aCoords (V[2]);
const gp_Pnt aP1 = myMesh->Node (V[0]);
const gp_Pnt aP2 = myMesh->Node (V[1]);
const gp_Pnt aP3 = myMesh->Node (V[2]);
gp_Vec aV1(aP1, aP2);
gp_Vec aV2(aP2, aP3);
@ -79,7 +75,7 @@ XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulat
else
aN.SetCoord(0.0, 0.0, 0.0);
for( j = 0; j < 3; j++ )
for (Standard_Integer j = 0; j < 3; j++)
{
myElemNodes->SetValue(i, j+1, V[j]);
}

View File

@ -158,31 +158,25 @@ void XmlMDataXtd_TriangulationDriver::Paste(const Handle(TDF_Attribute)& theSour
stream << PT->Deflection() << "\n";
// write the 3d nodes
const TColgp_Array1OfPnt& Nodes = PT->Nodes();
for (i = 1; i <= nbNodes; i++)
{
stream << Nodes(i).X() << " "
<< Nodes(i).Y() << " "
<< Nodes(i).Z() << " ";
const gp_Pnt aNode = PT->Node (i);
stream << aNode.X() << " " << aNode.Y() << " " << aNode.Z() << " ";
}
if (PT->HasUVNodes())
{
const TColgp_Array1OfPnt2d& UVNodes = PT->UVNodes();
for (i = 1; i <= nbNodes; i++)
{
stream << UVNodes(i).X() << " "
<< UVNodes(i).Y() << " ";
const gp_Pnt2d aNode2d = PT->UVNode (i);
stream << aNode2d.X() << " " << aNode2d.Y() << " ";
}
}
const Poly_Array1OfTriangle& Triangles = PT->Triangles();
for (i = 1; i <= nbTriangles; i++)
{
Triangles(i).Get(n1, n2, n3);
stream << n1 << " "
<< n2 << " "
<< n3 << " ";
PT->Triangle (i).Get (n1, n2, n3);
stream << n1 << " " << n2 << " " << n3 << " ";
}
stream << std::ends;

View File

@ -105,6 +105,8 @@ gp_Vec.lxx
gp_Vec2d.cxx
gp_Vec2d.hxx
gp_Vec2d.lxx
gp_Vec2f.hxx
gp_Vec3f.hxx
gp_VectorWithNullMagnitude.hxx
gp_XY.cxx
gp_XY.hxx

21
src/gp/gp_Vec2f.hxx Normal file
View File

@ -0,0 +1,21 @@
// Copyright (c) 2021 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 gp_Vec2f_HeaderFile
#define gp_Vec2f_HeaderFile
#include <NCollection_Vec2.hxx>
typedef NCollection_Vec2<Standard_ShortReal> gp_Vec2f;
#endif

23
src/gp/gp_Vec3f.hxx Normal file
View File

@ -0,0 +1,23 @@
// Created on: 2021-02-16
// Copyright (c) 2021 OPEN CASCADE SAS
// Created by: Vlad Romashko
//
// 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 gp_Vec3f_HeaderFile
#define gp_Vec3f_HeaderFile
#include <NCollection_Vec3.hxx>
typedef NCollection_Vec3<Standard_ShortReal> gp_Vec3f;
#endif