1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0023634: Eliminate Polyline and Polygon usage in drawers

Polylines and polygons removed, now everything is based on PrimitiveArrays.
Added use of Graphic3d_ArrayOfSegments, some additional clean up in Graphic3d_Group.
Dead code elimination in AIS and V3d
Corrected compilation errors
Fixed grid presentation
Adding test case correction
This commit is contained in:
kgv
2013-01-18 13:36:18 +04:00
parent 44cf55e600
commit b8ddfc2f5d
134 changed files with 4369 additions and 9572 deletions

View File

@@ -25,8 +25,8 @@
#include <StdPrs_Curve.ixx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
@@ -41,17 +41,14 @@
#include <TColgp_SequenceOfPnt.hxx>
static Standard_Integer myN = -1;
static Standard_Boolean first = Standard_True;
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
static void FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
{
First = aCurve.FirstParameter();
Last = aCurve.LastParameter();
@@ -63,125 +60,92 @@ static void FindLimits(const Adaptor3d_Curve& aCurve,
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
aCurve.D0(Last,P2);
do {
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
}
//==================================================================
// function: DrawCurve
// purpose:
//==================================================================
static void DrawCurve (const Adaptor3d_Curve& aCurve,
static void DrawCurve (const Adaptor3d_Curve& aCurve,
const Handle(Graphic3d_Group) aGroup,
const Standard_Integer NbP,
const Standard_Integer NbP,
const Standard_Real U1,
const Standard_Real U2,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
{
Standard_Integer nbintervals = 1;
if (aCurve.GetType() == GeomAbs_BSplineCurve) {
nbintervals = aCurve.NbKnots() - 1;
nbintervals = Max(1, nbintervals/3);
}
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable() && !drawCurve;
switch (aCurve.GetType()) {
case GeomAbs_Line:
switch (aCurve.GetType())
{
case GeomAbs_Line:
{
#ifdef OCC64
Graphic3d_Array1OfVertex VertexArray(1, 3);
gp_Pnt p = aCurve.Value(U1);
Points.Append(p);
VertexArray(1).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(0.5 * (U1 + U2));
Points.Append(p);
VertexArray(2).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(U2);
Points.Append(p);
VertexArray(3).SetCoord(p.X(), p.Y(), p.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
#else
static Graphic3d_Array1OfVertex VertexLine(1,2);
gp_Pnt p = aCurve.Value(U1);
Points.Append(p);
VertexLine(1).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(U2);
Points.Append(p);
VertexLine(2).SetCoord(p.X(), p.Y(), p.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexLine);
#endif
}
gp_Pnt p1 = aCurve.Value(U1);
gp_Pnt p2 = aCurve.Value(U2);
Points.Append(p1);
Points.Append(p2);
if(drawCurve)
{
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
aPrims->AddVertex(p1);
aPrims->AddVertex(p2);
aGroup->AddPrimitiveArray(aPrims);
}
}
break;
default:
default:
{
Standard_Real U;
Standard_Integer N = Max(2, NbP*nbintervals);
Standard_Real DU = (U2-U1) / (N-1);
const Standard_Integer N = Max(2, NbP*nbintervals);
const Standard_Real DU = (U2-U1) / (N-1);
gp_Pnt p;
if (first) {
myN = N;
first = Standard_False;
}
if (myN == N) {
Handle(Graphic3d_ArrayOfPolylines) aPrims;
if(drawCurve)
aPrims = new Graphic3d_ArrayOfPolylines(N);
static Graphic3d_Array1OfVertex VertexArray(1, N);
for (Standard_Integer i = 1; i <= N;i++) {
U = U1 + (i-1)*DU;
p = aCurve.Value(U);
Points.Append(p);
VertexArray(i).SetCoord(p.X(), p.Y(), p.Z());
}
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
}
else {
Graphic3d_Array1OfVertex VertexArray2(1, N);
for (Standard_Integer i = 1; i <= N;i++) {
U = U1 + (i-1)*DU;
p = aCurve.Value(U);
Points.Append(p);
VertexArray2(i).SetCoord(p.X(), p.Y(), p.Z());
}
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray2);
for (Standard_Integer i = 1; i <= N;i++) {
p = aCurve.Value(U1 + (i-1)*DU);
Points.Append(p);
if(drawCurve)
aPrims->AddVertex(p);
}
if(drawCurve)
aGroup->AddPrimitiveArray(aPrims);
}
}
}
//==================================================================
// function: MatchCurve
// purpose:
@@ -192,70 +156,61 @@ static Standard_Boolean MatchCurve (
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Quantity_Length TheDeflection,
const Quantity_Length TheDeflection,
const Standard_Integer NbP,
const Standard_Real U1,
const Standard_Real U2)
const Standard_Real U1,
const Standard_Real U2)
{
Quantity_Length retdist;
switch (aCurve.GetType()) {
case GeomAbs_Line:
switch (aCurve.GetType())
{
case GeomAbs_Line:
{
static Graphic3d_Array1OfVertex VertexArray(1,2);
gp_Pnt p1 = aCurve.Value(U1);
if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance)
return Standard_True;
gp_Pnt p2 = aCurve.Value(U2);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist);
}
break;
case GeomAbs_Circle:
{Standard_Real Radius = aCurve.Circle().Radius();
Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius);
Standard_Real Er = Abs( U2 - U1) / DU;
Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er));
gp_Pnt p1,p2;
if ( N > 0) {
Standard_Real U;
for (Standard_Integer Index = 1; Index <= N+1; Index++) {
U = U1 + (Index - 1) * DU;
p2 = aCurve.Value(U);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (Index>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
return Standard_False;
}
break;
default:
{
gp_Pnt p1,p2;
Standard_Real U;
Standard_Real DU = (U2-U1) / (NbP-1);
for (Standard_Integer i=1;i<=NbP;i++) {
U = U1 + (i-1)*DU;
p2 = aCurve.Value(U);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (i>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
return Standard_False;
gp_Pnt p1 = aCurve.Value(U1);
if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance)
return Standard_True;
gp_Pnt p2 = aCurve.Value(U2);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist);
}
case GeomAbs_Circle:
{
const Standard_Real Radius = aCurve.Circle().Radius();
const Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius);
const Standard_Real Er = Abs( U2 - U1) / DU;
const Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er));
if ( N > 0) {
gp_Pnt p1,p2;
for (Standard_Integer Index = 1; Index <= N+1; Index++) {
p2 = aCurve.Value(U1 + (Index - 1) * DU);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (Index>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
break;
}
default:
{
const Standard_Real DU = (U2-U1) / (NbP-1);
gp_Pnt p1,p2;
for (Standard_Integer i=1;i<=NbP;i++) {
p2 = aCurve.Value(U1 + (i-1)*DU);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (i>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
return Standard_False;
}
return Standard_False;
}
@@ -266,32 +221,26 @@ static Standard_Boolean MatchCurve (
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve) {
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve)
{
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect
(aDrawer->LineAspect()->Aspect());
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real V1, V2;
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
const Standard_Integer NbPoints = aDrawer->Discretisation();
TColgp_SequenceOfPnt Pnts;
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
NbPoints,
V1 , V2, Pnts, drawCurve);
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Pnts,drawCurve);
if (aDrawer->LineArrowDraw()) {
gp_Pnt Location;
gp_Vec Direction;
aCurve.D1(aCurve.LastParameter(),Location,Direction);
Prs3d_Arrow::Draw (aPresentation,
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
Prs3d_Arrow::Draw (aPresentation,Location,gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
}
}
@@ -301,80 +250,67 @@ void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Quantity_Length aDeflection,
const Handle(Prs3d_Drawer)& aDrawer,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
const Adaptor3d_Curve& aCurve,
const Quantity_Length aDeflection,
const Handle(Prs3d_Drawer)& aDrawer,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
{
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real aLimit = aDrawer->MaximalParameterValue();
Standard_Real V1, V2;
FindLimits(aCurve, aLimit, V1, V2);
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
NbPoints,
V1 , V2, Points, drawCurve);
const Standard_Integer NbPoints = aDrawer->Discretisation();
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Points,drawCurve);
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Quantity_Length aDeflection,
TColgp_SequenceOfPnt& Points,
const Standard_Integer NbPoints,
const Standard_Boolean drawCurve) {
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
NbPoints,
U1 , U2, Points, drawCurve);
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve) {
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Quantity_Length aDeflection,
TColgp_SequenceOfPnt& Points,
const Standard_Integer NbPoints,
const Standard_Boolean drawCurve)
{
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,U1,U2,Points,drawCurve);
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve)
{
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real V1 = U1;
Standard_Real V2 = U2;
if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue();
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
const Standard_Integer NbPoints = aDrawer->Discretisation();
TColgp_SequenceOfPnt Pnts;
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
NbPoints,
V1 , V2, Pnts, drawCurve);
DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Pnts,drawCurve);
if (aDrawer->LineArrowDraw()) {
gp_Pnt Location;
gp_Vec Direction;
aCurve.D1(aCurve.LastParameter(),Location,Direction);
Prs3d_Arrow::Draw (aPresentation,
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
Prs3d_Arrow::Draw (aPresentation,Location,gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
}
}
@@ -388,19 +324,19 @@ Standard_Boolean StdPrs_Curve::Match
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real V1, V2;
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
const Standard_Integer NbPoints = aDrawer->Discretisation();
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDrawer->MaximalChordialDeviation(), NbPoints,
V1 , V2);
aDrawer->MaximalChordialDeviation(),NbPoints,V1,V2);
}
//==================================================================
// function: Match
// purpose:
@@ -413,19 +349,16 @@ Standard_Boolean StdPrs_Curve::Match
const Adaptor3d_Curve& aCurve,
const Quantity_Length aDeflection,
const Standard_Real aLimit,
const Standard_Integer NbPoints) {
const Standard_Integer NbPoints)
{
Standard_Real V1, V2;
FindLimits(aCurve, aLimit, V1, V2);
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDeflection, NbPoints,
V1 , V2);
aDeflection,NbPoints,V1,V2);
}
//==================================================================
// function: Match
// purpose:
@@ -438,8 +371,8 @@ Standard_Boolean StdPrs_Curve::Match
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle (Prs3d_Drawer)& aDrawer) {
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real V1 = U1;
Standard_Real V2 = U2;
@@ -447,9 +380,8 @@ Standard_Boolean StdPrs_Curve::Match
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDrawer->MaximalChordialDeviation(),
aDrawer->Discretisation(),
V1 , V2);
aDrawer->MaximalChordialDeviation(),
aDrawer->Discretisation(),V1,V2);
}
@@ -468,8 +400,5 @@ Standard_Boolean StdPrs_Curve::Match
const Quantity_Length aDeflection,
const Standard_Integer aNbPoints)
{
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDeflection, aNbPoints,
U1 , U2);
return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,aNbPoints,U1,U2);
}

