Extension of triangular mesh of Open CASCADE to support quadrangular elements.
A Poly_Mesh class inherits Poly_Triangulation and manipulates quadrangles.
A TDataXtd_SurfacicMesh OCAF attribute is added to support a new surface mesh in OCAF operations.
// Porting of old development (for OCCT 7.1.0) to the current version of Open CASCADE.
// All remarks are checked, regressions are fixed.
// A new test-case is added : caf basic Z1
Versions of formats have been changed (11 for BinOCAF, 10 for XmlOCAF, 4 for BRep Shape and 3 for Binary BRep Shape).
Files written with the new version will not be readable by applications of old versions.
+
+@subsection upgrade_occt760_poly Changes in *Poly* package and *Poly_Triangulation* class:
+
+* Poly_Triangulation: Replaced all arrays with NCollection_Vector.
+* Poly_Triangulation: Old fashion of data access via getting collection reference is not more allowed for safety reasons.
+ Instead of old API, data access is organized via getters of single element by index.
+* New class Poly_Element that allows to store triangles or quads (quad consists of two triangles).
+* New class Poly_Mesh is extension of Poly_Triangulation that allows to store mesh with quad polygons as table of Poly_Element.
+* New OCAF attribute TDataXtd_SurfacicMesh that allows to store Poly_Mesh in OCAF documents.
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLocation);
- TColgp_Array1OfPnt aTriangNodes(1, (aTriangulation->NbNodes()));
- aTriangNodes = aTriangulation->Nodes();
- Poly_Array1OfTriangle aTriangles(1, aTriangulation->NbTriangles());
- aTriangles = aTriangulation->Triangles();
-
for (Standard_Integer i = 1; i <= (aTriangulation->NbTriangles()); i++)
{
- Poly_Triangle trian = aTriangles.Value(i);
+ const Poly_Triangle& trian = aTriangulation->Triangle (i);
Standard_Integer index1, index2, index3, M = 0, N = 0;
trian.Get(index1, index2, index3);
M = index2;
}
- BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangNodes.Value(M), aTriangNodes.Value(N));
+ BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangulation->Node (M), aTriangulation->Node (N));
if (anEdgeMaker.IsDone())
{
aBuilder.Add(aCompound, anEdgeMaker.Edge());
"\n"
" if(!aTr.IsNull())\n"
" { \n"
- " // takes the array of nodes for this triangulation\n"
- " const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); \n"
- " nbNodes = aNodes.Length();\n"
+ " nbNodes = aTr->NbNodes();\n"
"\n"
" for( Standard_Integer i = 1; i <= nbNodes; i++)\n"
" {\n"
" // create seguence of node points in absolute coordinate system\n"
- " gp_Pnt aPnt = aNodes(i).Transformed(aLocation);\n"
+ " gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);\n"
" aPoints.Append(aPnt);\n"
" \n"
" }\n"
if(!aTr.IsNull())
{
// takes the array of nodes for this triangulation
- const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
- nbNodes = aNodes.Length();
+ nbNodes = aTr->NbNodes();
for( Standard_Integer i = 1; i <= nbNodes; i++)
{
// create seguence of node points in absolute coordinate system
- gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
+ gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
aPoints.Append(aPnt);
}
" if(!aTr.IsNull()) // if this triangulation is not NULL" EOL
" { " EOL
- " // takes the array of nodes for this triangulation:" EOL
- " const TColgp_Array1OfPnt& aNodes = aTr->Nodes();" EOL
- " // takes the array of triangles for this triangulation:" EOL
- " const Poly_Array1OfTriangle& triangles = aTr->Triangles();" EOL EOL
-
" // create array of node points in absolute coordinate system" EOL
- " TColgp_Array1OfPnt aPoints(1, aNodes.Length());" EOL
- " for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)" EOL
- " aPoints(i) = aNodes(i).Transformed(aLocation);" EOL EOL
+ " TColgp_Array1OfPnt aPoints(1, aTr->NbNodes());" EOL
+ " for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)" EOL
+ " aPoints(i) = aTr->Node (i).Transformed (aLocation);" EOL EOL
" // Takes the node points of each triangle of this triangulation." EOL
" // takes a number of triangles:" EOL
" for( nt = 1 ; nt < nnn+1 ; nt++)" EOL
" {" EOL
" // takes the node indices of each triangle in n1,n2,n3:" EOL
- " triangles(nt).Get(n1,n2,n3);" EOL
+ " aTr->Triangle (nt).Get (n1,n2,n3);" EOL
" // takes the node points:" EOL
" gp_Pnt aPnt1 = aPoints(n1);" EOL
" gp_Pnt aPnt2 = aPoints(n2);" EOL
if(!aTr.IsNull())
{
- const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
aNumOfNodes += aTr->NbNodes();
//Standard_Integer aLower = aNodes.Lower();
//Standard_Integer anUpper = aNodes.Upper();
- const Poly_Array1OfTriangle& triangles = aTr->Triangles();
aNumOfTriangles += aTr->NbTriangles();
if(aCount == aNumOfFace)
Standard_Integer aLower = aNodesOfPol.Lower(), anUpper = aNodesOfPol.Upper();
for( int i = aLower; i < anUpper ; i++)
{
- gp_Pnt aPnt1 = aNodes(aNodesOfPol(i)).Transformed(aLocation);
- gp_Pnt aPnt2 = aNodes(aNodesOfPol(i+1)).Transformed(aLocation);
+ gp_Pnt aPnt1 = aTr->Node (aNodesOfPol (i)).Transformed (aLocation);
+ gp_Pnt aPnt2 = aTr->Node (aNodesOfPol (i+1)).Transformed (aLocation);
TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex (aPnt1);
TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex (aPnt2);
TopTools_DataMapOfIntegerShape aEdges;
TopTools_SequenceOfShape aVertices;
- for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)
+ for( Standard_Integer i = 1; i < aTr->NbNodes()+1; i++)
{
- gp_Pnt aPnt = aNodes(i).Transformed(aLocation);
+ gp_Pnt aPnt = aTr->Node (i).Transformed (aLocation);
TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(aPnt);
if(!aVertex.IsNull())
for( nt = 1 ; nt < nnn+1 ; nt++)
{
- triangles(nt).Get(n1,n2,n3);
+ aTr->Triangle (nt).Get (n1,n2,n3);
Standard_Integer key[3];
TopoDS_Face F =TopoDS::Face(ex.Current());
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
- TColgp_Array1OfPnt tab(1,(facing->NbNodes()));
- tab = facing->Nodes();
- Poly_Array1OfTriangle tri(1,facing->NbTriangles());
- tri = facing->Triangles();
for (Standard_Integer i=1;i<=(facing->NbTriangles());i++) {
- Poly_Triangle trian = tri.Value(i);
+ const Poly_Triangle& trian = facing->Triangle (i);
Standard_Integer index1,index2,index3,M = 0, N = 0;
trian.Get(index1,index2,index3);
M = index2;
}
- BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N));
+ BRepBuilderAPI_MakeEdge ME(facing->Node (M), facing->Node (N));
if (ME.IsDone()) {
builder.Add(Comp,ME.Edge());
}
TopoDS_Face F =TopoDS::Face(ex.Current()); \n\
TopLoc_Location L; \n\
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L); \n\
- TColgp_Array1OfPnt tab(1,(facing->NbNodes())); \n\
- tab = facing->Nodes(); \n\
- Poly_Array1OfTriangle tri(1,facing->NbTriangles()); \n\
- tri = facing->Triangles(); \n\
- \n\
+ \n\
for (Standard_Integer i=1;i<=(facing->NbTriangles());i++) { \n\
- Poly_Triangle trian = tri.Value(i); \n\
+ Poly_Triangle trian = facing->Triangle (i); \n\
Standard_Integer index1,index2,index3,M,N; \n\
trian.Get(index1,index2,index3); \n\
\n\
M = index2; \n\
} \n\
\n\
- BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N)); \n\
+ BRepBuilderAPI_MakeEdge ME(facing->Node (M),facing->Node (N)); \n\
if (ME.IsDone()) { \n\
builder.Add(Comp,ME.Edge()); \n\
} \n\
return;
}
- const TColgp_Array1OfPnt& Nodes= myT->Nodes();
-
- const Poly_Array1OfTriangle& triangles = myT->Triangles();
-
Standard_Integer nnn = myT->NbTriangles(); // nnn : nombre de triangles
Standard_Integer nt, n1, n2, n3 = 0;// nt : triangle courant
// ni : sommet i du triangle courant
// triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
- triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+ myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
- triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+ myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
- if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
+ if (TriangleIsValid (myT->Node (n1), myT->Node (n2), myT->Node (n3)) )
{ // Associates a vertexNT to each node
- gp_Pnt p = Nodes(n1).Transformed(myLocation.Transformation());
- gp_Pnt q = Nodes(n2).Transformed(myLocation.Transformation());
- gp_Pnt r = Nodes(n3).Transformed(myLocation.Transformation());
+ gp_Pnt p = myT->Node (n1).Transformed (myLocation.Transformation());
+ gp_Pnt q = myT->Node (n2).Transformed (myLocation.Transformation());
+ gp_Pnt r = myT->Node (n3).Transformed (myLocation.Transformation());
if (p.Z() > H.Z()) H=p;
if (q.Z() > H.Z()) H=q;
return;
}
Poly_Connect pc(myT);
- const TColgp_Array1OfPnt& Nodes= myT->Nodes();
+ TColgp_Array1OfPnt Nodes (1, myT->NbNodes());
+ for (Standard_Integer in = 1; in <= myT->NbNodes(); in++)
+ Nodes.SetValue(in, myT->Node (in));
BAR = GProp_PGProps::Barycentre(Nodes);
-
- //const TColgp_Array1OfPnt2d& UVNodes = myT->UVNodes();
- const Poly_Array1OfTriangle& triangles = myT->Triangles();
TColgp_Array1OfDir myNormal(Nodes.Lower(), Nodes.Upper());
-
StdPrs_ToolTriangulatedShape::Normal(myFace, pc, myNormal);
BRepTools::UVBounds(myFace,Umin, Umax, Vmin, Vmax);
dUmax = (Umax - Umin);
{
// triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
- triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+ myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
- triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+ myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
{ // Associates a vertexNT to each node
std::cout << "On traite actuellement le triangle : "<< nt <<"\n";
#endif
if (myFace.Orientation() == TopAbs_REVERSED) // si la face est "reversed"
- triangles(nt).Get(n1,n3,n2); // le triangle est n1,n3,n2
+ myT->Triangle (nt).Get (n1,n3,n2); // le triangle est n1,n3,n2
else
- triangles(nt).Get(n1,n2,n3); // le triangle est n1,n2,n3
+ myT->Triangle (nt).Get (n1,n2,n3); // le triangle est n1,n2,n3
if (TriangleIsValid (Nodes(n1),Nodes(n2),Nodes(n3)) )
{ // Associates a vertexNT to each node
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));
+ const Vec3f& aNormal = myTriangulation->Normal (i);
+ anArray->SetVertexNormal (i, aNormal.x(), aNormal.y(), aNormal.z());
}
}
else // !hasVColors
{
- for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
+ for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
- j = (i - nodes.Lower()) * 3;
- anArray->AddVertex(nodes(i));
- anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
+ anArray->AddVertex(myTriangulation->Node (i));
+ const Vec3f& aNormal = myTriangulation->Normal(i);
+ anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());
}
}
}
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
}
GeomLProp_SLProps aSLP(aSurf, 2, Precision::Confusion());
- const Standard_Integer anArrDim = 3*aPT->NbNodes();
- Handle(TShort_HArray1OfShortReal) aNormArr = new TShort_HArray1OfShortReal(1, anArrDim);
- Standard_Integer anNormInd = aNormArr->Lower();
- for(Standard_Integer i = aPT->UVNodes().Lower(); i <= aPT->UVNodes().Upper(); i++)
+ for(Standard_Integer i = 1; i <= aPT->NbNodes(); i++)
{
- const gp_Pnt2d &aP2d = aPT->UVNodes().Value(i);
+ const gp_Pnt2d &aP2d = aPT->UVNode (i);
aSLP.SetParameters(aP2d.X(), aP2d.Y());
gp_XYZ aNorm(0.,0.,0.);
if (aFace.Orientation() == TopAbs_REVERSED)
aNorm.Reverse();
}
- aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.X());
- aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Y());
- aNormArr->ChangeValue(anNormInd++) = static_cast<Standard_ShortReal>(aNorm.Z());
+ aPT->SetNormal (i, static_cast<Standard_ShortReal>(aNorm.X()),
+ static_cast<Standard_ShortReal>(aNorm.Y()),
+ static_cast<Standard_ShortReal>(aNorm.Z()));
}
aRetVal = Standard_True;
isNormalsFound = Standard_True;
- aPT->SetNormals(aNormArr);
}
if(!isNormalsFound)
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, aNorm2;
+ aPT1->Normal (aFNodF1, aNorm1);
+ aPT1->Normal (aFNodF2, aNorm2);
const Standard_Real aDot = aNorm1 * aNorm2;
if(aDot > aThresDot)
{
gp_XYZ aNewNorm = (aNorm1 + aNorm2).Normalized();
- aNormArr1.ChangeValue(aFNorm1FirstIndex) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex) =
- static_cast<Standard_ShortReal>(aNewNorm.X());
- aNormArr1.ChangeValue(aFNorm1FirstIndex+1) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex+1) =
- static_cast<Standard_ShortReal>(aNewNorm.Y());
- aNormArr1.ChangeValue(aFNorm1FirstIndex+2) =
- aNormArr2.ChangeValue(aFNorm2FirstIndex+2) =
- static_cast<Standard_ShortReal>(aNewNorm.Z());
+ aPT1->SetNormal (aFNodF1, aNewNorm);
+ aPT2->SetNormal (aFNodF2, aNewNorm);
aRetVal = Standard_True;
}
}
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).GetData() [k - 1] << " ";
+ if (!Compact)
+ {
+ OS << "\n";
+ }
+ else
+ {
+ OS << " ";
+ }
}
}
}
void BRepTools_ShapeSet::ReadTriangulation(Standard_IStream& IS, const Message_ProgressRange& theProgress)
{
char buffer[255];
- // Standard_Integer i, j, val, nbtri;
Standard_Integer i, j, nbtri =0;
Standard_Real d, x, y, z;
- Standard_Real normal;
+ Standard_Real normalX, normalY, normalZ;
Standard_Integer nbNodes =0, nbTriangles=0;
Standard_Boolean hasUV= Standard_False;
Standard_Boolean hasNormals= Standard_False;
}
GeomTools::GetReal(IS, d);
- TColgp_Array1OfPnt Nodes(1, nbNodes);
- TColgp_Array1OfPnt2d UVNodes(1, nbNodes);
- Handle(TShort_HArray1OfShortReal) Normals;
- if (hasNormals)
- {
- Normals = new TShort_HArray1OfShortReal(1, nbNodes * 3);
- }
+ T = new Poly_Triangulation (nbNodes, nbTriangles, hasUV, hasNormals);
+
for (j = 1; j <= nbNodes; j++) {
GeomTools::GetReal(IS, x);
GeomTools::GetReal(IS, y);
GeomTools::GetReal(IS, z);
- Nodes(j).SetCoord(x,y,z);
+ T->ChangeNode (j).SetCoord (x,y,z);
}
if (hasUV) {
for (j = 1; j <= nbNodes; j++) {
GeomTools::GetReal(IS, x);
GeomTools::GetReal(IS, y);
- UVNodes(j).SetCoord(x,y);
+ T->ChangeUVNode (j).SetCoord (x,y);
}
}
// read the triangles
Standard_Integer n1,n2,n3;
- Poly_Array1OfTriangle Triangles(1, nbTriangles);
for (j = 1; j <= nbTriangles; j++) {
IS >> n1 >> n2 >> n3;
- Triangles(j).Set(n1,n2,n3);
+ T->ChangeTriangle (j).Set (n1,n2,n3);
}
if (hasNormals)
{
- for (j = 1; j <= nbNodes * 3; j++)
+ for (j = 1; j <= nbNodes; j++)
{
- GeomTools::GetReal(IS, normal);
- Normals->SetValue(j, static_cast<Standard_ShortReal>(normal));
+ GeomTools::GetReal (IS, normalX);
+ GeomTools::GetReal (IS, normalY);
+ GeomTools::GetReal (IS, normalZ);
+ T->SetNormal (j, static_cast<Standard_ShortReal>(normalX),
+ static_cast<Standard_ShortReal>(normalY),
+ static_cast<Standard_ShortReal>(normalZ));
}
}
-
- if (hasUV) T = new Poly_Triangulation(Nodes,UVNodes,Triangles);
- else T = new Poly_Triangulation(Nodes,Triangles);
T->Deflection(d);
- if (hasNormals)
+ myTriangulations.Add(T, hasNormals);
+ }
+}
+
+// Writes meshes (Poly_Mesh).
+void BRepTools_ShapeSet::WriteMeshes (Standard_OStream& theOS,
+ const TColStd_IndexedMapOfTransient& theMeshes,
+ const Standard_Boolean theCompact)
+{
+ const Standard_Integer nbMeshes = theMeshes.Extent();
+
+ if (theCompact)
+ theOS << "Meshes " << nbMeshes << "\n";
+ else {
+ theOS << " -------\n";
+ theOS <<"Dump of " << nbMeshes << " meshes\n";
+ theOS << " -------\n";
+ }
+
+ Standard_Integer i = 1;
+ for (; i <= nbMeshes; i++)
+ {
+ const Handle(Poly_Mesh) aMesh = Handle(Poly_Mesh)::DownCast (theMeshes (i));
+ const Standard_Integer nbNodes = aMesh->NbNodes();
+ const Standard_Integer nbTriangles = aMesh->NbTriangles();
+ const Standard_Integer nbQuads = aMesh->NbQuads();
+ const Standard_Boolean hasUVNodes = aMesh->HasUVNodes();
+
+ if (theCompact)
{
- T->SetNormals(Normals);
+ theOS << nbNodes << " " << nbTriangles << " " << nbQuads << " ";
+ theOS << (hasUVNodes ? "1" : "0") << " ";
}
- myTriangulations.Add(T, hasNormals);
+ else
+ {
+ theOS << " "<< i << " : Mesh with " << nbNodes << " Nodes, " << nbTriangles << " Triangles, " << nbQuads << " Quadrangles\n";
+ theOS << " "<<(hasUVNodes ? "with" : "without") << " UV nodes\n";
+ }
+
+ // write the deflection
+ if (!theCompact)
+ theOS << " Deflection : ";
+ theOS << aMesh->Deflection() << "\n";
+
+ // write the 3d nodes
+ if (!theCompact)
+ theOS << "\n3D Nodes :\n";
+
+ Standard_Integer j;
+ for (j = 1; j <= nbNodes; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).X() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).Y() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->Node (j).Z();
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+
+ // write 2d nodes
+ if (hasUVNodes)
+ {
+ if (!theCompact) theOS << "\nUV Nodes :\n";
+ for (j = 1; j <= nbNodes; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->UVNode (j).X() << " ";
+ if (!theCompact) theOS << std::setw (17);
+ theOS << aMesh->UVNode (j).Y();
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+ }
+
+ // write triangles
+ if (!theCompact) theOS << "\nTriangles :\n";
+ Standard_Integer n1, n2, n3;
+ for (j = 1; j <= nbTriangles; j++)
+ {
+ if (!theCompact) theOS << std::setw (10) << j << " : ";
+ aMesh->Triangle (j).Get (n1, n2, n3);
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n1 << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n2 << " ";
+ if (!theCompact) theOS << std::setw (10);
+ theOS << n3;
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+
+ // write quadrangles
+ if (!theCompact) theOS << "\nQuadrangles :\n";
+ Standard_Integer n4;
+ for (j = 1; j <= nbQuads; j++)
+ {
+ if (!theCompact) theOS << std::setw(10) << j << " : ";
+ aMesh->Quad (j).Get (n1, n2, n3, n4);
+ if (!theCompact) theOS << std::setw(10);
+ theOS << n1 << " ";
+ if (!theCompact) theOS << std::setw(10);
+ theOS << n2 << " ";
+ if (!theCompact) theOS << std::setw(10);
+ theOS << n3 << " ";
+ if (!theCompact) theOS << std::setw(10);
+ theOS << n4;
+ if (!theCompact) theOS << "\n";
+ else theOS << " ";
+ }
+ theOS << "\n";
+ }
+}
+
+// Reads meshes (Poly_Mesh).
+void BRepTools_ShapeSet::ReadMeshes (Standard_IStream& theIS,
+ TColStd_IndexedMapOfTransient& theMeshes)
+{
+ char buffer[255];
+ Standard_Integer i, j;
+ Standard_Integer n1 (0), n2 (0), n3 (0), n4 (0);
+ Standard_Real deflection, x, y, z;
+ Standard_Integer nbMeshes (0), nbNodes (0), nbTriangles (0), nbQuads (0);
+ Standard_Boolean hasUV (Standard_False);
+ gp_Pnt p;
+
+ // Read the "Meshes" head-line.
+ theIS >> buffer;
+ if (strstr (buffer, "Meshes") == NULL)
+ return;
+
+ // Read number of meshes.
+ theIS >> nbMeshes;
+
+ for (i = 1; i <= nbMeshes; i++)
+ {
+ theIS >> nbNodes >> nbTriangles >> nbQuads >> hasUV;
+ GeomTools::GetReal (theIS, deflection);
+
+ // Allocate the mesh.
+ Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, hasUV);
+ aMesh->Deflection (deflection);
+
+ // Read nodes.
+ for (j = 1; j <= nbNodes; j++)
+ {
+ GeomTools::GetReal (theIS, x);
+ GeomTools::GetReal (theIS, y);
+ GeomTools::GetReal (theIS, z);
+ p.SetCoord (x, y, z);
+ aMesh->ChangeNode (j) = p;
+ }
+
+ // Reads 2d-nodes.
+ if (hasUV)
+ {
+ for (j = 1; j <= nbNodes; j++)
+ {
+ GeomTools::GetReal (theIS, x);
+ GeomTools::GetReal (theIS, y);
+ aMesh->ChangeUVNode (j).SetCoord (x, y);
+ }
+ }
+
+ // Reads the triangles.
+ for (j = 1; j <= nbTriangles; j++)
+ {
+ // Read the indices.
+ theIS >> n1 >> n2 >> n3;
+
+ // Set the triangle to the mesh.
+ aMesh->ChangeTriangle (j) = Poly_Triangle (n1, n2, n3);
+ }
+
+ // Reads the quadrangles.
+ for (j = 1; j <= nbQuads; j++)
+ {
+ // Read the indices.
+ theIS >> n1 >> n2 >> n3 >> n4;
+
+ // Set the quadrangle to the mesh.
+ aMesh->ChangeQuad (j) = Poly_Quad (n1, n2, n3, n4);
+ }
+
+ theMeshes.Add (aMesh);
}
}
//! 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 n1, n2, n3, n4;
+ Standard_Integer nbNodes (0), nbTriangles (0), nbQuads (0);
+ Standard_Boolean hasUV (Standard_False);
+ gp_Pnt p;
+
+ theSource >> nbNodes;
+ theSource >> nbTriangles;
+ theSource >> nbQuads;
+ theSource >> hasUV;
+ theSource >> deflection;
+
+ // allocate the mesh
+ Handle(Poly_Mesh) aMesh = new Poly_Mesh (nbNodes, nbTriangles, nbQuads, hasUV);
+
+ // deflection
+ aMesh->Deflection (deflection);
+
+ // read nodes
+ for (i = 1; i <= nbNodes; i++)
+ {
+ theSource >> x;
+ theSource >> y;
+ theSource >> z;
+ p.SetCoord (x, y, z);
+ aMesh->ChangeNode (i) = p;
+ }
+
+ // read 2d nodes
+ if (hasUV)
+ {
+ for (i = 1; i <= nbNodes; i++)
+ {
+ theSource >> x;
+ theSource >> y;
+ aMesh->ChangeUVNode (i).SetCoord (x,y);
+ }
+ }
+
+ // read triangles
+ for (i = 1; i <= nbTriangles; i++)
+ {
+ theSource >> n1;
+ theSource >> n2;
+ theSource >> n3;
+ aMesh->ChangeTriangle (i).Set (n1, n2, n3);
+ }
+
+ // read quadrangles
+ for (i = 1; i <= nbQuads; i++)
+ {
+ theSource >> n1;
+ theSource >> n2;
+ theSource >> n3;
+ theSource >> n4;
+ aMesh->ChangeQuad (i).Set (n1, n2, n3, n4);
+ }
+
+ // Set mesh to Ocaf attribute
+ attrMesh->Set (aMesh);
+ return !aMesh.IsNull();
+}
+
+//=======================================================================
+//function : Paste
+//purpose : transient -> persistent (store)
+//=======================================================================
+void BinMDataXtd_SurfacicMeshDriver::Paste (const Handle(TDF_Attribute)& theSource,
+ BinObjMgt_Persistent& theTarget,
+ BinObjMgt_SRelocationTable& ) const
+{
+ const Handle(TDataXtd_SurfacicMesh) attrMesh = Handle(TDataXtd_SurfacicMesh)::DownCast (theSource);
+ const Handle(Poly_Mesh)& aMesh = attrMesh->Get();
+ if (!aMesh.IsNull())
+ {
+ Standard_Integer nbNodes = aMesh->NbNodes();
+ Standard_Integer nbTriangles = aMesh->NbTriangles();
+ Standard_Integer nbQuads = aMesh->NbQuads();
+
+ // write number of elements
+ theTarget << nbNodes;
+ theTarget << nbTriangles;
+ theTarget << nbQuads;
+ theTarget << (aMesh->HasUVNodes() ? 1 : 0);
+ // write the deflection
+ theTarget << aMesh->Deflection();
+
+ // write 3d nodes
+ Standard_Integer i;
+ for (i = 1; i <= nbNodes; i++)
+ {
+ const gp_Pnt& aNode = aMesh->Node (i);
+ theTarget << aNode.X();
+ theTarget << aNode.Y();
+ theTarget << aNode.Z();
+ }
+
+ // write 2d nodes
+ if (aMesh->HasUVNodes())
+ {
+ for (i = 1; i <= nbNodes; i++)
+ {
+ const gp_Pnt2d& aUVNode = aMesh->UVNode (i);
+ theTarget << aUVNode.X();
+ theTarget << aUVNode.Y();
+ }
+ }
+
+ // write triangles
+ Standard_Integer n1, n2, n3;
+ for (i = 1; i <= nbTriangles; i++)
+ {
+ aMesh->Triangle (i).Get (n1, n2, n3);
+ theTarget << n1;
+ theTarget << n2;
+ theTarget << n3;
+ }
+
+ // write quadrangles
+ Standard_Integer n4;
+ for (i = 1; i <= nbQuads; i++)
+ {
+ aMesh->Quad (i).Get (n1, n2, n3, n4);
+ theTarget << n1;
+ theTarget << n2;
+ theTarget << n3;
+ theTarget << n4;
+ }
+ }
+}
--- /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 Vec3f& aNormal = aTriangulation->Normal (aNormalIter);
+ BinTools::PutShortReal (OS, aNormal.x());
+ BinTools::PutShortReal (OS, aNormal.y());
+ BinTools::PutShortReal (OS, 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);
+ aTriangulation->SetNormal (aNormalIter, aNormalX, aNormalY, aNormalZ);
}
}
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());
gp_Vec aNormal;
if (hasNormals)
{
- aNormal = aTriangulation->Normal (aNodeIter);
+ gp_XYZ anXYZ;
+ aTriangulation->Normal (aNodeIter, anXYZ);
+ aNormal.SetXYZ (anXYZ);
}
else
{
// 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_ListOfTriangulation.hxx
Poly_MakeLoops.cxx
Poly_MakeLoops.hxx
+Poly_Mesh.cxx
+Poly_Mesh.hxx
Poly_Polygon2D.cxx
Poly_Polygon2D.hxx
Poly_Polygon3D.cxx
Poly_Polygon3D.hxx
Poly_PolygonOnTriangulation.cxx
Poly_PolygonOnTriangulation.hxx
+Poly_Quad.hxx
Poly_Triangle.hxx
Poly_Triangulation.cxx
Poly_Triangulation.hxx
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();
}
// Normalize all vectors
+ gp_Dir aNormal;
gp_XYZ aNormXYZ;
for (Standard_Integer aNodeIter = 0; aNodeIter < aNbNodes; ++aNodeIter)
{
const Standard_Size anIndex = aNodeIter * 3;
aNormXYZ.SetCoord (aNormArr[anIndex + 0], aNormArr[anIndex + 1], aNormArr[anIndex + 2]);
const Standard_Real aMod2 = aNormXYZ.SquareModulus();
- if (aMod2 < anEps2)
- {
- aNormArr[anIndex + 0] = 0.0f;
- aNormArr[anIndex + 1] = 0.0f;
- aNormArr[anIndex + 2] = 1.0f;
- }
+ if (aMod2 > anEps2)
+ aNormal = aNormXYZ;
else
- {
- aNormXYZ /= Sqrt (aMod2);
- aNormArr[anIndex + 0] = Standard_ShortReal(aNormXYZ.X());
- aNormArr[anIndex + 1] = Standard_ShortReal(aNormXYZ.Y());
- aNormArr[anIndex + 2] = Standard_ShortReal(aNormXYZ.Z());
- }
- }
+ aNormal = gp::DZ();
- theTri->SetNormals (aNormals);
+ // Set normal.
+ theTri->SetNormal (aNodeIter + 1, aNormXYZ);
+ }
}
//=======================================================================
: theAlloc)
{
if (theTriangulation.IsNull() == Standard_False) {
- const TColgp_Array1OfPnt& arrNodes = theTriangulation->Nodes();
- const Poly_Array1OfTriangle& arrTriangle = theTriangulation->Triangles();
const Standard_Integer nNodes = theTriangulation->NbNodes();
- const Standard_Integer nTri = theTriangulation->NbTriangles();
Standard_Integer i;
// Copy the nodes
for (i = 0; i < nNodes; i++) {
- const Standard_Integer anOldInd = i + arrNodes.Lower();
- const Standard_Integer aNewInd = SetNode(arrNodes(anOldInd).XYZ(), i);
+ const Standard_Integer anOldInd = i + 1;
+ const Standard_Integer aNewInd = SetNode (theTriangulation->Node (anOldInd).XYZ(), i);
Poly_CoherentNode& aCopiedNode = myNodes(aNewInd);
aCopiedNode.SetIndex(anOldInd);
}
// Copy the triangles
- for (i = 0; i < nTri; i++) {
+ for (i = 1; i <= theTriangulation->NbTriangles(); i++) {
Standard_Integer iNode[3];
- arrTriangle(i + arrTriangle.Lower()).Get(iNode[0], iNode[1], iNode[2]);
+ theTriangulation->Triangle (i).Get (iNode[0], iNode[1], iNode[2]);
if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0])
AddTriangle (iNode[0]-1, iNode[1]-1, iNode[2]-1);
}
// Copy UV coordinates of nodes
if (theTriangulation->HasUVNodes()) {
- const TColgp_Array1OfPnt2d& arrNodes2d = theTriangulation->UVNodes();
for (i = 0; i < nNodes; i++) {
- const gp_Pnt2d& anUV = arrNodes2d(i + arrNodes2d.Lower());
+ const gp_Pnt2d& anUV = theTriangulation->UVNode (i + 1);
myNodes(i).SetUV(anUV.X(), anUV.Y());
}
}
// Copy the normals at nodes
if (theTriangulation->HasNormals()) {
- const TShort_Array1OfShortReal& arrNorm = theTriangulation->Normals();
for (i = 0; i < nNodes; i++) {
- const gp_XYZ aNormal (arrNorm(3 * i + 0 + arrNorm.Lower()),
- arrNorm(3 * i + 1 + arrNorm.Lower()),
- arrNorm(3 * i + 2 + arrNorm.Lower()));
- myNodes(i).SetNormal(aNormal);
+ const Vec3f& anXYZ = theTriangulation->Normal (i + 1);
+ gp_XYZ aNormal (anXYZ.x(), anXYZ.y(), anXYZ.z());
+ myNodes (i).SetNormal (aNormal);
}
}
myDeflection = theTriangulation->Deflection();
const Standard_Integer nTriangles = NTriangles();
if (nNodes > 0 && nTriangles > 0) {
aResult = new Poly_Triangulation(nNodes, nTriangles, Standard_True);
- const Handle(TShort_HArray1OfShortReal) harrNormal =
- new TShort_HArray1OfShortReal(1, 3 * nNodes);
- Standard_ShortReal * arrNormal = &harrNormal->ChangeValue(1);
- TColgp_Array1OfPnt& arrNodes = aResult->ChangeNodes();
- TColgp_Array1OfPnt2d& arrNodesUV = aResult->ChangeUVNodes();
- Poly_Array1OfTriangle& arrTriangle = aResult->ChangeTriangles();
NCollection_Vector<Standard_Integer> vecNodeId;
Standard_Integer i, aCount(0);
Standard_Boolean hasUV (Standard_False);
- Standard_Boolean hasNormals (Standard_False);
// Copy the nodes (3D and 2D coordinates)
for (i = 0; i < myNodes.Length(); i++) {
vecNodeId.SetValue(i, 0);
else {
const gp_XYZ aNormal = aNode.GetNormal();
- arrNormal[3 * aCount + 0] = static_cast<Standard_ShortReal>(aNormal.X());
- arrNormal[3 * aCount + 1] = static_cast<Standard_ShortReal>(aNormal.Y());
- arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
+ if (aNormal.SquareModulus() > Precision::Confusion()) {
+ aResult->SetNormal (aCount, static_cast<Standard_ShortReal>(aNormal.X()),
+ static_cast<Standard_ShortReal>(aNormal.Y()),
+ static_cast<Standard_ShortReal>(aNormal.Z()));
+ }
vecNodeId.SetValue(i, ++aCount);
- arrNodes.SetValue(aCount, aNode);
+ aResult->ChangeNode (aCount) = aNode;
- arrNodesUV.SetValue(aCount, gp_Pnt2d(aNode.GetU(), aNode.GetV()));
+ aResult->ChangeUVNode (aCount) = gp_Pnt2d (aNode.GetU(), aNode.GetV());
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
Precision::Confusion())
hasUV = Standard_True;
- if (aNormal.SquareModulus() > Precision::Confusion())
- hasNormals = Standard_True;
}
}
if (hasUV == Standard_False)
for (; anIterT.More(); anIterT.Next()) {
const Poly_CoherentTriangle& aTri = anIterT.Value();
if (aTri.IsEmpty() == Standard_False) {
- const Poly_Triangle aPolyTriangle (vecNodeId(aTri.Node(0)),
- vecNodeId(aTri.Node(1)),
- vecNodeId(aTri.Node(2)));
- arrTriangle.SetValue(++aCount, aPolyTriangle);
+ aResult->ChangeTriangle (++aCount) = Poly_Triangle (vecNodeId (aTri.Node (0)),
+ vecNodeId (aTri.Node (1)),
+ vecNodeId (aTri.Node (2)));;
}
}
- if (hasNormals)
- aResult->SetNormals (harrNormal);
aResult->Deflection(myDeflection);
}
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];
--- /dev/null
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Poly_Mesh.hxx>
+#include <Standard_DefineHandle.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh () : Poly_Triangulation (0, 0, Standard_False)
+{
+}
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh (const Standard_Integer theNbNodes,
+ const Standard_Integer theNbTriangles,
+ const Standard_Integer theNbQuads,
+ const Standard_Boolean theHasUVNodes,
+ const Standard_Boolean theHasNormals)
+: Poly_Triangulation (theNbNodes, theNbTriangles, theHasUVNodes, theHasNormals)
+{
+ if (theNbQuads > 0)
+ myQuads.Resize (1, theNbQuads, Standard_False);
+}
+
+//=======================================================================
+//function : Poly_Mesh
+//purpose :
+//=======================================================================
+
+Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
+: Poly_Triangulation ( theTriangulation )
+{
+ // No quadrangles.
+}
+
+//=======================================================================
+//function : Copy
+//purpose :
+//=======================================================================
+
+Handle(Poly_Triangulation) Poly_Mesh::Copy() const
+{
+ Handle(Poly_Triangulation) aCopiedTriangulation = Poly_Triangulation::Copy();
+ Handle(Poly_Mesh) aCopiedMesh = new Poly_Mesh (aCopiedTriangulation);
+ aCopiedMesh->myQuads = myQuads;
+ return aCopiedMesh;
+}
--- /dev/null
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Poly_Mesh_HeaderFile
+#define _Poly_Mesh_HeaderFile
+
+#include <Poly_Quad.hxx>
+#include <Poly_Triangulation.hxx>
+
+//! This class is extension for Poly_Triangulation.
+//! It allows to store mesh with quad polygons.
+class Poly_Mesh : public Poly_Triangulation
+{
+
+public:
+
+ //! Constructs an empty mesh.
+ Standard_EXPORT Poly_Mesh();
+
+ //! Constructs a mesh.
+ //! @param theNbNodes defines the number of nodes.
+ //! @param theNbTriangles defines the number of triangles.
+ //! @param theNbQuads defines the number of quadrangles.
+ //! @param theHasUVNodes indicates whether 2D nodes will be associated with
+ //! 3D ones, (i.e. to enable a 2D representation).
+ //! @param theHasNormals defines allocation of normals for the nodes.
+ Standard_EXPORT Poly_Mesh(const Standard_Integer theNbNodes,
+ const Standard_Integer theNbTriangles,
+ const Standard_Integer theNbQuads,
+ const Standard_Boolean theHasUVNodes = Standard_False,
+ const Standard_Boolean theHasNormals = Standard_False);
+
+ //! Constructs a mesh from existing triangulation.
+ //! @param theTriangulation source triangulation.
+ Standard_EXPORT Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation);
+
+ //! Creates full copy of current mesh
+ Standard_EXPORT virtual Handle(Poly_Triangulation) Copy() const Standard_OVERRIDE;
+
+ //! Sets a quadrangle to the mesh.
+ //! @param theIndex is an index of the quadrangle.
+ //! @param theN1 index of the first node.
+ //! @param theN2 index of the second node.
+ //! @param theN3 index of the third node.
+ //! @param theN4 index of the fourth node.
+ void SetQuad (const Standard_Integer theIndex,
+ const Standard_Integer theN1,
+ const Standard_Integer theN2,
+ const Standard_Integer theN3,
+ const Standard_Integer theN4)
+ {
+ myQuads.SetValue (theIndex, Poly_Quad (theN1, theN2, theN3, theN4));
+ }
+
+ //! @return the number of quadrangles in the mesh.
+ Standard_Integer NbQuads() const {
+ return myQuads.Size();
+ }
+
+ //! @return a quadrangle at the given index.
+ const Poly_Quad& Quad (const Standard_Integer theIndex) const {
+ return myQuads.Value (theIndex);
+ }
+
+ //! @return a reference to a quadrangle at the given index.
+ Poly_Quad& ChangeQuad (const Standard_Integer theIndex) {
+ return myQuads.ChangeValue (theIndex);
+ }
+
+protected:
+
+ NCollection_Array1<Poly_Quad> myQuads;
+
+public:
+
+ DEFINE_STANDARD_RTTIEXT(Poly_Mesh, Poly_Triangulation)
+
+};
+
+DEFINE_STANDARD_HANDLE(Poly_Mesh, Poly_Triangulation)
+
+#endif // _Poly_Mesh_HeaderFile
// 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 : Node
+//purpose :
+//=======================================================================
+
+Standard_Integer Poly_PolygonOnTriangulation::Node (const Standard_Integer theIndex) const
+{
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myNodes.Length()),
+ "Poly_PolygonOnTriangulation::Node : index out of range");
+ return myNodes.Value (theIndex);
+}
+
+//=======================================================================
+//function : SetNode
+//purpose :
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetNode (const Standard_Integer theIndex, const Standard_Integer theNode)
+{
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myNodes.Length()),
+ "Poly_PolygonOnTriangulation::SetNode : index out of range");
+ myNodes.SetValue (theIndex, theNode);
+}
+
+//=======================================================================
+//function : Parameter
+//purpose :
+//=======================================================================
+
+Standard_Real Poly_PolygonOnTriangulation::Parameter (const Standard_Integer theIndex) const
+{
+ Standard_NullObject_Raise_if (myParameters.IsNull(),
+ "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+ "Poly_PolygonOnTriangulation::Parameter : index out of range");
+ return myParameters->Value (theIndex);
+}
+
+//=======================================================================
+//function : SetParameter
+//purpose :
+//=======================================================================
+
+void Poly_PolygonOnTriangulation::SetParameter (const Standard_Integer theIndex, const Standard_Real theValue)
+{
+ Standard_NullObject_Raise_if (myParameters.IsNull(),
+ "Poly_PolygonOnTriangulation::Parameter : parameters is NULL");
+ Standard_OutOfRange_Raise_if ((theIndex < 1 || theIndex > myParameters->Length()),
+ "Poly_PolygonOnTriangulation::Parameter : index out of range");
+ myParameters->SetValue (theIndex, theValue);
+}
+
//=======================================================================
//function : SetParameters
//purpose :
//! 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.
--- /dev/null
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Poly_Quad_HeaderFile
+#define _Poly_Quad_HeaderFile
+
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Integer.hxx>
+#include <Poly_Triangle.hxx>
+
+//! Describes a quadric element of a mesh.
+class Poly_Quad : public Poly_Triangle
+{
+
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+ //! Constructs an empty Quad object.
+ Poly_Quad():myNode4 (0) {
+ myNodes[0] = myNodes[1] = myNodes[2] = 0;
+ }
+
+ //! Constructs a quadric element.
+ Poly_Quad (const Standard_Integer theNode1,
+ const Standard_Integer theNode2,
+ const Standard_Integer theNode3,
+ const Standard_Integer theNode4)
+ {
+ Set (theNode1, theNode2, theNode3, theNode4);
+ }
+
+ //! Sets indices of nodes.
+ void Set (const Standard_Integer theNode1,
+ const Standard_Integer theNode2,
+ const Standard_Integer theNode3,
+ const Standard_Integer theNode4)
+ {
+ myNodes[0] = theNode1;
+ myNodes[1] = theNode2;
+ myNodes[2] = theNode3;
+ myNode4 = theNode4;
+ }
+
+ //! Returns indices of nodes of the quadric element.
+ void Get (Standard_Integer& theNode1,
+ Standard_Integer& theNode2,
+ Standard_Integer& theNode3,
+ Standard_Integer& theNode4) const
+ {
+ theNode1 = myNodes[0];
+ theNode2 = myNodes[1];
+ theNode3 = myNodes[2];
+ theNode4 = myNode4;
+ }
+
+protected:
+
+ Standard_Integer myNode4;
+
+};
+
+#endif // _Poly_Quad_HeaderFile
Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
-private:
+protected:
Standard_Integer myNodes[3];
#include <gp_Pnt.hxx>
#include <Poly_Triangle.hxx>
-#include <Standard_DomainError.hxx>
#include <Standard_Dump.hxx>
-#include <Standard_NullObject.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, Standard_Transient)
//=======================================================================
Poly_Triangulation::Poly_Triangulation()
: myCachedMinMax (NULL),
- myDeflection (0)
+ myDeflection (0),
+ myHasUVNodes (Standard_False)
{
}
//function : Poly_Triangulation
//purpose :
//=======================================================================
-Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
- const Standard_Integer theNbTriangles,
- const Standard_Boolean theHasUVNodes)
+Poly_Triangulation::Poly_Triangulation (const Standard_Integer theNbNodes,
+ const Standard_Integer theNbTriangles,
+ const Standard_Boolean theHasUVNodes)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNbNodes),
- myTriangles (1, theNbTriangles)
+ myHasUVNodes (theHasUVNodes)
{
- if (theHasUVNodes) myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
+ if (theNbNodes > 0)
+ {
+ myNodes.Resize (1, theNbNodes, Standard_False);
+ if (myHasUVNodes)
+ {
+ myUVNodes.Resize (1, theNbNodes, Standard_False);
+ }
+ }
+ if (theNbTriangles > 0)
+ {
+ myTriangles.Resize (1, theNbTriangles, Standard_False);
+ }
}
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
-Poly_Triangulation::Poly_Triangulation(const Standard_Integer theNbNodes,
- const Standard_Integer theNbTriangles,
- const Standard_Boolean theHasUVNodes,
- const Standard_Boolean theHasNormals)
-: myDeflection(0),
- myNodes (1, theNbNodes),
- myTriangles (1, theNbTriangles)
+Poly_Triangulation::Poly_Triangulation (const Standard_Integer theNbNodes,
+ const Standard_Integer theNbTriangles,
+ const Standard_Boolean theHasUVNodes,
+ const Standard_Boolean theHasNormals)
+: Poly_Triangulation(theNbNodes, theNbTriangles, theHasUVNodes)
{
- if (theHasUVNodes)
- {
- myUVNodes = new TColgp_HArray1OfPnt2d(1, theNbNodes);
- }
if (theHasNormals)
{
- myNormals = new TShort_HArray1OfShortReal(1, theNbNodes * 3);
+ myNormals.Resize (1, theNbNodes, Standard_False);
}
}
//function : Poly_Triangulation
//purpose :
//=======================================================================
-Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
- const Poly_Array1OfTriangle& theTriangles)
+Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
+ const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNodes.Length()),
- myTriangles (1, theTriangles.Length())
+ myHasUVNodes (Standard_False)
{
+ myNodes.Resize (1, theNodes.Length(), Standard_False);
myNodes = theNodes;
+
+ myTriangles.Resize (1, theTriangles.Length(), Standard_False);
myTriangles = theTriangles;
}
//purpose :
//=======================================================================
-Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& theNodes,
- const TColgp_Array1OfPnt2d& theUVNodes,
- const Poly_Array1OfTriangle& theTriangles)
+Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
+ const TColgp_Array1OfPnt2d& theUVNodes,
+ const Poly_Array1OfTriangle& theTriangles)
: myCachedMinMax (NULL),
myDeflection (0),
- myNodes (1, theNodes.Length()),
- myTriangles (1, theTriangles.Length())
+ myHasUVNodes (theNodes.Length() == theUVNodes.Length())
{
+ myNodes.Resize (1, theNodes.Length(), Standard_False);
myNodes = theNodes;
+
+ myTriangles.Resize (1, theTriangles.Length(), Standard_False);
myTriangles = theTriangles;
- myUVNodes = new TColgp_HArray1OfPnt2d (1, theNodes.Length());
- myUVNodes->ChangeArray1() = theUVNodes;
+
+ if (myHasUVNodes) {
+ myUVNodes.Resize (1, theNodes.Length(), Standard_False);
+ myUVNodes = theUVNodes;
+ }
}
//=======================================================================
Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
{
- return new Poly_Triangulation (this);
+ Handle(Poly_Triangulation) aCopy = new Poly_Triangulation (NbNodes(), NbTriangles(), HasUVNodes());
+ aCopy->myNodes = myNodes;
+ aCopy->myTriangles = myTriangles;
+ aCopy->myDeflection = myDeflection;
+
+ if (HasUVNodes())
+ aCopy->myUVNodes = myUVNodes;
+
+ if (HasNormals()) {
+ aCopy->myNormals.Resize (1, myNodes.Size(), Standard_False);
+ aCopy->myNormals = myNormals;
+ }
+
+ return aCopy;
}
//=======================================================================
Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation)
: myCachedMinMax(NULL),
- myDeflection(theTriangulation->myDeflection),
- myNodes(theTriangulation->Nodes()),
- myTriangles(theTriangulation->Triangles())
+ myDeflection (theTriangulation->myDeflection),
+ myHasUVNodes (theTriangulation->myHasUVNodes)
{
SetCachedMinMax (theTriangulation->CachedMinMax());
- if (theTriangulation->HasUVNodes())
- {
- myUVNodes = new TColgp_HArray1OfPnt2d(theTriangulation->myUVNodes->Array1());
- }
- if (theTriangulation->HasNormals())
- {
- myNormals = new TShort_HArray1OfShortReal(theTriangulation->myNormals->Array1());
- }
-}
-//=======================================================================
-//function : Deflection
-//purpose :
-//=======================================================================
+ // Re-allocate the arrays.
+ myNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
+ if (myHasUVNodes)
+ myUVNodes.Resize (1, theTriangulation->NbNodes(), Standard_False);
+ myTriangles.Resize (1, theTriangulation->NbTriangles(), Standard_False);
+ if (theTriangulation->HasNormals())
+ myNormals.Resize (1, theTriangulation->NbNodes(), Standard_False);
-void Poly_Triangulation::Deflection(const Standard_Real theDeflection)
-{
- myDeflection = theDeflection;
+ // Copy data.
+ myNodes = theTriangulation->myNodes;
+ if (myHasUVNodes)
+ myUVNodes = theTriangulation->myUVNodes;
+ myTriangles = theTriangulation->myTriangles;
+ if (theTriangulation->HasNormals())
+ myNormals = theTriangulation->myNormals;
}
//=======================================================================
void Poly_Triangulation::RemoveUVNodes()
{
- myUVNodes.Nullify();
-}
-
-//=======================================================================
-//function : Node
-//purpose :
-//=======================================================================
-
-const gp_Pnt& Poly_Triangulation::Node (const Standard_Integer theIndex) const
-{
- if (theIndex < 1 || theIndex > myNodes.Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::Node : index out of range");
- }
- return myNodes.Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeNode
-//purpose :
-//=======================================================================
-
-gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
-{
- if (theIndex < 1 || theIndex > myNodes.Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::ChangeNode : index out of range");
- }
- return myNodes.ChangeValue (theIndex);
-}
-
-//=======================================================================
-//function : UVNode
-//purpose :
-//=======================================================================
-
-const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
-{
- if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::UVNode : index out of range");
- }
- return myUVNodes->Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeUVNode
-//purpose :
-//=======================================================================
-
-gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
-{
- if (myUVNodes.IsNull() || theIndex < 1 || theIndex > myUVNodes->Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::ChangeUVNode : index out of range");
- }
- return myUVNodes->ChangeValue (theIndex);
-}
-
-//=======================================================================
-//function : Triangle
-//purpose :
-//=======================================================================
-
-const Poly_Triangle& Poly_Triangulation::Triangle (const Standard_Integer theIndex) const
-{
- if (theIndex < 1 || theIndex > myTriangles.Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::Triangle : index out of range");
- }
- return myTriangles.Value (theIndex);
-}
-
-//=======================================================================
-//function : ChangeTriangle
-//purpose :
-//=======================================================================
-
-Poly_Triangle& Poly_Triangulation::ChangeTriangle (const Standard_Integer theIndex)
-{
- if (theIndex < 1 || theIndex > myTriangles.Size())
- {
- throw Standard_OutOfRange ("Poly_Triangulation::ChangeTriangle : index out of range");
- }
- return myTriangles.ChangeValue (theIndex);
+ myUVNodes = TColgp_Array1OfPnt2d();
+ myHasUVNodes = Standard_False;
}
//=======================================================================
throw Standard_DomainError("Poly_Triangulation::SetNormals : wrong length");
}
- myNormals = theNormals;
-}
-
-//=======================================================================
-//function : Normals
-//purpose :
-//=======================================================================
-
-const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
-{
-
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
- throw Standard_NullObject("Poly_Triangulation::Normals : "
- "wrong length or null array");
- }
-
- return myNormals->Array1();
-}
-
-//=======================================================================
-//function : ChangeNormals
-//purpose :
-//=======================================================================
-
-TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
-{
-
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
- throw Standard_NullObject("Poly_Triangulation::ChangeNormals : "
- "wrong length or null array");
- }
-
- return myNormals->ChangeArray1();
-}
-
-//=======================================================================
-//function : HasNormals
-//purpose :
-//=======================================================================
-
-Standard_Boolean Poly_Triangulation::HasNormals() const
-{
- if(myNormals.IsNull() || myNormals->Length() != 3 * NbNodes()) {
- return Standard_False;
+ Standard_Integer anArrayLower = theNormals->Lower();
+ for (Standard_Integer anIndex = 1; anIndex >= NbNodes(); anIndex--)
+ {
+ Standard_Integer anArrayInd = anArrayLower + (anIndex - 1) * 3;
+ SetNormal (anIndex, theNormals->Value(anArrayInd),
+ theNormals->Value(anArrayInd + 1),
+ theNormals->Value(anArrayInd + 2));
}
- return Standard_True;
}
-//=======================================================================
-//function : SetNormal
-//purpose :
-//=======================================================================
+// =======================================================================
+// function : ResizeNodes
+// purpose :
+// =======================================================================
-void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
+void Poly_Triangulation::ResizeNodes (const Standard_Integer theNbNodes)
{
- if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
- {
- throw Standard_NullObject ("Poly_Triangulation::SetNormal : empty array or index out of range");
+ if (theNbNodes > 0) {
+ myNodes.Resize (1, theNbNodes, Standard_True);
+ if (myHasUVNodes)
+ myUVNodes.Resize (1, theNbNodes, Standard_True);
+ if (HasNormals())
+ myNormals.Resize (1, theNbNodes, Standard_True);
}
-
- myNormals->ChangeValue (theIndex * 3 - 2) = (Standard_ShortReal) theNormal.X();
- myNormals->ChangeValue (theIndex * 3 - 1) = (Standard_ShortReal) theNormal.Y();
- myNormals->ChangeValue (theIndex * 3) = (Standard_ShortReal) theNormal.Z();
}
-//=======================================================================
-//function : Normal
-//purpose :
-//=======================================================================
+// =======================================================================
+// function : ResizeTriangles
+// purpose :
+// =======================================================================
-gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
+void Poly_Triangulation::ResizeTriangles (const Standard_Integer theNbTriangles)
{
- if (myNormals.IsNull() || theIndex < 1 || theIndex > myNodes.Size())
- {
- throw Standard_NullObject ("Poly_Triangulation::Normal : empty array or index out of range");
- }
-
- gp_Dir N(myNormals->Value(theIndex * 3 - 2),
- myNormals->Value(theIndex * 3 - 1),
- myNormals->Value(theIndex * 3));
-
- return N;
+ if (theNbTriangles > 0)
+ myTriangles.Resize (1, theNbTriangles, Standard_True);
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
+
void Poly_Triangulation::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
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 <Bnd_Box.hxx>
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Integer.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <TShort_HArray1OfShortReal.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Boolean.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TShort_Array1OfShortReal.hxx>
-class Standard_DomainError;
-class Standard_NullObject;
-
-
-class Poly_Triangulation;
-DEFINE_STANDARD_HANDLE(Poly_Triangulation, Standard_Transient)
-
-//! Provides a triangulation for a surface, a set of surfaces, or
-//! more generally a shape.
-//! A triangulation consists of an approximate representation
-//! of the actual shape, using a collection of points and
-//! triangles. The points are located on the surface. The
-//! edges of the triangles connect adjacent points with a
+
+typedef NCollection_Vec3 <Standard_ShortReal> Vec3f;
+
+//! Provides a triangulation for a surface, a set of surfaces, or more generally a shape.
+//! A triangulation consists of an approximate representation of the actual shape, using a collection of points and triangles.
+//! The points are located on the surface. The edges of the triangles connect adjacent points with a
//! straight line that approximates the true curve on the surface.
//! A triangulation comprises:
//! - A table of 3D nodes (3D points on the surface).
-//! - A table of triangles. Each triangle (Poly_Triangle
-//! object) comprises a triplet of indices in the table of 3D
-//! nodes specific to the triangulation.
-//! - A table of 2D nodes (2D points), parallel to the table of
-//! 3D nodes. This table is optional. If it exists, the
-//! coordinates of a 2D point are the (u, v) parameters
-//! of the corresponding 3D point on the surface
-//! approximated by the triangulation.
-//! - A deflection (optional), which maximizes the distance
-//! from a point on the surface to the corresponding point
-//! on its approximate triangulation.
-//! In many cases, algorithms do not need to work with the
-//! exact representation of a surface. A triangular
-//! representation induces simpler and more robust adjusting,
-//! faster performances, and the results are as good.
-//! This is a Transient class.
+//! - A table of triangles. Each triangle (Poly_Triangle object) comprises a triplet of indices in the table of 3D
+//! nodes specific to the triangulation.
+//! - A table of 2D nodes (2D points), parallel to the table of 3D nodes. This table is optional.
+//! If it exists, the coordinates of a 2D point are the (u, v) parameters of the corresponding 3D point on the surface approximated by the triangulation.
+//! - A deflection (optional), which maximizes the distance from a point on the surface to the corresponding point on its approximate triangulation.
+//! In many cases, algorithms do not need to work with the exact representation of a surface.
+//! A triangular representation induces simpler and more robust adjusting, faster performances, and the results are as good.
class Poly_Triangulation : public Standard_Transient
{
//! triangles. Here the UVNodes flag indicates whether
//! 2D nodes will be associated with 3D ones, (i.e. to
//! enable a 2D representation).
- Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean UVNodes);
+ Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes, const Standard_Integer nbTriangles, const Standard_Boolean hasUVNodes);
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized without a triangle or a node,
//! Here the hasNormals flag indicates whether normals will be given and associated with nodes.
Standard_EXPORT Poly_Triangulation(const Standard_Integer nbNodes,
const Standard_Integer nbTriangles,
- const Standard_Boolean UVNodes,
+ const Standard_Boolean hasUVNodes,
const Standard_Boolean hasNormals);
//! Constructs a triangulation from a set of triangles. The
Standard_EXPORT Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation);
//! Returns the deflection of this triangulation.
- Standard_Real Deflection() const { return myDeflection; }
+ Standard_Real Deflection() const {
+ return myDeflection;
+ }
//! Sets the deflection of this triangulation to theDeflection.
//! See more on deflection in Polygon2D
- Standard_EXPORT void Deflection (const Standard_Real theDeflection);
+ void Deflection (const Standard_Real theDeflection) {
+ myDeflection = theDeflection;
+ }
//! Deallocates the UV nodes.
Standard_EXPORT void RemoveUVNodes();
//! Returns TRUE if triangulation has some geometry.
- virtual Standard_Boolean HasGeometry() const { return !myNodes.IsEmpty() && !myTriangles.IsEmpty(); }
+ virtual Standard_Boolean HasGeometry() const {
+ return !myNodes.IsEmpty() && !myTriangles.IsEmpty();
+ }
//! Returns the number of nodes for this triangulation.
- Standard_Integer NbNodes() const { return myNodes.Length(); }
+ Standard_Integer NbNodes() const {
+ return myNodes.Size();
+ }
//! Returns the number of triangles for this triangulation.
- Standard_Integer NbTriangles() const { return myTriangles.Length(); }
+ Standard_Integer NbTriangles() const {
+ return myTriangles.Size();
+ }
- //! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
- Standard_Boolean HasUVNodes() const { return !myUVNodes.IsNull(); }
+ //! Sets a node coordinates.
+ void SetNode (const Standard_Integer theIndex,
+ const gp_Pnt& thePnt)
+ {
+ myNodes.SetValue (theIndex, thePnt);
+ }
- //! Returns the table of 3D nodes (3D points) for this triangulation.
- const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
+ //! Returns a node at the given index.
+ const gp_Pnt& Node (const Standard_Integer theIndex) const {
+ return myNodes.Value (theIndex);
+ }
+
+ //! Give access to the node at the given index.
+ gp_Pnt& ChangeNode (const Standard_Integer theIndex) {
+ return myNodes.ChangeValue (theIndex);
+ }
- //! Returns the table of 3D nodes (3D points) for this triangulation.
- //! The returned array is
- //! shared. Therefore if the table is selected by reference, you
- //! can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
+ //! Returns Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
+ Standard_Boolean HasUVNodes() const {
+ return myHasUVNodes;
+ }
- //! Returns node at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
- Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
+ //! Sets an UV-node coordinates.
+ void SetUVNode (const Standard_Integer theIndex,
+ const gp_Pnt2d& thePnt)
+ {
+ myUVNodes.SetValue (theIndex, thePnt);
+ }
- //! Give access to the node at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
- Standard_EXPORT gp_Pnt& ChangeNode (const Standard_Integer theIndex);
-
- //! Returns the table of 2D nodes (2D points) associated with
- //! each 3D node of this triangulation.
- //! The function HasUVNodes checks if 2D nodes
- //! are associated with the 3D nodes of this triangulation.
- //! Const reference on the 2d nodes values.
- const TColgp_Array1OfPnt2d& UVNodes() const { return myUVNodes->Array1(); }
-
- //! Returns the table of 2D nodes (2D points) associated with
- //! each 3D node of this triangulation.
- //! Function ChangeUVNodes shares the returned array.
- //! Therefore if the table is selected by reference,
- //! you can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- TColgp_Array1OfPnt2d& ChangeUVNodes() { return myUVNodes->ChangeArray1(); }
-
- //! Returns UVNode at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
- Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
+ //! Returns UV-node at the given index.
+ const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const {
+ return myUVNodes.Value (theIndex);
+ }
//! Give access to the UVNode at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
- Standard_EXPORT gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex);
-
- //! Returns the table of triangles for this triangulation.
- const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
+ gp_Pnt2d& ChangeUVNode (const Standard_Integer theIndex) {
+ return myUVNodes.ChangeValue (theIndex);
+ }
- //! Returns the table of triangles for this triangulation.
- //! Function ChangeUVNodes shares the returned array.
- //! Therefore if the table is selected by reference,
- //! you can, by simply modifying it, directly modify the data
- //! structure of this triangulation.
- Poly_Array1OfTriangle& ChangeTriangles() { return myTriangles; }
+ //! Sets a triangle.
+ void SetTriangle (const Standard_Integer theIndex,
+ const Poly_Triangle& theTriangle)
+ {
+ myTriangles.SetValue (theIndex, theTriangle);
+ }
//! Returns triangle at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
- Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
+ const Poly_Triangle& Triangle (const Standard_Integer theIndex) const {
+ return myTriangles.Value (theIndex);
+ }
//! Give access to the triangle at the given index.
- //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
- Standard_EXPORT Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex);
-
- //! Sets the table of node normals.
- //! raises exception if length of theNormals != 3*NbNodes
- Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
+ //! Raises an exception if theIndex is less than 1 or greater than number of triangles.
+ Poly_Triangle& ChangeTriangle (const Standard_Integer theIndex) {
+ return myTriangles.ChangeValue (theIndex);
+ }
- //! Returns the table of node normals.
- Standard_EXPORT const TShort_Array1OfShortReal& Normals() const;
+ //! Returns Standard_True if nodal normals are defined.
+ Standard_Boolean HasNormals() const {
+ return !myNormals.IsEmpty() && myNormals.Length() == NbNodes();
+ }
- //! Gives access to the table of node normals.
- Standard_EXPORT TShort_Array1OfShortReal& ChangeNormals();
+ //! Changes normal at the given index.
+ void SetNormal (const Standard_Integer theIndex,
+ const Vec3f& theNormal)
+ {
+ // If an array for normals is not allocated yet, do it now.
+ if (myNormals.IsEmpty())
+ myNormals.Resize (1, myNodes.Size(), Standard_False);
- //! Returns Standard_True if nodal normals are defined.
- Standard_EXPORT Standard_Boolean HasNormals() const;
+ // Set a normal.
+ myNormals.ChangeValue (theIndex) = theNormal;
+ }
- //! @return normal at the given index.
- //! Raises Standard_OutOfRange exception.
- Standard_EXPORT gp_Dir Normal (const Standard_Integer theIndex) const;
+ //! Changes normal at the given index.
+ void SetNormal (const Standard_Integer theIndex,
+ const gp_XYZ& theNormal)
+ {
+ SetNormal (theIndex, static_cast<Standard_ShortReal>(theNormal.X()),
+ static_cast<Standard_ShortReal>(theNormal.Y()),
+ static_cast<Standard_ShortReal>(theNormal.Z()));
+ }
//! Changes normal at the given index.
- //! Raises Standard_OutOfRange exception.
- Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
- const gp_Dir& theNormal);
+ void SetNormal (const Standard_Integer theIndex,
+ const Standard_ShortReal theNormalX,
+ const Standard_ShortReal theNormalY,
+ const Standard_ShortReal theNormalZ)
+ {
+ SetNormal (theIndex, Vec3f (theNormalX, theNormalY, theNormalZ));
+ }
+
+ //! Returns normal at the given index.
+ const Vec3f& Normal (const Standard_Integer theIndex) const {
+ return myNormals (theIndex);
+ }
+
+ //! Returns normal at the given index.
+ void Normal (const Standard_Integer theIndex,
+ gp_XYZ& theNormal) const
+ {
+ const Vec3f& aCoords = Normal (theIndex);
+ theNormal.SetCoord (aCoords.x(), aCoords.y(), aCoords.z());
+ }
+
+ //! Sets the table of node normals.
+ //! Raises exception if length of theNormals != 3 * NbNodes
+ Standard_DEPRECATED("Deprecated method SetNormals() should be replaced \
+ by method with array as object instead of handle. \
+ Array of floats should be replaced by vector of normals")
+ Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
+
+ //! An advanced method resizing an internal array of nodes.
+ //! The old nodes are copied into the new array.
+ //! UV-nodes as well as normals, if exist are extended and copied too.
+ Standard_EXPORT void ResizeNodes (const Standard_Integer theNbNodes);
+
+ //! An advanced method resizing an internal array of triangles.
+ //! The old triangles are copied into the new array.
+ Standard_EXPORT void ResizeTriangles (const Standard_Integer theNbTriangles);
//! Returns cached min - max range of triangulation data,
//! which is VOID by default (e.g, no cached information).
protected:
- Bnd_Box* myCachedMinMax;
- Standard_Real myDeflection;
- TColgp_Array1OfPnt myNodes;
- Handle(TColgp_HArray1OfPnt2d) myUVNodes;
- Poly_Array1OfTriangle myTriangles;
- Handle(TShort_HArray1OfShortReal) myNormals;
-
+ Bnd_Box* myCachedMinMax;
+ Standard_Real myDeflection;
+ Standard_Boolean myHasUVNodes;
+ TColgp_Array1OfPnt myNodes;
+ TColgp_Array1OfPnt2d myUVNodes;
+ Poly_Array1OfTriangle myTriangles;
+ NCollection_Array1<Vec3f> myNormals;
};
#endif // _Poly_Triangulation_HeaderFile
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 );
+ const Vec3f& aVec = aT->Normal ( i+1 );
+ gp_Dir aNormal (aVec.x(), aVec.y(), aVec.z());
if (aNormal.X() == 0 && aNormal.Y() == 0 && aNormal.Z() == 1)
{
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
if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
{
myCoordSysConverter.TransformNormal (*aVec3);
- setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (aVec3->x(), aVec3->y(), aVec3->z()));
+ setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_XYZ (aVec3->x(), aVec3->y(), aVec3->z()));
}
else
{
- setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
+ setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
}
}
}
}
if (aVec3->SquareModulus() >= THE_NORMAL_PREC2)
{
- setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (aVec3->x(), aVec3->y(), aVec3->z()));
+ setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_XYZ (aVec3->x(), aVec3->y(), aVec3->z()));
}
else
{
- setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp_Dir (0.0, 0.0, 1.0));
+ setNodeNormal (THE_LOWER_NODE_INDEX + aVertIter, gp::DZ().XYZ());
}
}
}
//! Resize array of position nodes to specified size.
virtual bool setNbPositionNodes (Standard_Integer theNbNodes)
{
- if (theNbNodes <= 0)
- {
- return false;
- }
- myTriangulation->ChangeNodes().Resize (1, theNbNodes, false);
- return true;
+ myTriangulation->ResizeNodes (theNbNodes);
+ return theNbNodes > 0;
}
//! Set node position.
}
//! Resize array of UV nodes to specified size.
- virtual bool setNbUVNodes (Standard_Integer theNbNodes)
+ virtual bool setNbUVNodes (Standard_Integer /*theNbNodes*/)
{
- if (theNbNodes <= 0
- || myTriangulation->NbNodes() != theNbNodes)
- {
- return false;
- }
- myTriangulation->ChangeUVNodes().Resize (1, theNbNodes, false);
+ // Resizing of the array of nodes extends an array of UV-nodes too.
return true;
}
}
//! Resize array of nodes normals to specified size.
- virtual bool setNbNormalNodes (Standard_Integer theNbNodes)
+ virtual bool setNbNormalNodes (Standard_Integer /*theNbNodes*/)
{
- if (theNbNodes <= 0
- || myTriangulation->NbNodes() != theNbNodes)
- {
- return false;
- }
- myTriangulation->SetNormals (new TShort_HArray1OfShortReal (1, theNbNodes * 3));
+ // Resizing of the array of nodes extends an array of normals too.
return true;
}
//! @param theIndex node index starting from 1
//! @param theNormal node normal
virtual void setNodeNormal (Standard_Integer theIndex,
- const gp_Dir& theNormal)
+ const gp_XYZ& theNormal)
{
myTriangulation->SetNormal (theIndex, theNormal);
}
//! Resize array of triangles to specified size.
virtual bool setNbTriangles (Standard_Integer theNbTris)
{
- if (theNbTris >= 1)
- {
- myTriangulation->ChangeTriangles().Resize (1, theNbTris, false);
- return true;
- }
- return false;
+ myTriangulation->ResizeTriangles (theNbTris);
+ return theNbTris > 0;
}
//! Add triangle element.
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());
- }
- }
+ const Vec3f& aVec = myPolyTriang->Normal (theNode);
+ aNormal.SetCoord (aVec.x(), aVec.y(), aVec.z());
+ if (aNormal.XYZ().Modulus() < Precision::Confusion())
+ aNormal = gp::DZ();
+ }
else if (myHasNormals
- && myNodeUVs != NULL)
+ && myPolyTriang->HasUVNodes())
{
- const gp_XY& anUV = myNodeUVs->Value (theNode).XY();
+ const gp_XY& anUV = myPolyTriang->UVNode (theNode).XY();
mySLTool.SetParameters (anUV.X(), anUV.Y());
if (mySLTool.IsNormalDefined())
{
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
}
if (hasNormals)
{
- const Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, myNodes.Length() * 3);
- Standard_ShortReal* aNormArr = &aNormals->ChangeFirst();
- Standard_Integer aNbInvalid = 0;
for (Standard_Integer aNodeIter = 0; aNodeIter < myNodes.Size(); ++aNodeIter)
{
const Graphic3d_Vec3& aNorm = myNormals.Value (aNodeIter);
const float aMod2 = aNorm.SquareModulus();
if (aMod2 > 0.001f)
{
- aNormArr[aNodeIter * 3 + 0] = aNorm.x();
- aNormArr[aNodeIter * 3 + 1] = aNorm.y();
- aNormArr[aNodeIter * 3 + 2] = aNorm.z();
+ aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
}
else
{
- ++aNbInvalid;
- aNormArr[aNodeIter * 3 + 0] = 0.0f;
- aNormArr[aNodeIter * 3 + 1] = 0.0f;
- aNormArr[aNodeIter * 3 + 2] = 1.0f;
+ aPoly->SetNormal (aNodeIter + 1, 0.0f, 0.0f, 1.0f);
}
- }
- if (aNbInvalid != myNodes.Length())
- {
- aPoly->SetNormals (aNormals);
+ aPoly->SetNormal (aNodeIter + 1, aNorm.x(), aNorm.y(), aNorm.z());
}
}
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)
const Standard_Real aModMax = eqPlan.Modulus();
aNorm = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
}
-
- const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 3;
- aNormals->SetValue (anId + 1, (Standard_ShortReal )aNorm.X());
- aNormals->SetValue (anId + 2, (Standard_ShortReal )aNorm.Y());
- aNormals->SetValue (anId + 3, (Standard_ShortReal )aNorm.Z());
+ theTris->SetNormal (aNodeIter, static_cast<Standard_ShortReal>(aNorm.X()),
+ static_cast<Standard_ShortReal>(aNorm.Y()),
+ static_cast<Standard_ShortReal>(aNorm.Z()));
}
- theTris->SetNormals (aNormals);
}
//=======================================================================
ComputeNormals (theFace, aPolyTri, thePolyConnect);
}
- const TColgp_Array1OfPnt& aNodes = aPolyTri->Nodes();
- const TShort_Array1OfShortReal& aNormals = aPolyTri->Normals();
- const Standard_ShortReal* aNormArr = &aNormals.First();
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
- const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
- const gp_Dir aNorm (aNormArr[anId + 0],
- aNormArr[anId + 1],
- aNormArr[anId + 2]);
- theNormals (aNodeIter) = aNorm;
+ const Vec3f& aNormal = aPolyTri->Normal (aNodeIter);
+ theNormals.ChangeValue (aNodeIter).SetCoord (aNormal.x(), aNormal.y(), aNormal.z());
}
if (theFace.Orientation() == TopAbs_REVERSED)
{
- for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
+ for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
theNormals.ChangeValue (aNodeIter).Reverse();
}
{
// 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_Presentation.cxx
TDataXtd_Shape.cxx
TDataXtd_Shape.hxx
+TDataXtd_SurfacicMesh.cxx
+TDataXtd_SurfacicMesh.hxx
TDataXtd_Triangulation.cxx
TDataXtd_Triangulation.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());
}
//=======================================================================
myTriangulation->ChangeTriangle(theIndex) = theTriangle;
}
-//=======================================================================
-//function : SetNormals
-//purpose : Sets the table of node normals.
-// Raises exception if length of theNormals = 3 * NbNodes
-//=======================================================================
-void TDataXtd_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals)
-{
- Backup();
- myTriangulation->SetNormals(theNormals);
-}
-
//=======================================================================
//function : SetNormal
//purpose : Changes normal at the given index.
// Raises Standard_OutOfRange exception.
//=======================================================================
void TDataXtd_Triangulation::SetNormal (const Standard_Integer theIndex,
- const gp_Dir& theNormal)
+ const gp_Dir& theNormal)
{
Backup();
- myTriangulation->SetNormal(theIndex, theNormal);
+ myTriangulation->SetNormal (theIndex, theNormal.XYZ());
}
//=======================================================================
//=======================================================================
const gp_Dir TDataXtd_Triangulation::Normal (const Standard_Integer theIndex) const
{
- return myTriangulation->Normal(theIndex);
+ const Vec3f& aVec = myTriangulation->Normal (theIndex);
+ gp_Dir aDir (aVec.x(), aVec.y(), aVec.z());
+ return aDir;
}
//=======================================================================
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT void SetTriangle (const Standard_Integer theIndex, const Poly_Triangle& theTriangle);
- //! Sets the table of node normals.
- //! Raises exception if length of theNormals != 3 * NbNodes
- Standard_EXPORT void SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals);
-
//! Changes normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
}
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++;
}
}
Poly_Connect* pc = new Poly_Connect(polyTriangulation);
- Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
-
Standard_Integer index[3];
Standard_Real Tol = Precision::Confusion();
gp_Dir Nor;
- for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
+ for (i = 1; i <= polyTriangulation->NbNodes(); i++) {
gp_XYZ eqPlan(0, 0, 0);
for ( pc->Initialize(i); pc->More(); pc->Next()) {
- pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
- gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
- gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
+ polyTriangulation->Triangle (pc->Value()).Get (index[0], index[1], index[2]);
+ gp_XYZ v1 (polyTriangulation->Node (index[1]).Coord() - polyTriangulation->Node (index[0]).Coord());
+ gp_XYZ v2 (polyTriangulation->Node (index[2]).Coord() - polyTriangulation->Node (index[1]).Coord());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
Nor = gp_Dir(eqPlan);
else
Nor = gp_Dir(0., 0., 1.);
-
- Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
- Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
- Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
- Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
+
+ polyTriangulation->SetNormal (i, Nor.XYZ());
}
delete pc;
- polyTriangulation->SetNormals(Normals);
-
return polyTriangulation;
}
= 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();
}
else {
// Copy the normals. Currently only normals-per-vertex are supported.
- Handle(TShort_HArray1OfShortReal) Normals =
- new TShort_HArray1OfShortReal(1, 3 * nbNodes);
if (myNormalPerVertex) {
if (myArrNormalInd == 0L) {
for (i = 0; i < nbNodes; i++)
{
- Standard_Integer anIdx = i * 3 + 1;
- const gp_XYZ& aNormal = myNormals->Normal(i);
- Normals->SetValue(anIdx + 0, Standard_ShortReal(aNormal.X()));
- Normals->SetValue(anIdx + 1, Standard_ShortReal(aNormal.Y()));
- Normals->SetValue(anIdx + 2, Standard_ShortReal(aNormal.Z()));
+ const gp_XYZ& aNormal = myNormals->Normal (i);
+ aTriangulation->SetNormal (i + 1, aNormal);
}
}
else
int nbn = IndiceNormals(i, arrIndice);
for (Standard_Integer j = 0; j < nbn; j++) {
const gp_XYZ& aNormal = myNormals->Normal(arrIndice[j]);
- Standard_Integer anInd = mapIdId(anArrNodes[j]) * 3 + 1;
- Normals->SetValue(anInd + 0, Standard_ShortReal(aNormal.X()));
- Normals->SetValue(anInd + 1, Standard_ShortReal(aNormal.Y()));
- Normals->SetValue(anInd + 2, Standard_ShortReal(aNormal.Z()));
+ aTriangulation->SetNormal (mapIdId (anArrNodes[j]) + 1, aNormal);
}
}
}
else {
//TODO ..
}
- aTriangulation->SetNormals(Normals);
}
myIsModified = Standard_False;
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));
+ const Vec3f& aVec = theTri->Normal (i + 1);
+ gp_XYZ aNormal (aVec.x(), aVec.y(), aVec.z());
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();
aNormal.SetY(0.);
if (aNormal.Z()*aNormal.Z() < aConf2)
aNormal.SetZ(0.);
- arrVec[i] = aNormal.XYZ();
-
- Standard_Integer j = i * 3;
- Normals->SetValue(j + 1, (Standard_ShortReal)aNormal.X());
- Normals->SetValue(j + 2, (Standard_ShortReal)aNormal.Y());
- Normals->SetValue(j + 3, (Standard_ShortReal)aNormal.Z());
+ arrVec[i] = aNormal.XYZ();
+ theTri->SetNormal (i + 1, aNormal.XYZ());
}
-
- theTri->SetNormals(Normals);
const Handle(VrmlData_Normal) aNormalNode =
new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
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_PositionDriver.cxx
XmlMDataXtd_PresentationDriver.hxx
XmlMDataXtd_PresentationDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.cxx
+XmlMDataXtd_SurfacicMeshDriver.hxx
XmlMDataXtd_TriangulationDriver.cxx
XmlMDataXtd_TriangulationDriver.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 += 3 * 5 * aMesh->NbTriangles(); // space for triangles (3 integers of 5 symbols)
+ aSize += 4 * 5 * aMesh->NbQuads(); // space for quadrangles (4 integers of 5 symbols)
+ aSize *= 2; // just in case :-)
+ if (!aSize)
+ aSize = 1;
+
+ // Allocate a string stream.
+ LDOM_OSStream aStream (aSize);
+
+ // Write the mesh.
+ BRepTools_ShapeSet aShapeSet;
+ TColStd_IndexedMapOfTransient aMeshes;
+ aMeshes.Add (aMesh);
+ aShapeSet.WriteMeshes (aStream, aMeshes, Standard_True/*compact*/);
+ aStream << std::ends;
+
+ Standard_Character* aDump = (Standard_Character*) aStream.str(); // copying! Don't forget to delete it.
+ XmlObjMgt::SetStringValue (theTarget, aDump, Standard_True);
+ delete[] aDump;
+ }
+}
--- /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"