1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

14 Commits

Author SHA1 Message Date
ssv
91849d81a1 Fixed incorrect range in initialization of a collection of elements 2015-08-25 11:14:55 +03:00
aml
af9ac4846b 0026493: BRepProj_Projection failed to project a wire on a shell
Cylindrical projection moved from old boolean operations to the new BOP.

Test case for issue CR26493

Conflicts:
	src/BRepProj/BRepProj_Projection.cxx
	tests/boolean/gdml_private/O1
2015-08-14 17:06:45 +03:00
aml
67961eb8ac 026464: BRepOffset_MakeOffset does not provide valid output
Handling of degenerated case improved.

Test-case for issue #26464
2015-08-14 17:03:19 +03:00
mkv
0515a4e4f6 0026442: Access violation in BRepOffset_MakeOffset
Test cases for issue CR26442
2015-08-14 17:02:43 +03:00
aml
bb03b99f97 0026418: Unjustified limitation on tolerance of a input shape in BRepOffset_MakeOffset
Performance improvements and regression elimination.
Handling of degenerated case added.

Update of test-case offset faces_type_a A2 according to the new behavior
Test-case for issue #26418
2015-08-14 17:01:50 +03:00
aml
208b7c3b3a 0026356: Wrong result done by projection algorithm
Changed internal one dimension search algorithm in case of fast changing curve.

Test-case for issue #26356
2015-08-14 17:00:50 +03:00
nbv
a5a597ad37 0026197: Incomplete intersection curve
Correct the algorithm to get right Start point for extension of the walking line.

Test case for issue CR26197

Correction of test case bugs/modalg_6/bug26197
2015-08-14 16:57:14 +03:00
azv
b055c88f4b 0026458: BRepBuilderAPI_Copy does not copy mesh structure
* The possibility to copy mesh is implemented. It may be enabled by copyMesh key, by default it is disabled.
* Poly_Triangulation::Copy() method is added
* Poly_Mesh::Copy() method is added

Conflicts:
	src/Poly/Poly_Triangulation.cxx
	src/Poly/Poly_Triangulation.hxx
2015-08-14 16:53:42 +03:00
ssv
8acdc1a772 Added copy ctor in Poly_Triangulation, Poly_Mesh conversion ctor optimized 2015-07-28 12:36:34 +03:00
ssv
2967f26f6e Added one more constructor accepting Poly_Triangulation. Thus it is now possible to create Poly_Mesh around Poly_Triangulation (copy of triangulation will be prepared). 2015-07-09 12:07:18 +03:00
ssv
62317aefee New Element() method was added at the level of Poly_Mesh class. This method is more convenient than direct accessing of Poly_Element structures with low-level treatment of its internal triangles. Moreover, the new method encapsulates the conventional order of nodes in the pair of triangles composing a quad. 2015-07-02 14:25:30 +03:00
ssv
f3a397c320 Get() method of Poly_Element was made const 2015-07-02 13:27:38 +03:00
ssv
fa9fbda259 API has been changed to be more convenient (indices of nodes are passed) 2015-07-01 15:04:26 +03:00
dbv
6c1f47fd0f 0025936: Reusable data structure for 2D tesselation (3- and 4-nodal mesh)
Replaced all arrays in Poly_Triangulation to NCollection_Vector.
Poly_Triangulation now does not provide access to whole arrays stored inside it. Only by one element.
New classes Poly_Element, Poly_Mesh.
2015-04-29 11:15:41 +03:00
83 changed files with 1725 additions and 908 deletions

View File

@@ -50,9 +50,6 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
switch (aMode)
{
case 0:
const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes(); //Nodes
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles(); //Triangle
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
Standard_Boolean hasVColors = (myFlagColor == 1);
@@ -62,29 +59,25 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
Standard_Integer i;
Standard_Integer j;
Standard_Real ambient = aspect->FrontMaterial().Ambient();
if (hasVNormals)
{
const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
if (hasVColors)
{
const TColStd_Array1OfInteger& colors = myColor->Array1();
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
j = (i - nodes.Lower()) * 3;
anArray->AddVertex(nodes(i), AttenuateColor(colors(i), ambient));
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
anArray->AddVertex(myTriangulation->Node (i), AttenuateColor(colors(i), ambient));
anArray->SetVertexNormal(i, myTriangulation->Normal (i));
}
}
else // !hasVColors
{
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
j = (i - nodes.Lower()) * 3;
anArray->AddVertex(nodes(i));
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
anArray->AddVertex(myTriangulation->Node (i));
anArray->SetVertexNormal(i, myTriangulation->Normal (i));
}
}
}
@@ -93,23 +86,23 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
if (hasVColors)
{
const TColStd_Array1OfInteger& colors = myColor->Array1();
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
anArray->AddVertex(nodes(i), AttenuateColor(colors(i), ambient));
anArray->AddVertex(myTriangulation->Node (i), AttenuateColor(colors(i), ambient));
}
}
else // !hasVColors
{
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
for ( i = 1; i <= myTriangulation->NbNodes(); i++ )
{
anArray->AddVertex(nodes(i));
anArray->AddVertex(myTriangulation->Node (i));
}
}
}
Standard_Integer indexTriangle[3] = {0,0,0};
for ( i = triangles.Lower(); i<= triangles.Upper(); i++ ) {
triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
for ( i = 1; i<= myTriangulation->NbTriangles(); i++ ) {
myTriangulation->Triangle (i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
anArray->AddEdge(indexTriangle[0]);
anArray->AddEdge(indexTriangle[1]);
anArray->AddEdge(indexTriangle[2]);

View File

@@ -57,10 +57,9 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
if (useTriangulation && !T.IsNull())
{
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) B.Add(Nodes(i));
else B.Add(Nodes(i).Transformed(l));
if (l.IsIdentity()) B.Add(T->Node (i));
else B.Add(T->Node (i).Transformed(l));
}
// B.Enlarge(T->Deflection());
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
@@ -118,12 +117,11 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
if (useTriangulation && !Poly.IsNull())
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
for (i = 1; i <= nbNodes; i++)
{
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
else B.Add(Nodes(Indices(i)).Transformed(l));
if (l.IsIdentity()) B.Add(T->Node (Indices(i)));
else B.Add(T->Node (Indices(i)).Transformed(l));
}
// B.Enlarge(T->Deflection());
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));

View File

@@ -37,7 +37,7 @@ is
returns Copy from BRepBuilderAPI;
Create(S: Shape from TopoDS; copyGeom: Boolean = Standard_True)
Create(S: Shape from TopoDS; copyGeom: Boolean = Standard_True; copyMesh: Boolean = Standard_False)
---Purpose: Constructs a copy framework and copies the shape S.
-- Use the function Shape to access the result.
-- If copyGeom is False, only topological objects will be copied, while
@@ -47,7 +47,7 @@ is
returns Copy from BRepBuilderAPI;
Perform(me: in out; S: Shape from TopoDS; copyGeom: Boolean = Standard_True)
Perform(me: in out; S: Shape from TopoDS; copyGeom: Boolean = Standard_True; copyMesh: Boolean = Standard_False)
---Purpose: Copies the shape S.
-- Use the function Shape to access the result.
-- If copyGeom is False, only topological objects will be copied, while

View File

@@ -23,13 +23,16 @@
#include <BRep_Tool.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Pnt.hxx>
#include <Poly_Triangulation.hxx>
//! Tool class implementing necessary functionality for copying geometry
class BRepBuilderAPI_Copy_Modification : public BRepTools_Modification
{
public:
BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom)
: myCopyGeom(copyGeom)
BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom,
const Standard_Boolean copyMesh = Standard_False)
: myCopyGeom(copyGeom),
myCopyMesh(copyMesh)
{
}
@@ -49,6 +52,22 @@ public:
return Standard_True;
}
//! Returns true to indicate the need to copy triangulation;
//! copies it if required
Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T)
{
TopLoc_Location L;
T = BRep_Tool::Triangulation(F, L);
if (!T.IsNull() && myCopyMesh)
{
T = T->Copy();
return Standard_True;
}
return Standard_False;
}
//! Returns true to indicate the need to copy edge;
//! copies curves if requested
Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C,
@@ -117,6 +136,7 @@ public:
private:
Standard_Boolean myCopyGeom;
Standard_Boolean myCopyMesh;
};
DEFINE_STANDARD_HANDLE(BRepBuilderAPI_Copy_Modification, BRepTools_Modification)
@@ -140,9 +160,9 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
//purpose :
//=======================================================================
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom)
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
{
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom);
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
DoModif(S);
}
@@ -152,9 +172,9 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_B
//purpose :
//=======================================================================
void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom)
void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
{
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom);
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
NotDone(); // on force la copie si on vient deja d`en faire une
DoModif(S);
}

View File

@@ -606,7 +606,6 @@ BRepCheck_Status BRepCheck_Edge::
aCR->PolygonOnTriangulation2() :
aCR->PolygonOnTriangulation();
const TColStd_Array1OfInteger& anIndices = aPOnTriag->Nodes();
const TColgp_Array1OfPnt& Nodes = aTriang->Nodes();
const Standard_Integer aNbNodes = anIndices.Length();
const Standard_Real aTol = aPOnTriag->Deflection() +
@@ -619,7 +618,7 @@ BRepCheck_Status BRepCheck_Edge::
{
const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
const gp_Pnt aPE(aBC.Value(aParam)),
aPT(Nodes(anIndices(i)).Transformed(aLL));
aPT(aTriang->Node (anIndices(i)).Transformed(aLL));
const Standard_Real aSQDist = aPE.SquareDistance(aPT);
if(aSQDist > aTol*aTol)
@@ -638,9 +637,9 @@ BRepCheck_Status BRepCheck_Edge::
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);

View File

@@ -75,12 +75,11 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
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));
}
}
}
@@ -96,12 +95,11 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoD
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
{
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
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));
}
}
}

View File

@@ -186,7 +186,7 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
for (Standard_Integer aVertIdx = 1; aVertIdx <= aTriangulation->NbNodes(); ++aVertIdx)
{
gp_Pnt aVertex = aTriangulation->Nodes().Value (aVertIdx);
gp_Pnt aVertex = aTriangulation->Node (aVertIdx);
aVertex.Transform (aLocation.Transformation());
@@ -194,8 +194,8 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
aVertex.Y(),
aVertex.Z()));
const Standard_Real aU = aTriangulation->UVNodes().Value (aVertIdx).X();
const Standard_Real aV = aTriangulation->UVNodes().Value (aVertIdx).Y();
const Standard_Real aU = aTriangulation->UVNode (aVertIdx).X();
const Standard_Real aV = aTriangulation->UVNode (aVertIdx).Y();
myVertUVArray.push_back (BVH_Vec2d (aU, aV));
}
@@ -206,9 +206,9 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
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,

View File

@@ -39,7 +39,7 @@
#include <BRepMesh_PairOfIndex.hxx>
#include <BRepMesh_Circle.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
@@ -52,7 +52,6 @@ class Handle_BRepMesh_FaceAttribute;
class BRepMesh_VertexInspector;
class BRepMesh_CircleInspector;
class BRepMesh_Classifier;
class Poly_Triangulation;
class BRepMesh_VertexTool;
namespace BRepMesh

View File

@@ -35,7 +35,7 @@ BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor(
const TopLoc_Location& theLocation)
: myProvider(theEdge, theFace, thePolygon->Parameters()),
myPCurve(thePCurve),
myNodes(theTriangulation->Nodes()),
myTriangulation(theTriangulation),
myIndices(thePolygon->Nodes()),
myLoc(theLocation)
{
@@ -51,7 +51,7 @@ void BRepMesh_EdgeTessellationExtractor::Value(
gp_Pnt& thePoint,
gp_Pnt2d& theUV)
{
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);

View File

@@ -22,12 +22,11 @@
#include <BRepMesh_EdgeParameterProvider.hxx>
#include <Handle_Geom2d_Curve.hxx>
#include <Handle_Poly_PolygonOnTriangulation.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TopLoc_Location.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfInteger.hxx>
class Poly_Triangulation;
class Poly_PolygonOnTriangulation;
class TopoDS_Edge;
class TopoDS_Face;
@@ -77,7 +76,7 @@ private:
BRepMesh_EdgeParameterProvider myProvider;
const Handle(Geom2d_Curve)& myPCurve;
const TColgp_Array1OfPnt& myNodes;
Handle(Poly_Triangulation) myTriangulation;
const TColStd_Array1OfInteger& myIndices;
const TopLoc_Location myLoc;
};

View File

@@ -844,15 +844,14 @@ void BRepMesh_FastDiscret::update(
if (aPolygon->Deflection() > 1.1 * theDefEdge)
continue;
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const TColStd_Array1OfInteger& aIndices = aPolygon->Nodes();
Handle(TColStd_HArray1OfReal) aParams = aPolygon->Parameters();
aEAttr.FirstVExtractor = new PolyVExplorer(aEAttr.FirstVertex,
aEAttr.IsSameUV, aEAttr.LastVertex, aIndices(1), aNodes, aLoc);
aEAttr.IsSameUV, aEAttr.LastVertex, aIndices(1), aTriangulation, aLoc);
aEAttr.LastVExtractor = new PolyVExplorer(aEAttr.LastVertex,
aEAttr.IsSameUV, aEAttr.FirstVertex, aIndices(aIndices.Length()), aNodes, aLoc);
aEAttr.IsSameUV, aEAttr.FirstVertex, aIndices(aIndices.Length()), aTriangulation, aLoc);
aEdgeTool = new BRepMesh_EdgeTessellationExtractor(theEdge, theC2d,
aFace, aTriangulation, aPolygon, aLoc);

View File

@@ -236,18 +236,18 @@ private:
const Standard_Boolean isSameUV,
const TopoDS_Vertex& theSameVertex,
const Standard_Integer theVertexIndex,
const TColgp_Array1OfPnt& thePolygon,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLoc)
: TopoDSVExplorer(theVertex, isSameUV, theSameVertex),
myVertexIndex(theVertexIndex),
myPolygon(thePolygon),
myTriangulation(theTriangulation),
myLoc(theLoc)
{
}
virtual gp_Pnt Point() const
{
return BRepMesh_ShapeTool::UseLocation(myPolygon(myVertexIndex), myLoc);
return BRepMesh_ShapeTool::UseLocation(myTriangulation->Node (myVertexIndex), myLoc);
}
private:
@@ -257,9 +257,9 @@ private:
}
private:
Standard_Integer myVertexIndex;
const TColgp_Array1OfPnt& myPolygon;
const TopLoc_Location myLoc;
Standard_Integer myVertexIndex;
Handle(Poly_Triangulation) myTriangulation;
const TopLoc_Location myLoc;
};
//! Structure keeps common parameters of edge

View File

@@ -1411,8 +1411,6 @@ void BRepMesh_FastDiscretFace::commitSurfaceTriangulation()
Handle(Poly_Triangulation) aNewTriangulation =
new Poly_Triangulation(aVerticesNb, aTrianglesNb, Standard_True);
Poly_Array1OfTriangle& aPolyTrianges = aNewTriangulation->ChangeTriangles();
Standard_Integer aTriangeId = 1;
BRepMesh::MapOfInteger::Iterator aTriIt(aTriangles);
for (; aTriIt.More(); aTriIt.Next())
@@ -1426,12 +1424,10 @@ void BRepMesh_FastDiscretFace::commitSurfaceTriangulation()
for (Standard_Integer i = 0; i < 3; ++i)
aNodeId[i] = aVetrexEdgeMap->FindIndex(aNode[i]);
aPolyTrianges(aTriangeId++).Set(aNodeId[0], aNodeId[1], aNodeId[2]);
aNewTriangulation->ChangeTriangle (aTriangeId++).Set(aNodeId[0], aNodeId[1], aNodeId[2]);
}
// Store mesh nodes
TColgp_Array1OfPnt& aNodes = aNewTriangulation->ChangeNodes();
TColgp_Array1OfPnt2d& aNodes2d = aNewTriangulation->ChangeUVNodes();
for (Standard_Integer i = 1; i <= aVerticesNb; ++i)
{
@@ -1439,8 +1435,8 @@ void BRepMesh_FastDiscretFace::commitSurfaceTriangulation()
const BRepMesh_Vertex& aVertex = aStructure->GetNode(aVertexId);
const gp_Pnt& aPoint = myAttribute->GetPoint(aVertex);
aNodes(i) = aPoint;
aNodes2d(i) = aVertex.Coord();
aNewTriangulation->ChangeNode (i) = aPoint;
aNewTriangulation->ChangeUVNode (i) = aVertex.Coord();
}
aNewTriangulation->Deflection(myAttribute->GetDefFace());

View File

@@ -23,7 +23,7 @@
#include <Standard_Transient.hxx>
#include <TopTools_MutexForShapeProvider.hxx>
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_Classifier.hxx>
@@ -36,7 +36,6 @@ class TopTools_DataMapOfShapeReal;
class TopoDS_Vertex;
class BRepAdaptor_HSurface;
class TopoDS_Edge;
class Poly_Triangulation;
class TopLoc_Location;
class gp_XY;
class gp_Pnt2d;

View File

@@ -398,11 +398,10 @@ Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed(
// #25080: check that indices of links forming triangles are in range.
Standard_Boolean isTriangulationConsistent = Standard_True;
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 n[3];
aTriangle.Get(n[0], n[1], n[2]);
for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j)

View File

@@ -21,12 +21,11 @@
#include <TopTools_MapOfShape.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepMesh.hxx>
#include <vector>
class Poly_Triangulation;
class TopoDS_Shape;
class TopoDS_Edge;
class TopoDS_Face;

View File

@@ -205,9 +205,8 @@ void BRepMesh_ShapeTool::AddInFace(
gp_Trsf aTrsf = aLoc.Transformation();
aTrsf.Invert();
TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i)
aNodes(i).Transform(aTrsf);
for (Standard_Integer i = 1; i <= theTriangulation->NbNodes(); ++i)
theTriangulation->ChangeNode (i).Transform(aTrsf);
}
BRep_Builder aBuilder;

View File

@@ -21,7 +21,7 @@
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <BRepMesh_FaceAttribute.hxx>
#include <BRepMesh.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
class TopoDS_Face;
class TopoDS_Edge;

View File