View File

@@ -38,12 +38,10 @@ uses
is
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aCurve : in out Curve from Adaptor3d;
aDrawer : Drawer from Prs3d;
drawCurve : Boolean from Standard = Standard_True);
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve with respect to the maximal chordial deviation defined
@@ -53,13 +51,11 @@ is
-- it is used if the curve is a part of some shape and PrimitiveArray
-- visualization approach is activated (it is activated by default).
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aCurve : in out Curve from Adaptor3d;
U1, U2 : Real from Standard;
aDrawer : Drawer from Prs3d;
drawCurve : Boolean from Standard = Standard_True);
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve with respect to the maximal chordial deviation defined
@@ -70,15 +66,12 @@ is
-- it is used if the curve is a part of some shape and PrimitiveArray
-- visualization approach is activated (it is activated by default).
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aCurve : in out Curve from Adaptor3d;
aDeflection : Real from Standard;
aLimit : Real from Standard;
anAngle : Real from Standard = 0.2;
drawCurve : Boolean from Standard = Standard_True);
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve with respect to the maximal chordial deviation aDeflection.
@@ -87,43 +80,38 @@ is
-- it is used if the curve is a part of some shape and PrimitiveArray
-- visualization approach is activated (it is activated by default).
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aCurve : in out Curve from Adaptor3d;
aDeflection : Real from Standard;
aDrawer : Drawer from Prs3d;
Points : out SequenceOfPnt from TColgp;
drawCurve : Boolean from Standard = Standard_True);
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve with respect to the maximal chordial deviation aDeflection.
-- The aspect is the current aspect
-- Points give a sequence of curve points.
-- Points give a sequence of curve points.
-- If drawCurve equals Standard_False the curve will not be displayed,
-- it is used if the curve is a part of some shape and PrimitiveArray
-- visualization approach is activated (it is activated by default).
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aCurve : in out Curve from Adaptor3d;
U1, U2 : Real from Standard;
aDeflection : Real from Standard;
Points : out SequenceOfPnt from TColgp;
Points : out SequenceOfPnt from TColgp;
anAngle : Real from Standard = 0.2;
drawCurve : Boolean from Standard = Standard_True);
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve with respect to the maximal chordial deviation aDeflection.
-- The aspect is the current aspect
-- The drawing will be limited between the points of parameter U1 and U2.
-- Points give a sequence of curve points.
-- Points give a sequence of curve points.
-- If drawCurve equals Standard_False the curve will not be displayed,
-- it is used if the curve is a part of some shape and PrimitiveArray
-- visualization approach is activated (it is activated by default).
Match(myclass; X, Y, Z : Length from Quantity;
aDistance : Length from Quantity;
aCurve : Curve from Adaptor3d;
@@ -135,8 +123,6 @@ is
-- chordial deviation defined by the drawer aDrawer is less then aDistance.
Match(myclass; X, Y, Z : Length from Quantity;
aDistance: Length from Quantity;
aCurve : Curve from Adaptor3d;
@@ -150,8 +136,6 @@ is
-- then aDistance. The drawing is considered between the points
-- of parameter U1 and U2;
Match(myclass; X,Y,Z : Length from Quantity;
aDistance : Length from Quantity;
aCurve : Curve from Adaptor3d;
@@ -165,8 +149,6 @@ is
-- aDeflection is less then aDistance.
Match(myclass; X, Y, Z : Length from Quantity;
aDistance : Length from Quantity;
aCurve : Curve from Adaptor3d;
@@ -180,9 +162,4 @@ is
-- aDeflection is less then aDistance. The drawing is considered
-- between the points of parameter U1 and U2;
end DeflectionCurve from StdPrs;

View File

@@ -22,8 +22,8 @@
#include <StdPrs_DeflectionCurve.ixx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
@@ -47,45 +47,46 @@
// purpose:
//==================================================================
static Standard_Real GetDeflection(const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle(Prs3d_Drawer)& aDrawer) {
Standard_Real TheDeflection;
Aspect_TypeOfDeflection TOD = aDrawer->TypeOfDeflection();
if (TOD == Aspect_TOD_RELATIVE) {
// On calcule la fleche en fonction des min max globaux de la piece:
Bnd_Box Total;
BndLib_Add3dCurve::Add(aCurve, U1, U2, 0.,Total);
Standard_Real m = RealFirst();
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
m = RealLast();
if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() ))
m = Abs (aXmax-aXmin);
if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() ))
m = Max ( m , Abs (aYmax-aYmin));
if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() ))
m = Max ( m , Abs (aZmax-aZmin));
m = Min ( m , aDrawer->MaximalParameterValue());
m = Max(m, Precision::Confusion());
TheDeflection = m * aDrawer->DeviationCoefficient();
}
else
TheDeflection = aDrawer->MaximalChordialDeviation();
const Standard_Real U1,
const Standard_Real U2,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Real TheDeflection;
return TheDeflection;
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
{
// On calcule la fleche en fonction des min max globaux de la piece:
Bnd_Box Total;
BndLib_Add3dCurve::Add(aCurve, U1, U2, 0.,Total);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
Standard_Real m = RealLast();
if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() ))
m = Abs (aXmax-aXmin);
if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() ))
m = Max ( m , Abs (aYmax-aYmin));
if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() ))
m = Max ( m , Abs (aZmax-aZmin));
m = Min ( m , aDrawer->MaximalParameterValue());
m = Max(m, Precision::Confusion());
TheDeflection = m * aDrawer->DeviationCoefficient();
}
else
TheDeflection = aDrawer->MaximalChordialDeviation();
return TheDeflection;
}
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
{
First = aCurve.FirstParameter();
Last = aCurve.LastParameter();
@@ -98,30 +99,30 @@ static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
Standard_Integer count = 0;
if (firstInf && lastInf) {
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
if (count++ == 100000) return Standard_False;
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
aCurve.D0(Last,P2);
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
if (count++ == 100000) return Standard_False;
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
if (count++ == 100000) return Standard_False;
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
@@ -129,95 +130,80 @@ static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
}
//==================================================================
// function: DrawCurve
// purpose:
//==================================================================
static void DrawCurve (Adaptor3d_Curve& aCurve,
static void DrawCurve (Adaptor3d_Curve& aCurve,
const Handle(Graphic3d_Group) aGroup,
const Quantity_Length TheDeflection,
const Standard_Real anAngle,
const Standard_Real anAngle,
const Standard_Real U1,
const Standard_Real U2,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
{
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable() && !drawCurve;
switch (aCurve.GetType()) {
case GeomAbs_Line:
switch (aCurve.GetType())
{
case GeomAbs_Line:
{
#ifdef OCC64
Graphic3d_Array1OfVertex VertexArray(1, 3);
gp_Pnt p = aCurve.Value(U1);
Points.Append(p);
VertexArray(1).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(0.5 * (U1 + U2));
Points.Append(p);
VertexArray(2).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(U2);
Points.Append(p);
VertexArray(3).SetCoord(p.X(), p.Y(), p.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
#else
static Graphic3d_Array1OfVertex VertexArray(1,2);
gp_Pnt p = aCurve.Value(U1);
Points.Append(p);
VertexArray(1).SetCoord(p.X(), p.Y(), p.Z());
p = aCurve.Value(U2);
Points.Append(p);
VertexArray(2).SetCoord(p.X(), p.Y(), p.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
#endif
}
break;
default:
gp_Pnt p1 = aCurve.Value(U1);
gp_Pnt p2 = aCurve.Value(U2);
Points.Append(p1);
Points.Append(p2);
if(drawCurve)
{
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
aPrims->AddVertex(p1);
aPrims->AddVertex(p2);
aGroup->AddPrimitiveArray(aPrims);
}
break;
}
default:
{
Standard_Integer nbinter = aCurve.NbIntervals(GeomAbs_C1);
Standard_Integer i, j;
const Standard_Integer nbinter = aCurve.NbIntervals(GeomAbs_C1);
TColStd_Array1OfReal T(1, nbinter+1);
aCurve.Intervals(T, GeomAbs_C1);
Standard_Real theU1, theU2;
Standard_Integer NumberOfPoints;
Standard_Integer NumberOfPoints, i, j;
TColgp_SequenceOfPnt SeqP;
for (j = 1; j <= nbinter; j++) {
theU1 = T(j); theU2 = T(j+1);
if (theU2 > U1 && theU1 < U2) {
theU1 = Max(theU1, U1);
theU2 = Min(theU2, U2);
theU1 = T(j); theU2 = T(j+1);
if (theU2 > U1 && theU1 < U2) {
theU1 = Max(theU1, U1);
theU2 = Min(theU2, U2);
GCPnts_TangentialDeflection Algo(aCurve, theU1, theU2, anAngle, TheDeflection);
NumberOfPoints = Algo.NbPoints();
if (NumberOfPoints > 0) {
for (i=1;i<NumberOfPoints;i++) {
SeqP.Append(Algo.Value(i));
}
if (j == nbinter) {
SeqP.Append(Algo.Value(NumberOfPoints));
}
}
}
GCPnts_TangentialDeflection Algo(aCurve, theU1, theU2, anAngle, TheDeflection);
NumberOfPoints = Algo.NbPoints();
if (NumberOfPoints > 0) {
for (i=1;i<NumberOfPoints;i++) {
SeqP.Append(Algo.Value(i));
}
if (j == nbinter) {
SeqP.Append(Algo.Value(NumberOfPoints));
}
}
}
}
Graphic3d_Array1OfVertex VertexArray(1, SeqP.Length());
Handle(Graphic3d_ArrayOfPolylines) aPrims;
if(drawCurve)
aPrims = new Graphic3d_ArrayOfPolylines(SeqP.Length());
Standard_Integer totalpoints = 1;
for (i = 1; i <= SeqP.Length(); i++) {
const gp_Pnt& p = SeqP.Value(i);
Points.Append(p);
VertexArray(totalpoints++).SetCoord(p.X(), p.Y(), p.Z());
const gp_Pnt& p = SeqP.Value(i);
Points.Append(p);
if(drawCurve)
aPrims->AddVertex(p);
}
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
if(drawCurve)
aGroup->AddPrimitiveArray(aPrims);
}
}
}
@@ -231,71 +217,65 @@ static Standard_Boolean MatchCurve (
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Quantity_Length TheDeflection,
const Quantity_Length TheDeflection,
const Standard_Real anAngle,
const Standard_Real U1,
const Standard_Real U2)
const Standard_Real U1,
const Standard_Real U2)
{
Quantity_Length retdist;
switch (aCurve.GetType()) {
case GeomAbs_Line:
switch (aCurve.GetType())
{
case GeomAbs_Line:
{
static Graphic3d_Array1OfVertex VertexArray(1,2);
gp_Pnt p1 = aCurve.Value(U1);
if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance)
return Standard_True;
gp_Pnt p2 = aCurve.Value(U2);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist);
}
break;
case GeomAbs_Circle:
gp_Pnt p1 = aCurve.Value(U1);
if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance)
return Standard_True;
gp_Pnt p2 = aCurve.Value(U2);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist);
}
case GeomAbs_Circle:
{
Standard_Real Radius = aCurve.Circle().Radius();
const Standard_Real Radius = aCurve.Circle().Radius();
if (!Precision::IsInfinite(Radius)) {
Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius);
Standard_Real Er = Abs( U2 - U1) / DU;
Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er));
gp_Pnt p1,p2;
if ( N > 0) {
Standard_Real U;
for (Standard_Integer Index = 1; Index <= N+1; Index++) {
U = U1 + (Index - 1) * DU;
p2 = aCurve.Value(U);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (Index>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
const Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius);
const Standard_Real Er = Abs( U2 - U1) / DU;
const Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er));
if ( N > 0) {
gp_Pnt p1,p2;
for (Standard_Integer Index = 1; Index <= N+1; Index++) {
p2 = aCurve.Value(U1 + (Index - 1) * DU);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (Index>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
}
return Standard_False;
}
break;
default:
break;
}
default:
{
GCPnts_TangentialDeflection Algo(aCurve,U1, U2, anAngle, TheDeflection);
gp_Pnt p1,p2;
Standard_Integer NumberOfPoints = Algo.NbPoints();
const Standard_Integer NumberOfPoints = Algo.NbPoints();
if (NumberOfPoints > 0) {
for (Standard_Integer i=1;i<=NumberOfPoints;i++) {
p2 = Algo.Value(i);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (i>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
gp_Pnt p1,p2;
for (Standard_Integer i=1;i<=NumberOfPoints;i++) {
p2 = Algo.Value(i);
if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance)
return Standard_True;
if (i>1) {
if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist))
return Standard_True;
}
p1=p2;
}
}
return Standard_False;
}
}
return Standard_False;
@@ -307,32 +287,31 @@ static Standard_Boolean MatchCurve (
// purpose:
//==================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve) {
Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve)
{
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
Standard_Real V1, V2, angle = aDrawer->DeviationAngle();
Standard_Boolean OK = FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
TColgp_SequenceOfPnt Points;
if (OK) {
Standard_Real V1, V2;
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
{
TColgp_SequenceOfPnt Points;
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
GetDeflection(aCurve, V1, V2, aDrawer),
angle,
V1 , V2, Points, drawCurve);
Prs3d_Root::CurrentGroup(aPresentation),
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(),
V1, V2, Points, drawCurve);
if (aDrawer->LineArrowDraw()) {
gp_Pnt Location;
gp_Vec Direction;
aCurve.D1(V2, Location,Direction);
Prs3d_Arrow::Draw (aPresentation,
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
}
}
}
@@ -343,38 +322,36 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
// purpose:
//==================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve) {
Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Handle (Prs3d_Drawer)& aDrawer,
const Standard_Boolean drawCurve)
{
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
Standard_Real V1 = U1;
Standard_Real V2 = U2;
if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue();
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
Standard_Real angle = aDrawer->DeviationAngle();
TColgp_SequenceOfPnt Points;
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
GetDeflection(aCurve, V1, V2, aDrawer),
angle,
V1 , V2, Points, drawCurve);
Prs3d_Root::CurrentGroup(aPresentation),
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(),
V1 , V2, Points, drawCurve);
if (aDrawer->LineArrowDraw()) {
gp_Pnt Location;
gp_Vec Direction;
aCurve.D1(V2, Location,Direction);
Prs3d_Arrow::Draw (aPresentation,
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
Location,
gp_Dir(Direction),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
}
}
@@ -383,36 +360,36 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
// purpose:
//==================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real aDeflection,
TColgp_SequenceOfPnt& Points,
const Standard_Real anAngle,
const Standard_Boolean drawCurve)
Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real aDeflection,
TColgp_SequenceOfPnt& Points,
const Standard_Real anAngle,
const Standard_Boolean drawCurve)
{
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
aDeflection, anAngle, U1, U2, Points, drawCurve);
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
Adaptor3d_Curve& aCurve,
const Standard_Real aDeflection,
const Standard_Real aLimit,
const Standard_Real anAngle,
const Standard_Boolean drawCurve)
Adaptor3d_Curve& aCurve,
const Standard_Real aDeflection,
const Standard_Real aLimit,
const Standard_Real anAngle,
const Standard_Boolean drawCurve)
{
Standard_Real V1, V2;
Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2);
TColgp_SequenceOfPnt Points;
if (OK) DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
aDeflection, anAngle, V1, V2, Points, drawCurve);
if (FindLimits(aCurve, aLimit, V1, V2))
{
TColgp_SequenceOfPnt Points;
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
aDeflection, anAngle, V1, V2, Points, drawCurve);
}
}
@@ -421,18 +398,16 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
// purpose:
//================================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
Adaptor3d_Curve& aCurve,
const Standard_Real aDeflection,
const Handle(Prs3d_Drawer)& aDrawer,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
Adaptor3d_Curve& aCurve,
const Standard_Real aDeflection,
const Handle(Prs3d_Drawer)& aDrawer,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
{
Standard_Real aLimit = aDrawer->MaximalParameterValue();
Standard_Real V1, V2;
Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2);
if (OK) DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
aDeflection, aDrawer->DeviationAngle(), V1, V2, Points, drawCurve);
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
aDeflection, aDrawer->DeviationAngle(), V1, V2, Points, drawCurve);
}
@@ -449,20 +424,16 @@ Standard_Boolean StdPrs_DeflectionCurve::Match
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real V1, V2;
Standard_Boolean OK = FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
if (OK) {
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
{
return MatchCurve(X,Y,Z,aDistance,aCurve,
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(),
V1 , V2);
}
else {
return Standard_False;
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(),
V1, V2);
}
return Standard_False;
}
//==================================================================
// function: Match
// purpose:
@@ -478,35 +449,32 @@ Standard_Boolean StdPrs_DeflectionCurve::Match
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real V1 = U1;
Standard_Real V2 = U2;
Standard_Real V2 = U2;
if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue();
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
return MatchCurve(X,Y,Z,aDistance,aCurve,
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(), V1 , V2);
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(), V1, V2);
}
//==================================================================
// function: Match
// purpose:
//==================================================================
Standard_Boolean StdPrs_DeflectionCurve::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real aDeflection,
const Standard_Real anAngle) {
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real aDeflection,
const Standard_Real anAngle)
{
return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,anAngle,U1,U2);
}
//==================================================================
@@ -521,24 +489,12 @@ Standard_Boolean StdPrs_DeflectionCurve::Match
const Adaptor3d_Curve& aCurve,
const Standard_Real aDeflection,
const Standard_Real aLimit,
const Standard_Real anAngle) {
const Standard_Real anAngle)
{
Standard_Real V1, V2;
Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2);
if (OK) {
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDeflection,
anAngle,
V1 , V2);
if (FindLimits(aCurve, aLimit, V1, V2))
{
return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,anAngle,V1,V2);
}
else {
return Standard_False;
}
return Standard_False;
}

