const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
const gp_Dir& theNormal)
{
- myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 1, theP1);
- myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 2, theP2);
- myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 3, theP3);
+ myTriangulation->ChangeNode (theIndex * 3 + 1) = theP1;
+ myTriangulation->ChangeNode (theIndex * 3 + 2) = theP2;
+ myTriangulation->ChangeNode (theIndex * 3 + 3) = theP3;
- myTriangulation->ChangeTriangles().SetValue (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
+ myTriangulation->ChangeTriangle (theIndex + 1) = Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3);
myArray->AddVertex (theP1, theNormal);
myArray->AddVertex (theP2, theNormal);
myArray->AddVertex (theP3, theNormal);
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();
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
Standard_Integer i;
- Standard_Integer j;
const Standard_Real ambient = 0.2;
if (hasVNormals)
{
- const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
if (hasVColors)
{
const TColStd_Array1OfInteger& colors = myColor->Array1();
- for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+ for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
- j = (i - nodes.Lower()) * 3;
- anArray->AddVertex(nodes(i), attenuateColor(colors(i), ambient));
- anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
+ anArray->AddVertex(myTriangulation->Node (i), attenuateColor(colors(i), ambient));
+ anArray->SetVertexNormal(i, myTriangulation->Normal (i));
}
}
else // !hasVColors
{
- for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+ for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
- j = (i - nodes.Lower()) * 3;
- anArray->AddVertex(nodes(i));
- anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
+ anArray->AddVertex(myTriangulation->Node (i));
+ anArray->SetVertexNormal(i, myTriangulation->Normal (i));
}
}
}
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]);
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());
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);
return 0;
const Standard_Integer aCNode = aTrng->NbNodes();
- const TColgp_Array1OfPnt& aNodesArr = aTrng->Nodes();
for (Standard_Integer i = 1; i <= aCNode; i++)
{
if (thePts)
{
- const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr[i] :
- aNodesArr[i].Transformed(aLoc);
+ const gp_Pnt aP = aLoc.IsIdentity() ? aTrng->Node (i) :
+ aTrng->Node (i).Transformed(aLoc);
(*thePts)(aRetVal) = aP;
}
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() +
{
const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
const gp_Pnt aPE(aBC.Value(aParam)),
- aPnt(Nodes(anIndices(i)).Transformed(aLL));
+ aPnt(aTriang->Node (anIndices(i)).Transformed(aLL));
const Standard_Real aSQDist = aPE.SquareDistance(aPnt);
if(aSQDist > aTol*aTol)
for (Standard_Integer i = 1; i <= aNbNodes; i++)
{
if (aLL.IsIdentity())
- aB.Add(Nodes(anIndices(i)));
+ aB.Add(aTriang->Node (anIndices(i)));
else
- aB.Add(Nodes(anIndices(i)).Transformed(aLL));
+ aB.Add(aTriang->Node (anIndices(i)).Transformed(aLL));
}
aB.Enlarge(aTol);
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
- const TColgp_Array1OfPnt& Nod = Tr->Nodes();
n = Tr->NbNodes();
for (i = 1; i <= n; i++)
{
nbn1++;
- TP1.SetValue(nbn1,Nod(i).Transformed(L));
+ TP1.SetValue(nbn1,Tr->Node (i).Transformed(L));
}
}
}
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
- const TColgp_Array1OfPnt& Nod = Tr->Nodes();
n = Tr->NbNodes();
for (i = 1; i <= n; i++)
{
nbn2++;
- TP2.SetValue(nbn2,Nod(i).Transformed(L));
+ TP2.SetValue(nbn2,Tr->Node (i).Transformed(L));
}
}
}
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());
Standard_Integer aVertex2;
Standard_Integer aVertex3;
- aTriangulation->Triangles().Value (aTriIdx).Get (aVertex1,
- aVertex2,
- aVertex3);
+ aTriangulation->Triangle (aTriIdx).Get (aVertex1,
+ aVertex2,
+ aVertex3);
myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
aVertex2 + aVertOffset,
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
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;
}
if (theLoc.IsIdentity())
{
- Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
+ Perform (theMesh, theOri);
}
else
{
Abs(Abs(aTr.ScaleFactor()) - 1.) > gp::Resolution();
if (isToCopy)
{
- TColgp_Array1OfPnt aNodes(1, theMesh->NbNodes());
- const TColgp_Array1OfPnt& aMeshNodes = theMesh->Nodes();
+ // Copy and transform nodes.
Standard_Integer i;
- for (i = 1; i <= aMeshNodes.Length(); ++i)
- {
- aNodes(i) = aMeshNodes.Value(i).Transformed(aTr);
- }
- Perform(aNodes, theMesh->Triangles(), theOri);
+ TColgp_Array1OfPnt aNodes (1, theMesh->NbNodes());
+ for (i = 1; i <= theMesh->NbNodes(); ++i)
+ aNodes (i) = theMesh->Node (i).Transformed (aTr);
+
+ // Copy triangles.
+ Poly_Array1OfTriangle aTriangles (1, theMesh->NbTriangles());
+ for (i = 1; i <= theMesh->NbTriangles();++i)
+ aTriangles (i) = theMesh->Triangle (i);
+
+ Perform(new Poly_Triangulation(aNodes, aTriangles), theOri);
return;
}
//
gp_Trsf aTrInv = aTr.Inverted();
gp_Pnt loc_save = loc;
loc.Transform(aTrInv);
- Perform(theMesh->Nodes(), theMesh->Triangles(), theOri);
+ Perform(theMesh, theOri);
//Computes the inertia tensor at mesh gravity center
gp_Mat HMat, inertia0;
gp_Pnt g0 = g;
//function : Perform
//purpose :
//=======================================================================
-void BRepGProp_MeshProps::Perform(const TColgp_Array1OfPnt& theNodes,
- const Poly_Array1OfTriangle& theTriangles,
+void BRepGProp_MeshProps::Perform (const Handle(Poly_Triangulation)& theMesh,
const TopAbs_Orientation theOri)
{
- if (theNodes.IsEmpty() || theTriangles.IsEmpty())
+ if (theMesh.IsNull() || !theMesh->NbNodes() || !theMesh->NbTriangles())
{
return;
}
Standard_Boolean isVolume = myType == Vinert;
Standard_Integer i;
- Standard_Integer n1, n2, n3; //node indices
- for (i = theTriangles.Lower(); i <= theTriangles.Upper(); ++i)
+ Standard_Integer n1, n2, n3; //node indeces
+ for (i = 1; i <= theMesh->NbTriangles(); ++i)
{
- const Poly_Triangle& aTri = theTriangles(i);
- aTri.Get(n1, n2, n3);
+ const Poly_Triangle& aTri = theMesh->Triangle (i);
+ aTri.Get (n1, n2, n3);
if (theOri == TopAbs_REVERSED)
{
Standard_Integer nn = n2;
n3 = nn;
}
// Calculate properties of a pyramid built on face and apex
- const gp_Pnt& p1 = theNodes(n1);
- const gp_Pnt& p2 = theNodes(n2);
- const gp_Pnt& p3 = theNodes(n3);
- CalculateProps(p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
+ const gp_Pnt& p1 = theMesh->Node (n1);
+ const gp_Pnt& p2 = theMesh->Node (n2);
+ const gp_Pnt& p3 = theMesh->Node (n3);
+ CalculateProps (p1, p2, p3, loc, isVolume, aGProps, aNbGaussPoints, GPtsWg);
}
dim = aGProps[0];
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
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.);
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;
const Standard_Integer aFNodF1 = aPTEF1->Nodes().Value(anEdgNode);
const Standard_Integer aFNodF2 = aPTEF2->Nodes().Value(anEdgNode);
- const Standard_Integer aFNorm1FirstIndex = aNormArr1.Lower() + 3*
- (aFNodF1 - aPT1->Nodes().Lower());
- const Standard_Integer aFNorm2FirstIndex = aNormArr2.Lower() + 3*
- (aFNodF2 - aPT2->Nodes().Lower());
-
- gp_XYZ aNorm1(aNormArr1.Value(aFNorm1FirstIndex),
- aNormArr1.Value(aFNorm1FirstIndex+1),
- aNormArr1.Value(aFNorm1FirstIndex+2));
- gp_XYZ aNorm2(aNormArr2.Value(aFNorm2FirstIndex),
- aNormArr2.Value(aFNorm2FirstIndex+1),
- aNormArr2.Value(aFNorm2FirstIndex+2));
+ gp_XYZ aNorm1 (aPT1->Normal (aFNodF1).XYZ());
+ gp_XYZ aNorm2 (aPT2->Normal (aFNodF2).XYZ());
const Standard_Real aDot = aNorm1 * aNorm2;
if(aDot > aThresDot)
{
gp_XYZ aNewNorm = (aNorm1 + aNorm2).Normalized();
- aNormArr1.ChangeValue(aFNorm1FirstIndex) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex) =
- static_cast<Standard_ShortReal>(aNewNorm.X());
- aNormArr1.ChangeValue(aFNorm1FirstIndex+1) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex+1) =
- static_cast<Standard_ShortReal>(aNewNorm.Y());
- aNormArr1.ChangeValue(aFNorm1FirstIndex+2) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex+2) =
- static_cast<Standard_ShortReal>(aNewNorm.Z());
+ aPT1->SetNormal (aFNodF1, aNewNorm);
+ aPT2->SetNormal (aFNodF2, aNewNorm);
aRetVal = Standard_True;
}
}
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation(
myUsedNodes->Extent(), aTriangles.Extent(), Standard_True);
- aTriangulation->ChangeTriangles() = aPolyTrianges;
+ for (Standard_Integer iTri = 1; iTri <= aPolyTrianges.Upper(); iTri++)
+ aTriangulation->ChangeTriangle (iTri) = aPolyTrianges (iTri);
+
return aTriangulation;
}
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))
const BRepMesh_Vertex& aVertex = myStructure->GetNode(i);
const Standard_Integer aNodeIndex = myUsedNodes->Find(i);
- aNodes(aNodeIndex) = myNodesMap->Value(aVertex.Location3d());
- aNodes2d(aNodeIndex) = getNodePoint2d(aVertex);
+ theTriangulation->ChangeNode (aNodeIndex) = myNodesMap->Value(aVertex.Location3d());
+ theTriangulation->ChangeUVNode (aNodeIndex) = getNodePoint2d(aVertex);
}
}
}
// commercial license or contractual agreement.
#include <BRepMesh_EdgeTessellationExtractor.hxx>
+#include <Poly_Triangulation.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
Handle (Poly_PolygonOnTriangulation) aPolygon =
BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc);
- myNodes = &aTriangulation->Nodes ();
+ myTriangulation = aTriangulation;
myIndices = &aPolygon->Nodes ();
myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
}
gp_Pnt& thePoint,
Standard_Real& theParameter) const
{
- const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex));
+ const gp_Pnt& theRefPnt = myTriangulation->Node ((*myIndices)(theIndex));
thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc);
theParameter = myProvider.Parameter (theIndex, thePoint);
private:
BRepMesh_EdgeParameterProvider<Handle(TColStd_HArray1OfReal)> myProvider;
- const TColgp_Array1OfPnt* myNodes;
+ Handle(Poly_Triangulation) myTriangulation;
const TColStd_Array1OfInteger* myIndices;
TopLoc_Location myLoc;
};
if (isTriangulationConsistent)
{
// #25080: check that indices of links forming triangles are in range.
- const Standard_Integer aNodesNb = aTriangulation->NbNodes();
- const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
- Standard_Integer i = aTriangles.Lower();
- for (; i <= aTriangles.Upper() && isTriangulationConsistent; ++i)
+ Standard_Integer i = 1;
+ for (; i <= aTriangulation->NbTriangles() && isTriangulationConsistent; ++i)
{
- const Poly_Triangle& aTriangle = aTriangles(i);
+ const Poly_Triangle& aTriangle = aTriangulation->Triangle (i);
Standard_Integer aNode[3];
aTriangle.Get(aNode[0], aNode[1], aNode[2]);
for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j)
{
- isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aNodesNb);
+ isTriangulationConsistent = (aNode[j] >= 1 && aNode[j] <= aTriangulation->NbNodes());
}
}
}
{
gp_Trsf aTrsf = aLoc.Transformation();
aTrsf.Invert();
-
- TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
- for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i)
- aNodes(i).Transform(aTrsf);
+ for (Standard_Integer i = 1; i <= theTriangulation->NbNodes(); ++i)
+ theTriangulation->ChangeNode (i).Transform (aTrsf);
}
BRep_Builder aBuilder;
#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)
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
+#include <Poly_Mesh.hxx>
#ifdef MacOS
#define strcasecmp(p,q) strcmp(p,q)
const Standard_Boolean Compact,
const Message_ProgressRange& theProgress)const
{
- Standard_Integer i, j, nbNodes, nbtri = myTriangulations.Extent();
+ Standard_Integer i, j, k, nbNodes, nbtri = myTriangulations.Extent();
Standard_Integer nbTriangles = 0, n1, n2, n3;
Message_ProgressScope aPS(theProgress, "Triangulations", nbtri);
if (!Compact) OS << "\n3D Nodes :\n";
nbNodes = T->NbNodes();
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (j = 1; j <= nbNodes; j++) {
if (!Compact) OS << std::setw(10) << j << " : ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(j).X() << " ";
+ OS << T->Node (j).X() << " ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(j).Y() << " ";
+ OS << T->Node (j).Y() << " ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(j).Z();
+ OS << T->Node (j).Z();
if (!Compact) OS << "\n";
else OS << " ";
}
if (T->HasUVNodes()) {
if (!Compact) OS << "\nUV Nodes :\n";
- const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (j = 1; j <= nbNodes; j++) {
if (!Compact) OS << std::setw(10) << j << " : ";
if (!Compact) OS << std::setw(17);
- OS << UVNodes(j).X() << " ";
+ OS << T->UVNode (j).X() << " ";
if (!Compact) OS << std::setw(17);
- OS << UVNodes(j).Y();
+ OS << T->UVNode (j).Y();
if (!Compact) OS << "\n";
else OS << " ";
}
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);
if (T->HasNormals() && toWriteNormals)
{
if (!Compact) OS << "\nNormals :\n";
- const TShort_Array1OfShortReal& Normals = T->Normals();
- for (j = 1; j <= nbNodes * 3; j++)
+ for (j = 1; j <= nbNodes; j++)
{
if (!Compact)
{
OS << std::setw(10) << j << " : ";
OS << std::setw(17);
}
- OS << Normals(j) << " ";
- if (!Compact)
- {
- OS << "\n";
- }
- else
+ for (k = 1; k <= 3; k++)
{
- OS << " ";
+ OS << T->Normal (j).Coord (k) << " ";
+ if (!Compact)
+ {
+ OS << "\n";
+ }
+ else
+ {
+ OS << " ";
+ }
}
}
}
myTriangulations.Add(T, hasNormals);
}
}
+
+// Writes meshes (Poly_Mesh).
+void BRepTools_ShapeSet::WriteMeshes (Standard_OStream& theOS,
+ const TColStd_IndexedMapOfTransient& theMeshes,
+ const Standard_Boolean theCompact)
+{
+ const Standard_Integer nbMeshes = theMeshes.Extent();
+
+ if (theCompact)
+ theOS << "Meshes " << nbMeshes << "\n";
+ else {
+ theOS << " -------\n";
+ theOS <<"Dump of " << nbMeshes << " meshes\n";
+ theOS << " -------\n";
+ }
+
+ Standard_Integer i = 1;
+ for (; i <= nbMeshes; i++)
+ {
+ const Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (theMeshes (i));
+ const Standard_Integer nbNodes = aMesh->NbNodes();
+ const Standard_Integer nbElements = aMesh->NbElements();
+ const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
+
+ if (theCompact)
+ {
+ theOS << nbNodes << " " << nbElements << " ";
+ theOS << (hasUVNodes ? "1" : "0") << " ";
+ }
+ else
+ {
+ theOS << " "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbElements <<" Triangles and Quadrangles\n";
+ theOS << " "<<(hasUVNodes ? "with" : "without") << " UV nodes\n";
+ }
+
+ // write the deflection
+ if (!theCompact)
+ theOS << " Deflection : ";
+ theOS << aMesh->Deflection() << "\n";
+
+ // write the 3d nodes
+ if (!theCompact)
+ theOS << "\n3D Nodes :\n";
+
+ Standard_Integer j;
+ for (j = 1; j <= nbNodes; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).X() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).Y() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).Z();
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+
+ // write 2d nodes
+ if (hasUVNodes)
+ {
+ if (!theCompact) theOS << "\nUV Nodes :\n";
+ for (j = 1; j <= nbNodes; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->UVNode (j).X() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->UVNode (j).Y();
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+ }
+
+ // write triangles and quadrangles
+ if (!theCompact) theOS << "\nElements :\n";
+ Standard_Integer n, n1, n2, n3, n4;
+ for (j = 1; j <= nbElements; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ aMesh->Element (j, n1, n2, n3, n4);
+ n = (n4 > 0) ? 4 : 3;
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n1 << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n2 << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n3;
+ if (n4 > 0)
+ {
+ theOS << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n4;
+ }
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+ theOS << "\n";
+ }
+}
+
+// Reads meshes (Poly_Mesh).
+void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
+ TColStd_IndexedMapOfTransient& theMeshes)
+{
+ char buffer[255];
+ Standard_Integer i, j;
+ Standard_Integer n, n1(0), n2(0), n3(0), n4(0);
+ Standard_Real deflection, x, y, z;
+ Standard_Integer nbMeshes(0), nbNodes(0), nbElements(0);
+ Standard_Boolean hasUV(Standard_False);
+ gp_Pnt p;
+
+ // Read the "Meshes" head-line.
+ theIS >> buffer;
+ if (strstr (buffer, "Meshes") == NULL)
+ return;
+
+ // Read number of meshes.
+ theIS >> nbMeshes;
+
+ for (i = 1; i <= nbMeshes; i++)
+ {
+ theIS >> nbNodes >> nbElements >> hasUV;
+ GeomTools::GetReal (theIS, deflection);
+
+ // Allocate the mesh.
+ Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
+ aMesh->Deflection (deflection);
+
+ // Read nodes.
+ for (j = 1; j <= nbNodes; j++)
+ {
+ GeomTools::GetReal (theIS, x);
+ GeomTools::GetReal (theIS, y);
+ GeomTools::GetReal (theIS, z);
+ p.SetCoord (x, y, z);
+ aMesh->AddNode (p);
+ }
+
+ // Reads 2d-nodes.
+ if (hasUV)
+ {
+ for (j = 1; j <= nbNodes; j++)
+ {
+ GeomTools::GetReal (theIS, x);
+ GeomTools::GetReal (theIS, y);
+ aMesh->ChangeUVNode (j).SetCoord (x, y);
+ }
+ }
+
+ // Reads the triangles and quadrangles.
+ for (j = 1; j <= nbElements; j++)
+ {
+ // Read the element.
+ theIS >> n;
+ if (n == 3)
+ theIS >> n1 >> n2 >> n3;
+ else if (n == 4)
+ theIS >> n1 >> n2 >> n3 >> n4;
+
+ // Set the element to the mesh.
+ if (n == 3)
+ aMesh->AddElement (n1, n2, n3);
+ else if (n == 4)
+ aMesh->AddElement (n1, n2, n3, n4);
+ }
+
+ theMeshes.Add (aMesh);
+ }
+}
//! on the stream <OS>.
Standard_EXPORT void DumpPolygonOnTriangulation (Standard_OStream& OS) const;
-
+ //! Writes meshes (Poly_Mesh).
+ //! TODO: Call this method when BRep_TFace refers to a list of meshes of type Poly_Mesh.
+ Standard_EXPORT static void WriteMeshes (Standard_OStream& theOS,
+ const TColStd_IndexedMapOfTransient& theMeshes,
+ const Standard_Boolean theCompact = Standard_True);
+
+ //! Reads meshes (Poly_Mesh).
+ //! TODO: Call this method when BRep_TFace refers to a list of meshes of type Poly_Mesh.
+ Standard_EXPORT static void ReadMeshes (Standard_IStream& theIS,
+ TColStd_IndexedMapOfTransient& theMeshes);
protected:
#include <BinMDataXtd_PresentationDriver.hxx>
#include <BinMDataXtd_PositionDriver.hxx>
#include <BinMDataXtd_TriangulationDriver.hxx>
-
+#include <BinMDataXtd_SurfacicMeshDriver.hxx>
+
static Standard_Integer myDocumentVersion = -1;
//=======================================================================
//function : AddDrivers
theDriverTable->AddDriver (new BinMDataXtd_GeometryDriver (theMsgDriver) );
theDriverTable->AddDriver (new BinMDataXtd_PatternStdDriver (theMsgDriver) );
theDriverTable->AddDriver (new BinMDataXtd_TriangulationDriver(theMsgDriver) );
+ theDriverTable->AddDriver (new BinMDataXtd_SurfacicMeshDriver (theMsgDriver) );
theDriverTable->AddDriver (new BinMDataXtd_PresentationDriver (theMsgDriver) );
theDriverTable->AddDriver (new BinMDataXtd_PositionDriver (theMsgDriver) );
--- /dev/null
+// Created on: 2015-12-17
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BinMDataXtd_SurfacicMeshDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <Standard_Type.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <TDF_Attribute.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMDataXtd_SurfacicMeshDriver,BinMDF_ADriver)
+
+//=======================================================================
+//function : BinMDataXtd_SurfacicMeshDriver
+//purpose : Constructor
+//=======================================================================
+BinMDataXtd_SurfacicMeshDriver::BinMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMsgDriver)
+ : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataXtd_SurfacicMesh)->Name())
+{
+
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) BinMDataXtd_SurfacicMeshDriver::NewEmpty() const
+{
+ return new TDataXtd_SurfacicMesh();
+}
+
+//=======================================================================
+//function : Paste
+//purpose : persistent -> transient (retrieve)
+//=======================================================================
+Standard_Boolean BinMDataXtd_SurfacicMeshDriver::Paste (const BinObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ BinObjMgt_RRelocationTable& ) const
+{
+ Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theTarget);
+
+ Standard_Integer i;
+ Standard_Real deflection, x, y, z;
+ Standard_Integer n, n1, n2, n3, n4;
+ Standard_Integer nbNodes(0), nbElements(0);
+ Standard_Boolean hasUV(Standard_False);
+ gp_Pnt p;
+
+ theSource >> nbNodes;
+ theSource >> nbElements;
+ theSource >> hasUV;
+ theSource >> deflection;
+
+ // allocate the mesh
+ Handle(Poly_Mesh) aMesh = new Poly_Mesh (hasUV);
+
+ // deflection
+ aMesh->Deflection (deflection);
+
+ // read nodes
+ for (i = 1; i <= nbNodes; i++)
+ {
+ theSource >> x;
+ theSource >> y;
+ theSource >> z;
+ p.SetCoord (x, y, z);
+ aMesh->AddNode (p);
+ }
+
+ // read 2d nodes
+ if (hasUV)
+ {
+ for (i = 1; i <= nbNodes; i++)
+ {
+ theSource >> x;
+ theSource >> y;
+ aMesh->ChangeUVNode (i).SetCoord (x,y);
+ }
+ }
+
+ // read triangles and quadrangles
+ for (i = 1; i <= nbElements; i++)
+ {
+ theSource >> n;
+ theSource >> n1;
+ theSource >> n2;
+ theSource >> n3;
+ if (n == 3)
+ aMesh->AddElement (n1, n2, n3);
+ else if (n == 4)
+ {
+ theSource >> n4;
+ aMesh->AddElement (n1, n2, n3, n4);
+ }
+ }
+
+ // Set mesh to Ocaf attribute
+ attrMesh->Set (aMesh);
+ return !aMesh.IsNull();
+}
+
+//=======================================================================
+//function : Paste
+//purpose : transient -> persistent (store)
+//=======================================================================
+void BinMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSource,
+ BinObjMgt_Persistent& theTarget,
+ BinObjMgt_SRelocationTable& ) const
+{
+ const Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theSource);
+ const Handle(Poly_Mesh)& aMesh = attrMesh->Get();
+ if (!aMesh.IsNull())
+ {
+ Standard_Integer nbNodes = aMesh->NbNodes();
+ Standard_Integer nbElements = aMesh->NbElements();
+
+ // write number of elements
+ theTarget << nbNodes;
+ theTarget << nbElements;
+ theTarget << (aMesh->HasUVNodes() ? 1 : 0);
+ // write the deflection
+ theTarget << aMesh->Deflection();
+
+ // write 3d nodes
+ Standard_Integer i;
+ for (i = 1; i <= nbNodes; i++)
+ {
+ const gp_Pnt& aNode = aMesh->Node(i);
+ theTarget << aNode.X();
+ theTarget << aNode.Y();
+ theTarget << aNode.Z();
+ }
+
+ // write 2d nodes
+ if (aMesh->HasUVNodes())
+ {
+ for (i = 1; i <= nbNodes; i++)
+ {
+ const gp_Pnt2d& aUVNode = aMesh->UVNode(i);
+ theTarget << aUVNode.X();
+ theTarget << aUVNode.Y();
+ }
+ }
+
+ // write triangles and quadrangles
+ Standard_Integer n, n1, n2, n3, n4;
+ for (i = 1; i <= nbElements; i++)
+ {
+ aMesh->Element (i, n1, n2, n3, n4);
+ n = (n4 > 0) ? 4 : 3;
+ theTarget << n;
+ theTarget << n1;
+ theTarget << n2;
+ theTarget << n3;
+ if (n4 > 0)
+ theTarget << n4;
+ }
+ }
+}
--- /dev/null
+// Created on: 2015-12-17
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinMDataXtd_SurfacicMeshDriver_HeaderFile
+#define _BinMDataXtd_SurfacicMeshDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <BinMDF_ADriver.hxx>
+#include <BinObjMgt_RRelocationTable.hxx>
+#include <BinObjMgt_SRelocationTable.hxx>
+
+class TDF_Attribute;
+class Message_Messenger;
+class BinObjMgt_Persistent;
+
+DEFINE_STANDARD_HANDLE(BinMDataXtd_SurfacicMeshDriver, BinMDF_ADriver)
+
+//! TDataXtd_SurfacicMesh attribute bin-driver.
+class BinMDataXtd_SurfacicMeshDriver : public BinMDF_ADriver
+{
+
+public:
+
+ Standard_EXPORT BinMDataXtd_SurfacicMeshDriver(const Handle(Message_Messenger)& theMessageDriver);
+
+ Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
+ BinObjMgt_Persistent& theTarget,
+ BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(BinMDataXtd_SurfacicMeshDriver, BinMDF_ADriver)
+};
+
+#endif // _BinMDataXtd_SurfacicMeshDriver_HeaderFile
Standard_Integer i;
for (i = 1; i <= nbNodes; i++)
{
- theTarget << PT->Node(i).X();
- theTarget << PT->Node(i).Y();
- theTarget << PT->Node(i).Z();
+ theTarget << PT->Node (i).X();
+ theTarget << PT->Node (i).Y();
+ theTarget << PT->Node (i).Z();
}
// write 2d nodes
{
for (i = 1; i <= nbNodes; i++)
{
- theTarget << PT->UVNode(i).X();
- theTarget << PT->UVNode(i).Y();
+ theTarget << PT->UVNode (i).X();
+ theTarget << PT->UVNode (i).Y();
}
}
// Write triangles
- const Poly_Array1OfTriangle& Triangles = PT->Triangles();
for (i = 1; i <= nbTriangles; i++)
{
- Triangles(i).Get(n1, n2, n3);
+ PT->Triangle (i).Get (n1, n2, n3);
theTarget << n1;
theTarget << n2;
theTarget << n3;
BinMDataXtd_PositionDriver.cxx
BinMDataXtd_TriangulationDriver.cxx
BinMDataXtd_TriangulationDriver.hxx
+BinMDataXtd_SurfacicMeshDriver.cxx
+BinMDataXtd_SurfacicMeshDriver.hxx
Standard_Integer aNbNodes = 0;
BinTools::GetInteger(IS, aNbNodes);
Handle(Poly_PolygonOnTriangulation) aPoly = new Poly_PolygonOnTriangulation (aNbNodes, Standard_False);
- TColStd_Array1OfInteger& aNodes = aPoly->ChangeNodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
- BinTools::GetInteger(IS, aNodes.ChangeValue (aNodeIter));
+ Standard_Integer aNode;
+ BinTools::GetInteger(IS, aNode);
+ aPoly->SetNode (aNodeIter, aNode);
}
Standard_Real aDefl = 0.0;
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());
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));
{
if (aTriangulation->HasNormals() && NeedToWriteNormals)
{
- const TShort_Array1OfShortReal& aNormals = aTriangulation->Normals();
- for (Standard_Integer aNormalIter = 1; aNormalIter <= 3 * aNbNodes; ++aNormalIter)
+ for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
{
- const Standard_ShortReal& aNormal = aNormals.Value(aNormalIter);
- BinTools::PutShortReal(OS, aNormal);
+ const gp_Dir aNormal = aTriangulation->Normal (aNormalIter);
+ BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.X());
+ BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Y());
+ BinTools::PutShortReal (OS, (Standard_ShortReal) aNormal.Z());
}
}
}
Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (aNbNodes, aNbTriangles, hasUV, hasNormals);
aTriangulation->Deflection (aDefl);
- TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
- Standard_Real* anXYZ = aNodes.ChangeValue (aNodeIter).ChangeCoord().ChangeData();
- BinTools::GetReal(IS, anXYZ[0]);
- BinTools::GetReal(IS, anXYZ[1]);
- BinTools::GetReal(IS, anXYZ[2]);
+ BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(1));
+ BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(2));
+ BinTools::GetReal(IS, aTriangulation->ChangeNode (aNodeIter).ChangeCoord().ChangeCoord(3));
}
if (hasUV)
{
- TColgp_Array1OfPnt2d& aUVNodes = aTriangulation->ChangeUVNodes();
for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
{
- gp_XY& anUV = aUVNodes.ChangeValue (aNodeIter).ChangeCoord();
- BinTools::GetReal(IS, anUV.ChangeCoord (1));
- BinTools::GetReal(IS, anUV.ChangeCoord (2));
+ BinTools::GetReal(IS, aTriangulation->ChangeUVNode (aNodeIter).ChangeCoord().ChangeCoord (1));
+ BinTools::GetReal(IS, aTriangulation->ChangeUVNode (aNodeIter).ChangeCoord().ChangeCoord (2));
}
}
// read the triangles
- Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
{
- Poly_Triangle& aTri = aTriangles.ChangeValue (aTriIter);
- BinTools::GetInteger(IS, aTri.ChangeValue (1));
- BinTools::GetInteger(IS, aTri.ChangeValue (2));
- BinTools::GetInteger(IS, aTri.ChangeValue (3));
+ BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (1));
+ BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (2));
+ BinTools::GetInteger(IS, aTriangulation->ChangeTriangle (aTriIter).ChangeValue (3));
}
if (hasNormals)
{
- TShort_Array1OfShortReal& aNormals = aTriangulation->ChangeNormals();
- for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes*3; ++aNormalIter)
+ for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)
{
- Standard_ShortReal aNormalFromFile;
- BinTools::GetShortReal(IS, aNormalFromFile);
- Standard_ShortReal& aNormalCoordinate = aNormals.ChangeValue(aNormalIter);
- aNormalCoordinate = aNormalFromFile;
+ Standard_ShortReal aNormalX, aNormalY, aNormalZ;
+ BinTools::GetShortReal(IS, aNormalX);
+ BinTools::GetShortReal(IS, aNormalY);
+ BinTools::GetShortReal(IS, aNormalZ);
+ gp_Dir aNormal(aNormalX, aNormalY, aNormalZ);
+ aTriangulation->SetNormal (aNormalIter, aNormal);
}
}
BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, PolyTr, loc);
if (!Poly.IsNull()) {
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
- const TColgp_Array1OfPnt& Nodes = PolyTr->Nodes();
for (i=Indices.Lower()+1; i<=Indices.Upper(); i++) {
- dis.Draw(Nodes(Indices(i-1)).Transformed(loc),
- Nodes(Indices(i)).Transformed(loc));
+ dis.Draw (PolyTr->Node (Indices (i-1)).Transformed (loc),
+ PolyTr->Node (Indices (i)).Transformed (loc));
if (dis.HasPicked()) {
pickshape = E->Edge();
upick = 0;
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) {
}
// 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
{
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));
}
}
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());
// LES ATTRIBUTES
#include <TDataStd.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
#include <TDataXtd_Triangulation.hxx>
#include <TDataStd_Comment.hxx>
#include <TDataStd_Name.hxx>
//purpose : DumpTriangulation (DF, entry)
//=======================================================================
-static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
- Standard_Integer nb,
- const char** arg)
+static Standard_Integer DDataStd_DumpTriangulation (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
{
if (nb == 3)
{
return 1;
}
+//=======================================================================
+//function : DDataStd_SetMesh
+//purpose : SetMesh (DF, entry, face)
+//=======================================================================
+
+static Standard_Integer DDataStd_SetMesh (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 4)
+ {
+ Handle(TDF_Data) aDF;
+ if (!DDF::GetDF (arg[1], aDF))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!DDF::AddLabel (aDF, arg[2], aLabel))
+ return 1;
+
+ // Get face.
+ TopoDS_Shape aFace = DBRep::Get (arg[3]);
+ if (aFace.IsNull() ||
+ aFace.ShapeType() != TopAbs_FACE)
+ {
+ di << "The face is null or not a face.\n";
+ return 1;
+ }
+
+ // Get triangulation of the face.
+ TopLoc_Location aLoc;
+ Handle(Poly_Triangulation) aTris = BRep_Tool::Triangulation (TopoDS::Face (aFace), aLoc);
+ if (aTris.IsNull())
+ {
+ di << "No triangulation in the face.\n";
+ return 1;
+ }
+
+ // Make a mesh.
+ Handle(Poly_Mesh) aMesh = new Poly_Mesh (aTris);
+
+ // Set the attribute.
+ TDataXtd_SurfacicMesh::Set (aLabel, aMesh);
+ return 0;
+ }
+ di << "DDataStd_SetMesh : Error\n";
+ return 1;
+}
+
+//=======================================================================
+//function : DDataStd_DumpMesh
+//purpose : DumpMesh (DF, entry)
+//=======================================================================
+
+static Standard_Integer DDataStd_DumpMesh (Draw_Interpretor& di,
+ Standard_Integer nb,
+ const char** arg)
+{
+ if (nb == 3)
+ {
+ Handle(TDF_Data) aDF;
+ if (!DDF::GetDF (arg[1], aDF))
+ return 1;
+
+ Handle(TDataXtd_SurfacicMesh) aMesh;
+ if (!DDF::Find (aDF, arg[2], TDataXtd_SurfacicMesh::GetID(), aMesh))
+ {
+ di << "The attribute mesh doesn't exist at the label.\n";
+ return 1;
+ }
+
+ // Dump of the mesh.
+ if (aMesh->Get().IsNull())
+ {
+ di << "No mesh in the attribute.\n";
+ return 1;
+ }
+
+ di << "Deflection " << aMesh->Deflection() <<"\n";
+ di << "Number of nodes " << aMesh->NbNodes() << "\n";
+ di << "Number of triangles " << aMesh->NbTriangles() << "\n";
+ di << "Number of quadrangles " << aMesh->NbQuads() << "\n";
+ if (aMesh->HasUVNodes())
+ di << "It has 2d-nodes\n";
+ if (aMesh->HasNormals())
+ di << "It has normals\n";
+
+ return 0;
+ }
+ di << "DDataStd_DumpMesh : Error\n";
+ return 1;
+}
+
//=======================================================================
//function : BasicCommands
//purpose :
"SetTriangulation (DF, entry, face) - adds label with passed entry to \
DF and put an attribute with the triangulation from passed face",
__FILE__, DDataStd_SetTriangulation, g);
+
+ theCommands.Add ("SetMesh",
+ "SetMesh (DF, entry, face) - adds label with passed entry to \
+ DF and put an attribute with the triangulation from passed face",
+ __FILE__, DDataStd_SetMesh, g);
theCommands.Add ("InsertBeforeExtStringList",
"InsertBeforeExtStringList (DF, entry, index, value )",
theCommands.Add ("DumpTriangulation",
"DumpTriangulations (DF, entry) - dumps info about triangulation that \
stored in DF in triangulation attribute of a label with the passed entry",
+ __FILE__, DDataStd_DumpTriangulation, g);
+
+ theCommands.Add ("DumpMesh",
+ "DumpMesh (DF, entry) - dumps info about mesh that stored \
+ in DF in mesh attribute of a label with the passed entry",
__FILE__, DDataStd_DumpMesh, g);
//======================================================================
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) {
// 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
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
n = myTriangulation->NbNodes();
for (i = 1; i <= n; i++) {
Sprintf(text,"%d",i);
- dis.DrawString(Nodes(i),text);
+ dis.DrawString (myTriangulation->Node (i), text);
}
}
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);
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) {
// Display the edges
Standard_Integer i,n;
if (myTriangulation->HasUVNodes()) {
-
- const TColgp_Array1OfPnt2d& Nodes = myTriangulation->UVNodes();
-
+
// free edges
dis.SetColor(Draw_rouge);
const TColStd_Array1OfInteger& Free = myFree->Array1();
n = Free.Length() / 2;
for (i = 1; i <= n; i++) {
- dis.Draw(Nodes(Free(2*i-1)),Nodes(Free(2*i)));
+ dis.Draw (myTriangulation->UVNode (Free (2*i-1)),
+ myTriangulation->UVNode (Free (2*i)));
}
// internal edges
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
n = Internal.Length() / 2;
for (i = 1; i <= n; i++) {
- dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
+ dis.Draw (myTriangulation->UVNode (Internal (2*i-1)),
+ myTriangulation->UVNode (Internal (2*i)));
}
}
TTMa[2][0] = ttma.Value(3,1);
TTMa[2][1] = ttma.Value(3,2);
TTMa[2][2] = ttma.Value(3,3);
- Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
- TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
- Standard_Integer nbN = Nod.Upper();
- Standard_Integer nbT = Tri.Upper();
+ Standard_Integer nbN = Tr->NbNodes();
+ Standard_Integer nbT = Tr->NbTriangles();
PD (f) = new HLRAlgo_PolyData();
psd->PolyData().ChangeValue(iFace) = PD(f);
PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
HLRAlgo_Array1OfTData* TData = &pid->TData();
HLRAlgo_Array1OfPISeg* PISeg = &pid->PISeg();
HLRAlgo_Array1OfPINod* PINod = &pid->PINod();
- Poly_Triangle * OT = &(Tri.ChangeValue(1));
HLRAlgo_TriangleData* NT = &TData->ChangeValue(1);
for (i = 1; i <= nbT; i++) {
- OT->Get(NT->Node1, NT->Node2, NT->Node3);
+ Tr->Triangle (i).Get (NT->Node1, NT->Node2, NT->Node3);
NT->Flags = 0;
if (reversed) {
j = NT->Node1;
NT->Node1 = NT->Node3;
NT->Node3 = j;
}
- OT++;
NT++;
}
- gp_Pnt * ON = &(Nod.ChangeValue(1));
Handle(HLRAlgo_PolyInternalNode)* NN = &PINod->ChangeValue(1);
for (i = 1; i <= nbN; i++) {
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;
aNodIndices.Flag &= ~NMsk_Norm;
Nod1RValues.Scal = 0;
}
- OUVN++;
NN++;
}
}
{
Standard_Integer aNbNodes = aPolyOnTriangulation->NbNodes();
const TColStd_Array1OfInteger& aPointIds = aPolyOnTriangulation->Nodes();
- const TColgp_Array1OfPnt& aPoints = aTriangulation->Nodes();
+
+ TColgp_Array1OfPnt aPoints(1, aTriangulation->NbNodes());
+ for (Standard_Integer anI = 1; anI <= aTriangulation->NbNodes(); anI++)
+ {
+ aPoints.SetValue (anI, aTriangulation->Node (anI));
+ }
processPolyline (aNbNodes,
aPoints,
}
// Get triangulation points.
- const TColgp_Array1OfPnt& aPoints = anOcctTriangulation->Nodes();
Standard_Integer aNbPoints = anOcctTriangulation->NbNodes();
// Keep inserted points id's of triangulation in an array.
Standard_Integer anI;
for (anI = 1; anI <= aNbPoints; anI++)
{
- gp_Pnt aPoint = aPoints (anI);
+ gp_Pnt aPoint = anOcctTriangulation->Node (anI);
if (!noTransform)
{
}
// 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);
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;
{
double aV = aVMin + iV * aDV;
gp_Pnt aP = anAdSurf.Value (aU, aV);
- aNodes.SetValue (iShift + iV, aP);
+ aTriangulation->ChangeNode (iShift + iV) = aP;
}
}
// fill triangles
- Poly_Array1OfTriangle &aTriangles = aTriangulation->ChangeTriangles();
for (int iU = 0, iShift = 1, iTri = 0; iU < aNbU; iU++, iShift += aNbV + 1)
{
for (int iV = 0; iV < aNbV; iV++)
int iBase = iShift + iV;
Poly_Triangle aTri1 (iBase, iBase + aNbV + 2, iBase + 1);
Poly_Triangle aTri2 (iBase, iBase + aNbV + 1, iBase + aNbV + 2);
- aTriangles.SetValue (++iTri, aTri1);
- aTriangles.SetValue (++iTri, aTri2);
+ aTriangulation->ChangeTriangle (++iTri) = aTri1;
+ aTriangulation->ChangeTriangle (++iTri) = aTri2;
}
}
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);
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;
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) {
// 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;
}
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;
}
}
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();
// 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);
// 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;
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());
// 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();
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));
- }
+ }
}
}
}
// 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]);
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);
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);
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));
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 << "} ";
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;
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);
break;
}
- const Poly_Array1OfTriangle& aTris = aT->Triangles();
NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
- Standard_Integer aTriNum = aTris.Length();
+ Standard_Integer aTriNum = aT->NbTriangles();
for ( Standard_Integer aTriIndx = 1; aTriIndx <= aTriNum; aTriIndx++ )
{
- const Poly_Triangle& aTri = aTris(aTriIndx);
+ const Poly_Triangle& aTri = aT->Triangle (aTriIndx);
Standard_Integer aTriNodes[3] = { aTri.Value(1), aTri.Value(2), aTri.Value(3)};
for (Standard_Integer j = 1; j <= 3; ++j)
{
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);
{
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));
Poly_CoherentTriPtr.hxx
Poly_Connect.cxx
Poly_Connect.hxx
+Poly_Element.cxx
+Poly_Element.hxx
Poly_HArray1OfTriangle.hxx
Poly_ListOfTriangulation.hxx
Poly_MakeLoops.cxx
Poly_MakeLoops.hxx
+Poly_Mesh.cxx
+Poly_Mesh.hxx
Poly_Polygon2D.cxx
Poly_Polygon2D.hxx
Poly_Polygon3D.cxx
Standard_Integer i, iNode[3];
nNodes = 0;
nTrian = 0;
- TColgp_Array1OfPnt& arrNode = aResult->ChangeNodes();
- Poly_Array1OfTriangle& arrTrian = aResult->ChangeTriangles();
for (anIter.Init(lstTri); anIter.More(); anIter.Next()) {
const Handle(Poly_Triangulation)& aTri = anIter.Value();
if (aTri.IsNull() == Standard_False) {
- const TColgp_Array1OfPnt& srcNode = aTri->Nodes();
- const Poly_Array1OfTriangle& srcTrian = aTri->Triangles();
const Standard_Integer nbNodes = aTri->NbNodes();
const Standard_Integer nbTrian = aTri->NbTriangles();
for (i = 1; i <= nbNodes; i++) {
- arrNode.SetValue(i + nNodes, srcNode(i));
+ aResult->ChangeNode (i + nNodes) = aTri->Node (i);
}
for (i = 1; i <= nbTrian; i++) {
- srcTrian(i).Get(iNode[0], iNode[1], iNode[2]);
- arrTrian.SetValue(i + nTrian, Poly_Triangle(iNode[0] + nNodes,
- iNode[1] + nNodes,
- iNode[2] + nNodes));
+ aTri->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
+ aResult->ChangeTriangle (i + nTrian) = Poly_Triangle (iNode[0] + nNodes,
+ iNode[1] + nNodes,
+ iNode[2] + nNodes);
}
nNodes += nbNodes;
nTrian += nbTrian;
if (!Compact) OS << "\n3D Nodes :\n";
Standard_Integer i, nbNodes = T->NbNodes();
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (!Compact) OS << std::setw(10) << i << " : ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(i).X() << " ";
+ OS << T->Node (i).X() << " ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(i).Y() << " ";
+ OS << T->Node (i).Y() << " ";
if (!Compact) OS << std::setw(17);
- OS << Nodes(i).Z() << "\n";
+ OS << T->Node (i).Z() << "\n";
}
if (T->HasUVNodes()) {
if (!Compact) OS << "\nUV Nodes :\n";
- const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (i = 1; i <= nbNodes; i++) {
if (!Compact) OS << std::setw(10) << i << " : ";
if (!Compact) OS << std::setw(17);
- OS << UVNodes(i).X() << " ";
+ OS << T->UVNode (i).X() << " ";
if (!Compact) OS << std::setw(17);
- OS << UVNodes(i).Y() << "\n";
+ OS << T->UVNode (i).Y() << "\n";
}
}
if (!Compact) OS << "\nTriangles :\n";
Standard_Integer nbTriangles = T->NbTriangles();
Standard_Integer n1, n2, n3;
- const Poly_Array1OfTriangle& Triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
if (!Compact) OS << std::setw(10) << i << " : ";
- Triangles(i).Get(n1, n2, n3);
+ T->Triangle (i).Get (n1, n2, n3);
if (!Compact) OS << std::setw(10);
OS << n1 << " ";
if (!Compact) OS << std::setw(10);
//=======================================================================
void Poly::ComputeNormals (const Handle(Poly_Triangulation)& theTri)
{
- const TColgp_Array1OfPnt& aNodes = theTri->Nodes();
- const Standard_Integer aNbNodes = aNodes.Size();
-
+ const Standard_Integer aNbNodes = theTri->NbNodes();
const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, aNbNodes * 3);
aNormals->Init (0.0f);
Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
Standard_Integer anElem[3] = {0, 0, 0};
const Standard_Real anEps2 = gp::Resolution();
- for (Poly_Array1OfTriangle::Iterator aTriIter (theTri->Triangles()); aTriIter.More(); aTriIter.Next())
+ for (Standard_Integer iTri = 1; iTri <= theTri->NbTriangles(); iTri++)
{
- aTriIter.Value().Get (anElem[0], anElem[1], anElem[2]);
- const gp_Pnt& aNode0 = aNodes.Value (anElem[0]);
- const gp_Pnt& aNode1 = aNodes.Value (anElem[1]);
- const gp_Pnt& aNode2 = aNodes.Value (anElem[2]);
+ theTri->Triangle (iTri).Get (anElem[0], anElem[1], anElem[2]);
+ const gp_Pnt& aNode0 = theTri->Node (anElem[0]);
+ const gp_Pnt& aNode1 = theTri->Node (anElem[1]);
+ const gp_Pnt& aNode2 = theTri->Node (anElem[2]);
const gp_XYZ aVec01 = aNode1.XYZ() - aNode0.XYZ();
const gp_XYZ aVec02 = aNode2.XYZ() - aNode0.XYZ();
: theAlloc)
{
if (theTriangulation.IsNull() == Standard_False) {
- const TColgp_Array1OfPnt& arrNodes = theTriangulation->Nodes();
- const Poly_Array1OfTriangle& arrTriangle = theTriangulation->Triangles();
const Standard_Integer nNodes = theTriangulation->NbNodes();
- const Standard_Integer nTri = theTriangulation->NbTriangles();
Standard_Integer i;
// Copy the nodes
for (i = 0; i < nNodes; i++) {
- const Standard_Integer anOldInd = i + arrNodes.Lower();
- const Standard_Integer aNewInd = SetNode(arrNodes(anOldInd).XYZ(), i);
+ const Standard_Integer anOldInd = i + 1;
+ const Standard_Integer aNewInd = SetNode (theTriangulation->Node (anOldInd).XYZ(), i);
Poly_CoherentNode& aCopiedNode = myNodes(aNewInd);
aCopiedNode.SetIndex(anOldInd);
}
// Copy the triangles
- for (i = 0; i < nTri; i++) {
+ for (i = 1; i <= theTriangulation->NbTriangles(); i++) {
Standard_Integer iNode[3];
- arrTriangle(i + arrTriangle.Lower()).Get(iNode[0], iNode[1], iNode[2]);
+ theTriangulation->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0])
AddTriangle (iNode[0]-1, iNode[1]-1, iNode[2]-1);
}
// Copy UV coordinates of nodes
if (theTriangulation->HasUVNodes()) {
- const TColgp_Array1OfPnt2d& arrNodes2d = theTriangulation->UVNodes();
for (i = 0; i < nNodes; i++) {
- const gp_Pnt2d& anUV = arrNodes2d(i + arrNodes2d.Lower());
+ const gp_Pnt2d& anUV = theTriangulation->UVNode (i + 1);
myNodes(i).SetUV(anUV.X(), anUV.Y());
}
}
// Copy the normals at nodes
if (theTriangulation->HasNormals()) {
- const TShort_Array1OfShortReal& arrNorm = theTriangulation->Normals();
for (i = 0; i < nNodes; i++) {
- const gp_XYZ aNormal (arrNorm(3 * i + 0 + arrNorm.Lower()),
- arrNorm(3 * i + 1 + arrNorm.Lower()),
- arrNorm(3 * i + 2 + arrNorm.Lower()));
+ const gp_XYZ aNormal = theTriangulation->Normal (i + 1).XYZ();
myNodes(i).SetNormal(aNormal);
}
}
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);
arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
vecNodeId.SetValue(i, ++aCount);
- arrNodes.SetValue(aCount, aNode);
+ aResult->ChangeNode (aCount) = aNode;
- arrNodesUV.SetValue(aCount, gp_Pnt2d(aNode.GetU(), aNode.GetV()));
+ aResult->ChangeUVNode (aCount) = gp_Pnt2d (aNode.GetU(), aNode.GetV());
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
Precision::Confusion())
hasUV = Standard_True;
for (; anIterT.More(); anIterT.Next()) {
const Poly_CoherentTriangle& aTri = anIterT.Value();
if (aTri.IsEmpty() == Standard_False) {
- const Poly_Triangle aPolyTriangle (vecNodeId(aTri.Node(0)),
- vecNodeId(aTri.Node(1)),
- vecNodeId(aTri.Node(2)));
- arrTriangle.SetValue(++aCount, aPolyTriangle);
+ aResult->ChangeTriangle (++aCount) = Poly_Triangle (vecNodeId (aTri.Node (0)),
+ vecNodeId (aTri.Node (1)),
+ vecNodeId (aTri.Node (2)));;
}
}
if (hasNormals)
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];
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];
}
}
// 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];
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];
// commercial license or contractual agreement.
#include <Poly_PolygonOnTriangulation.hxx>
+#include <Standard_NullObject.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation,Standard_Transient)
return aCopy;
}
+//=======================================================================
+//function : SetNode
+//purpose :
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetNode (const Standard_Integer theIndex, const Standard_Integer theNode)
+{
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myNodes.Length()),
+ "Poly_PolygonOnTriangulation::SetNode : index out of range");
+ myNodes.SetValue (theIndex, theNode);
+}
+
+//=======================================================================
+//function : Parameter
+//purpose :
+//=======================================================================
+
+Standard_Real Poly_PolygonOnTriangulation::Parameter (const Standard_Integer theIndex) const
+{
+ Standard_NullObject_Raise_if (myParameters.IsNull(),
+ "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+ "Poly_PolygonOnTriangulation::Parameter : index out of range");
+ return myParameters->Value (theIndex);
+}
+
+//=======================================================================
+//function : SetParameter
+//purpose :
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetParameter (const Standard_Integer theIndex, const Standard_Real theValue)
+{
+ Standard_NullObject_Raise_if (myParameters.IsNull(),
+ "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+ "Poly_PolygonOnTriangulation::Parameter : index out of range");
+ myParameters->SetValue (theIndex, theValue);
+}
+
//=======================================================================
//function : SetParameters
//purpose :
//! triangulation of a shape.
const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
- //! Returns the table of nodes for this polygon for modification.
- TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
+ //! Return node at the given index.
+ //! Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
+ Standard_EXPORT Standard_Integer Node(const Standard_Integer theIndex) const;
+
+ //! Sets node at the given index.
+ //! Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
+ Standard_EXPORT void SetNode(const Standard_Integer theIndex, const Standard_Integer theNode);
//! Returns true if parameters are associated with the nodes in this polygon.
Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
//! are associated with the nodes in this polygon.
const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
- //! Returns the table of the parameters associated with each node in this polygon.
- //! Warning! HasParameters() should be called beforehand to check if parameters array is allocated.
- TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
+ //! Return parameter at the given index.
+ //! Raises Standard_NullObject exception if parameters has not been initialized.
+ //! Raises Standard_OutOfRange exception if theIndex is less than ParametersLowerIndex or bigger than ParametersUpperIndex.
+ Standard_EXPORT Standard_Real Parameter(const Standard_Integer theIndex) const;
+
+ //! Sets parameter at the given index.
+ //! Raises Standard_NullObject exception if parameters has not been initialized.
+ //! Raises Standard_OutOfRange exception if theIndex is less than ParametersLowerIndex or bigger than ParametersUpperIndex.
+ Standard_EXPORT void SetParameter(const Standard_Integer theIndex, const Standard_Real theValue);
+
//! Sets the table of the parameters associated with each node in this polygon.
//! Raises exception if array size doesn't much number of polygon nodes.
//=======================================================================
Poly_Triangulation::Poly_Triangulation()
: myCachedMinMax (NULL),
- myDeflection (0)
+ myDeflection (0),
+ myHasUVNodes (Standard_False)
{
}
const Standard_Boolean theHasUVNodes)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNbNodes),
- myTriangles (1, theNbTriangles)
+ myHasUVNodes (theHasUVNodes)
{
- if (theHasUVNodes) myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
+ if (theNbNodes > 0)
+ {
+ myNodes.SetValue (theNbNodes - 1, gp_Pnt());
+ if (myHasUVNodes)
+ {
+ myUVNodes.SetValue (theNbNodes - 1, gp_Pnt2d());
+ }
+ }
+ if (theNbTriangles > 0)
+ {
+ myTriangles.SetValue (theNbTriangles - 1, Poly_Triangle());
+ }
}
//=======================================================================
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes,
const Standard_Boolean theHasNormals)
-: myDeflection(0),
- myNodes (1, theNbNodes),
- myTriangles (1, theNbTriangles)
+: Poly_Triangulation(theNbNodes, theNbTriangles, theHasUVNodes)
{
- if (theHasUVNodes)
- {
- myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
- }
if (theHasNormals)
{
- myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
+ myNormals.SetValue (theNbNodes - 1, gp_Dir());
}
}
const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNodes.Length()),
- myTriangles (1, theTriangles.Length())
+ myHasUVNodes (Standard_False)
{
- myNodes = theNodes;
- myTriangles = theTriangles;
+ for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
+ {
+ myNodes.SetValue (anIndex - 1, theNodes (anIndex));
+ }
+ for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
+ {
+ myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
+ }
}
//=======================================================================
const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNodes.Length()),
- myTriangles (1, theTriangles.Length())
+ myHasUVNodes (theNodes.Length() == theUVNodes.Length())
{
- myNodes = theNodes;
- myTriangles = theTriangles;
- myUVNodes = new TColgp_HArray1OfPnt2d (1, theNodes.Length());
- myUVNodes->ChangeArray1() = theUVNodes;
+ for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
+ {
+ myNodes.SetValue (anIndex - 1, theNodes (anIndex));
+ }
+ if (myHasUVNodes)
+ {
+ for (Standard_Integer anIndex = theUVNodes.Upper(); anIndex >= theUVNodes.Lower(); anIndex--)
+ {
+ myUVNodes.SetValue (anIndex - 1, theUVNodes (anIndex));
+ }
+ }
+ for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
+ {
+ myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
+ }
}
//=======================================================================
Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
{
- return new Poly_Triangulation (this);
+ Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (NbNodes(), NbTriangles(), HasUVNodes());
+ aCopy->myNodes = myNodes;
+ aCopy->myTriangles = myTriangles;
+ aCopy->myUVNodes = myUVNodes;
+ aCopy->myDeflection = myDeflection;
+ aCopy->myNormals = myNormals;
+ return aCopy;
}
//=======================================================================
Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation)
: myCachedMinMax(NULL),
- myDeflection(theTriangulation->myDeflection),
- myNodes(theTriangulation->Nodes()),
- myTriangles(theTriangulation->Triangles())
+ myDeflection (theTriangulation->myDeflection),
+ myHasUVNodes (theTriangulation->myHasUVNodes)
{
SetCachedMinMax (theTriangulation->CachedMinMax());
- if (theTriangulation->HasUVNodes())
- {
- myUVNodes = new TColgp_HArray1OfPnt2d(theTriangulation->myUVNodes->Array1());
- }
- if (theTriangulation->HasNormals())
+ myNodes.Assign(theTriangulation->myNodes);
+ if (myHasUVNodes)
{
- myNormals = new TShort_HArray1OfShortReal(theTriangulation->myNormals->Array1());
+ myUVNodes.Assign(theTriangulation->myUVNodes);
}
+ myTriangles.Assign(theTriangulation->myTriangles);
+ myNormals.Assign(theTriangulation->myNormals);
}
//=======================================================================
//purpose :
//=======================================================================
-void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
+void Poly_Triangulation::Deflection (const Standard_Real theDeflection)
{
myDeflection = theDeflection;
}
void Poly_Triangulation::RemoveUVNodes()
{
- myUVNodes.Nullify();
+ myUVNodes.Clear();
+ myHasUVNodes = Standard_False;
+}
+
+//=======================================================================
+//function : AddNode
+//purpose :
+//=======================================================================
+Standard_Integer Poly_Triangulation::AddNode (const gp_Pnt& theNode)
+{
+ myNodes.Append (theNode);
+
+ if (myHasUVNodes)
+ {
+ myUVNodes.Append (gp_Pnt2d());
+ }
+
+ if (!myNormals.IsEmpty())
+ {
+ Standard_Integer aNbNormals = myNodes.Size();
+ myNormals.SetValue (aNbNormals, gp_Dir());
+ }
+
+ return myNodes.Size();
}
//=======================================================================
{
throw Standard_OutOfRange ("Poly_Triangulation::Node : index out of range");
}
- return myNodes.Value (theIndex);
+ return myNodes.Value (theIndex - 1);
}
//=======================================================================
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeNode : index out of range");
}
- return myNodes.ChangeValue (theIndex);
+ return myNodes.ChangeValue (theIndex - 1);
}
//=======================================================================
const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
{
- if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
+ if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
{
throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
}
- return myUVNodes->Value (theIndex);
+ return myUVNodes.Value (theIndex - 1);
}
//=======================================================================
gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
{
- if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
+ if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
}
- return myUVNodes->ChangeValue (theIndex);
+ return myUVNodes.ChangeValue (theIndex - 1);
+}
+
+//=======================================================================
+//function : Triangle
+//purpose :
+//=======================================================================
+
+Standard_Integer Poly_Triangulation::AddTriangle (const Poly_Triangle& theTriangle)
+{
+ myTriangles.Append (theTriangle);
+ return myTriangles.Size();
}
//=======================================================================
{
throw Standard_OutOfRange ("Poly_Triangulation::Triangle : index out of range");
}
- return myTriangles.Value (theIndex);
+ return myTriangles.Value (theIndex - 1);
}
//=======================================================================
{
throw Standard_OutOfRange ("Poly_Triangulation::ChangeTriangle : index out of range");
}
- return myTriangles.ChangeValue (theIndex);
+ return myTriangles.ChangeValue (theIndex - 1);
}
//=======================================================================
throw Standard_DomainError("Poly_Triangulation::SetNormals : wrong length");
}
- myNormals = theNormals;
-}
-
-//=======================================================================
-//function : Normals
-//purpose :
-//=======================================================================
-
-const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
-{
-
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
- throw Standard_NullObject("Poly_Triangulation::Normals : "
- "wrong length or null array");
+ Standard_Integer anArrayLower = theNormals->Lower();
+ Standard_Integer anArrayInd;
+ for (Standard_Integer anIndex = NbNodes() - 1; anIndex >= 0; anIndex--)
+ {
+ anArrayInd = anArrayLower + anIndex * 3;
+ gp_Dir aNormal(theNormals->Value(anArrayInd),
+ theNormals->Value(anArrayInd),
+ theNormals->Value(anArrayInd));
+ myNormals.SetValue (anIndex, aNormal);
}
-
- return myNormals->Array1();
}
//=======================================================================
-//function : ChangeNormals
+//function : SetNormal
//purpose :
//=======================================================================
-TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
+void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
{
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
+ if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size()) {
throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
"wrong length or null array");
}
- return myNormals->ChangeArray1();
+ myNormals.ChangeValue (theIndex - 1) = theNormal;
}
//=======================================================================
Standard_Boolean Poly_Triangulation::HasNormals() const
{
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
+ if (myNormals.IsEmpty() || myNormals.Length() != NbNodes()) {
return Standard_False;
}
return Standard_True;
}
-//=======================================================================
-//function : SetNormal
-//purpose :
-//=======================================================================
-
-void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
-{
- if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
- {
- throw Standard_NullObject ("Poly_Triangulation::SetNormal : empty array or index out of range");
- }
-
- myNormals->ChangeValue (theIndex * 3 - 2) = (Standard_ShortReal) theNormal.X();
- myNormals->ChangeValue (theIndex * 3 - 1) = (Standard_ShortReal) theNormal.Y();
- myNormals->ChangeValue (theIndex * 3) = (Standard_ShortReal) theNormal.Z();
-}
-
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
-gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
+const gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
{
- if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
+ if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size())
{
throw Standard_NullObject ("Poly_Triangulation::Normal : empty array or index out of range");
}
-
- gp_Dir N(myNormals->Value(theIndex * 3 - 2),
- myNormals->Value(theIndex * 3 - 1),
- myNormals->Value(theIndex * 3));
-
- return N;
+ return myNormals (theIndex - 1);
}
// =======================================================================
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())
}
#include <Standard_Boolean.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TShort_Array1OfShortReal.hxx>
+#include <NCollection_Vector.hxx>
class Standard_DomainError;
class Standard_NullObject;
-
-class Poly_Triangulation;
-DEFINE_STANDARD_HANDLE(Poly_Triangulation, Standard_Transient)
-
-//! Provides a triangulation for a surface, a set of surfaces, or
-//! more generally a shape.
-//! A triangulation consists of an approximate representation
-//! of the actual shape, using a collection of points and
-//! triangles. The points are located on the surface. The
-//! edges of the triangles connect adjacent points with a
+//! Provides a triangulation for a surface, a set of surfaces, or more generally a shape.
+//! A triangulation consists of an approximate representation of the actual shape, using a collection of points and triangles.
+//! The points are located on the surface. The edges of the triangles connect adjacent points with a
//! straight line that approximates the true curve on the surface.
//! A triangulation comprises:
//! - A table of 3D nodes (3D points on the surface).
-//! - A table of triangles. Each triangle (Poly_Triangle
-//! object) comprises a triplet of indices in the table of 3D
-//! nodes specific to the triangulation.
-//! - A table of 2D nodes (2D points), parallel to the table of
-//! 3D nodes. This table is optional. If it exists, the
-//! coordinates of a 2D point are the (u, v) parameters
-//! of the corresponding 3D point on the surface
-//! approximated by the triangulation.
-//! - A deflection (optional), which maximizes the distance
-//! from a point on the surface to the corresponding point
-//! on its approximate triangulation.
-//! In many cases, algorithms do not need to work with the
-//! exact representation of a surface. A triangular
-//! representation induces simpler and more robust adjusting,
-//! faster performances, and the results are as good.
-//! This is a Transient class.
+//! - A table of triangles. Each triangle (Poly_Triangle object) comprises a triplet of indices in the table of 3D
+//! nodes specific to the triangulation.
+//! - A table of 2D nodes (2D points), parallel to the table of 3D nodes. This table is optional.
+//! If it exists, the coordinates of a 2D point are the (u, v) parameters of the corresponding 3D point on the surface approximated by the triangulation.
+//! - A deflection (optional), which maximizes the distance from a point on the surface to the corresponding point on its approximate triangulation.
+//! In many cases, algorithms do not need to work with the exact representation of a surface.
+//! A triangular representation induces simpler and more robust adjusting, faster performances, and the results are as good.
class Poly_Triangulation : public Standard_Transient
{
//! Returns TRUE if triangulation has some geometry.
virtual Standard_Boolean HasGeometry() const { return !myNodes.IsEmpty() && !myTriangles.IsEmpty(); }
- //! Returns the number of nodes for this triangulation.
- Standard_Integer NbNodes() const { return myNodes.Length(); }
+ //! @return the number of nodes for this triangulation.
+ Standard_Integer NbNodes() const { return myNodes.Size(); }
- //! Returns the number of triangles for this triangulation.
- Standard_Integer NbTriangles() const { return myTriangles.Length(); }
+ //! @return the number of triangles for this triangulation.
+ Standard_Integer NbTriangles() const { return myTriangles.Size(); }
- //! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
- Standard_Boolean HasUVNodes() const { return !myUVNodes.IsNull(); }
+ //! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+ Standard_Boolean HasUVNodes() const { return myHasUVNodes; }
- //! Returns the table of 3D nodes (3D points) for this triangulation.
- const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
+ //! Adds Node to the triangulation. If triangulation has UVNodes or Normals
+ //! they will be expanded and set to zero values to match the new number of nodes.
+ //! @return index of the added Node.
+ Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
- //! Returns the table of 3D nodes (3D points) for this triangulation.
- //! The returned array is
- //! shared. Therefore if the table is selected by reference, you
- //! can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
-
- //! Returns node at the given index.
+ //! @return node at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT gp_Pnt& ChangeNode (const Standard_Integer theIndex);
- //! Returns the table of 2D nodes (2D points) associated with
- //! each 3D node of this triangulation.
- //! The function HasUVNodes checks if 2D nodes
- //! are associated with the 3D nodes of this triangulation.
- //! Const reference on the 2d nodes values.
- const TColgp_Array1OfPnt2d& UVNodes() const { return myUVNodes->Array1(); }
-
- //! Returns the table of 2D nodes (2D points) associated with
- //! each 3D node of this triangulation.
- //! Function ChangeUVNodes shares the returned array.
- //! Therefore if the table is selected by reference,
- //! you can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- TColgp_Array1OfPnt2d& ChangeUVNodes() { return myUVNodes->ChangeArray1(); }
-
- //! Returns UVNode at the given index.
+ //! @return UVNode at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex);
- //! Returns the table of triangles for this triangulation.
- const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
-
- //! Returns the table of triangles for this triangulation.
- //! Function ChangeUVNodes shares the returned array.
- //! Therefore if the table is selected by reference,
- //! you can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- Poly_Array1OfTriangle& ChangeTriangles() { return myTriangles; }
+ //! Adds triangle to the triangulation.
+ //! @return index of the added triangle.
+ Standard_EXPORT virtual Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
- //! Returns triangle at the given index.
+ //! @return triangle at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
//! Sets the table of node normals.
- //! raises exception if length of theNormals != 3*NbNodes
+ //! Raises exception if length of theNormals != 3 * NbNodes
+ Standard_DEPRECATED("Deprecated method SetNormals() should be replaced \
+ by method with array as object instead of handle. \
+ Array of floats should be replaced by vector of normals")
Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
- //! Returns the table of node normals.
- Standard_EXPORT const TShort_Array1OfShortReal& Normals() const;
-
- //! Gives access to the table of node normals.
- Standard_EXPORT TShort_Array1OfShortReal& ChangeNormals();
+ //! Changes normal at the given index.
+ //! Raises Standard_OutOfRange exception.
+ Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
+ const gp_Dir& theNormal);
//! Returns Standard_True if nodal normals are defined.
Standard_EXPORT Standard_Boolean HasNormals() const;
//! @return normal at the given index.
//! Raises Standard_OutOfRange exception.
- Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
-
- //! Changes normal at the given index.
- //! Raises Standard_OutOfRange exception.
- Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
- const gp_Dir& theNormal);
+ Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
//! Returns cached min - max range of triangulation data,
//! which is VOID by default (e.g, no cached information).
protected:
- Bnd_Box* myCachedMinMax;
- Standard_Real myDeflection;
- TColgp_Array1OfPnt myNodes;
- Handle(TColgp_HArray1OfPnt2d) myUVNodes;
- Poly_Array1OfTriangle myTriangles;
- Handle(TShort_HArray1OfShortReal) myNormals;
+ Bnd_Box* myCachedMinMax;
+ Standard_Real myDeflection;
+ Standard_Boolean myHasUVNodes;
+ NCollection_Vector<gp_Pnt> myNodes;
+ NCollection_Vector<gp_Pnt2d> myUVNodes;
+ NCollection_Vector<Poly_Triangle> myTriangles;
+ NCollection_Vector<gp_Dir> myNormals;
};
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];
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;
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);
}
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;
const Standard_Integer aVertId = aU * (myStacksNb + 1) + (aV + 1);
gp_Pnt aVertex = Vertex (aParamU, aParamV).Transformed (theTrsf);
- aNodes.SetValue (aVertId, aVertex);
+ aTriangulation->ChangeNode (aVertId) = aVertex;
if (aU != 0 && aV != 0)
{
- aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1));
- aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1));
+ aTriangulation->ChangeTriangle (++anIndex) = Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1);
+ aTriangulation->ChangeTriangle (++anIndex) = Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1);
}
}
}
continue;
Poly::ComputeNormals(aT);
- const TColgp_Array1OfPnt& aVertices = aT->Nodes();
- const TShort_Array1OfShortReal& aNormals = aT->Normals();
// Number of nodes in the triangulation
- int aVertexNb = aT->Nodes().Length();
- if (aVertexNb*3 != aNormals.Length())
- {
- theDI << "Failed. Different number of normals vs. vertices\n";
- return 1;
- }
+ int aVertexNb = aT->NbNodes();
// Get each vertex index, checking common vertexes between shapes
for( int i=0; i < aVertexNb; i++ )
{
- gp_Pnt aPoint = aVertices.Value( i+1 );
- gp_Vec aNormal = gp_Vec(
- aNormals.Value( i*3 + 1 ),
- aNormals.Value( i*3 + 2 ),
- aNormals.Value( i*3 + 3 ) );
+ gp_Pnt aPoint = aT->Node ( i+1 );
+ gp_Dir aNormal = aT->Normal ( i+1 );
if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
{
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());
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());
// =======================================================================
void RWGltf_TriangulationReader::reset()
{
- myTriangulation = new Poly_Triangulation (1, 1, true);
- {
- TColgp_Array1OfPnt anEmpty;
- myTriangulation->ChangeNodes().Move (anEmpty);
- }
- {
- TColgp_Array1OfPnt2d anEmpty;
- myTriangulation->ChangeUVNodes().Move (anEmpty);
- }
- {
- Poly_Array1OfTriangle anEmpty;
- myTriangulation->ChangeTriangles().Move (anEmpty);
- }
+ myTriangulation = new Poly_Triangulation (0, 0, true);
}
// =======================================================================
{
return Handle(Poly_Triangulation)();
}
- if (myTriangulation->UVNodes().Size() != myTriangulation->NbNodes())
- {
- myTriangulation->RemoveUVNodes();
- }
-
if (myTriangulation->NbTriangles() < 1)
{
// reconstruct indexes
{
return false;
}
- myTriangulation->ChangeNodes().Resize (1, theNbNodes, false);
+ Standard_Integer i = myTriangulation->NbNodes();
+ while (++i <= theNbNodes)
+ myTriangulation->AddNode (gp::Origin());
return true;
}
{
return false;
}
- myTriangulation->ChangeUVNodes().Resize (1, theNbNodes, false);
+
+ // Resizing of the array of nodes extends the array of UV-nodes too.
return true;
}
{
if (theNbTris >= 1)
{
- myTriangulation->ChangeTriangles().Resize (1, theNbTris, false);
+ Poly_Triangle emptyTri (0, 0, 0);
+ Standard_Integer i = myTriangulation->NbTriangles();
+ while (++i <= theNbTris)
+ myTriangulation->AddTriangle (emptyTri);
return true;
}
return false;
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;
}
: myDefStyle (theStyle),
myToMapColors (theToMapColors),
mySLTool (1, 1e-12),
- myNodes (NULL),
- myNormals (NULL),
- myNodeUVs (NULL),
myHasNormals (false),
myIsMirrored (false),
myHasFaceColor (false)
gp_Dir RWMesh_FaceIterator::normal (Standard_Integer theNode)
{
gp_Dir aNormal (gp::DZ());
- if (myNormals != NULL)
+ if (myPolyTriang->HasNormals())
{
- const Standard_Integer aNodeIndex = theNode - myNodes->Lower();
- const Graphic3d_Vec3 aNormVec3 (myNormals->Value (myNormals->Lower() + aNodeIndex * 3),
- myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 1),
- myNormals->Value (myNormals->Lower() + aNodeIndex * 3 + 2));
- if (aNormVec3.Modulus() != 0.0f)
- {
- aNormal.SetCoord (aNormVec3.x(), aNormVec3.y(), aNormVec3.z());
- }
- }
+ aNormal = myPolyTriang->Normal (theNode);
+ if (aNormal.XYZ().Modulus() < Precision::Confusion())
+ aNormal = gp::DZ();
+ }
else if (myHasNormals
- && myNodeUVs != NULL)
+ && myPolyTriang->HasUVNodes())
{
- const gp_XY& anUV = myNodeUVs->Value (theNode).XY();
+ const gp_XY& anUV = myPolyTriang->UVNode (theNode).XY();
mySLTool.SetParameters (anUV.X(), anUV.Y());
if (mySLTool.IsNormalDefined())
{
myPolyTriang = BRep_Tool::Triangulation (myFace, myFaceLocation);
myTrsf = myFaceLocation.Transformation();
if (myPolyTriang.IsNull()
- || myPolyTriang->Triangles().Length() == 0)
+ || myPolyTriang->NbTriangles() == 0)
{
resetFace();
continue;
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)
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
bool HasNormals() const { return myHasNormals; }
//! Return true if triangulation has defined normals.
- bool HasTexCoords() const { return myNodeUVs != NULL; }
+ bool HasTexCoords() const { return myPolyTriang->HasUVNodes(); }
//! Return normal at specified node index with face transformation applied and face orientation applied.
gp_Dir NormalTransformed (Standard_Integer theNode)
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
//! 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:
{
myPolyTriang.Nullify();
myFace.Nullify();
- myNodes = NULL;
- myNormals = NULL;
- myNodeUVs = NULL;
myHasNormals = false;
myHasFaceColor = false;
myFaceColor = Quantity_ColorRGBA();
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
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);
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)
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);
{
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);
for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= aNbTriangles; aTriangleIdx++)
{
aPoly.Triangles (aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
- aTriangles (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
- aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
+ myTriangul->Triangle (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
+ aCenter += (myTriangul->Node (aTrNodeIdx[0]).XYZ() + myTriangul->Node (aTrNodeIdx[1]).XYZ()+ myTriangul->Node (aTrNodeIdx[2]).XYZ()) / 3.0;
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; aVertIdx++)
{
Standard_Integer aNextVert = (aVertIdx + 1) % 3;
Standard_Integer aTrNodeIdx[3];
for (Standard_Integer aTrIdx = 1; aTrIdx <= aNbTriangles; aTrIdx++)
{
- aTriangles (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
- aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
+ myTriangul->Triangle (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
+ aCenter += (myTriangul->Node (aTrNodeIdx[0]).XYZ() + myTriangul->Node (aTrNodeIdx[1]).XYZ()+ myTriangul->Node (aTrNodeIdx[2]).XYZ()) / 3.0;
}
}
if (aNbTriangles != 0)
myBndBox.Clear();
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
{
- myBndBox.Add (SelectMgr_Vec3 (aNodes (aNodeIdx).X(),
- aNodes (aNodeIdx).Y(),
- aNodes (aNodeIdx).Z()));
+ myBndBox.Add (SelectMgr_Vec3 (myTriangul->Node (aNodeIdx).X(),
+ myTriangul->Node (aNodeIdx).Y(),
+ myTriangul->Node (aNodeIdx).Z()));
}
if (theIsInterior)
{
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)
{
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())),
{
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()),
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;
}
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);
}
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);
}
}
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;
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;
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);
}
//=======================================================================
Standard_Integer Select3D_SensitiveTriangulation::NbSubElements() const
{
- return myTriangul->Nodes().Length();
+ return myTriangul->NbNodes();
}
//=======================================================================
{
aPT = new Triangulation;
aPT->myPersistent = new pTriangulation;
+
+ // Create an array of nodes.
+ Standard_Integer i;
+ TColgp_Array1OfPnt pArrayOfNodes (1, thePolyTriang->NbNodes());
+ for (i = 1; i <= thePolyTriang->NbNodes(); i++)
+ pArrayOfNodes.SetValue (i, thePolyTriang->Node (i));
+
+ // Create an array of triangles.
+ Poly_Array1OfTriangle pArrayOfTriangles (1, thePolyTriang->NbTriangles());
+ for (i = 1; i <= thePolyTriang->NbTriangles(); i++)
+ pArrayOfTriangles.SetValue (i, thePolyTriang->Triangle (i));
+
aPT->myPersistent->myNodes =
- StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePolyTriang->Nodes());
+ StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", pArrayOfNodes);
aPT->myPersistent->myTriangles =
- StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", thePolyTriang->Triangles());
+ StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", pArrayOfTriangles);
if (thePolyTriang->HasUVNodes()) {
+
+ // Create an array of UV-nodes.
+ TColgp_Array1OfPnt2d pArrayOfUVNodes (1, thePolyTriang->NbNodes());
+ for (i = 1; i <= thePolyTriang->NbNodes(); i++)
+ pArrayOfUVNodes.SetValue (i, thePolyTriang->UVNode (i));
+
aPT->myPersistent->myUVNodes =
- StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePolyTriang->UVNodes());
+ StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", pArrayOfUVNodes);
}
theMap.Bind(thePolyTriang, aPT);
}
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;
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;
// Determinant of transform matrix less then 0 means that mirror transform applied.
Standard_Boolean isMirrored = aTrsf.VectorialPart().Determinant() < 0;
+ Poly_Connect aPolyConnect (aT);
// Extracts vertices & normals from nodes
- const TColgp_Array1OfPnt& aNodes = aT->Nodes();
- const TColgp_Array1OfPnt2d* aUVNodes = theHasTexels && aT->HasUVNodes() && aT->UVNodes().Upper() == aNodes.Upper()
- ? &aT->UVNodes()
- : NULL;
- StdPrs_ToolTriangulatedShape::ComputeNormals (aFace, aT);
- const TShort_Array1OfShortReal& aNormals = aT->Normals();
- const Standard_ShortReal* aNormArr = &aNormals.First();
+ TColgp_Array1OfDir aNormals (1, aT->NbNodes());
+ StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
if (theHasTexels)
{
}
const Standard_Integer aDecal = anArray->VertexNumber();
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aT->NbNodes(); ++aNodeIter)
{
- aPoint = aNodes (aNodeIter);
- const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
- gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
+ aPoint = aT->Node (aNodeIter);
+ gp_Dir aNorm = aNormals (aNodeIter);
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aNorm.Reverse();
aNorm.Transform (aTrsf);
}
- if (aUVNodes != NULL)
+ if (theHasTexels && aT->HasUVNodes())
{
const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0)
- ? aUVNodes->Value (aNodeIter)
- : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes->Value (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
- (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes->Value (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
+ ? aT->UVNode (aNodeIter)
+ : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aT->UVNode (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
+ (-theUVOrigin.Y() + (theUVRepeat.Y() * (aT->UVNode (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
anArray->AddVertex (aPoint, aNorm, aTexel);
}
else
}
// Fill array with vertex and edge visibility info
- const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if ((aFace.Orientation() == TopAbs_REVERSED))
{
- aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
+ aT->Triangle (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}
else
{
- aTriangles (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
+ aT->Triangle (aTriIter).Get (anIndex[0], anIndex[1], anIndex[2]);
}
- gp_Pnt aP1 = aNodes (anIndex[0]);
- gp_Pnt aP2 = aNodes (anIndex[1]);
- gp_Pnt aP3 = aNodes (anIndex[2]);
+ gp_Pnt aP1 = aT->Node (anIndex[0]);
+ gp_Pnt aP2 = aT->Node (anIndex[1]);
+ gp_Pnt aP3 = aT->Node (anIndex[2]);
gp_Vec aV1 (aP1, aP2);
if (aV1.SquareMagnitude() <= aPreci)
}
// get edge nodes indexes from face triangulation
- const TColgp_Array1OfPnt& aTriNodes = aTriangulation->Nodes();
const TColStd_Array1OfInteger& anEdgeNodes = anEdgePoly->Nodes();
// collect the edge nodes
// 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);
// 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
const Standard_Real aTol = Precision::Confusion();
Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, theTris->NbNodes() * 3);
- const TColgp_Array1OfPnt2d& aNodesUV = theTris->UVNodes();
Standard_Integer aTri[3];
- const TColgp_Array1OfPnt& aNodes = theTris->Nodes();
gp_Dir aNorm;
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= theTris->NbNodes(); ++aNodeIter)
{
// try to retrieve normal from real surface first, when UV coordinates are available
- if (GeomLib::NormEstim (aSurf, aNodesUV.Value (aNodeIter), aTol, aNorm) > 1)
+ if (GeomLib::NormEstim (aSurf, theTris->UVNode (aNodeIter), aTol, aNorm) > 1)
{
if (thePolyConnect.Triangulation() != theTris)
{
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)
aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
}
- const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 3;
+ const Standard_Integer anId = (aNodeIter - 1) * 3;
aNormals->SetValue (anId + 1, (Standard_ShortReal )aNorm.X());
aNormals->SetValue (anId + 2, (Standard_ShortReal )aNorm.Y());
aNormals->SetValue (anId + 3, (Standard_ShortReal )aNorm.Z());
ComputeNormals (theFace, aPolyTri, thePolyConnect);
}
- const TColgp_Array1OfPnt& aNodes = aPolyTri->Nodes();
- const TShort_Array1OfShortReal& aNormals = aPolyTri->Normals();
- const Standard_ShortReal* aNormArr = &aNormals.First();
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
- const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
- const gp_Dir aNorm (aNormArr[anId + 0],
- aNormArr[anId + 1],
- aNormArr[anId + 2]);
- theNormals (aNodeIter) = aNorm;
+ theNormals.ChangeValue (aNodeIter) = aPolyTri->Normal (aNodeIter);
}
if (theFace.Orientation() == TopAbs_REVERSED)
{
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
theNormals.ChangeValue (aNodeIter).Reverse();
}
{
// 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));
}
}
}
if (!anHIndices.IsNull())
{
const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
- const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
{
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;
BRep_Builder BuildTool;
BuildTool.MakeCompound (aComp);
- const TColgp_Array1OfPnt& aNodes = aMesh->Nodes();
- const Poly_Array1OfTriangle& aTriangles = aMesh->Triangles();
- for (Standard_Integer aTriIdx = aTriangles.Lower();
- aTriIdx <= aTriangles.Upper();
+ for (Standard_Integer aTriIdx = 1;
+ aTriIdx <= aMesh->NbTriangles();
++aTriIdx)
{
- const Poly_Triangle& aTriangle = aTriangles(aTriIdx);
+ const Poly_Triangle& aTriangle = aMesh->Triangle (aTriIdx);
Standard_Integer anId[3];
aTriangle.Get(anId[0], anId[1], anId[2]);
- const gp_Pnt& aPnt1 = aNodes (anId[0]);
- const gp_Pnt& aPnt2 = aNodes (anId[1]);
- const gp_Pnt& aPnt3 = aNodes (anId[2]);
+ const gp_Pnt& aPnt1 = aMesh->Node (anId[0]);
+ const gp_Pnt& aPnt2 = aMesh->Node (anId[1]);
+ const gp_Pnt& aPnt3 = aMesh->Node (anId[2]);
if ((!(aPnt1.IsEqual (aPnt2, 0.0)))
&& (!(aPnt1.IsEqual (aPnt3, 0.0))))
{
continue;
}
- const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
- const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
-
// copy nodes
gp_Trsf aTrsf = aLoc.Transformation();
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
{
- gp_Pnt aPnt = aNodes (aNodeIter);
+ gp_Pnt aPnt = aTriangulation->Node (aNodeIter);
aPnt.Transform (aTrsf);
aMesh->ChangeNode (aNodeIter + aNodeOffset) = aPnt;
}
// copy triangles
const TopAbs_Orientation anOrientation = anExpSF.Current().Orientation();
- for (Standard_Integer aTriIter = aTriangles.Lower(); aTriIter <= aTriangles.Upper(); ++aTriIter)
+ for (Standard_Integer aTriIter = 1; aTriIter <= aTriangulation->NbTriangles(); ++aTriIter)
{
- Poly_Triangle aTri = aTriangles (aTriIter);
+ Poly_Triangle aTri = aTriangulation->Triangle (aTriIter);
Standard_Integer anId[3];
aTri.Get (anId[0], anId[1], anId[2]);
aMesh->ChangeTriangle (aTriIter + aTriangleOffet) = aTri;
}
- aNodeOffset += aNodes.Size();
- aTriangleOffet += aTriangles.Size();
+ aNodeOffset += aTriangulation->NbNodes();
+ aTriangleOffet += aTriangulation->NbTriangles();
}
OSD_Path aPath (theFileName);
TDataXtd_Shape.hxx
TDataXtd_Triangulation.cxx
TDataXtd_Triangulation.hxx
+TDataXtd_SurfacicMesh.cxx
+TDataXtd_SurfacicMesh.hxx
#include <TDataXtd_Point.hxx>
#include <TDataXtd_Position.hxx>
#include <TDataXtd_Shape.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
#include <TDF_IDList.hxx>
//=======================================================================
//=======================================================================
void TDataXtd::IDList(TDF_IDList& anIDList)
{
- anIDList.Append(TDataXtd_Axis::GetID());
- anIDList.Append(TDataXtd_Constraint::GetID());
- anIDList.Append(TDataXtd_Geometry::GetID());
- anIDList.Append(TDataXtd_PatternStd::GetID());
- anIDList.Append(TDataXtd_Placement::GetID());
- anIDList.Append(TDataXtd_Point::GetID());
- anIDList.Append(TDataXtd_Plane::GetID());
- anIDList.Append(TDataXtd_Position::GetID());
- anIDList.Append(TDataXtd_Shape::GetID());
-
+ anIDList.Append (TDataXtd_Axis::GetID());
+ anIDList.Append (TDataXtd_Constraint::GetID());
+ anIDList.Append (TDataXtd_Geometry::GetID());
+ anIDList.Append (TDataXtd_PatternStd::GetID());
+ anIDList.Append (TDataXtd_Placement::GetID());
+ anIDList.Append (TDataXtd_Point::GetID());
+ anIDList.Append (TDataXtd_Plane::GetID());
+ anIDList.Append (TDataXtd_Position::GetID());
+ anIDList.Append (TDataXtd_Shape::GetID());
+ anIDList.Append (TDataXtd_SurfacicMesh::GetID());
}
//=======================================================================
--- /dev/null
+// Created on: 2015-12-10
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <Standard_GUID.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_RelocationTable.hxx>
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& TDataXtd_SurfacicMesh::GetID()
+{
+ static Standard_GUID TDataXtd_SurfacicMeshID ("D7E3F1CF-38A4-4DCA-94F4-51C31F3FCBA5");
+ return TDataXtd_SurfacicMeshID;
+}
+
+//=======================================================================
+//function : SetAttr
+//purpose :
+//=======================================================================
+static Handle(TDataXtd_SurfacicMesh) SetAttr (const TDF_Label& theLabel,
+ const Standard_GUID& theID)
+{
+ Handle(TDataXtd_SurfacicMesh) hMesh;
+ if (!theLabel.FindAttribute (theID, hMesh)) {
+ hMesh = new TDataXtd_SurfacicMesh();
+ hMesh->SetID (theID);
+ theLabel.AddAttribute (hMesh);
+ }
+ return hMesh;
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel)
+{
+ return SetAttr (theLabel, GetID());
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+ const Standard_GUID& theID)
+{
+ return SetAttr (theLabel, theID);
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+ const Handle(Poly_Mesh)& theMesh)
+{
+ Handle(TDataXtd_SurfacicMesh) hMesh = Set (theLabel);
+ hMesh->Set (theMesh);
+ return hMesh;
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(TDataXtd_SurfacicMesh) TDataXtd_SurfacicMesh::Set (const TDF_Label& theLabel,
+ const Standard_GUID& theID,
+ const Handle(Poly_Mesh)& theMesh)
+{
+ Handle(TDataXtd_SurfacicMesh) hMesh = Set (theLabel, theID);
+ hMesh->Set (theMesh);
+ return hMesh;
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose :
+//=======================================================================
+TDataXtd_SurfacicMesh::TDataXtd_SurfacicMesh():myID (GetID())
+{
+
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::Set (const Handle(Poly_Mesh)& theMesh)
+{
+ Backup();
+ myMesh = theMesh;
+}
+
+//=======================================================================
+//function : TDataXtd_SurfacicMesh
+//purpose :
+//=======================================================================
+const Handle(Poly_Mesh)& TDataXtd_SurfacicMesh::Get() const
+{
+ return myMesh;
+}
+
+// Poly_Mesh methods
+
+//=======================================================================
+//function : Deflection
+//purpose :
+//=======================================================================
+Standard_Real TDataXtd_SurfacicMesh::Deflection() const
+{
+ return myMesh->Deflection();
+}
+
+//=======================================================================
+//function : Deflection
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::Deflection (const Standard_Real theDeflection)
+{
+ Backup();
+ myMesh->Deflection (theDeflection);
+}
+
+//=======================================================================
+//function : RemoveUVNodes
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::RemoveUVNodes()
+{
+ Backup();
+ myMesh->RemoveUVNodes();
+}
+
+//=======================================================================
+//function : NbNodes
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbNodes() const
+{
+ return myMesh->NbNodes();
+}
+
+//=======================================================================
+//function : NbTriangles
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbTriangles() const
+{
+ return myMesh->NbTriangles();
+}
+
+//=======================================================================
+//function : HasUVNodes
+//purpose :
+//=======================================================================
+Standard_Boolean TDataXtd_SurfacicMesh::HasUVNodes() const
+{
+ return myMesh->HasUVNodes();
+}
+
+//=======================================================================
+//function : AddNode
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddNode (const gp_Pnt& theNode)
+{
+ Backup();
+ return myMesh->AddNode (theNode);
+}
+
+//=======================================================================
+//function : Node
+//purpose :
+//=======================================================================
+const gp_Pnt& TDataXtd_SurfacicMesh::Node (const Standard_Integer theIndex) const
+{
+ return myMesh->Node (theIndex);
+}
+
+//=======================================================================
+//function : SetNode
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode)
+{
+ Backup();
+ myMesh->ChangeNode (theIndex) = theNode;
+}
+
+//=======================================================================
+//function : UVNode
+//purpose :
+//=======================================================================
+const gp_Pnt2d& TDataXtd_SurfacicMesh::UVNode (const Standard_Integer theIndex) const
+{
+ return myMesh->UVNode (theIndex);
+}
+
+//=======================================================================
+//function : SetUVNode
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode)
+{
+ Backup();
+ myMesh->ChangeUVNode (theIndex) = theUVNode;
+}
+
+//=======================================================================
+//function : AddTriangle
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddTriangle (const Poly_Triangle& theTriangle)
+{
+ Backup();
+ return myMesh->AddTriangle (theTriangle);
+}
+
+//=======================================================================
+//function : Triangle
+//purpose :
+//=======================================================================
+const Poly_Triangle& TDataXtd_SurfacicMesh::Triangle (const Standard_Integer theIndex) const
+{
+ return myMesh->Triangle (theIndex);
+}
+
+//=======================================================================
+//function : SetTriangle
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle)
+{
+ Backup();
+ myMesh->ChangeTriangle (theIndex) = theTriangle;
+}
+
+//=======================================================================
+//function : SetNormal
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetNormal (const Standard_Integer theIndex,
+ const gp_Dir& theNormal)
+{
+ Backup();
+ myMesh->SetNormal (theIndex, theNormal);
+}
+
+//=======================================================================
+//function : HasNormals
+//purpose :
+//=======================================================================
+Standard_Boolean TDataXtd_SurfacicMesh::HasNormals() const
+{
+ return myMesh->HasNormals();
+}
+
+//=======================================================================
+//function : Normal
+//purpose :
+//=======================================================================
+const gp_Dir TDataXtd_SurfacicMesh::Normal (const Standard_Integer theIndex) const
+{
+ return myMesh->Normal (theIndex);
+}
+
+//=======================================================================
+//function : AddElement
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
+ const Standard_Integer theN2,
+ const Standard_Integer theN3)
+{
+ Backup();
+ return myMesh->AddElement (theN1, theN2, theN3);
+}
+
+//=======================================================================
+//function : AddElement
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::AddElement (const Standard_Integer theN1,
+ const Standard_Integer theN2,
+ const Standard_Integer theN3,
+ const Standard_Integer theN4)
+{
+ Backup();
+ return myMesh->AddElement (theN1, theN2, theN3, theN4);
+}
+
+//=======================================================================
+//function : NbElements
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbElements() const
+{
+ return myMesh->NbElements();
+}
+
+//=======================================================================
+//function : NbQuads
+//purpose :
+//=======================================================================
+Standard_Integer TDataXtd_SurfacicMesh::NbQuads() const
+{
+ return myMesh->NbQuads();
+}
+
+//=======================================================================
+//function : Element
+//purpose :
+//=======================================================================
+const Poly_Element& TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex) const
+{
+ return myMesh->Element (theIndex);
+}
+
+//=======================================================================
+//function : Element
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::Element (const Standard_Integer theIndex,
+ Standard_Integer& theN1,
+ Standard_Integer& theN2,
+ Standard_Integer& theN3,
+ Standard_Integer& theN4) const
+{
+ myMesh->Element (theIndex, theN1, theN2, theN3, theN4);
+}
+
+//=======================================================================
+//function : SetElement
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
+{
+ Backup();
+ myMesh->SetElement (theIndex, theElement);
+}
+
+//=======================================================================
+//function : SetID
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetID (const Standard_GUID& theID)
+{
+ if (myID != theID) {
+ Backup();
+ myID = theID;
+ }
+}
+
+//=======================================================================
+//function : SetID
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::SetID()
+{
+ Backup();
+ myID = GetID();
+}
+
+//=======================================================================
+//function : ID
+//purpose :
+//=======================================================================
+const Standard_GUID& TDataXtd_SurfacicMesh::ID () const
+{
+ return myID;
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) TDataXtd_SurfacicMesh::NewEmpty () const
+{
+ return new TDataXtd_SurfacicMesh();
+}
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::Restore (const Handle(TDF_Attribute)& theWithMesh)
+{
+ myMesh.Nullify();
+ Handle(TDataXtd_SurfacicMesh) withMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theWithMesh);
+ if (!withMesh->myMesh.IsNull()) {
+ Handle(Poly_Triangulation) withTris = withMesh->myMesh->Copy();
+ if (!withTris.IsNull())
+ myMesh = Handle(Poly_Mesh)::DownCast (withTris);
+ }
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::Paste (const Handle(TDF_Attribute)& theIntoMesh,
+ const Handle(TDF_RelocationTable)& ) const
+{
+ Handle(TDataXtd_SurfacicMesh) intoMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theIntoMesh);
+ intoMesh->myMesh.Nullify();
+ if (!myMesh.IsNull()) {
+ Handle(Poly_Triangulation) aTris = myMesh->Copy();
+ if (!aTris.IsNull())
+ intoMesh->myMesh = Handle(Poly_Mesh)::DownCast (aTris);
+ }
+}
+
+//=======================================================================
+//function : Dump
+//purpose :
+//=======================================================================
+Standard_OStream& TDataXtd_SurfacicMesh::Dump (Standard_OStream& theOS) const
+{
+ theOS << "Mesh: ";
+
+ Standard_Character aStrID[Standard_GUID_SIZE_ALLOC];
+ myID.ToCString (aStrID);
+ theOS << aStrID;
+
+ if (!myMesh.IsNull()) {
+ theOS << "\n\tDeflection: " << myMesh->Deflection();
+ theOS << "\n\tNodes: " << myMesh->NbNodes();
+ theOS << "\n\tTriangles: " << myMesh->NbTriangles();
+ if (myMesh->HasUVNodes())
+ theOS << "\n\tHas UV-Nodes";
+ else
+ theOS << "\n\tNo UV-Nodes";
+ if (myMesh->HasNormals())
+ theOS << "\n\tHas normals";
+ else
+ theOS << "\n\tNo normals";
+ }
+
+ theOS << "\nAttribute fields: ";
+ TDF_Attribute::Dump (theOS);
+ return theOS;
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void TDataXtd_SurfacicMesh::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
+ OCCT_DUMP_BASE_CLASS(theOStream, theDepth, TDF_Attribute)
+ if (!myMesh.IsNull())
+ myMesh->DumpJson (theOStream, theDepth);
+}
--- /dev/null
+// Created on: 2015-12-10
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _TDataXtd_SurfacicMesh_HeaderFile
+#define _TDataXtd_SurfacicMesh_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <Poly_Mesh.hxx>
+#include <TDF_Attribute.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard_Integer.hxx>
+#include <Standard_OStream.hxx>
+#include <Standard_GUID.hxx>
+
+class TDF_Label;
+class TDF_RelocationTable;
+
+class TDataXtd_SurfacicMesh;
+DEFINE_STANDARD_HANDLE(TDataXtd_SurfacicMesh, TDF_Attribute)
+
+//! An Ocaf attribute containing a mesh (Poly_Mesh).
+//! It duplicates all methods from Poly_Mesh (and Poly_Triangulation).
+//! It is highly recommended to modify the mesh through the methods of this attribute,
+//! but not directly via the underlying Poly_Mesh object.
+//! In this case Undo/Redo will work fine and robust.
+class TDataXtd_SurfacicMesh : public TDF_Attribute
+{
+public:
+
+ //! Static methods
+ // ==============
+
+ //! Returns the ID of the mesh attribute.
+ Standard_EXPORT static const Standard_GUID& GetID();
+
+ //! Finds or creates a mesh attribute.
+ Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel);
+
+ //! Finds or creates a mesh attribute with specified ID.
+ //! It allows setting several mesh-attributes at the same label.
+ Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+ const Standard_GUID& theID);
+
+ //! Finds or creates a mesh attribute.
+ //! Initializes the attribute by a mesh (Poly_Mesh) object.
+ //! If the mesh consists of only triangles,
+ //! you may put Poly_Triangulation object as a 2nd parameter of this method.
+ Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+ const Handle(Poly_Mesh)& theMesh);
+
+ //! Finds or creates a mesh attribute (the same method as above).
+ //! Additionally, it allows setting several mesh-attributes at the same label.
+ Standard_EXPORT static Handle(TDataXtd_SurfacicMesh) Set (const TDF_Label& theLabel,
+ const Standard_GUID& theID,
+ const Handle(Poly_Mesh)& theMesh);
+
+ //! Object methods
+ // ==============
+
+ //! A constructor.
+ //! Don't use it directly,
+ //! use please the static method Set(),
+ //! which returns the attribute attached to a label.
+ Standard_EXPORT TDataXtd_SurfacicMesh();
+
+ //! Sets the explicit ID (user defined) for the attribute.
+ Standard_EXPORT void SetID (const Standard_GUID& theID) Standard_OVERRIDE;
+
+ //! Sets default ID for the attribute.
+ Standard_EXPORT void SetID() Standard_OVERRIDE;
+
+ //! Sets the mesh.
+ //! If the mesh consists of only triangles,
+ //! you may put Poly_Triangulation object.
+ Standard_EXPORT void Set (const Handle(Poly_Mesh)& theMesh);
+
+ //! Returns the underlying mesh.
+ Standard_EXPORT const Handle(Poly_Mesh)& Get() const;
+
+
+ //! Poly_Mesh methods
+ // =================
+
+ //! The methods are "covered" by this attribute to prevent direct modification of the mesh.
+ //! There is no performance problem to call Poly_Mesh method through this attribute.
+ //! The most of the methods are considered as "inline" by the compiler in release mode.
+
+ //! Returns the deflection of this triangulation.
+ Standard_EXPORT Standard_Real Deflection() const;
+
+ //! Sets the deflection of this triangulation to theDeflection.
+ //! See more on deflection in Polygon2D
+ Standard_EXPORT void Deflection (const Standard_Real theDeflection);
+
+ //! Deallocates the UV nodes.
+ Standard_EXPORT void RemoveUVNodes();
+
+ //! @return the number of nodes for this triangulation.
+ Standard_EXPORT Standard_Integer NbNodes() const;
+
+ //! @return the number of triangles for this triangulation.
+ Standard_EXPORT Standard_Integer NbTriangles() const;
+
+ //! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+ Standard_EXPORT Standard_Boolean HasUVNodes() const;
+
+ //! Adds Node to the triangulation. If triangulation has UVNodes or Normals
+ //! they will be expanded and set to zero values to match the new number of nodes.
+ //! @return index of the added Node.
+ Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
+
+ //! @return node at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+ Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
+
+ //! The method differs from Poly_Mesh!
+ //! Sets a node at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+ Standard_EXPORT void SetNode (const Standard_Integer theIndex, const gp_Pnt& theNode);
+
+ //! @return UVNode at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+ Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
+
+ //! The method differs from Poly_Mesh!
+ //! Sets a UVNode at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
+ Standard_EXPORT void SetUVNode (const Standard_Integer theIndex, const gp_Pnt2d& theUVNode);
+
+ //! Adds triangle to the triangulation.
+ //! @return index of the added triangle.
+ Standard_EXPORT Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
+
+ //! @return triangle at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
+ Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
+
+ //! The method differs from Poly_Mesh!
+ //! Sets a triangle at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
+ Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
+
+ //! Changes normal at the given index.
+ //! Raises Standard_OutOfRange exception.
+ Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
+ const gp_Dir& theNormal);
+
+ //! Returns Standard_True if nodal normals are defined.
+ Standard_EXPORT Standard_Boolean HasNormals() const;
+
+ //! @return normal at the given index.
+ //! Raises Standard_OutOfRange exception.
+ Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
+
+ //! Adds element to the mesh.
+ //! @param theN1 index of the first node.
+ //! @param theN2 index of the second node.
+ //! @param theN3 index of the third node.
+ //! @return index of the added element.
+ Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
+ const Standard_Integer theN2,
+ const Standard_Integer theN3);
+
+ //! Adds element to the mesh.
+ //! @param theN1 index of the first node.
+ //! @param theN2 index of the second node.
+ //! @param theN3 index of the third node.
+ //! @param theN4 index of the fourth node.
+ //! @return index of the added element.
+ Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
+ const Standard_Integer theN2,
+ const Standard_Integer theN3,
+ const Standard_Integer theN4);
+
+ //! @return the number of elements for this mesh.
+ Standard_EXPORT Standard_Integer NbElements() const;
+
+ //! @return the number of quads for this mesh.
+ Standard_EXPORT Standard_Integer NbQuads() const;
+
+ //! @return element at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
+ Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const;
+
+ //! @return nodes of the element at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
+ Standard_EXPORT void Element (const Standard_Integer theIndex,
+ Standard_Integer& theN1,
+ Standard_Integer& theN2,
+ Standard_Integer& theN3,
+ Standard_Integer& theN4) const;
+
+ //! Sets an element at the given index.
+ //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
+ Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement);
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+
+ //! Inherited attribute methods
+ // ===========================
+
+ Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Restore (const Handle(TDF_Attribute)& theWithMesh) Standard_OVERRIDE;
+
+ Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theIntoMesh, const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& theOS) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTI_INLINE(TDataXtd_SurfacicMesh,TDF_Attribute)
+
+private:
+
+ Handle(Poly_Mesh) myMesh;
+ Standard_GUID myID;
+};
+
+#endif // _TDataXtd_SurfacicMesh_HeaderFile
}
Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
- TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
- Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
if ( mStartPhi <= 0.0 ){
x[0] = mCenter[0];
x[1] = mCenter[1];
x[2] = mCenter[2] + mRadius;
- PointsOfArray.SetValue(1,gp_Pnt(x[0],x[1],x[2]));
+ polyTriangulation->ChangeNode (1) = gp_Pnt (x[0],x[1],x[2]);
}
// Create south pole if needed
x[0] = mCenter[0];
x[1] = mCenter[1];
x[2] = mCenter[2] - mRadius;
- PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
+ polyTriangulation->ChangeNode (2) = gp_Pnt (x[0],x[1],x[2]);
}
number_point = 3;
x[0] = n[0] + mCenter[0];
x[1] = n[1] + mCenter[1];
x[2] = n[2] + mCenter[2];
- PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
+ polyTriangulation->ChangeNode (number_point) = gp_Pnt (x[0],x[1],x[2]);
number_point++;
}
}
pts[0] = phiResolution*i + numPoles;
pts[1] = (phiResolution*(i+1) % base) + numPoles;
pts[2] = 1;
- pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+ polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
number_triangle++;
}
}
pts[0] = phiResolution*i + numOffset;
pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
pts[1] = numPoles - 1;
- pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+ polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
number_triangle++;
}
}
pts[0] = phiResolution*i + j + numPoles;
pts[1] = pts[0] + 1;
pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
- pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+ polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
number_triangle++;
pts[1] = pts[2];
pts[2] = pts[1] - 1;
- pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
+ polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle (pts[0],pts[1],pts[2]);
number_triangle++;
}
}
Standard_Real Tol = Precision::Confusion();
gp_Dir Nor;
- for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
+ for (i = 1; i <= polyTriangulation->NbNodes(); i++) {
gp_XYZ eqPlan(0, 0, 0);
for ( pc->Initialize(i); pc->More(); pc->Next()) {
- pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
- gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
- gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
+ polyTriangulation->Triangle (pc->Value()).Get (index[0], index[1], index[2]);
+ gp_XYZ v1 (polyTriangulation->Node (index[1]).Coord() - polyTriangulation->Node (index[0]).Coord());
+ gp_XYZ v2 (polyTriangulation->Node (index[2]).Coord() - polyTriangulation->Node (index[1]).Coord());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
Nor = gp_Dir(eqPlan);
else
Nor = gp_Dir(0., 0., 1.);
-
- Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
- Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
- Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
- Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
+
+ Standard_Integer j = (i - 1) * 3;
+ Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
+ Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
+ Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
}
delete pc;
= new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
aResolution,
aRadius));
- Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
- Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
+ Standard_Integer aNumberPoints = aShape->GetTriangulation()->NbNodes();
+ Standard_Integer aNumberTriangles = aShape->GetTriangulation()->NbTriangles();
// stupid initialization of Green color in RGBA space as integer
// probably wrong for big-endian CPUs
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);
// 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)
// 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);
// 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);
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) {
}
}
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);
Handle(Poly_Triangulation) aTriangulation =
new Poly_Triangulation(aNodes.Length(), aTriangles.Extent(), Standard_False);
// Copy the triangulation vertices
- TColgp_Array1OfPnt& aTNodes = aTriangulation->ChangeNodes();
for (i = 0; i < aNodes.Length(); i++)
{
- aTNodes.SetValue(i + 1, gp_Pnt(aNodes(i)));
+ aTriangulation->ChangeNode (i + 1) = gp_Pnt (aNodes (i));
}
// Copy the triangles.
- Poly_Array1OfTriangle& aTTriangles = aTriangulation->ChangeTriangles();
NCollection_List<Poly_Triangle>::Iterator itT(aTriangles);
for (i = 1; itT.More(); itT.Next(), i++)
{
- aTTriangles.SetValue(i, itT.Value());
+ aTriangulation->ChangeTriangle (i) = itT.Value();
}
Handle(BRep_TFace) aFace = new BRep_TFace();
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);
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);
if(theTri->HasNormals()) {
gp_XYZ * arrVec = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
- const TShort_Array1OfShortReal& Norm = theTri->Normals();
Standard_Integer j;
for (i = 0, j = 1; i < nNodes; i++, j += 3)
{
- gp_XYZ aNormal(Norm(j), Norm(j+1), Norm(j+2));
+ gp_XYZ aNormal = theTri->Normal (i + 1).XYZ();
if (isReverse)
{
aNormal.Reverse();
Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, nbNormVal);
- const TColgp_Array1OfPnt2d& arrUV = theTri->UVNodes();
gp_XYZ * arrVec = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
// Compute the normal vectors
Standard_Real Tol = Sqrt(aConf2);
for (i = 0; i < nNodes; i++) {
- const gp_Pnt2d& aUV = arrUV(i+1);
+ const gp_Pnt2d& aUV = theTri->UVNode (i+1);
gp_Dir aNormal;
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();
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;
}
// Hide all nodes by default
Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
- Standard_Integer aLen = aSTLMesh->Nodes().Length();
+ Standard_Integer aLen = aSTLMesh->NbNodes();
for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
aNodes->ChangeMap().Add( anIndex );
aMesh->SetHiddenNodes( aNodes );
if( !myMesh.IsNull() )
{
- const TColgp_Array1OfPnt& aCoords = myMesh->Nodes();
- Standard_Integer len = aCoords.Length(), i, j;
+ Standard_Integer len = myMesh->NbNodes(), i, j;
myNodeCoords = new TColStd_HArray2OfReal(1, len, 1, 3);
std::cout << "Nodes : " << len << std::endl;
for( i = 1; i <= len; i++ )
{
myNodes.Add( i );
- xyz = aCoords(i).XYZ();
+ xyz = myMesh->Node (i).XYZ();
myNodeCoords->SetValue(i, 1, xyz.X());
myNodeCoords->SetValue(i, 2, xyz.Y());
myNodeCoords->SetValue(i, 3, xyz.Z());
}
- const Poly_Array1OfTriangle& aSeq = myMesh->Triangles();
- len = aSeq.Length();
+ len = myMesh->NbTriangles();
myElemNormals = new TColStd_HArray2OfReal(1, len, 1, 3);
myElemNodes = new TColStd_HArray2OfInteger(1, len, 1, 3);
{
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);
XmlMDataXtd_PresentationDriver.cxx
XmlMDataXtd_TriangulationDriver.cxx
XmlMDataXtd_TriangulationDriver.hxx
+XmlMDataXtd_SurfacicMeshDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.hxx
#include <XmlMDataXtd_GeometryDriver.hxx>
#include <XmlMDataXtd_PatternStdDriver.hxx>
#include <XmlMDataXtd_TriangulationDriver.hxx>
+#include <XmlMDataXtd_SurfacicMeshDriver.hxx>
#include <XmlMDF_ADriverTable.hxx>
#include <XmlMDataXtd_PresentationDriver.hxx>
void XmlMDataXtd::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
const Handle(Message_Messenger)& anMsgDrv)
{
- aDriverTable->AddDriver(new XmlMDataXtd_GeometryDriver (anMsgDrv));
- aDriverTable->AddDriver(new XmlMDataXtd_ConstraintDriver (anMsgDrv));
- aDriverTable->AddDriver(new XmlMDataXtd_PatternStdDriver (anMsgDrv));
- aDriverTable->AddDriver(new XmlMDataXtd_TriangulationDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_GeometryDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_ConstraintDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_PatternStdDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_TriangulationDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_SurfacicMeshDriver (anMsgDrv));
- aDriverTable->AddDriver(new XmlMDataXtd_PresentationDriver (anMsgDrv));
- aDriverTable->AddDriver(new XmlMDataXtd_PositionDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_PresentationDriver (anMsgDrv));
+ aDriverTable->AddDriver (new XmlMDataXtd_PositionDriver (anMsgDrv));
}
//=======================================================================
--- /dev/null
+// Created on: 2015-12-15
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XmlMDataXtd_SurfacicMeshDriver.hxx>
+#include <Message_Messenger.hxx>
+#include <NCollection_LocalArray.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XmlObjMgt.hxx>
+#include <XmlObjMgt_Persistent.hxx>
+#include <TDataXtd_SurfacicMesh.hxx>
+#include <LDOM_OSStream.hxx>
+#include <BRepTools_ShapeSet.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XmlMDataXtd_SurfacicMeshDriver,XmlMDF_ADriver)
+IMPLEMENT_DOMSTRING (MeshString, "mesh")
+IMPLEMENT_DOMSTRING (NullString, "null")
+IMPLEMENT_DOMSTRING (ExistString, "exists")
+
+//=======================================================================
+//function : XmlMDataXtd_SurfacicMeshDriver
+//purpose : Constructor
+//=======================================================================
+XmlMDataXtd_SurfacicMeshDriver::XmlMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMsgDriver)
+ : XmlMDF_ADriver (theMsgDriver, NULL)
+{
+
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) XmlMDataXtd_SurfacicMeshDriver::NewEmpty() const
+{
+ return new TDataXtd_SurfacicMesh();
+}
+
+//=======================================================================
+//function : Paste
+//purpose : persistent -> transient (retrieve)
+//=======================================================================
+Standard_Boolean XmlMDataXtd_SurfacicMeshDriver::Paste (const XmlObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ XmlObjMgt_RRelocationTable& ) const
+{
+ const XmlObjMgt_Element& anElement = theSource;
+ Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theTarget);
+
+ // Read the FirstIndex; if the attribute is absent initialize to 1
+ XmlObjMgt_DOMString aMeshStatus = anElement.getAttribute (::MeshString());
+ if (aMeshStatus == NULL ||
+ aMeshStatus.Type() != LDOMBasicString::LDOM_AsciiDoc ||
+ strcmp (aMeshStatus.GetString(), ::ExistString().GetString()))
+ {
+ // No mesh.
+ return Standard_True;
+ }
+
+ // Get mesh as a string.
+ const XmlObjMgt_DOMString& aData = XmlObjMgt::GetStringValue (anElement);
+ std::stringstream aStream (std::string (aData.GetString()));
+
+ // Read the mesh.
+ BRepTools_ShapeSet aShapeSet;
+ TColStd_IndexedMapOfTransient aMeshes;
+ aShapeSet.ReadMeshes (aStream, aMeshes);
+
+ // Set mesh.
+ if (!aMeshes.IsEmpty()) {
+ // We expect only one mesh.
+ Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (aMeshes (1));
+ if (!aMesh.IsNull())
+ attrMesh->Set (aMesh);
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose : transient -> persistent (store)
+//=======================================================================
+void XmlMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSource,
+ XmlObjMgt_Persistent& theTarget,
+ XmlObjMgt_SRelocationTable& ) const
+{
+ const Handle(TDataXtd_SurfacicMesh) meshAttr = Handle(TDataXtd_SurfacicMesh)::DownCast (theSource);
+ if (meshAttr->Get().IsNull())
+ theTarget.Element().setAttribute (::MeshString(), ::NullString());
+ else
+ {
+ theTarget.Element().setAttribute (::MeshString(), ::ExistString());
+
+ // Analyse the size of the mesh
+ // (to allocate properly the string array).
+ const Handle(Poly_Mesh)& aMesh = meshAttr->Get();
+ Standard_Integer aSize = aMesh->NbNodes();
+ aSize *= 3; // 3 coordinates for a node
+ aSize *= 8; // 8 characters are used to represent a coordinate (double) in XML
+ aSize += 4 * 5 * aMesh->NbElements(); // space for elements (triangles and quadrangles)
+ aSize *= 2; // just in case :-)
+ if (!aSize)
+ aSize = 1;
+
+ // Allocate a string stream.
+ LDOM_OSStream aStream (aSize);
+
+ // Write the mesh.
+ BRepTools_ShapeSet aShapeSet;
+ TColStd_IndexedMapOfTransient aMeshes;
+ aMeshes.Add (aMesh);
+ aShapeSet.WriteMeshes (aStream, aMeshes, Standard_True/*compact*/);
+ aStream << std::ends;
+
+ Standard_Character* aDump = (Standard_Character*) aStream.str(); // copying! Don't forget to delete it.
+ XmlObjMgt::SetStringValue (theTarget, aDump, Standard_True);
+ delete[] aDump;
+ }
+}
--- /dev/null
+// Created on: 2015-12-15
+// Created by: Vlad Romashko
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
+#define _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <XmlMDF_ADriver.hxx>
+#include <XmlObjMgt_RRelocationTable.hxx>
+#include <XmlObjMgt_SRelocationTable.hxx>
+
+class Message_Messenger;
+class TDF_Attribute;
+class XmlObjMgt_Persistent;
+
+DEFINE_STANDARD_HANDLE(XmlMDataXtd_SurfacicMeshDriver, XmlMDF_ADriver)
+
+//! TDataXtd_SurfacicMesh attribute XML-driver.
+class XmlMDataXtd_SurfacicMeshDriver : public XmlMDF_ADriver
+{
+
+public:
+
+ Standard_EXPORT XmlMDataXtd_SurfacicMeshDriver (const Handle(Message_Messenger)& theMessageDriver);
+
+ Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource, XmlObjMgt_Persistent& theTarget,
+ XmlObjMgt_SRelocationTable& RelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(XmlMDataXtd_SurfacicMeshDriver, XmlMDF_ADriver)
+};
+
+#endif // _XmlMDataXtd_SurfacicMeshDriver_HeaderFile
stream << PT->Deflection() << "\n";
// write the 3d nodes
- const TColgp_Array1OfPnt& Nodes = PT->Nodes();
for (i = 1; i <= nbNodes; i++)
{
- stream << Nodes(i).X() << " "
- << Nodes(i).Y() << " "
- << Nodes(i).Z() << " ";
+ stream << PT->Node (i).X() << " "
+ << PT->Node (i).Y() << " "
+ << PT->Node (i).Z() << " ";
}
if (PT->HasUVNodes())
{
- const TColgp_Array1OfPnt2d& UVNodes = PT->UVNodes();
for (i = 1; i <= nbNodes; i++)
{
- stream << UVNodes(i).X() << " "
- << UVNodes(i).Y() << " ";
+ stream << PT->UVNode (i).X() << " "
+ << PT->UVNode (i).Y() << " ";
}
}
- const Poly_Array1OfTriangle& Triangles = PT->Triangles();
for (i = 1; i <= nbTriangles; i++)
{
- Triangles(i).Get(n1, n2, n3);
+ PT->Triangle (i).Get (n1, n2, n3);
stream << n1 << " "
<< n2 << " "
<< n3 << " ";
--- /dev/null
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: TDataStd_Mesh
+#
+# Testing command: SetMesh
+# Testing command: DumpMesh
+#
+puts "caf001-Z1"
+set QA_DUP 0
+
+# Make a sphere and produce triangulation
+box s 100 200 300
+explode s f
+incmesh s_1 0.1
+
+# Set mesh from the spherical face
+NewCommand D
+SetMesh D 0:1 s_1
+NewCommand D
+
+# Test Undo/Redo.
+Undo D
+Redo D
+
+# Print the mesh data
+set dump1 [DumpMesh D 0:1]
+
+# Save document on disk.
+set filename ${imagedir}/${casename}.cbf
+SaveAs D ${filename}
+
+# Close and open the document again.
+Close D
+Open ${filename} DD
+
+# Print mesh data
+set dump2 [DumpMesh DD 0:1]
+
+Close DD
+
+# Check data
+if { ${dump1}!=${dump2} } {
+ puts "TDataStd_Mesh(XML) attribute: Error"
+ return
+}
+puts "TDataStd_Mesh(XML) attribute: OK"