@@ -656,8 +656,6 @@ static void EvalMax(const TopoDS_Shape& S, Standard_Real& Tol)
Standard_Real TolV = BRep_Tool::Tolerance(V);
if (TolV > Tol) Tol = TolV;
}
//Patch
Tol *= 5.;
}
//=======================================================================
@@ -684,10 +682,9 @@ void BRepOffset_MakeOffset::MakeOffsetShape()
// Preanalyse.
// ------------
EvalMax(myShape,myTol);
if (myTol > Abs(myOffset*0.5)) {
Standard_ConstructionError::Raise("BRepOffset_MakeOffset : Tol > Offset");
}
Standard_Real TolAngle = 4*ASin(myTol/Abs(myOffset*0.5));
// There are possible second variant: analytical continuation of arcsin.
Standard_Real TolAngleCoeff = Min(myTol/Abs(myOffset*0.5), 1.0);
Standard_Real TolAngle = 4*ASin(TolAngleCoeff);
myAnalyse.Perform(myShape,TolAngle);
//---------------------------------------------------
// Construction of Offset from preanalysis.

View File

@@ -536,11 +536,29 @@ void BRepOffset_Offset::Init(const TopoDS_Face& Face,
TopTools_SequenceOfShape DegEdges;
TopExp_Explorer Explo(Face, TopAbs_EDGE);
for (; Explo.More(); Explo.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
if (BRep_Tool::Degenerated(anEdge))
DegEdges.Append(anEdge);
}
{
const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
if (BRep_Tool::Degenerated(anEdge))
{
Standard_Real aF, aL;
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface(anEdge, Face, aF, aL);
gp_Pnt2d aFPnt2d = c2d->Value(aF),
aLPnt2d = c2d->Value(aL);
gp_Pnt aFPnt = S->Value(aFPnt2d.X(), aFPnt2d.Y()),
aLPnt = S->Value(aLPnt2d.X(), aLPnt2d.Y());
// aFPnt.SquareDistance(aLPnt) > Precision::SquareConfusion() -
// is a sufficient condition of troubles: non-singular case, but edge is degenerated.
// So, normal handling of degenerated edges is not applicable in case of non-singular point.
if (aFPnt.SquareDistance(aLPnt) < Precision::SquareConfusion())
{
DegEdges.Append(anEdge);
}
}
}
if (!DegEdges.IsEmpty())
{
const Standard_Real TolApex = 1.e-5;
@@ -1639,6 +1657,3 @@ BRepOffset_Status BRepOffset_Offset::Status() const
{
return myStatus;
}

View File

@@ -1163,14 +1163,15 @@ static Handle(Geom2d_Curve) ConcatPCurves(const TopoDS_Edge& E1,
//=======================================================================
static TopoDS_Edge Glue(const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const TopoDS_Vertex& Vfirst,
const TopoDS_Vertex& Vlast,
const Standard_Boolean After,
const TopoDS_Face& F1,
const Standard_Boolean addPCurve1,
const TopoDS_Face& F2,
const Standard_Boolean addPCurve2)
const TopoDS_Edge& E2,
const TopoDS_Vertex& Vfirst,
const TopoDS_Vertex& Vlast,
const Standard_Boolean After,
const TopoDS_Face& F1,
const Standard_Boolean addPCurve1,
const TopoDS_Face& F2,
const Standard_Boolean addPCurve2,
const Standard_Real theGlueTol)
{
Standard_Real Tol = 1.e-7;
GeomAbs_Shape Continuity = GeomAbs_C1;
@@ -1208,7 +1209,7 @@ static TopoDS_Edge Glue(const TopoDS_Edge& E1,
Handle(Geom_TrimmedCurve) TC1 = new Geom_TrimmedCurve( C1, first1, last1 );
Handle(Geom_TrimmedCurve) TC2 = new Geom_TrimmedCurve( C2, first2, last2 );
GeomConvert_CompCurveToBSplineCurve Concat( TC1 );
Concat.Add( TC2, Precision::Confusion(), After );
Concat.Add( TC2, theGlueTol, After );
newCurve = Concat.BSplineCurve();
if (newCurve->Continuity() < GeomAbs_C1)
{
@@ -1496,6 +1497,7 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS,
const TopTools_SequenceOfShape& EdgesForConcat)
{
TopoDS_Edge CurEdge = TopoDS::Edge( EdgesForConcat(1) );
Standard_Real aGlueTol = Precision::Confusion();
for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++)
{
TopoDS_Edge anEdge = TopoDS::Edge( EdgesForConcat(j) );
@@ -1520,6 +1522,7 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS,
{
TopoDS_Vertex CV, V11, V12, V21, V22;
TopExp::CommonVertex( CurEdge, anEdge, CV );
aGlueTol = BRep_Tool::Tolerance(CV);
TopExp::Vertices( CurEdge, V11, V12 );
TopExp::Vertices( anEdge, V21, V22 );
if (V11.IsSame(CV) && V21.IsSame(CV))
@@ -1544,9 +1547,8 @@ static TopoDS_Edge AssembleEdge(const BOPDS_PDS& pDS,
}
} //end of else (open wire)
TopoDS_Edge NewEdge = Glue(CurEdge, anEdge,
Vfirst, Vlast, After,
F1, addPCurve1, F2, addPCurve2);
TopoDS_Edge NewEdge = Glue(CurEdge, anEdge, Vfirst, Vlast, After,
F1, addPCurve1, F2, addPCurve2, aGlueTol);
CurEdge = NewEdge;
} //end of for (Standard_Integer j = 2; j <= EdgesForConcat.Length(); j++)

View File

@@ -14,7 +14,7 @@
#include <BRepProj_Projection.ixx>
#include <BRepAlgo_Section.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <Precision.hxx>
#include <BRepBndLib.hxx>
@@ -129,8 +129,7 @@ void BRepProj_Projection::BuildSection (const TopoDS_Shape& theShape,
Standard_ConstructionError::Raise(__FILE__": target shape has no faces");
// build section computing pcurves on the shape
// BRepAlgoAPI_Section aSectionTool (aShape, theTool, Standard_False);
BRepAlgo_Section aSectionTool (aShape, theTool, Standard_False);
BRepAlgoAPI_Section aSectionTool (aShape, theTool, Standard_False);
aSectionTool.Approximation (Standard_True);
aSectionTool.ComputePCurveOn1 (Standard_True);
aSectionTool.Build();

View File

@@ -211,24 +211,39 @@ static Standard_Integer deform(Draw_Interpretor& di,Standard_Integer n,const cha
static Standard_Integer tcopy(Draw_Interpretor& di,Standard_Integer n,const char** a)
{
Standard_Boolean copyGeom = Standard_True;
Standard_Boolean copyMesh = Standard_False;
Standard_Integer iFirst = 1; // index of first shape argument
if (n > 1 && a[1][0] == '-' && a[1][1] == 'n' )
if (n > 1)
{
copyGeom = Standard_False;
iFirst = 2;
for (Standard_Integer i = 1; i <= 2; i++)
{
if (a[i][0] != '-')
break;
if (a[i][1] == 'n')
{
copyGeom = Standard_False;
iFirst++;
}
else if (a[i][1] == 'm')
{
copyMesh = Standard_True;
iFirst++;
}
}
}
if (n < 3 || (n - iFirst) % 2) {
cout << "Use: " << a[0] << " [-n(ogeom)] shape1 copy1 [shape2 copy2 [...]]" << endl;
cout << "Option -n forbids copying of geometry (it will be shared)" << endl;
cout << "Use: " << a[0] << " [-n(ogeom)] [-m(esh)] shape1 copy1 [shape2 copy2 [...]]" << endl;
cout << "Option -n forbids copying of geometry (it will be shared)" << endl;
cout << "Option -m forces copying of mesh (disabled by default)" << endl;
return 1;
}
BRepBuilderAPI_Copy cop;
Standard_Integer nbPairs = (n - iFirst) / 2;
for (Standard_Integer i=0; i < nbPairs; i++) {
cop.Perform(DBRep::Get(a[i+iFirst]), copyGeom);
cop.Perform(DBRep::Get(a[i+iFirst]), copyGeom, copyMesh);
DBRep::Set(a[i+iFirst+1],cop.Shape());
di << a[i+iFirst+1] << " ";
}
@@ -869,7 +884,7 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
transform,g);
theCommands.Add("tcopy",
"tcopy [-n(ogeom)] name1 result1 [name2 result2 ...]",
"tcopy [-n(ogeom)] [-m(esh)] name1 result1 [name2 result2 ...]",
__FILE__,
tcopy,g);

View File

@@ -70,7 +70,8 @@ uses
TColStd,
TCollection,
MMgt,
Message
Message,
Poly
is

View File

@@ -31,7 +31,9 @@ uses Face from TopoDS,
Surface from Geom,
Curve from Geom,
Curve from Geom2d,
Pnt from gp
Pnt from gp,
Triangulation from Poly
is
@@ -60,6 +62,16 @@ is
returns Boolean from Standard
is deferred;
NewTriangulation(me: mutable; F : Face from TopoDS;
T : out Triangulation from Poly)
---Purpose: Returns true if the face has been modified according to changed triangulation.
-- If the face has been modified:
-- - T is a new triangulation on the face
returns Boolean from Standard
is virtual;
NewCurve(me: mutable; E : Edge from TopoDS;
C : out Curve from Geom;

View File

@@ -16,4 +16,7 @@
#include <BRepTools_Modification.ixx>
Standard_Boolean BRepTools_Modification::NewTriangulation(const TopoDS_Face&, Handle(Poly_Triangulation)&)
{
return Standard_False;
}

View File

@@ -283,6 +283,20 @@ Standard_Boolean BRepTools_Modifier::Rebuild
B.NaturalRestriction(TopoDS::Face(result),
BRep_Tool::NaturalRestriction(TopoDS::Face(S)));
}
// update triangulation on the copied face
Handle(Poly_Triangulation) aTriangulation;
if (M->NewTriangulation(TopoDS::Face(S), aTriangulation))
{
if (rebuild) // the copied face already exists => update it
B.UpdateFace(TopoDS::Face(result), aTriangulation);
else
{ // create new face with bare triangulation
B.MakeFace(TopoDS::Face(result), aTriangulation);
result.Location(S.Location());
}
rebuild = Standard_True;
}
}
break;

View File

@@ -1516,28 +1516,26 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (!Compact) OS << "\n3D Nodes :\n";
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (j = 1; j <= nbNodes; j++) {
if (!Compact) OS << setw(10) << j << " : ";
if (!Compact) OS << setw(17);
OS << Nodes(j).X() << " ";
OS << T->Node (j).X() << " ";
if (!Compact) OS << setw(17);
OS << Nodes(j).Y() << " ";
OS << T->Node (j).Y() << " ";
if (!Compact) OS << 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 << setw(10) << j << " : ";
if (!Compact) OS << setw(17);
OS << UVNodes(j).X() << " ";
OS << T->UVNode (j).X() << " ";
if (!Compact) OS << setw(17);
OS << UVNodes(j).Y();
OS << T->UVNode (j).Y();
if (!Compact) OS << "\n";
else OS << " ";
}
@@ -1545,10 +1543,9 @@ void BRepTools_ShapeSet::WriteTriangulation(Standard_OStream& OS,
if (!Compact) OS << "\nTriangles :\n";
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& Triangles = T->Triangles();
for (j = 1; j <= nbTriangles; j++) {
if (!Compact) OS << setw(10) << j << " : ";
Triangles(j).Get(n1, n2, n3);
T->Triangle (j).Get(n1, n2, n3);
if (!Compact) OS << setw(10);
OS << n1 << " ";
if (!Compact) OS << setw(10);

View File

@@ -1403,24 +1403,21 @@ void BinTools_ShapeSet::WriteTriangulation(Standard_OStream& OS) const
// write the 3d nodes
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (j = 1; j <= nbNodes; j++) {
BinTools::PutReal(OS, Nodes(j).X());
BinTools::PutReal(OS, Nodes(j).Y());
BinTools::PutReal(OS, Nodes(j).Z());
BinTools::PutReal(OS, T->Node (j).X());
BinTools::PutReal(OS, T->Node (j).Y());
BinTools::PutReal(OS, T->Node (j).Z());
}
if (T->HasUVNodes()) {
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
for (j = 1; j <= nbNodes; j++) {
BinTools::PutReal(OS, UVNodes(j).X());
BinTools::PutReal(OS, UVNodes(j).Y());
BinTools::PutReal(OS, T->UVNode (j).X());
BinTools::PutReal(OS, T->UVNode (j).Y());
}
}
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& Triangles = T->Triangles();
for (j = 1; j <= nbTriangles; j++) {
Triangles(j).Get(n1, n2, n3);
T->Triangle (j).Get(n1, n2, n3);
BinTools::PutInteger(OS, n1);
BinTools::PutInteger(OS, n2);
BinTools::PutInteger(OS, n3);

View File

@@ -781,10 +781,9 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, Tr, loc);
if (!Poly.IsNull()) {
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = Tr->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(Tr->Node (Indices(i-1)).Transformed(loc),
Tr->Node (Indices(i)).Transformed(loc));
if (dis.HasPicked()) {
pickshape = E->Edge();
upick = 0;
@@ -1123,11 +1122,10 @@ void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
TColStd_DataMapOfIntegerInteger Internal;
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) {
@@ -1145,16 +1143,13 @@ void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
}
// Display the edges
const TColgp_Array1OfPnt& Nodes = T->Nodes();
// cout<<"nb nodes = "<<Nodes.Length()<<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
@@ -1166,8 +1161,8 @@ void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
//alvays pair is put
aIt.Next();
Standard_Integer n2 = aIt.Value();
dis.Draw(Nodes(n1).Transformed(tr),
Nodes(n2).Transformed(tr));
dis.Draw(T->Node (n1).Transformed(tr),
T->Node (n2).Transformed(tr));
}
}

View File

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

View File

@@ -60,11 +60,10 @@ DrawTrSurf_Triangulation2D::DrawTrSurf_Triangulation2D
TColStd_Array1OfInteger& Internal = myInternals->ChangeArray1();
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer n[3];
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
T->Triangle(i).Get(n[0],n[1],n[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
@@ -102,16 +101,14 @@ void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
// 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
@@ -120,7 +117,7 @@ void DrawTrSurf_Triangulation2D::DrawOn(Draw_Display& dis) const
const TColStd_Array1OfInteger& Internal = myInternals->Array1();
n = Internal.Length() / 2;
for (i = 1; i <= n; i++) {
dis.Draw(Nodes(Internal(2*i-1)),Nodes(Internal(2*i)));
dis.Draw(myTriangulation->UVNode (Internal(2*i-1)), myTriangulation->UVNode (Internal(2*i)));
}
}

View File

@@ -1753,8 +1753,20 @@ void Geom_OffsetSurface::SetD0(const Standard_Real U, const Standard_Real V,
CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV);
if (NStatus == CSLib_Defined)
P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ());
else
else
{
if (NStatus == CSLib_InfinityOfSolutions &&
D1U.SquareMagnitude() + D1V.SquareMagnitude() > MagTol * MagTol)
{
// Use non-null derivative as normal direction in degenerated case.
gp_Vec aNorm = D1U.SquareMagnitude() > MagTol * MagTol ? D1U : D1V;
aNorm.Normalize();
P.SetXYZ(P.XYZ() + offsetValue * signe * aNorm.XYZ());
return;
}
Geom_UndefinedValue::Raise();
}
}
}
@@ -1763,21 +1775,70 @@ void Geom_OffsetSurface::SetD0(const Standard_Real U, const Standard_Real V,
//function :
//purpose : private
//=======================================================================/
void Geom_OffsetSurface::SetD1(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
const Vec& d2u, const Vec& d2v, const Vec& d2uv ) const
void Geom_OffsetSurface::SetD1(const Standard_Real U,
const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V, // First derivative
const Vec& D2UU, const Vec& D2VV, const Vec& D2UV ) const // Second derivative
{
Standard_Real MagTol=0.000000001;
// Check offset side.
Handle(Geom_BSplineSurface) L;
Standard_Boolean AlongU = Standard_False,
AlongV = Standard_False;
Standard_Boolean IsOpposite=Standard_False;
AlongU = UOsculatingSurface(U,V,IsOpposite,L);
AlongV = VOsculatingSurface(U,V,IsOpposite,L);
Standard_Real signe = 1.0;
if ((AlongV || AlongU) && IsOpposite)
signe = -1.0;
Dir Normal;
CSLib_NormalStatus NStatus;
CSLib::Normal (D1U, D1V, MagTol, NStatus, Normal);
Standard_Integer MaxOrder;
if (NStatus == CSLib_Defined)
{
MaxOrder=0;
if (!AlongV && !AlongU)
{
// AlongU or AlongV leads to more complex D1 computation
// Try to compute D0 and D1 much simpler
P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ());
gp_Vec aN0(Normal.XYZ()), aN1U, aN1V;
Standard_Real aScale = (D1U^D1V).Dot(aN0);
aN1U.SetX(D2UU.Y() * D1V.Z() + D1U.Y() * D2UV.Z()
- D2UU.Z() * D1V.Y() - D1U.Z() * D2UV.Y());
aN1U.SetY((D2UU.X() * D1V.Z() + D1U.X() * D2UV.Z()
- D2UU.Z() * D1V.X() - D1U.Z() * D2UV.X() ) * -1.0);
aN1U.SetZ(D2UU.X() * D1V.Y() + D1U.X() * D2UV.Y()
- D2UU.Y() * D1V.X() - D1U.Y() * D2UV.X());
Standard_Real aScaleU = aN1U.Dot(aN0);
aN1U.Subtract(aScaleU * aN0);
aN1U /= aScale;
aN1V.SetX(D2UV.Y() * D1V.Z() + D2VV.Z() * D1U.Y()
- D2UV.Z() * D1V.Y() - D2VV.Y() * D1U.Z());
aN1V.SetY((D2UV.X() * D1V.Z() + D2VV.Z() * D1U.X()
- D2UV.Z() * D1V.X() - D2VV.X() * D1U.Z()) * -1.0);
aN1V.SetZ(D2UV.X() * D1V.Y() + D2VV.Y() * D1U.X()
- D2UV.Y() * D1V.X() - D2VV.X() * D1U.Y());
Standard_Real aScaleV = aN1V.Dot(aN0);
aN1V.Subtract(aScaleV * aN0);
aN1V /= aScale;
D1U += offsetValue * signe * aN1U;
D1V += offsetValue * signe * aN1V;
return;
}
}
else
MaxOrder=3;
Standard_Integer OrderU,OrderV;
TColgp_Array2OfVec DerNUV(0,MaxOrder+1,0,MaxOrder+1);
TColgp_Array2OfVec DerSurf(0,MaxOrder+2,0,MaxOrder+2);
@@ -1785,17 +1846,9 @@ void Geom_OffsetSurface::SetD1(const Standard_Real U, const Standard_Real V,
Bounds(Umin,Umax,Vmin,Vmax);
DerSurf.SetValue(1, 0, D1U);
DerSurf.SetValue(0, 1, D1V);
DerSurf.SetValue(1, 1, d2uv);
DerSurf.SetValue(2, 0, d2u);
DerSurf.SetValue(0, 2, d2v);
Handle(Geom_BSplineSurface) L;
Standard_Boolean AlongU = Standard_False,
AlongV = Standard_False;
Standard_Boolean IsOpposite=Standard_False;
Standard_Real signe = 1.;
AlongU = UOsculatingSurface(U,V,IsOpposite,L);
AlongV = VOsculatingSurface(U,V,IsOpposite,L);
if ((AlongV || AlongU) && IsOpposite) signe = -1;
DerSurf.SetValue(1, 1, D2UV);
DerSurf.SetValue(2, 0, D2UU);
DerSurf.SetValue(0, 2, D2VV);
derivatives(MaxOrder,2,U,V,basisSurf,1,1,AlongU,AlongV,L,DerNUV,DerSurf);
CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV);
@@ -1807,7 +1860,6 @@ void Geom_OffsetSurface::SetD1(const Standard_Real U, const Standard_Real V,
+ offsetValue * signe * CSLib::DNNormal(1,0,DerNUV,OrderU,OrderV);
D1V = DerSurf(0,1)
+ offsetValue * signe * CSLib::DNNormal(0,1,DerNUV,OrderU,OrderV);
}
//=======================================================================

View File

@@ -802,10 +802,8 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
TTMa[2][0] = ttma.Value(3,1);
TTMa[2][1] = ttma.Value(3,2);
TTMa[2][2] = ttma.Value(3,3);
Poly_Array1OfTriangle & Tri = Tr->ChangeTriangles();
TColgp_Array1OfPnt & Nod = Tr->ChangeNodes();
Standard_Integer nbN = Nod.Upper();
Standard_Integer nbT = Tri.Upper();
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);
@@ -819,24 +817,21 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
Standard_Address TData = &pid->TData();
Standard_Address PISeg = &pid->PISeg();
Standard_Address PINod = &pid->PINod();
Poly_Triangle * OT = &(Tri.ChangeValue(1));
HLRAlgo_TriangleData* NT =
&(((HLRAlgo_Array1OfTData*)TData)->ChangeValue(1));
for (i = 1; i <= nbT; i++) {
Standard_Address Tri2Indices = NT->Indices();
OT->Get(Tri2Node1,Tri2Node2,Tri2Node3);
Tr->Triangle (i).Get(Tri2Node1, Tri2Node2, Tri2Node3);
Tri2Flags = 0;
if (reversed) {
j = Tri2Node1;
Tri2Node1 = Tri2Node3;
Tri2Node3 = j;
}
OT++;
NT++;
}
gp_Pnt * ON = &(Nod.ChangeValue(1));
Handle(HLRAlgo_PolyInternalNode)* NN =
&(((HLRAlgo_Array1OfPINod*)PINod)->ChangeValue(1));
@@ -845,26 +840,23 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
const Standard_Address Nod1Indices = (*NN)->Indices();
Nod1NdSg = 0;
Nod1Flag = 0;
Nod1PntX = ON->X();
Nod1PntY = ON->Y();
Nod1PntZ = ON->Z();
Nod1PntX = Tr->Node (i).X();
Nod1PntY = Tr->Node(i).Y();
Nod1PntZ = Tr->Node(i).Z();
TTMultiply(Nod1PntX,Nod1PntY,Nod1PntZ);
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++) {
const Standard_Address Nod1Indices = (*NN)->Indices();
const Standard_Address Nod1RValues = (*NN)->RValues();
Nod1PntU = OUVN->X();
Nod1PntV = OUVN->Y();
Nod1PntU = Tr->UVNode (i).X();
Nod1PntV = Tr->UVNode (i).Y();
if (Normal(i,Nod1Indices,Nod1RValues,
TData,PISeg,PINod,Standard_False))
Nod1Flag |= NMskNorm;
@@ -872,7 +864,6 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
Nod1Flag &= ~NMskNorm;
Nod1Scal = 0;
}
OUVN++;
NN++;
}
}

View File

@@ -2209,7 +2209,6 @@ PutToBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
IsParallel(line, Standard_True, aTol, isU1parallel, isV1parallel);
IsParallel(line, Standard_False, aTol, isU2parallel, isV2parallel);
const Standard_Integer aNbPnts = line->NbPoints();
Standard_Real u1, v1, u2, v2;
line->Value(1).Parameters(u1, v1, u2, v2);
Standard_Real aDelta = 0.0;
@@ -2297,6 +2296,7 @@ PutToBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
v1, u2, v2, Standard_True);
}
const Standard_Integer aNbPnts = line->NbPoints();
isNeedAdding = Standard_False;
line->Value(aNbPnts).Parameters(u1, v1, u2, v2);