View File

@@ -26,8 +26,6 @@
#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Prs3d_LineAspect.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
@@ -60,8 +58,6 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
TopExp_Explorer ex;
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
// find vertices not under ancestors.
TopAbs_ShapeEnum E = aShape.ShapeType();
if (E == TopAbs_COMPOUND) {
@@ -71,14 +67,11 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
}
}
Graphic3d_Array1OfVertex Vertex(1,2);
TColgp_SequenceOfPnt HiddenPnts;
TColgp_SequenceOfPnt SeenPnts;
Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
Standard_Real def;
if (rel) def = aDrawer->HLRDeviationCoefficient();
else def = aDrawer->MaximalChordialDeviation();
const Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
Standard_Real def = rel? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation();
BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle());
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape);
@@ -86,10 +79,8 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
hider->Projector(aProjector->Projector());
hider->Angle(aDrawer->HLRAngle());
hider->Update();
//Standard_Integer i;
Standard_Real sta,end,dx,dy,dz;
Standard_ShortReal tolsta, tolend;
//gp_Pnt PSta, PEnd;
HLRAlgo_EdgeStatus status;
HLRAlgo_EdgeIterator It;
Standard_Boolean reg1,regn,outl, intl;
@@ -98,105 +89,76 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
HLRBRep_ListOfBPoint BiPntVis, BiPntHid;
for (hider->InitHide(); hider->MoreHide(); hider->NextHide()) {
for (hider->InitHide(); hider->MoreHide(); hider->NextHide())
{
hider->Hide(Coordinates, status, S, reg1, regn, outl, intl);
dx = PntX2 - PntX1;
dy = PntY2 - PntY1;
dz = PntZ2 - PntZ1;
for (It.InitVisible(status); It.MoreVisible(); It.NextVisible()) {
for (It.InitVisible(status); It.MoreVisible(); It.NextVisible())
{
It.Visible(sta,tolsta,end,tolend);
BiPntVis.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
}
for (It.InitHidden(status); It.MoreHidden(); It.NextHidden()) {
for (It.InitHidden(status); It.MoreHidden(); It.NextHidden())
{
It.Hidden(sta,tolsta,end,tolend);
BiPntHid.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
}
}
// storage in the group:
HLRBRep_ListIteratorOfListOfBPoint ItB;
if (aDrawer->DrawHiddenLine()) {
if(!isPrimArrayEnabled) {
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->BeginPrimitives();
}
for (ItB.Initialize(BiPntHid); ItB.More(); ItB.Next()) {
const HLRBRep_BiPoint& BP = ItB.Value();
if (!BP.RgNLine() || BP.OutLine()) {
const gp_Pnt& P1 = BP.P1();
const gp_Pnt& P2 = BP.P2();
HiddenPnts.Append(P1);
HiddenPnts.Append(P2);
Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z());
Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(Vertex);
HiddenPnts.Append(BP.P1());
HiddenPnts.Append(BP.P2());
}
}
if(!isPrimArrayEnabled)
aGroup->EndPrimitives();
}
if(!isPrimArrayEnabled) {
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->BeginPrimitives();
}
for (ItB.Initialize(BiPntVis); ItB.More(); ItB.Next()) {
const HLRBRep_BiPoint& BP = ItB.Value();
if (!BP.RgNLine() || BP.OutLine()) {
const gp_Pnt& P1 = BP.P1();
const gp_Pnt& P2 = BP.P2();
SeenPnts.Append(P1);
SeenPnts.Append(P2);
Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z());
Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(Vertex);
SeenPnts.Append(BP.P1());
SeenPnts.Append(BP.P2());
}
}
if(!isPrimArrayEnabled)
aGroup->EndPrimitives();
if(isPrimArrayEnabled) {
Standard_Integer nbVertices = HiddenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
HiddenArray->AddBound(2);
HiddenArray->AddVertex(HiddenPnts.Value(i));
HiddenArray->AddVertex(HiddenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->BeginPrimitives();
aGroup->AddPrimitiveArray(HiddenArray);
aGroup->EndPrimitives();
Standard_Integer nbVertices = HiddenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
HiddenArray->AddBound(2);
HiddenArray->AddVertex(HiddenPnts.Value(i));
HiddenArray->AddVertex(HiddenPnts.Value(i+1));
}
nbVertices = SeenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
SeenArray->AddBound(2);
SeenArray->AddVertex(SeenPnts.Value(i));
SeenArray->AddVertex(SeenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->BeginPrimitives();
aGroup->AddPrimitiveArray(SeenArray);
aGroup->EndPrimitives();
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->AddPrimitiveArray(HiddenArray);
}
nbVertices = SeenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
SeenArray->AddBound(2);
SeenArray->AddVertex(SeenPnts.Value(i));
SeenArray->AddVertex(SeenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->AddPrimitiveArray(SeenArray);
}
}

View File

@@ -18,10 +18,9 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <StdPrs_Plane.ixx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
@@ -37,8 +36,8 @@
void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Surface& aPlane,
const Handle (Prs3d_Drawer)& aDrawer)
const Adaptor3d_Surface& aPlane,
const Handle (Prs3d_Drawer)& aDrawer)
{
// Prs3d_Root::NewGroup(aPresentation);
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
@@ -49,45 +48,38 @@ void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation,
gp_Pnt p1;
Standard_Real Xmax,Ymax;
Xmax = Standard_Real(theaspect->PlaneXLength())/2.;
Ymax = Standard_Real(theaspect->PlaneYLength())/2.;
Xmax = 0.5*Standard_Real(theaspect->PlaneXLength());
Ymax = 0.5*Standard_Real(theaspect->PlaneYLength());
if (theaspect->DisplayEdges()) {
static Graphic3d_Array1OfVertex EdgesArray(1,5);
TheGroup->SetPrimitivesAspect(theaspect->EdgesAspect()->Aspect());
thegeom->D0(-Xmax,Ymax,p1);
EdgesArray(1).SetCoord(p1.X(),p1.Y(),p1.Z());
EdgesArray(5).SetCoord(p1.X(),p1.Y(),p1.Z());
thegeom->D0(Xmax,Ymax,p1);
EdgesArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
thegeom->D0(Xmax,-Ymax,p1);
EdgesArray(3).SetCoord(p1.X(),p1.Y(),p1.Z());
thegeom->D0(-Xmax,-Ymax,p1);
EdgesArray(4).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(EdgesArray);
Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(5);
p1 = thegeom->Value(-Xmax,Ymax);
aPrims->AddVertex(p1);
aPrims->AddVertex(thegeom->Value( Xmax, Ymax));
aPrims->AddVertex(thegeom->Value( Xmax,-Ymax));
aPrims->AddVertex(thegeom->Value(-Xmax,-Ymax));
aPrims->AddVertex(p1);
TheGroup->AddPrimitiveArray(aPrims);
}
if (theaspect->DisplayIso()) {
static Graphic3d_Array1OfVertex IsoArray(1,2);
TheGroup->SetPrimitivesAspect(theaspect->IsoAspect()->Aspect());
Standard_Real dist = theaspect->IsoDistance();
const Standard_Real dist = theaspect->IsoDistance();
const Standard_Integer nbx = Standard_Integer(Abs(2.*Xmax) / dist) - 1;
const Standard_Integer nby = Standard_Integer(Abs(2.*Ymax) / dist) - 1;
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2*(nbx+nby));
Standard_Integer i;
Standard_Real cur = -Xmax+dist;
while (cur+dist/2. <= Xmax) {
thegeom->D0(cur,Ymax,p1);
IsoArray(1).SetCoord(p1.X(),p1.Y(),p1.Z());
thegeom->D0(cur,-Ymax,p1);
IsoArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(IsoArray);
cur += dist;
for (i = 0; i < nbx; i++, cur += dist) {
aPrims->AddVertex(thegeom->Value(cur, Ymax));
aPrims->AddVertex(thegeom->Value(cur,-Ymax));
}
cur = -Ymax+dist;
while (cur+dist/2. < Ymax) {
thegeom->D0(Xmax,cur,p1);
IsoArray(1).SetCoord(p1.X(),p1.Y(),p1.Z());
thegeom->D0(-Xmax,cur,p1);
IsoArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(IsoArray);
cur += dist;
for (i = 0; i < nby; i++, cur += dist) {
aPrims->AddVertex(thegeom->Value( Xmax,cur));
aPrims->AddVertex(thegeom->Value(-Xmax,cur));
}
TheGroup->AddPrimitiveArray(aPrims);
}
gp_Dir norm = thegeom->Pln().Axis().Direction();
@@ -97,63 +89,46 @@ void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation,
Quantity_PlaneAngle ang = theaspect->ArrowsAngle();
gp_Vec trans(norm);
trans.Scale(Standard_Real(siz));
TheGroup->SetPrimitivesAspect(theaspect->ArrowAspect()->Aspect());
Graphic3d_Array1OfVertex ArrowArray(1,2);
if (theaspect->DisplayCenterArrow()) {
loc = thegeom->Location();
p1 = loc.Translated(trans);
ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z());
ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(ArrowArray);
Prs3d_Arrow::Draw(aPresentation,
p1,
norm,
ang,
len);
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
aPrims->AddVertex(loc);
aPrims->AddVertex(p1);
TheGroup->AddPrimitiveArray(aPrims);
Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len);
}
if (theaspect->DisplayEdgesArrows()) {
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(8);
//
thegeom->D0(-Xmax,-Ymax,loc);
p1 = loc.Translated(trans);
ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z());
ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(ArrowArray);
Prs3d_Arrow::Draw(aPresentation,
p1,
norm,
ang,
len);
aPrims->AddVertex(loc);
aPrims->AddVertex(p1);
Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len);
//
thegeom->D0(-Xmax,Ymax,loc);
p1 = loc.Translated(trans);
ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z());
ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(ArrowArray);
Prs3d_Arrow::Draw(aPresentation,
p1,
norm,
ang,
len);
aPrims->AddVertex(loc);
aPrims->AddVertex(p1);
Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len);
//
thegeom->D0(Xmax,Ymax,loc);
p1 = loc.Translated(trans);
ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z());
ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(ArrowArray);
Prs3d_Arrow::Draw(aPresentation,
p1,
norm,
ang,
len);
aPrims->AddVertex(loc);
aPrims->AddVertex(p1);
Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len);
//
thegeom->D0(Xmax,-Ymax,loc);
p1 = loc.Translated(trans);
ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z());
ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z());
TheGroup->Polyline(ArrowArray);
Prs3d_Arrow::Draw(aPresentation,
p1,
norm,
ang,
len);
aPrims->AddVertex(loc);
aPrims->AddVertex(p1);
Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len);
//
TheGroup->AddPrimitiveArray(aPrims);
}
}
Standard_Boolean StdPrs_Plane::Match

View File

@@ -18,10 +18,9 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <StdPrs_PoleCurve.ixx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
@@ -47,27 +46,22 @@ void StdPrs_PoleCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
GeomAbs_CurveType CType = aCurve.GetType();
if (CType == GeomAbs_BezierCurve || CType == GeomAbs_BSplineCurve) {
Standard_Real x,y,z;
Standard_Integer i, Nb;
if (CType == GeomAbs_BezierCurve) {
Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
Nb = Bz->NbPoles();
Graphic3d_Array1OfVertex VertexArray(1, Nb);
for (i = 1; i <= Nb; i++) {
(Bz->Pole(i)).Coord(x,y,z);
VertexArray(i).SetCoord(x,y,z);
}
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray);
Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb);
for (i = 1; i <= Nb; i++)
aPrims->AddVertex(Bz->Pole(i));
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
}
else if (CType == GeomAbs_BSplineCurve) {
Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
Nb = Bs->NbPoles();
Graphic3d_Array1OfVertex VertexArray(1, Nb);
for (i = 1; i <= Nb; i++) {
(Bs->Pole(i)).Coord(x,y,z);
VertexArray(i).SetCoord(x,y,z);
}
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray);
Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb);
for (i = 1; i <= Nb; i++)
aPrims->AddVertex(Bs->Pole(i));
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
}
}