View File

@@ -436,10 +436,9 @@ static void MeshStats(const TopoDS_Shape& theSape,
BRepMesh_MapOfCouple aMap;
//count number of links
Poly_Array1OfTriangle& Trian = T->ChangeTriangles();
for(Standard_Integer i = 1; i<=Trian.Length();i++) {
for(Standard_Integer i = 1; i<=T->NbTriangles();i++) {
Standard_Integer v1, v2, v3;
Trian(i).Get(v1,v2,v3);
T->Triangle (i).Get(v1,v2,v3);
AddLink(aMap, v1, v2);
AddLink(aMap, v2, v3);
@@ -505,9 +504,8 @@ static Standard_Integer triangule(Draw_Interpretor& di, Standard_Integer nbarg,
if (!aTriangulation.IsNull())
{
const Standard_Integer aLength = aTriangulation->NbNodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
for (Standard_Integer i = 1; i <= aLength; ++i)
aBox.Add(aNodes(i));
aBox.Add(aTriangulation->Node (i));
}
}
@@ -1039,21 +1037,18 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
Standard_Real deflemax = 0, deflemin = 1.e100;
if (!T.IsNull()) {
Standard_Real defstock = T->Deflection();
const Poly_Array1OfTriangle& triangles = T->Triangles();
const TColgp_Array1OfPnt2d& Nodes2d = T->UVNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
S = BRep_Tool::Surface(F, L);
for(i = 1; i <= triangles.Length(); i++) {
for(i = 1; i <= T->NbTriangles(); i++) {
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(n1,n3,n2);
T->Triangle (i).Get(n1,n3,n2);
else
triangles(i).Get(n1,n2,n3);
T->Triangle (i).Get(n1,n2,n3);
const gp_XY& xy1 = Nodes2d(n1).XY();
const gp_XY& xy2 = Nodes2d(n2).XY();
const gp_XY& xy3 = Nodes2d(n3).XY();
const gp_XY& xy1 = T->UVNode (n1).XY();
const gp_XY& xy2 = T->UVNode (n2).XY();
const gp_XY& xy3 = T->UVNode (n3).XY();
mi2d1.SetCoord((xy2.X()+xy3.X())*0.5,
(xy2.Y()+xy3.Y())*0.5);
@@ -1062,9 +1057,9 @@ static Standard_Integer veriftriangles(Draw_Interpretor& di, Standard_Integer n,
mi2d3.SetCoord((xy1.X()+xy2.X())*0.5,
(xy1.Y()+xy2.Y())*0.5);
gp_XYZ p1 = Nodes(n1).Transformed(L.Transformation()).XYZ();
gp_XYZ p2 = Nodes(n2).Transformed(L.Transformation()).XYZ();
gp_XYZ p3 = Nodes(n3).Transformed(L.Transformation()).XYZ();
gp_XYZ p1 = T->Node (n1).Transformed (L.Transformation()).XYZ();
gp_XYZ p2 = T->Node (n2).Transformed (L.Transformation()).XYZ();
gp_XYZ p3 = T->Node (n3).Transformed (L.Transformation()).XYZ();
vecEd1=p2-p1;
vecEd2=p3-p2;
@@ -1190,11 +1185,10 @@ Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char** a)
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) {
@@ -1213,16 +1207,14 @@ Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char** a)
// 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)),
Seg = new Draw_Segment2D(T->UVNode (Free(2*i-1)),
T->UVNode (Free(2*i)),
Draw_rouge);
dout << Seg;
}
@@ -1231,8 +1223,8 @@ Standard_Integer tri2d(Draw_Interpretor&, Standard_Integer n, const char** a)
nn = nInternal;
for (i = 1; i <= nn; i++) {
Seg = new Draw_Segment2D(Nodes2d(Internal(2*i-1)),
Nodes2d(Internal(2*i)),
Seg = new Draw_Segment2D(T->UVNode (Internal(2*i-1)),
T->UVNode (Internal(2*i)),
Draw_bleu);
dout << Seg;
}
@@ -1306,11 +1298,10 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
if (!Tr.IsNull()) {
nbNodes = Tr->NbNodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
// les noeuds.
for (i = 1; i <= nbNodes; i++) {
gp_Pnt Pnt = Nodes(i).Transformed(L.Transformation());
gp_Pnt Pnt = Tr->Node (i).Transformed(L.Transformation());
x = Pnt.X();
y = Pnt.Y();
z = Pnt.Z();
@@ -1323,12 +1314,11 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
// les normales.
if (Tr->HasUVNodes()) {
const TColgp_Array1OfPnt2d& UVNodes = Tr->UVNodes();
BRepAdaptor_Surface BS(F, Standard_False);
for (i = 1; i <= nbNodes; i++) {
U = UVNodes(i).X();
V = UVNodes(i).Y();
U = Tr->UVNode (i).X();
V = Tr->UVNode (i).Y();
BS.D1(U,V,P,D1U,D1V);
CSLib::Normal(D1U,D1V,Precision::Angular(),Status,Nor);
@@ -1348,14 +1338,12 @@ static Standard_Integer wavefront(Draw_Interpretor&, Standard_Integer nbarg, con
// les triangles.
Standard_Integer nbTriangles = Tr->NbTriangles();
const Poly_Array1OfTriangle& triangles = Tr->Triangles();
for (i = 1; i <= nbTriangles; i++) {
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(n1, n3, n2);
Tr->Triangle (i).Get(n1, n3, n2);
else
triangles(i).Get(n1, n2, n3);
Tr->Triangle (i).Get(n1, n2, n3);
k1 = n1+totalnodes;
k2 = n2+totalnodes;
k3 = n3+totalnodes;
@@ -1565,14 +1553,13 @@ Standard_Integer triedgepoints(Draw_Interpretor& di, Standard_Integer nbarg, con
BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(it.Key()), aPoly, aT, aLoc);
if ( aT.IsNull() || aPoly.IsNull() )
continue;
const TColgp_Array1OfPnt& Nodes = aT->Nodes();
const TColStd_Array1OfInteger& Indices = aPoly->Nodes();
const Standard_Integer nbnodes = Indices.Length();
for( Standard_Integer j = 1; j <= nbnodes; j++ )
{
gp_Pnt P3d = Nodes(Indices(j));
gp_Pnt P3d = aT->Node (Indices(j));
if( !aLoc.IsIdentity() )
P3d.Transform(aLoc.Transformation());

View File

@@ -88,8 +88,6 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// check distances between corresponding points
Standard_Real aDefle = Max(aT1->Deflection(), aT2->Deflection());
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();
@@ -97,8 +95,8 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
gp_Trsf aTrsf1 = aFace1.Location().Transformation();
gp_Trsf aTrsf2 = aFace2.Location().Transformation();
for (; i1 <= aNodes1.Upper(); i1++, i2++) {
gp_Pnt aP1 = aPoints1(aNodes1(i1)).Transformed(aTrsf1);
gp_Pnt aP2 = aPoints2(aNodes2(i2)).Transformed(aTrsf2);
gp_Pnt aP1 = aT1->Node (aNodes1(i1)).Transformed(aTrsf1);
gp_Pnt aP2 = aT2->Node (aNodes2(i2)).Transformed(aTrsf2);
Standard_Real aDist = aP1.Distance(aP2);
if (aDist > aDefle) {
myErrors.Append(iF1);
@@ -140,10 +138,9 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
// check of free links and nodes
Poly_Connect aConn(aT);
const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
Standard_Integer nbTri = aT->NbTriangles(), i, j, n[3], t[3];
for (i = 1; i <= nbTri; i++) {
aTriangles(i).Get(n[0], n[1], n[2]);
aT->Triangle (i).Get(n[0], n[1], n[2]);
aUsedNodes.Add (n[0]);
aUsedNodes.Add (n[1]);

View File

@@ -253,10 +253,9 @@ void MeshTest_DrawableMesh::Whatis(Draw_Interpretor& theStream) const
// Count number of links
BRepMesh_MapOfLinks aMap;
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
for (Standard_Integer i = 1, v[3]; i <= aTriangles.Length(); ++i)
for (Standard_Integer i = 1, v[3]; i <= aTriangulation->NbTriangles(); ++i)
{
aTriangles(i).Get(v[0], v[1], v[2]);
aTriangulation->Triangle (i).Get(v[0], v[1], v[2]);
addLink(v[0], v[1], aMap);
addLink(v[1], v[2], aMap);

View File

@@ -300,15 +300,13 @@ static Standard_Integer triarea (Draw_Interpretor& di, int n, const char ** a)
cout << "face "<<i<<" has no triangulation"<<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);
@@ -365,8 +363,6 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
const TopoDS_Face& aFace = TopoDS::Face(aShape);
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(aFace, aLoc);
const TColgp_Array1OfPnt& aPoints = aT->Nodes();
const TColgp_Array1OfPnt2d& aPoints2d = aT->UVNodes();
const gp_Trsf& trsf = aLoc.Transformation();
TColgp_Array1OfPnt pnts(1,2);
@@ -375,14 +371,14 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
Standard_Integer n1, n2;
aCheck.GetFreeLink(k, i, n1, n2);
di << "{" << n1 << " " << n2 << "} ";
pnts(1) = aPoints(n1).Transformed(trsf);
pnts(2) = aPoints(n2).Transformed(trsf);
pnts(1) = aT->Node (n1).Transformed(trsf);
pnts(2) = aT->Node (n2).Transformed(trsf);
Handle(Poly_Polygon3D) poly = new Poly_Polygon3D (pnts);
DrawTrSurf::Set (name, poly);
DrawTrSurf::Set (name, pnts(1));
DrawTrSurf::Set (name, pnts(2));
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));
@@ -481,12 +477,11 @@ static Standard_Integer tricheck (Draw_Interpretor& di, int n, const char ** a)
break;
}
const Poly_Array1OfTriangle& aTris = aT->Triangles();
NCollection_Map<BRepMesh_Edge> aFreeEdgeMap;
Standard_Integer aTriNum = aTris.Length();
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 i = 1; i <= 3; ++i)

View File

@@ -48,6 +48,26 @@ static Handle(PColgp_HArray1OfPnt) ArrayCopy
return PArray;
}
//=======================================================================
//function : CopyNodes
//purpose : Copy the gp_Pnt
// from an Poly_Triangulation
// to an HArray1 from PColgp (PCollection)
//=======================================================================
static Handle(PColgp_HArray1OfPnt) CopyNodes
(const Handle(Poly_Triangulation)& theTriangulation)
{
Standard_Integer Lower = 1;
Standard_Integer Upper = theTriangulation->NbNodes();
Standard_Integer Index;
Handle(PColgp_HArray1OfPnt) PArray = new PColgp_HArray1OfPnt(Lower, Upper);
for (Index = Lower; Index <= Upper; Index++) {
PArray->SetValue(Index, theTriangulation->Node (Index));
}
return PArray;
}
//=======================================================================
//function : ArrayCopy
//purpose : Copy the gp_Pnt
@@ -87,6 +107,27 @@ static Handle(PColgp_HArray1OfPnt2d) ArrayCopy
return PArray;
}
//=======================================================================
//function : CopyUVNodes
//purpose : Copy the gp_Pnt2d
// from an Poly_Triangulation
// to an Array1 from PColgp (PCollection)
//=======================================================================
static Handle(PColgp_HArray1OfPnt2d) CopyUVNodes
(const Handle(Poly_Triangulation)& theTriangulation)
{
Standard_Integer Lower = 1;
Standard_Integer Upper = theTriangulation->NbNodes();
Standard_Integer Index;
Handle(PColgp_HArray1OfPnt2d) PArray =
new PColgp_HArray1OfPnt2d(Lower, Upper);
for (Index = Lower; Index <= Upper; Index++) {
PArray->SetValue(Index, theTriangulation->UVNode (Index));
}
return PArray;
}
//=======================================================================
//function : ArrayCopy
//purpose : Copy the gp_Pnt2d
@@ -108,22 +149,22 @@ static void ArrayCopy
//=======================================================================
//function : ArrayCopy
//function : CopyTriangles
//purpose : Copy the Triangle
// from an Array1 from Poly (TCollection)
// from an from Poly_Triangulation
// to an HArray1 from PPoly (PCollection)
//=======================================================================
static Handle(PPoly_HArray1OfTriangle) ArrayCopy
(const Poly_Array1OfTriangle& TArray)
static Handle(PPoly_HArray1OfTriangle) CopyTriangles
(const Handle(Poly_Triangulation)& theTrinagulation)
{
Standard_Integer Lower = TArray.Lower();
Standard_Integer Upper = TArray.Upper();
Standard_Integer Lower = 1;
Standard_Integer Upper = theTrinagulation->NbTriangles();
Standard_Integer Index;
Handle(PPoly_HArray1OfTriangle) PArray =
new PPoly_HArray1OfTriangle(Lower, Upper);
for (Index = Lower; Index <= Upper; Index++) {
PPoly_Triangle aPTriangle = MgtPoly::Translate(TArray(Index));
PPoly_Triangle aPTriangle = MgtPoly::Translate(theTrinagulation->Triangle (Index));
PArray->SetValue(Index, aPTriangle);
}
return PArray;
@@ -312,27 +353,24 @@ Handle(PPoly_Triangulation) MgtPoly::Translate
}
else {
// myNodes
const TColgp_Array1OfPnt& TNodes = TObj->Nodes();
Handle(PColgp_HArray1OfPnt) PNodes =
new PColgp_HArray1OfPnt(TNodes.Lower(),
TNodes.Upper());
PNodes = ArrayCopy(TNodes);
new PColgp_HArray1OfPnt(1,
TObj->NbNodes());
PNodes = CopyNodes(TObj);
// myTriangles
const Poly_Array1OfTriangle& TTriangle = TObj->Triangles();
Handle(PPoly_HArray1OfTriangle) PTriangle =
new PPoly_HArray1OfTriangle(TTriangle.Lower(),
TTriangle.Upper());
PTriangle = ArrayCopy(TTriangle);
new PPoly_HArray1OfTriangle(1,
TObj->NbTriangles());
PTriangle = CopyTriangles(TObj);
// myUVNodes
Handle(PColgp_HArray1OfPnt2d) PUVNodes;
if (TObj->HasUVNodes()) {
const TColgp_Array1OfPnt2d& TUVNodes = TObj->UVNodes();
PUVNodes =
new PColgp_HArray1OfPnt2d(TUVNodes.Lower(),
TUVNodes.Upper());
PUVNodes = ArrayCopy(TUVNodes);
new PColgp_HArray1OfPnt2d(1,
TObj->NbNodes());
PUVNodes = CopyUVNodes(TObj);
}
// Constructor + Deflection
PT = new PPoly_Triangulation(TObj->Deflection(),

View File

@@ -103,27 +103,25 @@ NIS_Surface::NIS_Surface (const Handle(Poly_Triangulation)& theTri,
// Copy the data from the original triangulation.
Standard_Integer i, iN(0), iT(0);
const Poly_Array1OfTriangle& arrTri = theTri->Triangles();
const TColgp_Array1OfPnt& arrNodes = theTri->Nodes();
for (i = arrTri.Lower(); i <= arrTri.Upper(); i++) {
for (i = 1; i <= theTri->NbTriangles(); i++) {
Standard_Integer iNode[3];
arrTri(i).Get(iNode[0], iNode[1], iNode[2]);
gp_XYZ aNorm = ((arrNodes(iNode[1]).XYZ() - arrNodes(iNode[0]).XYZ()) ^
(arrNodes(iNode[2]).XYZ() - arrNodes(iNode[0]).XYZ()));
theTri->Triangle (i).Get(iNode[0], iNode[1], iNode[2]);
gp_XYZ aNorm = ((theTri->Node (iNode[1]).XYZ() - theTri->Node (iNode[0]).XYZ()) ^
(theTri->Node (iNode[2]).XYZ() - theTri->Node (iNode[0]).XYZ()));
const Standard_Real aMagn = aNorm.Modulus();
if (aMagn > Precision::Confusion())
aNorm /= aMagn;
else
aNorm.SetCoord(0., 0., 1.);
mypNodes[iN+0] = static_cast<Standard_ShortReal>(arrNodes(iNode[0]).X());
mypNodes[iN+1] = static_cast<Standard_ShortReal>(arrNodes(iNode[0]).Y());
mypNodes[iN+2] = static_cast<Standard_ShortReal>(arrNodes(iNode[0]).Z());
mypNodes[iN+3] = static_cast<Standard_ShortReal>(arrNodes(iNode[1]).X());
mypNodes[iN+4] = static_cast<Standard_ShortReal>(arrNodes(iNode[1]).Y());
mypNodes[iN+5] = static_cast<Standard_ShortReal>(arrNodes(iNode[1]).Z());
mypNodes[iN+6] = static_cast<Standard_ShortReal>(arrNodes(iNode[2]).X());
mypNodes[iN+7] = static_cast<Standard_ShortReal>(arrNodes(iNode[2]).Y());
mypNodes[iN+8] = static_cast<Standard_ShortReal>(arrNodes(iNode[2]).Z());
mypNodes[iN+0] = static_cast<Standard_ShortReal>(theTri->Node (iNode[0]).X());
mypNodes[iN+1] = static_cast<Standard_ShortReal>(theTri->Node (iNode[0]).Y());
mypNodes[iN+2] = static_cast<Standard_ShortReal>(theTri->Node (iNode[0]).Z());
mypNodes[iN+3] = static_cast<Standard_ShortReal>(theTri->Node (iNode[1]).X());
mypNodes[iN+4] = static_cast<Standard_ShortReal>(theTri->Node (iNode[1]).Y());
mypNodes[iN+5] = static_cast<Standard_ShortReal>(theTri->Node (iNode[1]).Z());
mypNodes[iN+6] = static_cast<Standard_ShortReal>(theTri->Node (iNode[2]).X());
mypNodes[iN+7] = static_cast<Standard_ShortReal>(theTri->Node (iNode[2]).Y());
mypNodes[iN+8] = static_cast<Standard_ShortReal>(theTri->Node(iNode[2]).Z());
mypNormals[iN+0] = static_cast<Standard_ShortReal>(aNorm.X());
mypNormals[iN+1] = static_cast<Standard_ShortReal>(aNorm.Y());
mypNormals[iN+2] = static_cast<Standard_ShortReal>(aNorm.Z());
@@ -235,12 +233,10 @@ void NIS_Surface::Init (const TopoDS_Shape& theShape,
Standard_Boolean isReverse = (aFace.Orientation() == TopAbs_REVERSED);
// Store all nodes of the current face in the data model
const TColgp_Array1OfPnt& tabNode = aTriangulation->Nodes();
const TColgp_Array1OfPnt2d& tabUV = aTriangulation->UVNodes();
for (i = tabNode.Lower(); i <= tabNode.Upper(); i++)
for (i = 1; i <= aTriangulation->NbNodes(); i++)
{
Standard_Real t[3];
tabNode(i).Transformed(aTrf).Coord (t[0], t[1], t[2]);
aTriangulation->Node (i).Transformed(aTrf).Coord (t[0], t[1], t[2]);
// write node to mesh data
mypNodes[3*aNodeInd + 0] = static_cast<Standard_ShortReal>(t[0]);
mypNodes[3*aNodeInd + 1] = static_cast<Standard_ShortReal>(t[1]);
@@ -252,13 +248,11 @@ void NIS_Surface::Init (const TopoDS_Shape& theShape,
if (aTriangulation->HasNormals()) {
// Retrieve the normal direction from the triangulation
aNorm.SetCoord(aTriangulation->Normals().Value(3*i-2),
aTriangulation->Normals().Value(3*i-1),
aTriangulation->Normals().Value(3*i-0));
aNorm = aTriangulation->Normal (i).XYZ();
} else if (aSurf.IsNull() == Standard_False)
{
// Compute the surface normal at the Node.
aSurf->D1(tabUV(i).X(), tabUV(i).Y(), aP, aD1U, aD1V);
aSurf->D1(aTriangulation->UVNode (i).X(), aTriangulation->UVNode (i).Y(), aP, aD1U, aD1V);
aNorm = (aD1U.Crossed(aD1V)).XYZ();
}
@@ -282,11 +276,10 @@ void NIS_Surface::Init (const TopoDS_Shape& theShape,
}
const Standard_Integer nNodes1 = nNodes - 1;
// Store all triangles of the current face in the data model
const Poly_Array1OfTriangle& tabTri = aTriangulation->Triangles();
for (i = tabTri.Lower(); i <= tabTri.Upper(); i++)
for (i = 1; i <= aTriangulation->NbTriangles(); i++)
{
Standard_Integer aN[3];
tabTri(i).Get (aN[0], aN[1], aN[2]);
aTriangulation->Triangle (i).Get (aN[0], aN[1], aN[2]);
Standard_Integer * pTriangle = &mypTriangles[nTriangles*3];
pTriangle[0] = aN[0] + nNodes1;
if (isReverse) {
@@ -327,17 +320,17 @@ void NIS_Surface::Init (const TopoDS_Shape& theShape,
Standard_Integer aLen = arrNode.Length();
Standard_Integer * pEdge = static_cast<Standard_Integer *>
(myAlloc->Allocate(sizeof(Standard_Integer) * (aLen + 1)));
const gp_Pnt* pLast = &tabNode(arrNode(arrNode.Lower()));
const gp_Pnt* pLast = &aTriangulation->Node (arrNode(arrNode.Lower()));
pEdge[1] = arrNode(arrNode.Lower()) + nNodes1;
Standard_Integer iPNode(arrNode.Lower() + 1), iENode(1);
for (; iPNode <= arrNode.Upper(); iPNode++)
{
const Standard_Integer aN(arrNode(iPNode));
if (pLast->SquareDistance(tabNode(aN)) < eps2)
if (pLast->SquareDistance(aTriangulation->Node (aN)) < eps2)
{
aLen--;
} else {
pLast = &tabNode(aN);
pLast = &aTriangulation->Node (aN);
pEdge[++iENode] = aN + nNodes1;
}
}
@@ -349,7 +342,7 @@ void NIS_Surface::Init (const TopoDS_Shape& theShape,
}
}
}
nNodes += tabNode.Length();
nNodes += aTriangulation->NbNodes();
}
}
myNTriangles = nTriangles;

View File

@@ -11,3 +11,9 @@ Poly_CoherentLink.cxx
Poly_MakeLoops.hxx
Poly_MakeLoops.cxx
Poly_ListOfTriangulation.hxx
Poly_Triangulation.hxx
Poly_Triangulation.cxx
Poly_Element.hxx
Poly_Element.cxx
Poly_Mesh.hxx
Poly_Mesh.cxx

View File

@@ -47,7 +47,9 @@ is
instantiates HArray1 from TCollection(Triangle from Poly,
Array1OfTriangle from Poly);
class Triangulation;
imported transient class Triangulation;
imported transient class Mesh;
imported Element;
class Polygon3D;

View File

@@ -57,23 +57,19 @@ Handle(Poly_Triangulation) Poly::Catenate (const Poly_ListOfTriangulation& lstTr
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,
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));
iNode[2] + nNodes);
}
nNodes += nbNodes;
nTrian += nbTrian;
@@ -113,36 +109,33 @@ void Poly::Write(const Handle(Poly_Triangulation)& T,
if (!Compact) OS << "\n3D Nodes :\n";
Standard_Integer i, nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (!Compact) OS << setw(10) << i << " : ";
if (!Compact) OS << setw(17);
OS << Nodes(i).X() << " ";
OS << T->Node (i).X() << " ";
if (!Compact) OS << setw(17);
OS << Nodes(i).Y() << " ";
OS << T->Node (i).Y() << " ";
if (!Compact) OS << 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 << setw(10) << i << " : ";
if (!Compact) OS << setw(17);
OS << UVNodes(i).X() << " ";
OS << T->UVNode (i).X() << " ";
if (!Compact) OS << 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 << setw(10) << i << " : ";
Triangles(i).Get(n1, n2, n3);
T->Triangle(i).Get(n1, n2, n3);
if (!Compact) OS << setw(10);
OS << n1 << " ";
if (!Compact) OS << setw(10);
@@ -448,8 +441,6 @@ Handle(Poly_Polygon2D) Poly::ReadPolygon2D(Standard_IStream& IS)
void Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
{
const TColgp_Array1OfPnt& arrNodes = Tri->Nodes();
const Poly_Array1OfTriangle & arrTri = Tri->Triangles();
Standard_Integer nbNormVal = Tri->NbNodes() * 3;
const Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, nbNormVal);
@@ -462,12 +453,12 @@ void Poly::ComputeNormals(const Handle(Poly_Triangulation)& Tri)
Standard_Integer iN, iTri;
const Standard_Real eps2 = Precision::SquareConfusion();
for (iTri = 1; iTri <= arrTri.Length(); iTri++) {
for (iTri = 1; iTri <= Tri->NbTriangles(); iTri++) {
// Get the nodes of the current triangle
arrTri(iTri).Get (iNode[0], iNode[1], iNode[2]);
Tri->Triangle (iTri).Get (iNode[0], iNode[1], iNode[2]);
const gp_XYZ aVec[2] = {
arrNodes(iNode[1]).XYZ() - arrNodes(iNode[0]).XYZ(),
arrNodes(iNode[2]).XYZ() - arrNodes(iNode[0]).XYZ()
Tri->Node (iNode[1]).XYZ() - Tri->Node (iNode[0]).XYZ(),
Tri->Node (iNode[2]).XYZ() - Tri->Node (iNode[0]).XYZ()
};
// Find the normal vector of the current triangle

View File

@@ -51,44 +51,37 @@ Poly_CoherentTriangulation::Poly_CoherentTriangulation
: theAlloc)
{
if (theTriangulation.IsNull() == Standard_False) {
const TColgp_Array1OfPnt& arrNodes = theTriangulation->Nodes();
const Poly_Array1OfTriangle& arrTriangle = theTriangulation->Triangles();
const Standard_Integer nNodes = theTriangulation->NbNodes();
const Standard_Integer nTri = theTriangulation->NbTriangles();
Standard_Integer i;
// Copy the nodes
for (i = 0; i < nNodes; i++) {
const Standard_Integer anOldInd = i + arrNodes.Lower();
const Standard_Integer aNewInd = SetNode(arrNodes(anOldInd).XYZ(), i);
const Standard_Integer anOldInd = i + 1;
const Standard_Integer aNewInd = SetNode(theTriangulation->Node (anOldInd).XYZ(), i);
Poly_CoherentNode& aCopiedNode = myNodes(aNewInd);
aCopiedNode.SetIndex(anOldInd);
}
// Copy the triangles
for (i = 0; i < nTri; i++) {
for (i = 1; i <= theTriangulation->NbTriangles(); i++) {
Standard_Integer iNode[3];
arrTriangle(i + arrTriangle.Lower()).Get(iNode[0], iNode[1], iNode[2]);
theTriangulation->Triangle (i).Get(iNode[0], iNode[1], iNode[2]);
if (iNode[0] != iNode[1] && iNode[1] != iNode[2] && iNode[2] != iNode[0])
AddTriangle (iNode[0]-1, iNode[1]-1, iNode[2]-1);
}
// Copy UV coordinates of nodes
if (theTriangulation->HasUVNodes()) {
const TColgp_Array1OfPnt2d& arrNodes2d = theTriangulation->UVNodes();
for (i = 0; i < nNodes; i++) {
const gp_Pnt2d& anUV = arrNodes2d(i + arrNodes2d.Lower());
const gp_Pnt2d& anUV = theTriangulation->UVNode (i + 1);
myNodes(i).SetUV(anUV.X(), anUV.Y());
}
}
// Copy the normals at nodes
if (theTriangulation->HasNormals()) {
const TShort_Array1OfShortReal& arrNorm = theTriangulation->Normals();
for (i = 0; i < nNodes; i++) {
const gp_XYZ aNormal (arrNorm(3 * i + 0 + arrNorm.Lower()),
arrNorm(3 * i + 1 + arrNorm.Lower()),
arrNorm(3 * i + 2 + arrNorm.Lower()));
const gp_XYZ aNormal = theTriangulation->Normal (i + 1).XYZ();
myNodes(i).SetNormal(aNormal);
}
}
@@ -125,9 +118,6 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
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);
@@ -145,9 +135,9 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
arrNormal[3 * aCount + 2] = static_cast<Standard_ShortReal>(aNormal.Z());
vecNodeId.SetValue(i, ++aCount);
arrNodes.SetValue(aCount, aNode);
aResult->ChangeNode (aCount) = aNode;
arrNodesUV.SetValue(aCount, gp_Pnt2d(aNode.GetU(), aNode.GetV()));
aResult->ChangeUVNode (aCount) = gp_Pnt2d(aNode.GetU(), aNode.GetV());
if (aNode.GetU()*aNode.GetU() + aNode.GetV()*aNode.GetV() >
Precision::Confusion())
hasUV = Standard_True;
@@ -164,10 +154,9 @@ Handle(Poly_Triangulation) Poly_CoherentTriangulation::GetTriangulation() const
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)

View File

@@ -59,12 +59,11 @@ Poly_Connect::Poly_Connect(const Handle(Poly_Triangulation)& T) :
// loop on the triangles
Standard_Integer j,k,n[3],n1,n2;
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
for (i = 1; i <= nbTriangles; i++) {
// get the nodes
triangles(i).Get(n[0],n[1],n[2]);
myTriangulation->Triangle (i).Get(n[0],n[1],n[2]);
// Update the myTriangles array
myTriangles(n[0]) = i;
@@ -121,7 +120,7 @@ Poly_Connect::Poly_Connect(const Handle(Poly_Triangulation)& T) :
for (i = 1; i <= nbTriangles; i++) {
// get the nodes
triangles(i).Get(n[0],n[1],n[2]);
myTriangulation->Triangle (i).Get(n[0],n[1],n[2]);
// fore each edge
for (j = 0; j < 3; j++) {
@@ -213,8 +212,7 @@ void Poly_Connect::Initialize(const Standard_Integer N)
if (mymore)
{
Standard_Integer i, no[3];
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
triangles(myfirst).Get(no[0], no[1], no[2]);
myTriangulation->Triangle (myfirst).Get(no[0], no[1], no[2]);
for (i = 0; i < 3; i++)
if (no[i] == mynode) break;
myothernode = no[(i+2)%3];
@@ -231,12 +229,11 @@ void Poly_Connect::Next()
Standard_Integer i, j;
Standard_Integer n[3];
Standard_Integer t[3];
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
Triangles(mytr, t[0], t[1], t[2]);
if (mysense) {
for (i = 0; i < 3; i++) {
if (t[i] != 0) {
triangles(t[i]).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (t[i]).Get(n[0], n[1], n[2]);
for (j = 0; j < 3; j++) {
if ((n[j] == mynode) && (n[(j+1)%3] == myothernode)) {
mytr = t[i];
@@ -248,7 +245,7 @@ void Poly_Connect::Next()
}
}
// sinon, depart vers la gauche.
triangles(myfirst).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (myfirst).Get(n[0], n[1], n[2]);
for (i = 0; i < 3; i++)
if (n[i] == mynode) break;
myothernode = n[(i+1)%3];
@@ -259,7 +256,7 @@ void Poly_Connect::Next()
if (!mysense) {
for (i = 0; i < 3; i++) {
if (t[i] != 0) {
triangles(t[i]).Get(n[0], n[1], n[2]);
myTriangulation->Triangle (t[i]).Get(n[0], n[1], n[2]);
for (j = 0; j < 3; j++) {
if ((n[j] == mynode) && (n[(j+2)%3] == myothernode)) {
mytr = t[i];

View File

@@ -1,7 +1,4 @@
// Created on: 1995-03-06
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -14,33 +11,50 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Poly_Element.hxx>
//=======================================================================
//function : NbNodes
//purpose :
//function : Poly_Element
//purpose :
//=======================================================================
inline Standard_Integer Poly_Triangulation::NbNodes() const
Poly_Element::Poly_Element()
{
return myNbNodes;
myTriangles[0] = myTriangles[1] = 0;
}
//=======================================================================
//function : NbTriangles
//purpose :
//function : Poly_Element
//purpose :
//=======================================================================
inline Standard_Integer Poly_Triangulation::NbTriangles() const
Poly_Element::Poly_Element (const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2)
{
return myNbTriangles;
myTriangles[0] = theTriangle1;
myTriangles[1] = theTriangle2;
}
//=======================================================================
//function : HasUVNodes
//purpose :
//function : Set
//purpose :
//=======================================================================
inline Standard_Boolean Poly_Triangulation::HasUVNodes() const
void Poly_Element::Set (const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2)
{
return !myUVNodes.IsNull();
myTriangles[0] = theTriangle1;
myTriangles[1] = theTriangle2;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
void Poly_Element::Get (Standard_Integer& theTriangle1,
Standard_Integer& theTriangle2) const
{
theTriangle1 = myTriangles[0];
theTriangle2 = myTriangles[1];
}

84
src/Poly/Poly_Element.hxx Normal file
View File

@@ -0,0 +1,84 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Poly_Element_HeaderFile
#define _Poly_Element_HeaderFile
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OutOfRange.hxx>
//! Describes an element on mesh.
//! It can be defined as triangle index (in this case second index will be 0)
//! or as a pair of triangles indices that make up the quad.
class Poly_Element
{
public:
DEFINE_STANDARD_ALLOC
//! Constructs an element and sets all indices to zero.
Standard_EXPORT Poly_Element();
//! Constructs an element and sets it indices.
Standard_EXPORT Poly_Element (const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2);
//! Sets the value of triangles indices.
Standard_EXPORT void Set (const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2);
//! Returns the triangles indices of this element in theTriangle1, theTriangle2.
Standard_EXPORT void Get (Standard_Integer& theTriangle1,
Standard_Integer& theTriangle2) const;
//! @return the triangle index of given element theIndex.
//! Raises OutOfRange from Standard if theIndex is not in 1,2.
Standard_Integer Value (const Standard_Integer theIndex) const
{
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > 2, NULL);
return myTriangles[theIndex - 1];
}
Standard_Integer operator() (const Standard_Integer theIndex) const { return Value (theIndex); }
//! @return the triangle index of given element theIndex.
//! Raises OutOfRange from Standard if theIndex is not in 1,2.
Standard_Integer& ChangeValue (const Standard_Integer theIndex)
{
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > 2, NULL);
return myTriangles[theIndex - 1];
}
Standard_Integer& operator() (const Standard_Integer theIndex) { return ChangeValue (theIndex); }
//! @return Standard_True if the first element index > 0 and the second index == 0.
Standard_Boolean IsTriangle()
{
return (myTriangles[0] > 0 && myTriangles[1] == 0);
}
//! @return Standard_True if the first and the second element indices > 0.
Standard_Boolean IsQuad()
{
return (myTriangles[0] > 0 && myTriangles[1] > 0);
}
private:
Standard_Integer myTriangles[2];
};
#endif // _Poly_Element_HeaderFile

200
src/Poly/Poly_Mesh.cxx Normal file
View File

@@ -0,0 +1,200 @@
// 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_HANDLE (Poly_Mesh, Poly_Triangulation)
IMPLEMENT_STANDARD_RTTIEXT (Poly_Mesh, Poly_Triangulation)
//=======================================================================
//function : Poly_Mesh
//purpose :
//=======================================================================
Poly_Mesh::Poly_Mesh (const Standard_Boolean theHasUVNodes)
: Poly_Triangulation (0, 0, theHasUVNodes),
myNbQuads (0)
{}
//=======================================================================
//function : Poly_Mesh
//purpose :
//=======================================================================
Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
: Poly_Triangulation ( theTriangulation ),
myNbQuads (0)
{
const Standard_Integer aNbTris = theTriangulation->NbTriangles();
// Fill collection of elements
if ( aNbTris )
myElements.SetValue( aNbTris - 1, Poly_Element() );
// Populate elements with triangles
for ( Standard_Integer i = 1; i <= aNbTris; ++i )
{
myElements(i - 1).Set(i, 0);
}
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Poly_Triangulation) Poly_Mesh::Copy() const
{
const Standard_Boolean hasUV = HasUVNodes();
Handle(Poly_Mesh) aCopy = new Poly_Mesh(hasUV);
// Copy nodes
Standard_Integer aNbNodes = NbNodes();
for ( Standard_Integer i = 1; i <= aNbNodes; ++i )
{
aCopy->AddNode(Node(i));
if ( hasUV )
aCopy->ChangeUVNode(i) = UVNode(i);
}
// Copy triangles
Standard_Integer aNbTriangles = NbTriangles();
const Standard_Boolean hasNormals = HasNormals();
for ( Standard_Integer i = 1; i <= aNbTriangles; ++i )
{
aCopy->AddTriangle(Triangle(i));
// Pass normal vector (if any)
if ( hasNormals )
aCopy->SetNormal(i, Normal(i));
}
// Copy quads
aCopy->myNbQuads = myNbQuads;
aCopy->myElements = myElements;
return aCopy;
}
//=======================================================================
//function : AddElement
//purpose :
//=======================================================================
Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1,
const Standard_Integer theN2,
const Standard_Integer theN3)
{
Standard_Integer anIndex = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN2, theN3) );
return addElement( Poly_Element(anIndex, 0) );
}
//=======================================================================
//function : AddElement
//purpose :
//=======================================================================
Standard_Integer Poly_Mesh::AddElement (const Standard_Integer theN1,
const Standard_Integer theN2,
const Standard_Integer theN3,
const Standard_Integer theN4)
{
Standard_Integer anIndex1 = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN2, theN3) );
Standard_Integer anIndex2 = Poly_Triangulation::AddTriangle( Poly_Triangle(theN1, theN3, theN4) );
return addElement( Poly_Element(anIndex1, anIndex2) );
}
//=======================================================================
//function : Element
//purpose :
//=======================================================================
const Poly_Element& Poly_Mesh::Element (const Standard_Integer theIndex) const
{
if ( theIndex < 1 || theIndex > myElements.Size() )
{
Standard_OutOfRange::Raise("Poly_Mesh::Element : index out of range");
}
return myElements.Value(theIndex - 1);
}
//=======================================================================
//function : Element
//purpose :
//=======================================================================
void Poly_Mesh::Element (const Standard_Integer theIndex,
Standard_Integer& theN1,
Standard_Integer& theN2,
Standard_Integer& theN3,
Standard_Integer& theN4) const
{
if ( theIndex < 1 || theIndex > myElements.Size() )
{
Standard_OutOfRange::Raise("Poly_Mesh::Element : index out of range");
}
const Poly_Element& anElem = Element(theIndex);
Standard_Integer aTriIdx1, aTriIdx2;
anElem.Get(aTriIdx1, aTriIdx2);
// Get node indices for the first triangle
const Poly_Triangle& aTri1 = Poly_Triangulation::Triangle(aTriIdx1);
aTri1.Get(theN1, theN2, theN3);
// If the second triangle exists, take its node indices for quad
if ( aTriIdx2 )
{
const Poly_Triangle& aTri2 = Poly_Triangulation::Triangle(aTriIdx2);
aTri2.Get(theN1, theN3, theN4);
}
else
theN4 = 0;
}
//=======================================================================
//function : SetElement
//purpose :
//=======================================================================
void Poly_Mesh::SetElement (const Standard_Integer theIndex, const Poly_Element& theElement)
{
if ( theIndex < 1 || theIndex > myElements.Size() )
{
Standard_OutOfRange::Raise("Poly_Mesh::SetElement : index out of range");
}
if ( myElements.Value(theIndex - 1).Value(2) == 0 && theElement.Value(2) != 0 )
{
myNbQuads++;
}
else if ( myElements.Value(theIndex - 1).Value(2) != 0 && theElement.Value(2) == 0 )
{
myNbQuads--;
}
myElements.SetValue(theIndex - 1, theElement);
}
//=======================================================================
//function : addElement
//purpose :
//=======================================================================
Standard_Integer Poly_Mesh::addElement(const Poly_Element& theElement)
{
myElements.Append(theElement);
if ( theElement.Value(2) != 0 )
{
myNbQuads++;
}
return myElements.Size();
}

104
src/Poly/Poly_Mesh.hxx Normal file
View File

@@ -0,0 +1,104 @@
// 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_Element.hxx>
#include <Poly_Triangulation.hxx>
//! This class is extension for Poly_Triangulation.
//! It allows to store mesh with quad polygons as table of Poly_Element.
//! Keep in mind that when you add a triangle, it is also added to the table of elements
//! as Poly_Element. And it will have first index set to triangle index from Poly_Triangulation
//! and second index will be set to 0.
class Poly_Mesh : public Poly_Triangulation
{
public:
//! Constructs an empty mesh.
//! @param theHasUVNodes indicates whether 2D nodes will be associated with
//! 3D ones, (i.e. to enable a 2D representation).
Standard_EXPORT Poly_Mesh (const Standard_Boolean theHasUVNodes = 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;
//! Adds element to the mesh.
//! @param theN1 index of the first node.
//! @param theN2 index of the second node.
//! @param theN3 index of the third node.
//! @return index of the added element.
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
const Standard_Integer theN2,
const Standard_Integer theN3);
//! Adds element to the mesh.
//! @param theN1 index of the first node.
//! @param theN2 index of the second node.
//! @param theN3 index of the third node.
//! @param theN4 index of the fourth node.
//! @return index of the added element.
Standard_EXPORT Standard_Integer AddElement (const Standard_Integer theN1,
const Standard_Integer theN2,
const Standard_Integer theN3,
const Standard_Integer theN4);
//! @return the number of elements for this mesh.
Standard_Integer NbElements() const { return myElements.Size(); }
//! @return the number of quads for this mesh.
Standard_Integer NbQuads() const { return myNbQuads; }
//! @return element at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex) const;
//! @return nodes of the element at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
Standard_EXPORT void Element (const Standard_Integer theIndex,
Standard_Integer& theN1,
Standard_Integer& theN2,
Standard_Integer& theN3,
Standard_Integer& theN4) const;
//! Give access to the element at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement);
protected:
//! Adds element to the mesh.
//! @param theElement element to add.
//! @return index of the added element.
Standard_EXPORT Standard_Integer addElement (const Poly_Element& theElement);
private:
NCollection_Vector<Poly_Element> myElements;
Standard_Integer myNbQuads;
public:
DEFINE_STANDARD_RTTI(Poly_Mesh)
};
DEFINE_STANDARD_HANDLE(Poly_Mesh, Poly_Triangulation)
#endif // _Poly_Mesh_HeaderFile

View File

@@ -81,7 +81,15 @@ is
---C++: return const &
raises NullObject from Standard;
Node(me; theIndex: Integer from Standard) returns Integer from Standard;
---Purpose: @return node at the given index.
-- Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
SetNode(me: mutable; theIndex: Integer from Standard; theNode: Integer from Standard);
---Purpose: Sets node at the given index.
-- Raises exception if theIndex is less than NodesLowerIndex or bigger than NodesUpperIndex.
HasParameters(me) returns Boolean from Standard;
---Purpose:
-- Returns true if parameters are associated with the nodes in this polygon.
@@ -92,8 +100,17 @@ is
-- are associated with the nodes in this polygon.
--
raises NullObject from Standard;
Parameter(me; theIndex: Integer from Standard) returns Real from Standard;
---Purpose: @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.
SetParameter(me: mutable; theIndex: Integer from Standard; theValue: Real from Standard);
---Purpose: 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.
fields
myDeflection : Real from Standard;

View File

@@ -75,6 +75,29 @@ const TColStd_Array1OfInteger& Poly_PolygonOnTriangulation::Nodes() const
return myNodes;
}
//=======================================================================
//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 : HasParameters
@@ -96,3 +119,30 @@ Handle(TColStd_HArray1OfReal) Poly_PolygonOnTriangulation::Parameters() const
return myParameters;
}
//=======================================================================
//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);
}

View File

@@ -1,190 +0,0 @@
-- Created on: 1995-03-06
-- Created by: Laurent PAINNOT
-- Copyright (c) 1995-1999 Matra Datavision
-- Copyright (c) 1999-2014 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.
class Triangulation from Poly inherits TShared from MMgt
---Purpose: 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.
uses
HArray1OfPnt2d from TColgp,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
Array1OfTriangle from Poly,
HArray1OfShortReal from TShort,
Array1OfShortReal from TShort
raises
DomainError from Standard,
NullObject from Standard
is
Create(nbNodes, nbTriangles: Integer; UVNodes: Boolean)
returns Triangulation from Poly;
---Purpose: Constructs a triangulation from a set of triangles. The
-- triangulation is initialized without a triangle or a node, but capable of
-- containing nbNodes nodes, and nbTriangles
-- triangles. Here the UVNodes flag indicates whether
-- 2D nodes will be associated with 3D ones, (i.e. to
-- enable a 2D representation).
Create(Nodes: Array1OfPnt from TColgp;
Triangles: Array1OfTriangle from Poly)
returns Triangulation from Poly;
---Purpose: Constructs a triangulation from a set of triangles. The
-- triangulation is initialized with 3D points from Nodes and triangles
-- from Triangles.
Create(Nodes: Array1OfPnt from TColgp;
UVNodes: Array1OfPnt2d from TColgp;
Triangles: Array1OfTriangle from Poly)
returns Triangulation from Poly;
---Purpose: Constructs a triangulation from a set of triangles. The
-- triangulation is initialized with 3D points from Nodes, 2D points from
-- UVNodes and triangles from Triangles, where
-- coordinates of a 2D point from UVNodes are the
-- (u, v) parameters of the corresponding 3D point
-- from Nodes on the surface approximated by the
-- constructed triangulation.
Deflection(me) returns Real;
---Purpose: Returns the deflection of this triangulation.
Deflection(me : mutable; D : Real);
---Purpose: Sets the deflection of this triangulation to D.
-- See more on deflection in Polygon2D
RemoveUVNodes(me : mutable);
---Purpose: Deallocates the UV nodes.
NbNodes(me) returns Integer;
---Purpose: Returns the number of nodes for this triangulation.
-- Null if the nodes are not yet defined.
---C++: inline
NbTriangles(me) returns Integer;
---Purpose: Returns the number of triangles for this triangulation.
-- Null if the Triangles are not yet defined.
---C++: inline
HasUVNodes(me) returns Boolean;
---Purpose: Returns true if 2D nodes are associated with 3D nodes for
-- this triangulation.
---C++: inline
Nodes(me) returns Array1OfPnt from TColgp
---Purpose: Returns the table of 3D nodes (3D points) for this triangulation.
---C++: return const &
raises NullObject from Standard;
ChangeNodes(me : mutable) returns Array1OfPnt from TColgp
---Purpose: 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.
---C++: return &
raises NullObject from Standard;
UVNodes(me) returns Array1OfPnt2d from TColgp
---Purpose: 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.
---C++: return const &
raises NullObject from Standard;
ChangeUVNodes(me : mutable) returns Array1OfPnt2d from TColgp
---Purpose: 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.
---C++: return &
raises NullObject from Standard;
Triangles(me) returns Array1OfTriangle from Poly
---Purpose: Returns the table of triangles for this triangulation.
---C++: return const &
raises NullObject from Standard;
ChangeTriangles(me : mutable) returns Array1OfTriangle from Poly
---Purpose: 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.
---C++: return &
raises NullObject from Standard;
SetNormals(me : mutable; theNormals : HArray1OfShortReal from TShort)
---Purpose: Sets the table of node normals.
-- raises exception if length of theNormals != 3*NbNodes
raises DomainError from Standard;
Normals(me) returns Array1OfShortReal from TShort
---C++: return const &
-- raises exception if array of normals is empty or
-- its length != 3*NbNodes
raises NullObject from Standard;
ChangeNormals(me : mutable) returns Array1OfShortReal from TShort
---C++: return &
-- raises exception if array of normals is empty or
-- its length != 3*NbNodes
raises NullObject from Standard;
HasNormals(me) returns Boolean from Standard;
fields
myDeflection : Real;
myNbNodes : Integer;
myNbTriangles : Integer;
myNodes : Array1OfPnt from TColgp;
myUVNodes : HArray1OfPnt2d from TColgp;
myTriangles : Array1OfTriangle from Poly;
---- Optional normals ---
myNormals : HArray1OfShortReal from TShort;
end Triangulation;

View File

@@ -14,26 +14,39 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Poly_Triangulation.ixx>
#include <Poly_Triangulation.hxx>
#include <gp_Pnt.hxx>
#include <Poly_Triangle.hxx>
#include <Standard_NullObject.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TShort_HArray1OfShortReal.hxx>
IMPLEMENT_STANDARD_HANDLE (Poly_Triangulation, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT (Poly_Triangulation, MMgt_TShared)
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const Standard_Integer NbNodes,
const Standard_Integer NbTriangles,
const Standard_Boolean UVNodes) :
myDeflection(0),
myNbNodes(NbNodes),
myNbTriangles(NbTriangles),
myNodes(1, NbNodes),
myTriangles(1, NbTriangles)
Poly_Triangulation::Poly_Triangulation (const Standard_Integer theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes)
: myHasUVNodes (theHasUVNodes),
myDeflection (0)
{
if (UVNodes) myUVNodes = new TColgp_HArray1OfPnt2d(1, myNbNodes);
if (theNbNodes > 0)
{
myNodes.SetValue (theNbNodes - 1, gp_Pnt());
if (myHasUVNodes)
{
myUVNodes.SetValue (theNbNodes - 1, gp_Pnt2d());
}
}
if (theNbTriangles > 0)
{
myTriangles.SetValue (theNbTriangles - 1, Poly_Triangle());
}
}
//=======================================================================
@@ -41,16 +54,19 @@ Poly_Triangulation::Poly_Triangulation(const Standard_Integer NbNodes,
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& Nodes,
const Poly_Array1OfTriangle& Triangles) :
myDeflection(0),
myNbNodes(Nodes.Length()),
myNbTriangles(Triangles.Length()),
myNodes(1, Nodes.Length()),
myTriangles(1, Triangles.Length())
Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles)
: myHasUVNodes (Standard_False),
myDeflection (0)
{
myNodes = Nodes;
myTriangles = Triangles;
for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
{
myNodes.SetValue (anIndex - 1, theNodes (anIndex));
}
for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
{
myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
}
}
@@ -60,19 +76,62 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& Nodes,
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& Nodes,
const TColgp_Array1OfPnt2d& UVNodes,
const Poly_Array1OfTriangle& Triangles) :
myDeflection(0),
myNbNodes(Nodes.Length()),
myNbTriangles(Triangles.Length()),
myNodes(1, Nodes.Length()),
myTriangles(1, Triangles.Length())
Poly_Triangulation::Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const TColgp_Array1OfPnt2d& theUVNodes,
const Poly_Array1OfTriangle& theTriangles)
: myHasUVNodes (theNodes.Length() == theUVNodes.Length()),
myDeflection (0)
{
myNodes = Nodes;
myTriangles = Triangles;
myUVNodes = new TColgp_HArray1OfPnt2d(1, myNbNodes);
myUVNodes->ChangeArray1() = UVNodes;
for (Standard_Integer anIndex = theNodes.Upper(); anIndex >= theNodes.Lower(); anIndex--)
{
myNodes.SetValue (anIndex - 1, theNodes (anIndex));
}
if (myHasUVNodes)
{
for (Standard_Integer anIndex = theUVNodes.Upper(); anIndex >= theUVNodes.Lower(); anIndex--)
{
myUVNodes.SetValue (anIndex - 1, theUVNodes (anIndex));
}
}
for (Standard_Integer anIndex = theTriangles.Upper(); anIndex >= theTriangles.Lower(); anIndex--)
{
myTriangles.SetValue (anIndex - 1, theTriangles (anIndex));
}
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Poly_Triangulation) Poly_Triangulation::Copy() const
{
Handle(Poly_Triangulation) aCopy = new Poly_Triangulation(NbNodes(), NbTriangles(), HasUVNodes());
aCopy->myNodes = myNodes;
aCopy->myTriangles = myTriangles;
aCopy->myUVNodes = myUVNodes;
aCopy->myDeflection = myDeflection;
aCopy->myNormals = myNormals;
return aCopy;
}
//=======================================================================
//=======================================================================
//function : Poly_Triangulation
//purpose :
//=======================================================================
Poly_Triangulation::Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation)
: myHasUVNodes ( theTriangulation->myHasUVNodes ),
myDeflection ( theTriangulation->myDeflection )
{
myNodes.Assign(theTriangulation->myNodes);
if (myHasUVNodes)
{
myUVNodes.Assign(theTriangulation->myUVNodes);
}
myTriangles.Assign(theTriangulation->myTriangles);
myNormals.Assign(theTriangulation->myNormals);
}
//=======================================================================
@@ -80,7 +139,7 @@ Poly_Triangulation::Poly_Triangulation(const TColgp_Array1OfPnt& Nodes,
//purpose :
//=======================================================================
Standard_Real Poly_Triangulation::Deflection() const
Standard_Real Poly_Triangulation::Deflection() const
{
return myDeflection;
}
@@ -90,9 +149,9 @@ Standard_Real Poly_Triangulation::Deflection() const
//purpose :
//=======================================================================
void Poly_Triangulation::Deflection(const Standard_Real D)
void Poly_Triangulation::Deflection (const Standard_Real theDeflection)
{
myDeflection = D;
myDeflection = theDeflection;
}
@@ -104,119 +163,163 @@ void Poly_Triangulation::Deflection(const Standard_Real D)
void Poly_Triangulation::RemoveUVNodes()
{
myUVNodes.Nullify();
myUVNodes.Clear();
myHasUVNodes = Standard_False;
}
//=======================================================================
//function : Nodes
//function : AddNode
//purpose :
//=======================================================================
Standard_Integer Poly_Triangulation::AddNode (const gp_Pnt& theNode)
{
myNodes.Append (theNode);
if (myHasUVNodes)
{
myUVNodes.Append (gp_Pnt2d());
}
if (!myNormals.IsEmpty())
{
Standard_Integer aNbNormals = myNodes.Size();
myNormals.SetValue (aNbNormals + 2, 0.0);
myNormals.SetValue (aNbNormals + 1, 0.0);
myNormals.SetValue (aNbNormals, 0.0);
}
return myNodes.Size();
}
//=======================================================================
//function : Node
//purpose :
//=======================================================================
const TColgp_Array1OfPnt& Poly_Triangulation::Nodes() const
const gp_Pnt& Poly_Triangulation::Node (const Standard_Integer theIndex) const
{
return myNodes;
if (theIndex < 1 || theIndex > myNodes.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::Node : index out of range");
}
return myNodes.Value (theIndex - 1);
}
//=======================================================================
//function : ChangeNodes
//function : ChangeNode
//purpose :
//=======================================================================
TColgp_Array1OfPnt& Poly_Triangulation::ChangeNodes()
gp_Pnt& Poly_Triangulation::ChangeNode (const Standard_Integer theIndex)
{
return myNodes;
if (theIndex < 1 || theIndex > myNodes.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::ChangeNode : index out of range");
}
return myNodes.ChangeValue (theIndex - 1);
}
//=======================================================================
//function : UVNodes
//function : UVNode
//purpose :
//=======================================================================
const TColgp_Array1OfPnt2d& Poly_Triangulation::UVNodes() const
const gp_Pnt2d& Poly_Triangulation::UVNode (const Standard_Integer theIndex) const
{
return myUVNodes->Array1();
if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::UVNode : index out of range");
}
return myUVNodes.Value (theIndex - 1);
}
//=======================================================================
//function : ChangeUVNodes
//function : ChangeUVNode
//purpose :
//=======================================================================
TColgp_Array1OfPnt2d& Poly_Triangulation::ChangeUVNodes()
gp_Pnt2d& Poly_Triangulation::ChangeUVNode (const Standard_Integer theIndex)
{
return myUVNodes->ChangeArray1();
if (myUVNodes.IsEmpty() || theIndex < 1 || theIndex > myUVNodes.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::ChangeUVNode : index out of range");
}
return myUVNodes.ChangeValue (theIndex - 1);
}
//=======================================================================
//function : Triangles
//function : Triangle
//purpose :
//=======================================================================
const Poly_Array1OfTriangle& Poly_Triangulation::Triangles() const
Standard_Integer Poly_Triangulation::AddTriangle (const Poly_Triangle& theTriangle)
{
return myTriangles;
myTriangles.Append (theTriangle);
return myTriangles.Size();
}
//=======================================================================
//function : ChangeTriangles
//function : Triangle
//purpose :
//=======================================================================
Poly_Array1OfTriangle& Poly_Triangulation::ChangeTriangles()
const Poly_Triangle& Poly_Triangulation::Triangle (const Standard_Integer theIndex) const
{
return myTriangles;
if (theIndex < 1 || theIndex > myTriangles.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::Triangle : index out of range");
}
return myTriangles.Value (theIndex - 1);
}
//=======================================================================
//function : ChangeTriangle
//purpose :
//=======================================================================
Poly_Triangle& Poly_Triangulation::ChangeTriangle (const Standard_Integer theIndex)
{
if (theIndex < 1 || theIndex > myTriangles.Size())
{
Standard_OutOfRange::Raise ("Poly_Triangulation::ChangeTriangle : index out of range");
}
return myTriangles.ChangeValue (theIndex - 1);
}
//=======================================================================
//function : SetNormals
//purpose :
//=======================================================================
void Poly_Triangulation::SetNormals
(const Handle(TShort_HArray1OfShortReal)& theNormals)
void Poly_Triangulation::SetNormals (const Handle(TShort_HArray1OfShortReal)& theNormals)
{
if(theNormals.IsNull() || theNormals->Length() != 3*myNbNodes) {
if (theNormals.IsNull() || theNormals->Length() != 3 * NbNodes())
{
Standard_DomainError::Raise("Poly_Triangulation::SetNormals : wrong length");
}
myNormals = theNormals;
for (Standard_Integer anIndex = theNormals->Upper(); anIndex >= theNormals->Lower(); anIndex--)
{
myNormals.SetValue (anIndex, (theNormals->Value (anIndex)));
}
}
//=======================================================================
//function : Normals
//function : SetNormal
//purpose :
//=======================================================================
const TShort_Array1OfShortReal& Poly_Triangulation::Normals() const
void Poly_Triangulation::SetNormal (const Standard_Integer theIndex, const gp_Dir& theNormal)
{
if(myNormals.IsNull() || myNormals->Length() != 3*myNbNodes) {
Standard_NullObject::Raise("Poly_Triangulation::Normals : "
"wrong length or null array");
if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size())
{
Standard_NullObject::Raise("Poly_Triangulation::SetNormal : empty array or index out of range");
}
return myNormals->Array1();
}
//=======================================================================
//function : ChangeNormals
//purpose :
//=======================================================================
TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
{
if(myNormals.IsNull() || myNormals->Length() != 3*myNbNodes) {
Standard_NullObject::Raise("Poly_Triangulation::ChangeNormals : "
"wrong length or null array");
}
return myNormals->ChangeArray1();
Standard_Integer anIndex = (theIndex - 1) * 3;
myNormals.ChangeValue (anIndex) = (Standard_ShortReal) theNormal.X();
myNormals.ChangeValue (anIndex + 1) = (Standard_ShortReal) theNormal.Y();
myNormals.ChangeValue (anIndex + 2) = (Standard_ShortReal) theNormal.Z();
}
//=======================================================================
@@ -226,12 +329,27 @@ TShort_Array1OfShortReal& Poly_Triangulation::ChangeNormals()
Standard_Boolean Poly_Triangulation::HasNormals() const
{
if(myNormals.IsNull() || myNormals->Length() != 3*myNbNodes) {
if (myNormals.IsEmpty() || myNormals.Length() != 3 * NbNodes())
{
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
const gp_Dir Poly_Triangulation::Normal (const Standard_Integer theIndex) const
{
if (myNormals.IsEmpty() || theIndex < 1 || theIndex > myNodes.Size())
{
Standard_NullObject::Raise("Poly_Triangulation::Normal : empty array or index out of range");
}
Standard_Integer anIndex = (theIndex - 1) * 3;
return gp_Dir (myNormals (anIndex),
myNormals (anIndex + 1),
myNormals (anIndex + 2));
}

View File

@@ -0,0 +1,170 @@
// 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_Triangulation_HeaderFile
#define _Poly_Triangulation_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Handle_TColgp_HArray1OfPnt2d.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Handle_TShort_HArray1OfShortReal.hxx>
#include <MMgt_TShared.hxx>
#include <Standard_Boolean.hxx>
#include <NCollection_Vector.hxx>
#include <Poly_Triangle.hxx>
class TColgp_HArray1OfPnt2d;
class TShort_HArray1OfShortReal;
class Standard_DomainError;
class Standard_NullObject;
class TColgp_Array1OfPnt;
class Poly_Array1OfTriangle;
class TColgp_Array1OfPnt2d;
class TShort_Array1OfShortReal;
class Handle_Poly_Triangulation;
//! 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.
class Poly_Triangulation : public MMgt_TShared
{
public:
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized without a triangle or a node, but capable of containing theNbNodes nodes, and theNbTriangles triangles.
//! Here theHasUVNodes 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 theNbNodes,
const Standard_Integer theNbTriangles,
const Standard_Boolean theHasUVNodes);
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized with 3D points from Nodes and triangles from Triangles.
Standard_EXPORT Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const Poly_Array1OfTriangle& theTriangles);
//! Constructs a triangulation from a set of triangles.
//! The triangulation is initialized with 3D points from Nodes, 2D points from theUVNodes and triangles from theTriangles,
//! where coordinates of a 2D point from theUVNodes are the (u, v) parameters of the corresponding 3D point
//! from theNodes on the surface approximated by the constructed triangulation. If size of theUVNodes != size of theNodes
//! then triangulation will be created without theUVNodes.
Standard_EXPORT Poly_Triangulation (const TColgp_Array1OfPnt& theNodes,
const TColgp_Array1OfPnt2d& theUVNodes,
const Poly_Array1OfTriangle& theTriangles);
//! Creates full copy of current triangulation
Standard_EXPORT virtual Handle(Poly_Triangulation) Copy() const;
//! Copy constructor for triangulation.
Standard_EXPORT Poly_Triangulation (const Handle(Poly_Triangulation)& theTriangulation);
//! Returns the deflection of this triangulation.
Standard_EXPORT Standard_Real Deflection() const;
//! Sets the deflection of this triangulation to theDeflection.
//! See more on deflection in Polygon2D
Standard_EXPORT void Deflection (const Standard_Real theDeflection);
//! Deallocates the UV nodes.
Standard_EXPORT void RemoveUVNodes();
//! @return the number of nodes for this triangulation.
Standard_Integer NbNodes() const { return myNodes.Size(); }
//! @return the number of triangles for this triangulation.
Standard_Integer NbTriangles() const { return myTriangles.Size(); }
//! @return Standard_True if 2D nodes are associated with 3D nodes for this triangulation.
Standard_Boolean HasUVNodes() const { return myHasUVNodes; }
//! Adds Node to the triangulation. If triangulation has UVNodes or Normals
//! they will be expanded and set to zero values to match the new number of nodes.
//! @return index of the added Node.
Standard_EXPORT Standard_Integer AddNode (const gp_Pnt& theNode);
//! @return node at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT const gp_Pnt& Node (const Standard_Integer theIndex) const;
//! 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);
//! @return UVNode at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbNodes.
Standard_EXPORT const gp_Pnt2d& UVNode (const Standard_Integer theIndex) const;
//! 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);
//! Adds triangle to the triangulation.
//! @return index of the added triangle.
Standard_EXPORT virtual Standard_Integer AddTriangle (const Poly_Triangle& theTriangle);
//! @return triangle at the given index.
//! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbTriangles.
Standard_EXPORT const Poly_Triangle& Triangle (const Standard_Integer theIndex) const;
//! 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);
//! Changes normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT void SetNormal (const Standard_Integer theIndex,
const gp_Dir& theNormal);
//! Returns Standard_True if nodal normals are defined.
Standard_EXPORT Standard_Boolean HasNormals() const;
//! @return normal at the given index.
//! Raises Standard_OutOfRange exception.
Standard_EXPORT const gp_Dir Normal (const Standard_Integer theIndex) const;
protected:
Standard_Boolean myHasUVNodes;
Standard_Real myDeflection;
NCollection_Vector<gp_Pnt> myNodes;
NCollection_Vector<gp_Pnt2d> myUVNodes;
NCollection_Vector<Poly_Triangle> myTriangles;
NCollection_Vector<Standard_ShortReal> myNormals;
public:
DEFINE_STANDARD_RTTI(Poly_Triangulation)
};
DEFINE_STANDARD_HANDLE(Poly_Triangulation, MMgt_TShared)
#endif // _Poly_Triangulation_HeaderFile

View File

@@ -98,21 +98,20 @@ Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge& theEdge,
if (!aHIndices.IsNull())
{
const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
Standard_Integer anIndex = anIndices.Lower();
if (aLocation.IsIdentity())
{
for (; anIndex <= anIndices.Upper(); ++anIndex)
{
thePoints.Append (aNodes (anIndices (anIndex)));
thePoints.Append (aTriangulation->Node (anIndices (anIndex)));
}
}
else
{
for (; anIndex <= anIndices.Upper(); ++anIndex)
{
thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
thePoints.Append (aTriangulation->Node (anIndices (anIndex)).Transformed (aLocation));
}
}
return Standard_True;
@@ -327,7 +326,6 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
Handle(Poly_Triangulation) T = aTool.CurrentTriangulation (aLocation);
if (!T.IsNull())
{
const TColgp_Array1OfPnt& aNodes = T->Nodes();
// Build the connect tool
Poly_Connect aPolyConnect (T);
@@ -354,11 +352,10 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
TColStd_Array1OfInteger anInternal (0, 2 * aNbInternal);
Standard_Integer aFreeIndex = 1, anIntIndex = 1;
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
for (anI = 1; anI <= aNbTriangles; ++anI)
{
aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
aTriangles (anI).Get (aN[0], aN[1], aN[2]);
T->Triangle (anI).Get (aN[0], aN[1], aN[2]);
for (aJ = 0; aJ < 3; aJ++)
{
Standard_Integer k = (aJ + 1) % 3;
@@ -384,8 +381,8 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
Standard_Integer aFreeHalfNb = aFree.Length() / 2;
for (anI = 1; anI <= aFreeHalfNb; ++anI)
{
gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (aLocation);
gp_Pnt aPoint1 = T->Node (aFree (2 * anI - 1)).Transformed (aLocation);
gp_Pnt aPoint2 = T->Node (aFree (2 * anI )).Transformed (aLocation);
aSurfPoints.Append (aPoint1);
aSurfPoints.Append (aPoint2);
}

View File

@@ -57,8 +57,6 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
myDetectedTr (-1)
{
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);
@@ -77,8 +75,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
for (Standard_Integer aTriangleIdx = 1; aTriangleIdx <= aNbTriangles; aTriangleIdx++)
{
aPoly.Triangles (aTriangleIdx, aTriangle[0], aTriangle[1], aTriangle[2]);
aTriangles (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
myTriangul->Triangle (aTriangleIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
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;
@@ -96,8 +94,8 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
Standard_Integer aTrNodeIdx[3];
for (Standard_Integer aTrIdx = 1; aTrIdx <= aNbTriangles; aTrIdx++)
{
aTriangles (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
aCenter += (aNodes (aTrNodeIdx[0]).XYZ() + aNodes (aTrNodeIdx[1]).XYZ()+ aNodes (aTrNodeIdx[2]).XYZ()) / 3.0;
myTriangul->Triangle (aTrIdx).Get (aTrNodeIdx[0], aTrNodeIdx[1], aTrNodeIdx[2]);
aCenter += (myTriangul->Node (aTrNodeIdx[0]).XYZ() + myTriangul->Node (aTrNodeIdx[1]).XYZ()+ myTriangul->Node (aTrNodeIdx[2]).XYZ()) / 3.0;
}
}
if (aNbTriangles != 0)
@@ -107,9 +105,9 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
myBndBox.Clear();
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++aNodeIdx)
{
myBndBox.Add (SelectMgr_Vec3 (aNodes (aNodeIdx).X(),
aNodes (aNodeIdx).Y(),
aNodes (aNodeIdx).Z()));
myBndBox.Add (SelectMgr_Vec3 (myTriangul->Node (aNodeIdx).X(),
myTriangul->Node (aNodeIdx).Y(),
myTriangul->Node (aNodeIdx).Z()));
}
if (theIsInterior)
@@ -149,7 +147,7 @@ Select3D_SensitiveTriangulation::Select3D_SensitiveTriangulation (const Handle(S
myDetectedTr (-1)
{
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)
{
@@ -192,14 +190,14 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
if (mySensType == Select3D_TOS_INTERIOR)
{
Standard_Integer aNode1, aNode2, aNode3;
myTriangul->Triangles() (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
myTriangul->Triangle (aPrimIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = hasInitLoc ? myTriangul->Nodes().Value (aNode1).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode1);
gp_Pnt aPnt2 = hasInitLoc ? myTriangul->Nodes().Value (aNode2).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode2);
gp_Pnt aPnt3 = hasInitLoc ? myTriangul->Nodes().Value (aNode3).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode3);
gp_Pnt aPnt1 = hasInitLoc ? myTriangul->Node (aNode1).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode1);
gp_Pnt aPnt2 = hasInitLoc ? myTriangul->Node (aNode2).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode2);
gp_Pnt aPnt3 = hasInitLoc ? myTriangul->Node (aNode3).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode3);
aMinPnt = SelectMgr_Vec3 (Min (aPnt1.X(), Min (aPnt2.X(), aPnt3.X())),
Min (aPnt1.Y(), Min (aPnt2.Y(), aPnt3.Y())),
@@ -212,10 +210,10 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::Box (const Standard_Integer t
{
Standard_Integer aNodeIdx1 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx);
Standard_Integer aNodeIdx2 = myFreeEdges->Value (myFreeEdges->Lower() + aPrimIdx + 1);
gp_Pnt aNode1 = hasInitLoc ? myTriangul->Nodes().Value (aNodeIdx1).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNodeIdx1);
gp_Pnt aNode2 = hasInitLoc ? myTriangul->Nodes().Value (aNodeIdx2).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNodeIdx2);
gp_Pnt aNode1 = hasInitLoc ? myTriangul->Node (aNodeIdx1).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNodeIdx1);
gp_Pnt aNode2 = hasInitLoc ? myTriangul->Node (aNodeIdx2).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNodeIdx2);
aMinPnt = SelectMgr_Vec3 (Min (aNode1.X(), aNode2.X()),
Min (aNode1.Y(), aNode2.Y()),
@@ -273,10 +271,10 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
Standard_Integer aSegmStartIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 1);
Standard_Integer aSegmEndIdx = myFreeEdges->Value (aPrimitiveIdx * 2 + 2);
Handle(TColgp_HArray1OfPnt) anEdgePnts = new TColgp_HArray1OfPnt (1, 2);
gp_Pnt aSegmStart = hasInitLoc ? myTriangul->Nodes().Value (aSegmStartIdx).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aSegmStartIdx);
gp_Pnt aSegmEnd = hasInitLoc ? myTriangul->Nodes().Value (aSegmEndIdx).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aSegmEndIdx);
gp_Pnt aSegmStart = hasInitLoc ? myTriangul->Node (aSegmStartIdx).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aSegmStartIdx);
gp_Pnt aSegmEnd = hasInitLoc ? myTriangul->Node (aSegmEndIdx).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aSegmEndIdx);
anEdgePnts->SetValue (1, aSegmStart);
anEdgePnts->SetValue (2, aSegmEnd);
Standard_Boolean isMatched = theMgr.Overlaps (anEdgePnts, Select3D_TOS_BOUNDARY, theMatchDepth);
@@ -285,15 +283,14 @@ Standard_Boolean Select3D_SensitiveTriangulation::overlapsElement (SelectBasics_
}
else
{
const Poly_Array1OfTriangle& aTriangles = myTriangul->Triangles();
Standard_Integer aNode1, aNode2, aNode3;
aTriangles (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = hasInitLoc ? myTriangul->Nodes().Value (aNode1).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode1);
gp_Pnt aPnt2 = hasInitLoc ? myTriangul->Nodes().Value (aNode2).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode2);
gp_Pnt aPnt3 = hasInitLoc ? myTriangul->Nodes().Value (aNode3).Transformed (myInitLocation.Transformation())
: myTriangul->Nodes().Value (aNode3);
myTriangul->Triangle (aPrimitiveIdx + 1).Get (aNode1, aNode2, aNode3);
gp_Pnt aPnt1 = hasInitLoc ? myTriangul->Node (aNode1).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode1);
gp_Pnt aPnt2 = hasInitLoc ? myTriangul->Node (aNode2).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode2);
gp_Pnt aPnt3 = hasInitLoc ? myTriangul->Node (aNode3).Transformed (myInitLocation.Transformation())
: myTriangul->Node (aNode3);
return theMgr.Overlaps (aPnt1, aPnt2, aPnt3, Select3D_TOS_INTERIOR, theMatchDepth);
}
}
@@ -360,12 +357,10 @@ Select3D_BndBox3d Select3D_SensitiveTriangulation::BoundingBox()
if (myBndBox.IsValid())
return applyTransformation();
const Standard_Integer aLower = myTriangul->Nodes().Lower();
const Standard_Integer anUpper = myTriangul->Nodes().Upper();
Select3D_BndBox3d aBndBox;
for (Standard_Integer aNodeIdx = aLower; aNodeIdx <= anUpper; ++aNodeIdx)
for (Standard_Integer aNodeIdx = 1; aNodeIdx <= myTriangul->NbNodes(); ++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);
}
@@ -391,5 +386,5 @@ gp_Pnt Select3D_SensitiveTriangulation::CenterOfGeometry() const
//=======================================================================
Standard_Integer Select3D_SensitiveTriangulation::NbSubElements()
{
return myTriangul->Nodes().Length();
return myTriangul->NbNodes();
}

View File

@@ -25,7 +25,7 @@
#include <Standard_DefineHandle.hxx>
#include <Standard_Type.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TopLoc_Location.hxx>
#include <gp_Trsf.hxx>
#include <gp_Pnt.hxx>

View File

@@ -193,9 +193,7 @@ namespace
Poly_Connect aPolyConnect (aT);
// Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& aNodes = aT->Nodes();
const TColgp_Array1OfPnt2d& aUVNodes = aT->UVNodes();
TColgp_Array1OfDir aNormals (aNodes.Lower(), aNodes.Upper());
TColgp_Array1OfDir aNormals (1, aT->NbNodes());
StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
if (theHasTexels)
@@ -206,9 +204,9 @@ namespace
}
const Standard_Integer aDecal = anArray->VertexNumber();
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aT->NbNodes(); ++aNodeIter)
{
aPoint = aNodes (aNodeIter);
aPoint = aT->Node (aNodeIter);
if (!aLoc.IsIdentity())
{
aPoint.Transform (aTrsf);
@@ -216,10 +214,10 @@ namespace
aNormals (aNodeIter) = aNormals (aNodeIter).Transformed (aTrsf);
}
if (theHasTexels && aUVNodes.Upper() == aNodes.Upper())
if (theHasTexels && aT->HasUVNodes())
{
const gp_Pnt2d aTexel = gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
const gp_Pnt2d aTexel = 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, aNormals (aNodeIter), aTexel);
}
else
@@ -229,22 +227,21 @@ namespace
}
// Fill array with vertex and edge visibility info
const Poly_Array1OfTriangle& aTriangles = aT->Triangles();
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
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)
@@ -345,7 +342,6 @@ namespace
continue;
// get edge nodes indexes from face triangulation
const TColgp_Array1OfPnt& aTriNodes = aTriangulation->Nodes ();
const TColStd_Array1OfInteger& anEdgeNodes = anEdgePoly->Nodes ();
if (anEdgeNodes.Length () < 2)
@@ -362,7 +358,7 @@ namespace
Standard_Integer aTriIndex = anEdgeNodes.Value (aNodeIdx);
// get node and apply location transformation to the node
gp_Pnt aTriNode = aTriNodes.Value (aTriIndex);
gp_Pnt aTriNode = aTriangulation->Node (aTriIndex);
if (!aTrsf.IsIdentity ())
aTriNode.Transform (aTrsf);

View File

@@ -146,24 +146,17 @@ void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
TColgp_Array1OfDir& theNormals)
{
const Handle(Poly_Triangulation)& aPolyTri = thePolyConnect.Triangulation();
const TColgp_Array1OfPnt& aNodes = aPolyTri->Nodes();
if (aPolyTri->HasNormals())
{
// normals pre-computed in triangulation structure
const TShort_Array1OfShortReal& aNormals = aPolyTri->Normals();
const Standard_ShortReal* aNormArr = &(aNormals.Value (aNormals.Lower()));
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
const gp_Dir aNorm (aNormArr[anId + 0],
aNormArr[anId + 1],
aNormArr[anId + 2]);
theNormals (aNodeIter) = aNorm;
theNormals (aNodeIter) = aPolyTri->Normal (aNodeIter);
}
if (theFace.Orientation() == TopAbs_REVERSED)
{
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
theNormals.ChangeValue (aNodeIter).Reverse();
}
@@ -176,24 +169,21 @@ void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aZeroFace);
const Standard_Real aTol = Precision::Confusion();
Handle(TShort_HArray1OfShortReal) aNormals = new TShort_HArray1OfShortReal (1, aPolyTri->NbNodes() * 3);
const Poly_Array1OfTriangle& aTriangles = aPolyTri->Triangles();
const TColgp_Array1OfPnt2d* aNodesUV = aPolyTri->HasUVNodes() && !aSurf.IsNull()
? &aPolyTri->UVNodes()
: NULL;
Standard_Boolean hasUVNodes = aPolyTri->HasUVNodes() && !aSurf.IsNull();
Standard_Integer aTri[3];
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
// try to retrieve normal from real surface first, when UV coordinates are available
if (aNodesUV == NULL
|| GeomLib::NormEstim (aSurf, aNodesUV->Value (aNodeIter), aTol, theNormals (aNodeIter)) > 1)
if (hasUVNodes == Standard_False
|| GeomLib::NormEstim (aSurf, aPolyTri->UVNode (aNodeIter), aTol, theNormals (aNodeIter)) > 1)
{
// compute flat normals
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());
aPolyTri->Triangle (thePolyConnect.Value()).Get (aTri[0], aTri[1], aTri[2]);
const gp_XYZ v1 (aPolyTri->Node (aTri[1]).Coord() - aPolyTri->Node (aTri[0]).Coord());
const gp_XYZ v2 (aPolyTri->Node (aTri[2]).Coord() - aPolyTri->Node (aTri[1]).Coord());
const gp_XYZ vv = v1 ^ v2;
const Standard_Real aMod = vv.Modulus();
if (aMod >= aTol)
@@ -205,7 +195,7 @@ void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
theNormals (aNodeIter) = (aModMax > aTol) ? gp_Dir (eqPlan) : gp::DZ();
}
const Standard_Integer anId = (aNodeIter - aNodes.Lower()) * 3;
const Standard_Integer anId = (aNodeIter - 1) * 3;
aNormals->SetValue (anId + 1, (Standard_ShortReal )theNormals (aNodeIter).X());
aNormals->SetValue (anId + 2, (Standard_ShortReal )theNormals (aNodeIter).Y());
aNormals->SetValue (anId + 3, (Standard_ShortReal )theNormals (aNodeIter).Z());
@@ -214,7 +204,7 @@ void StdPrs_ToolShadedShape::Normal (const TopoDS_Face& theFace,
if (theFace.Orientation() == TopAbs_REVERSED)
{
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aPolyTri->NbNodes(); ++aNodeIter)
{
theNormals.ChangeValue (aNodeIter).Reverse();
}

View File

@@ -17,10 +17,9 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <Poly_Triangulation.hxx>
class TopoDS_Shape;
class Poly_Triangulation;
class TopoDS_Face;
class TopLoc_Location;
class Poly_Connect;

View File

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

View File

@@ -518,8 +518,6 @@ void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(SelectMgr_Sel
const Handle(Poly_Triangulation)& PT =
(*((Handle(Select3D_SensitiveTriangulation)*) &Ent))->Triangulation();
const Poly_Array1OfTriangle& triangles = PT->Triangles();
const TColgp_Array1OfPnt& Nodes = PT->Nodes();
Standard_Integer n[3];
TopLoc_Location iloc, bidloc;
@@ -534,10 +532,10 @@ void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(SelectMgr_Sel
Standard_Integer i;
for (i = 1; i <= PT->NbTriangles(); i++)
{
triangles (i).Get (n[0], n[1], n[2]);
gp_Pnt P1 (Nodes (n[0]).Transformed (iloc));
gp_Pnt P2 (Nodes (n[1]).Transformed (iloc));
gp_Pnt P3 (Nodes (n[2]).Transformed (iloc));
PT->Triangle (i).Get (n[0], n[1], n[2]);
gp_Pnt P1 (PT->Node (n[0]).Transformed (iloc));
gp_Pnt P2 (PT->Node (n[1]).Transformed (iloc));
gp_Pnt P3 (PT->Node (n[2]).Transformed (iloc));
gp_XYZ V1 (P1.XYZ());
gp_XYZ V2 (P2.XYZ());
gp_XYZ V3 (P3.XYZ());
@@ -564,7 +562,7 @@ void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(SelectMgr_Sel
for (i = 1; i <= PT->NbTriangles(); i++)
{
pc.Triangles (i, t[0], t[1], t[2]);
triangles (i).Get (n[0], n[1], n[2]);
PT->Triangle (i).Get (n[0], n[1], n[2]);
for (j = 0; j < 3; j++)
{
Standard_Integer k = (j + 1) % 3;
@@ -578,7 +576,7 @@ void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(SelectMgr_Sel
}
for (Standard_Integer ifri = 1; ifri <= FreeE.Length(); ifri += 2)
{
gp_Pnt pe1 (Nodes (FreeE (ifri)).Transformed (iloc)), pe2 (Nodes (FreeE (ifri + 1)).Transformed (iloc));
gp_Pnt pe1 (PT->Node (FreeE (ifri)).Transformed (iloc)), pe2 (PT->Node (FreeE (ifri + 1)).Transformed (iloc));
aSeqFree.Append(pe1);
aSeqFree.Append(pe2);
}

View File

@@ -60,11 +60,10 @@ static void Normal(const TopoDS_Face& aFace,
CSLib_DerivativeStatus Status;
CSLib_NormalStatus NStat;
S.Initialize(aFace, Standard_False);
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
if (S.GetType() != GeomAbs_Plane) {
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(),Status,Nor(i));
if (Status != CSLib_Done) {
@@ -76,8 +75,8 @@ static void Normal(const TopoDS_Face& aFace,
}
else {
gp_Dir NPlane;
U = UVNodes(UVNodes.Lower()).X();
V = UVNodes(UVNodes.Lower()).Y();
U = T->UVNode (1).X();
V = T->UVNode (1).Y();
S.D1(U,V,P,D1U,D1V);
CSLib::Normal(D1U,D1V,Precision::Angular(),Status,NPlane);
if (Status != CSLib_Done) {
@@ -90,16 +89,14 @@ static void Normal(const TopoDS_Face& aFace,
}
}
else {
const TColgp_Array1OfPnt& Nodes = T->Nodes();
Standard_Integer n[3];
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
for (i = 1; i <= T->NbNodes(); i++) {
gp_XYZ eqPlan(0, 0, 0);
for (pc.Initialize(i); pc.More(); pc.Next()) {
triangles(pc.Value()).Get(n[0], n[1], n[2]);
gp_XYZ v1(Nodes(n[1]).Coord()-Nodes(n[0]).Coord());
gp_XYZ v2(Nodes(n[2]).Coord()-Nodes(n[1]).Coord());
T->Triangle (pc.Value()).Get(n[0], n[1], n[2]);
gp_XYZ v1(T->Node (n[1]).Coord() - T->Node (n[0]).Coord());
gp_XYZ v2(T->Node (n[2]).Coord() - T->Node (n[1]).Coord());
eqPlan += (v1^v2).Normalized();
}
Nor(i) = gp_Dir(eqPlan);
@@ -116,30 +113,25 @@ void StlTransfer::RetrieveMesh (const TopoDS_Shape& Shape,
TopLoc_Location Loc, loc;
Handle(Poly_Triangulation) theTriangulation = BRep_Tool::Triangulation(face, Loc);
if (theTriangulation.IsNull()) continue; //Meshing was not done for this face!
Poly_Array1OfTriangle theTriangles(1,theTriangulation->NbTriangles());
theTriangles.Assign(theTriangulation->Triangles());
Mesh->AddDomain (theTriangulation->Deflection());
TColgp_Array1OfPnt thePoints(1, theTriangulation->NbNodes());
thePoints.Assign(theTriangulation->Nodes());
//compute normal of face
const TColgp_Array1OfPnt& Nodes = theTriangulation->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
TColgp_Array1OfDir NORMAL(1, theTriangulation->NbNodes());
Poly_Connect pc(theTriangulation);
Normal(face, pc, NORMAL);
Standard_Integer i;
for(i=1;i<=thePoints.Length();i++) {
for(i=1;i<=theTriangulation->NbNodes();i++) {
Standard_Real X1, Y1, Z1;
gp_Pnt p = thePoints.Value(i);
gp_Pnt p = theTriangulation->Node (i);
p.Transform(Loc.Transformation());
p.Coord (X1, Y1, Z1);
Mesh->AddVertex (X1, Y1, Z1);
}
try {
OCC_CATCH_SIGNALS
for (i=1;i<=theTriangles.Length();i++) {
for (i=1;i<=theTriangulation->NbTriangles();i++) {
Standard_Integer V1, V2, V3;
Poly_Triangle triangle = theTriangles.Value(i);
Poly_Triangle triangle = theTriangulation->Triangle (i);
triangle.Get(V1, V2, V3);
gp_Pnt P1, P2, P3;
P1 = Mesh->Vertices(Mesh->NbDomains()).Value(V1);

View File

@@ -2764,14 +2764,12 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
}
Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
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
@@ -2779,7 +2777,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
x[0] = mCenter[0];
x[1] = mCenter[1];
x[2] = mCenter[2] - mRadius;
PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
polyTriangulation->ChangeNode (2) = gp_Pnt(x[0],x[1],x[2]);
}
number_point = 3;
@@ -2794,7 +2792,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
x[0] = n[0] + mCenter[0];
x[1] = n[1] + mCenter[1];
x[2] = n[2] + mCenter[2];
PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
polyTriangulation->ChangeNode (number_point) = gp_Pnt(x[0],x[1],x[2]);
number_point++;
}
}
@@ -2806,7 +2804,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + numPoles;
pts[1] = (phiResolution*(i+1) % base) + numPoles;
pts[2] = 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle(pts[0],pts[1],pts[2]);
number_triangle++;
}
}
@@ -2817,7 +2815,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + numOffset;
pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
pts[1] = numPoles - 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->ChangeTriangle (number_triangle) = Poly_Triangle(pts[0],pts[1],pts[2]);
number_triangle++;
}
}
@@ -2829,11 +2827,11 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
pts[0] = phiResolution*i + j + numPoles;
pts[1] = pts[0] + 1;
pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
polyTriangulation->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++;
}
}
@@ -2846,12 +2844,12 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
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;
@@ -2865,7 +2863,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
else
Nor = gp_Dir(0., 0., 1.);
Standard_Integer j = (i - PointsOfArray.Lower()) * 3;
Standard_Integer j = (i - 1) * 3;
Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
@@ -2917,8 +2915,8 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
= new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
aResolution,
aRadius));
Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
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
@@ -5734,20 +5732,19 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
continue;
}
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
const gp_Trsf& aTrsf = aLocation.Transformation();
// extract normals from nodes
TColgp_Array1OfDir aNormals (aNodes.Lower(), hasNormals ? aNodes.Upper() : aNodes.Lower());
TColgp_Array1OfDir aNormals (1, hasNormals ? aTriangulation->NbNodes() : 1);
if (hasNormals)
{
Poly_Connect aPolyConnect (aTriangulation);
StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
}
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter)
{
gp_Pnt aPoint = aNodes (aNodeIter);
gp_Pnt aPoint = aTriangulation->Node (aNodeIter);
if (!aLocation.IsIdentity())
{
aPoint.Transform (aTrsf);

View File

@@ -223,9 +223,7 @@ Standard_Boolean Voxel_FastConverter::Convert(Standard_Integer& progress,
if (transform)
trsf = L.Transformation();
const TColgp_Array1OfPnt& nodes = T->Nodes();
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
Standard_Integer itriangle = 1, nb_triangles = T->NbTriangles();
for (; itriangle <= nb_triangles; itriangle++)
{
ithread_triangle++;
@@ -242,11 +240,11 @@ Standard_Boolean Voxel_FastConverter::Convert(Standard_Integer& progress,
return Standard_True;
}
const Poly_Triangle& t = triangles.Value(itriangle);
const Poly_Triangle& t = T->Triangle (itriangle);
t.Get(n1, n2, n3);
gp_Pnt p1 = nodes.Value(n1);
gp_Pnt p2 = nodes.Value(n2);
gp_Pnt p3 = nodes.Value(n3);
gp_Pnt p1 = T->Node (n1);
gp_Pnt p2 = T->Node (n2);
gp_Pnt p3 = T->Node (n3);
if (transform)
{
p1.Transform(trsf);
@@ -361,9 +359,7 @@ Standard_Boolean Voxel_FastConverter::ConvertUsingSAT(Standard_Integer& pro
if (transform)
trsf = L.Transformation();
const TColgp_Array1OfPnt& nodes = T->Nodes();
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
Standard_Integer itriangle = 1, nb_triangles = T->NbTriangles();
for (; itriangle <= nb_triangles; itriangle++)
{
ithread_triangle++;
@@ -380,12 +376,12 @@ Standard_Boolean Voxel_FastConverter::ConvertUsingSAT(Standard_Integer& pro
return Standard_True;
}
const Poly_Triangle& t = triangles.Value(itriangle);
const Poly_Triangle& t = T->Triangle (itriangle);
t.Get(n1, n2, n3);
gp_Pnt p1 = nodes.Value(n1);
gp_Pnt p2 = nodes.Value(n2);
gp_Pnt p3 = nodes.Value(n3);
gp_Pnt p1 = T->Node (n1);
gp_Pnt p2 = T->Node (n2);
gp_Pnt p3 = T->Node (n3);
if (transform)
{
p1.Transform(trsf);

View File

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

View File

@@ -133,18 +133,16 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
myTShape = aFace;
// Copy the triangulation vertices
TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
NCollection_DataMap <int, int>::Iterator anIterN(mapNodeId);
for (i = 1; anIterN.More(); anIterN.Next()) {
const int aKey = anIterN.Key();
const gp_XYZ& aNodePnt = arrNodes[aKey];
aNodes(i) = gp_Pnt (aNodePnt);
aTriangulation->ChangeNode (i) = gp_Pnt (aNodePnt);
anIterN.ChangeValue() = i++;
}
// Copy the triangles. Only the triangle-type polygons are supported.
// In this loop we also get rid of any possible degenerated triangles.
Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
nTri = 0;
for (i = 0; i < (int)myNbPolygons; i++) {
const Standard_Integer * arrIndice;
@@ -153,9 +151,9 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
arrIndice[0] < nNodes &&
arrIndice[1] < nNodes &&
arrIndice[2] < nNodes) // check to avoid previously skipped faces
aTriangles(++nTri).Set (mapNodeId(arrIndice[0]),
mapNodeId(arrIndice[1]),
mapNodeId(arrIndice[2]));
aTriangulation->ChangeTriangle (++nTri).Set (mapNodeId(arrIndice[0]),
mapNodeId(arrIndice[1]),
mapNodeId(arrIndice[2]));
}
// Normals should be defined; if they are not, compute them

View File

@@ -308,8 +308,6 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
Standard_Integer i;
const Standard_Integer nNodes (theTri->NbNodes());
const Standard_Integer nTriangles (theTri->NbTriangles());
const TColgp_Array1OfPnt& arrPolyNodes = theTri->Nodes();
const Poly_Array1OfTriangle& arrTriangles = theTri->Triangles();
const Handle(VrmlData_IndexedFaceSet) aFaceSet =
new VrmlData_IndexedFaceSet (myScene,
@@ -330,7 +328,7 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
Standard_Integer * aPolygon = static_cast<Standard_Integer *>
(anAlloc->Allocate (4*sizeof(Standard_Integer)));
aPolygon[0] = 3;
arrTriangles(i+1).Get (aPolygon[1],aPolygon[2],aPolygon[3]);
theTri->Triangle (i+1).Get (aPolygon[1],aPolygon[2],aPolygon[3]);
aPolygon[1]--;
if (isReverse) {
const Standard_Integer aTmp = aPolygon[2]-1;
@@ -350,7 +348,7 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
gp_XYZ * arrNodes = static_cast <gp_XYZ *>
(anAlloc->Allocate (nNodes * sizeof(gp_XYZ)));
for (i = 0; i < nNodes; i++)
arrNodes[i] = arrPolyNodes(i+1).XYZ() * myScale;
arrNodes[i] = theTri->Node (i+1).XYZ() * myScale;
const Handle(VrmlData_Coordinate) aCoordNode =
new VrmlData_Coordinate (myScene, 0L, nNodes, arrNodes);
@@ -362,13 +360,9 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
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));
arrVec[i] = aNormal;
for (i = 0; i < nNodes; i++)
{
arrVec[i] = theTri->Normal (i + 1).XYZ();
}
const Handle(VrmlData_Normal) aNormalNode =
new VrmlData_Normal (myScene, 0L, nNodes, arrVec);
@@ -389,14 +383,13 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
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;
@@ -406,9 +399,9 @@ Handle(VrmlData_Geometry) VrmlData_ShapeConvert::triToIndexedFaceSet
gp_XYZ eqPlan(0., 0., 0.);
for (PC.Initialize(i+1); PC.More(); PC.Next()) {
arrTriangles(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());
theTri->Triangle (PC.Value()).Get(n[0], n[1], n[2]);
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();

View File

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

View File

@@ -144,10 +144,9 @@ Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
BRep_Tool::Triangulation(aFace, aLoc);
const Standard_Integer aLength = aTriangulation->NbNodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
for ( Standard_Integer i = 1; i <= aLength; ++i )
{
const gp_Pnt& aPoint = aNodes(i);
const gp_Pnt& aPoint = aTriangulation->Node (i);
anOut << " "
<< aPoint.X() << " "
@@ -171,10 +170,9 @@ Standard_Boolean XSDRAWSTLVRML_ToVRML::Write
BRep_Tool::Triangulation(aFace, aLoc);
const Standard_Integer aNbTriangles = aTriangulation->NbTriangles();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
for ( Standard_Integer i = 1, v[3]; i <= aNbTriangles; ++i )
{
aTriangles(i).Get(v[0], v[1], v[2]);
aTriangulation->Triangle (i).Get(v[0], v[1], v[2]);
anOut << " "
<< v[0] - 1 << ", "

View File

@@ -125,18 +125,16 @@ Standard_Boolean MyDirFunction::Value(const Standard_Real x,
p = Dir->Value(i);
P->Value(i) = p * x + P0->Value(i);
}
if( F->Value(*P, *FV) ) {
if( F->Value(*P, *FV) )
{
Standard_Real aVal = 0.;
Standard_Real aVal = 0.0;
for(Standard_Integer i = FV->Lower(); i <= FV->Upper(); i++) {
for(Standard_Integer i = FV->Lower(); i <= FV->Upper(); i++)
{
aVal = FV->Value(i);
if(aVal < 0.) {
if(aVal <= -1.e+100) // Precision::HalfInfinite() later
// if(Precision::IsInfinite(Abs(FV->Value(i)))) {
// fval = Precision::Infinite();
return Standard_False;
}
if(aVal <= -1.e+100) // Precision::HalfInfinite() later
return Standard_False;
else if(aVal >= 1.e+100) // Precision::HalfInfinite() later
return Standard_False;
}
@@ -317,7 +315,8 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
// (2) Si l'on a pas assez progresser on realise une recherche
// en bonne et due forme, a partir des inits precedents
if ((fsol > 0.2*PValue) && (tol1d < 0.5)) {
if ((fsol > 0.2*PValue) && (tol1d < 0.5))
{
if (tsol <0) {
ax = tsol; bx = 0.0; cx = 1.0;
@@ -328,17 +327,52 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
FSR_DEBUG(" minimisation dans la direction");
math_BrentMinimum Sol(tol1d, 100, tol1d);
Sol.Perform(F, ax, bx, cx);
if(Sol.IsDone()) {
if (Sol.Minimum() <= Result) {
// Base invocation.
Sol.Perform(F, ax, bx, cx);
if(Sol.IsDone())
{
if (Sol.Minimum() <= Result)
{
tsol = Sol.Location();
good = Standard_True;
FSR_DEBUG("t= "<<tsol<<" F ="<< Sol.Minimum() << " OldF = "<<Result)
}
}
Result = Sol.Minimum();
// Objective function changes too fast ->
// perform additional computations.
if (Gradient.Norm2() > 1.0 / Precision::SquareConfusion() &&
tsol > ax &&
tsol < cx) // Solution inside of (ax, cx) interval.
{
// First and second part invocation.
Sol.Perform(F, ax, (ax + tsol) / 2.0, tsol);
if(Sol.IsDone())
{
if (Sol.Minimum() <= Result)
{
tsol = Sol.Location();
good = Standard_True;
Result = Sol.Minimum();
}
}
Sol.Perform(F, tsol, (cx + tsol) / 2.0, cx);
if(Sol.IsDone())
{
if (Sol.Minimum() <= Result)
{
tsol = Sol.Location();
good = Standard_True;
Result = Sol.Minimum();
}
}
}
} // if (Sol.Minimum() <= Result)
} // if(Sol.IsDone())
}
if (good) {
if (good)
{
// mise a jour du Delta
Dir.Multiply(tsol);
}

View File

@@ -0,0 +1,44 @@
puts "=========="
puts "OCC26197"
puts "=========="
puts ""
############################################################
# Incomplete intersection curve
############################################################
restore [locate_data_file bug26197_profile_1093.brep] b1
restore [locate_data_file bug26197_endcut1_1093.brep] b2
explode b1 f
copy b1_107 f1
explode b2 f
copy b2_2 f2
bsection result f1 f2
explode result e
mk2dcurve c2d2 result_1 f2
bounds c2d2 u1 u2
puts [dval u1]
puts [dval u2]
2dcvalue c2d2 u1 x y1
2dcvalue c2d2 u2 x y2
set y1_ [dval y1]
set y2_ [dval y2]
set tol_abs 1.e-7
set tol_rel 1.e-7
#V-last of the surface of f2 face
set expected_y 1.1883793591414735
checkreal "extension the section line to the surface boundary?" ${y2_} ${expected_y} ${tol_abs} ${tol_rel}
smallview
donly result f1 f2
fit
set only_screen_axo 1

View File

@@ -0,0 +1,37 @@
puts "========"
puts "OCC26356"
puts "========"
puts ""
#############################################
# Wrong result done by projection algorithm
#############################################
restore [locate_data_file OCC26356-f.brep] b1
restore [locate_data_file OCC26356-w.brep] b2
explode b2 v
point p1 31350.009765625 7100 -2.17374844144233e-013
set bug_info_1 [projponf b1 p1 -min -g]
set bug_info_1 [string trim [string range $bug_info_1 [expr {[string first "=" $bug_info_1] + 1}] [expr {[string length $bug_info_1] - 1}]]]
set bug_info_1 [string trim [string range $bug_info_1 0 [expr {[string first " " $bug_info_1] - 1}]]]
set bug_info_2 [projponf b1 p1 -minmax -g]
set bug_info_2 [string trim [string range $bug_info_2 [expr {[string first "=" $bug_info_2] + 1}] [expr {[string length $bug_info_2] - 1}]]]
set bug_info_2 [string trim [string range $bug_info_2 0 [expr {[string first " " $bug_info_2] - 1}]]]
point p2 29200.099609375 7100 -2.17374753743702e-013
set bug_info_3 [projponf b1 p2 -min -g]
set bug_info_3 [string trim [string range $bug_info_3 [expr {[string first "=" $bug_info_3] + 1}] [expr {[string length $bug_info_3] - 1}]]]
set bug_info_3 [string trim [string range $bug_info_3 0 [expr {[string first " " $bug_info_3] - 1}]]]
set bug_info_4 [projponf b1 p2 -minmax -g]
set bug_info_4 [string trim [string range $bug_info_4 [expr {[string first "=" $bug_info_4] + 1}] [expr {[string length $bug_info_4] - 1}]]]
set bug_info_4 [string trim [string range $bug_info_4 0 [expr {[string first " " $bug_info_4] - 1}]]]
if {$bug_info_1 != $bug_info_2} {
puts "ERROR: OCC26356 is reproduced."
puts "For point #1: distance min is: ${bug_info_1}, distance minmax is: ${bug_info_2}."
}
if {$bug_info_3 != $bug_info_4} {
puts "ERROR: OCC26356 is reproduced."
puts "For point #2: distance min is: ${bug_info_3}, distance minmax is: ${bug_info_4}."
}

View File

@@ -0,0 +1,12 @@
puts "========"
puts "OCC26418"
puts "========"
puts ""
#################################################################################
# Unjustified limitation on tolerance of a input shape in BRepOffset_MakeOffset
#################################################################################
offsetparameter 1e-7 a i
restore [locate_data_file OCC26418-extracted_Plate103contour.brep] sh
offsetload sh 10
offsetperform r

View File

@@ -0,0 +1,12 @@
puts "========"
puts "OCC26418"
puts "========"
puts ""
#################################################################################
# Unjustified limitation on tolerance of a input shape in BRepOffset_MakeOffset
#################################################################################
offsetparameter 1e-7 a i
restore [locate_data_file OCC26418-extracted_Plate103contour.brep] sh
offsetload sh 16
offsetperform r

View File

@@ -0,0 +1,12 @@
puts "========"
puts "OCC26418"
puts "========"
puts ""
#################################################################################
# Unjustified limitation on tolerance of a input shape in BRepOffset_MakeOffset
#################################################################################
offsetparameter 1e-7 a i
restore [locate_data_file OCC26418-extracted_Plate310contour.brep] sh
offsetload sh 10
offsetperform r

View File

@@ -0,0 +1,12 @@
puts "========"
puts "OCC26418"
puts "========"
puts ""
#################################################################################
# Unjustified limitation on tolerance of a input shape in BRepOffset_MakeOffset
#################################################################################
offsetparameter 1e-7 a i
restore [locate_data_file OCC26418-extracted_Plate310contour.brep] sh
offsetload sh 15
offsetperform r

View File

@@ -0,0 +1,17 @@
puts "========="
puts "OCC26442"
puts "========="
puts ""
###############################################
# Access violation in BRepOffset_MakeOffset
###############################################
restore [locate_data_file OCC26464-extracted_Plate5520contour.brep] sh
offsetparameter 1.e-7 p i
offsetload sh 40
offsetperform result
checkshape result
set 2dviewer 1

View File

@@ -0,0 +1,17 @@
puts "========="
puts "OCC26442"
puts "========="
puts ""
###############################################
# Access violation in BRepOffset_MakeOffset
###############################################
restore [locate_data_file OCC26464-extracted_Plate5520contour.brep] sh
offsetparameter 1.e-7 p i
offsetload sh 60
offsetperform result
checkshape result
set 2dviewer 1

View File

@@ -0,0 +1,17 @@
puts "========"
puts "OCC26464"
puts "========"
puts ""
#######################################################
# BRepOffset_MakeOffset does not provide valid output
#######################################################
smallview
restore [locate_data_file OCC26464-extracted_Plate5520contour.brep] sh
offsetparameter 1e-7 p i
offsetload sh 60
offsetperform r
fit
set only_screen_axo 1

30
tests/bugs/modalg_6/bug26493 Executable file
View File

@@ -0,0 +1,30 @@
puts "============"
puts "OCC26493"
puts "============"
puts ""
#######################################################################
# BRepProj_Projection failed to project a wire on a shell
#######################################################################
restore [locate_data_file bug26493_plate.brep] plate
restore [locate_data_file bug26493_wire.brep] wire
prj res wire plate 0 0 -1
renamevar res_1 result
set length 1003.94
set nbshapes_expected "
Number of shapes in shape
VERTEX : 2
EDGE : 1
WIRE : 1
FACE : 0
SHELL : 0
SOLID : 0
COMPSOLID : 0
COMPOUND : 0
SHAPE : 4
"
checknbshapes result -ref ${nbshapes_expected} -t -m "fuzzy booleans with multiple tools"

View File

@@ -1,10 +1,7 @@
puts "TODO OCC23068 ALL: An exception was caught"
puts "TODO OCC23068 ALL: \\*\\* Exception \\*\\*"
puts "TODO OCC23068 ALL: TEST INCOMPLETE"
#old file fritesb
restore [locate_data_file fritehaut] s
OFFSETSHAPE -.004 {s_3} $calcul $type
set volume 0
set volume 0.000514386