View File

@@ -206,9 +206,7 @@ namespace
}
}
}
Prs3d_Root::CurrentGroup (thePresentation)->BeginPrimitives();
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPArray);
Prs3d_Root::CurrentGroup (thePresentation)->EndPrimitives();
}
return Standard_True;
}
@@ -332,9 +330,7 @@ namespace
Handle(Graphic3d_Group) aPrsGrp = Prs3d_Root::NewGroup (thePresentation);
aPrsGrp->SetGroupPrimitivesAspect (aBoundaryAspect);
aPrsGrp->BeginPrimitives ();
aPrsGrp->AddPrimitiveArray (aSegments);
aPrsGrp->EndPrimitives ();
}
};

View File

@@ -76,7 +76,6 @@ void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs,
gp_Pnt P1, P2;
gp_Vec D1U, D1V, D1, D2;
Prs3d_Root::CurrentGroup (thePrs)->BeginPrimitives();
for (Standard_Integer NU = 1; NU <= aNBUintv; ++NU)
{
for (Standard_Integer NV = 1; NV <= aNBVintv; ++NV)
@@ -113,6 +112,5 @@ void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs,
}
Prs3d_Root::CurrentGroup (thePrs)->AddPrimitiveArray (aPArray);
}
Prs3d_Root::CurrentGroup (thePrs)->EndPrimitives();
}
}

View File

@@ -23,8 +23,6 @@
#include <StdPrs_WFDeflectionRestrictedFace.ixx>
#include <Hatch_Hatcher.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Group.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
@@ -118,8 +116,6 @@ void StdPrs_WFDeflectionRestrictedFace::Add
FFaceTimer1.Start();
#endif
Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable();
StdPrs_ToolRFace ToolRst (aFace);
Standard_Real UF, UL, VF, VL;
UF = aFace->FirstUParameter();
@@ -326,7 +322,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add
FindLimits(GC, aLimit,b1, b2);
if (b2-b1>Precision::Confusion()) {
TColgp_SequenceOfPnt Points;
StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, !isPA);
StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, Standard_False);
Curves.Append(Points);
}
}
@@ -338,7 +334,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add
FindLimits(anIso, aLimit,b1, b2);
if (b2-b1>Precision::Confusion()) {
TColgp_SequenceOfPnt Points;
StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, !isPA);
StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, Standard_False);
Curves.Append(Points);
}
}
@@ -493,27 +489,18 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
void StdPrs_WFDeflectionRestrictedFace::Add
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer){
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
TheGroup->BeginPrimitives();
const Handle (Prs3d_Drawer)& aDrawer)
{
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (aPresentation,
aFace,
Standard_True,
Standard_True,
Deflection,
finu,
finv,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number(),
aDrawer,
Curves);
TheGroup->EndPrimitives();
}
@@ -524,20 +511,17 @@ void StdPrs_WFDeflectionRestrictedFace::Add
void StdPrs_WFDeflectionRestrictedFace::AddUIso
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
const Handle (Prs3d_Drawer)& aDrawer)
{
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_False,
Deflection,
finu,
finv,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number(),
aDrawer,
Curves);
}
@@ -550,20 +534,17 @@ void StdPrs_WFDeflectionRestrictedFace::AddUIso
void StdPrs_WFDeflectionRestrictedFace::AddVIso
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
const Handle (Prs3d_Drawer)& aDrawer)
{
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_False,
Standard_True,
Deflection,
finu,
finv,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number(),
aDrawer,
Curves);
}
@@ -579,20 +560,17 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
const Quantity_Length Z,
const Quantity_Length aDistance,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer){
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
const Handle (Prs3d_Drawer)& aDrawer)
{
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_True,
Deflection,
finu,
finv);
aFace,
aDrawer,
Standard_True,
Standard_True,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number());
}
@@ -606,20 +584,17 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchUIso
const Quantity_Length Z,
const Quantity_Length aDistance,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
const Handle (Prs3d_Drawer)& aDrawer)
{
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_False,
Deflection,
finu,
finv);
aFace,
aDrawer,
Standard_True,
Standard_False,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number());
}
@@ -633,20 +608,15 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchVIso
const Quantity_Length Z,
const Quantity_Length aDistance,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Quantity_Length Deflection = aDrawer->MaximalChordialDeviation();
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
const Handle (Prs3d_Drawer)& aDrawer)
{
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_False,
Standard_True,
Deflection,
finu,
finv);
aFace,
aDrawer,
Standard_False,
Standard_True,
aDrawer->MaximalChordialDeviation(),
aDrawer->UIsoAspect()->Number(),
aDrawer->VIsoAspect()->Number());
}

View File

@@ -18,48 +18,41 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <StdPrs_WFPoleSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
static void AddPoles(const Handle (Prs3d_Presentation)& aPresentation,
const TColgp_Array2OfPnt& A,
const Handle (Prs3d_Drawer)& aDrawer)
const TColgp_Array2OfPnt& A,
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Integer i,j;
Standard_Real x,y,z;
Standard_Integer n = A.ColLength();
Standard_Integer m = A.RowLength();
const Standard_Integer n = A.ColLength();
const Standard_Integer m = A.RowLength();
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
Graphic3d_Array1OfVertex VertexArray1(1,m);
Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(n*m,n);
for (i=1; i<=n; i++){
for (j=1; j<=m; j++) {
A(i,j).Coord(x,y,z);
VertexArray1(j).SetCoord(x,y,z);
}
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray1);
aPrims->AddBound(m);
for (j=1; j<=m; j++)
aPrims->AddVertex(A(i,j));
}
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());
Graphic3d_Array1OfVertex VertexArray2(1,n);
aPrims = new Graphic3d_ArrayOfPolylines(n*m,m);
for (j=1; j<=m; j++){
for (i=1; i<=n; i++) {
A(i,j).Coord(x,y,z);
VertexArray2(i).SetCoord(x,y,z);
}
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray2);
aPrims->AddBound(n);
for (i=1; i<=n; i++)
aPrims->AddVertex(A(i,j));
}
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
}

View File

@@ -144,8 +144,6 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
Standard_Real U1, U2, V1, V2;
Standard_Real MaxP = aDrawer->MaximalParameterValue();
Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable();
FindLimits(aSurface, MaxP, U1, U2, V1, V2);
Prs3d_NListOfSequenceOfPnt freeCurves;
@@ -191,22 +189,22 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
if ( !UClosed )
{
anIso.Load(GeomAbs_IsoU,U1,V1,V2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
freeCurves.Append(Pnts);
Pnts.Clear();
anIso.Load(GeomAbs_IsoU,U2,V1,V2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
freeCurves.Append(Pnts);
Pnts.Clear();
}
if ( !VClosed )
{
anIso.Load(GeomAbs_IsoV,V1,U1,U2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
freeCurves.Append(Pnts);
Pnts.Clear();
anIso.Load(GeomAbs_IsoV,V2,U1,U2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
freeCurves.Append(Pnts);
Pnts.Clear();
}
@@ -224,7 +222,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
Standard_Real du= UClosed ? (U2-U1)/fin : (U2-U1)/(1+fin);
for (Standard_Integer i=1; i<=fin;i++){
anIso.Load(GeomAbs_IsoU,U1+du*i,V1,V2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
UIsoCurves.Append(Pnts);
Pnts.Clear();
}
@@ -238,14 +236,12 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
Standard_Real dv= VClosed ?(V2-V1)/fin : (V2-V1)/(1+fin);
for (Standard_Integer i=1; i<=fin;i++){
anIso.Load(GeomAbs_IsoV,V1+dv*i,U1,U2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
VIsoCurves.Append(Pnts);
Pnts.Clear();
}
}
if(!Graphic3d_ArrayOfPrimitives::IsEnable())
return;
Standard_Integer nbVertices = 0, nbBounds = 0;
//Draw surface via primitive array
if(UIsoCurves.Size() > 0) {
@@ -264,9 +260,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(UIsoArray);
TheGroup->EndPrimitives();
}
if(VIsoCurves.Size() > 0) {
@@ -285,9 +279,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(VIsoArray);
TheGroup->EndPrimitives();
}
if(freeCurves.Size() > 0) {
nbBounds = freeCurves.Size();
@@ -305,9 +297,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(freeArray);
TheGroup->EndPrimitives();
}
}