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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

152
src/StdPrs/StdPrs.cdl Executable file
View File

@@ -0,0 +1,152 @@
-- File: Prs.cdl
-- Created: Wed Aug 26 17:38:18 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
package StdPrs
---Purpose: The StdPrs package provides standard display tools
-- for specific geometries and topologies whereas
-- Prs3d provides those for generic objects. Among
-- these classes are definitions of the display of the
-- specific geometry or topology in various display
-- modes such as wireframe, shading or hidden line removal mode.
uses
Prs3d,
Geom,
Geom2d,
Adaptor3d,
Adaptor2d,
GeomAdaptor,
Geom2dAdaptor,
BRepAdaptor,
TopTools,
TopoDS,
TopExp,
TopAbs,
BRepTools,
Bnd,
TColStd,
HLRAlgo,
HLRBRep,
Quantity,
BRepMesh,
gp,
TColgp,
Poly,
TopLoc,
Graphic3d
is
class ToolPoint;
class ToolVertex;
class ToolRFace;
class HLRToolShape;
--class ToolSectionShape;
class ToolShadedShape;
class Point
instantiates Point from Prs3d(Point from Geom, ToolPoint from StdPrs);
class Vertex
instantiates Point from Prs3d(Vertex from TopoDS, ToolVertex from StdPrs);
class PoleCurve;
---Purpose: computes the presentation of curves by drawing
-- a broken line linking the poles of the curve.
class Plane;
---Purpose: computes the presentation of a infinite plane.
class WFPoleSurface;
---Purpose: computes the presentation of surfaces by drawing a
-- double network of lines linking the poles of the surface
-- in the two parametric direction.
class DeflectionCurve;
---Purpose: computes the presentation of objects to be
-- seen as curves. The computation will be made
-- according to a maximal chordial deviation.
---Category: Wireframe algorithms
class WFDeflectionSurface;
---Purpose: computes the wireframe presentation of surfaces
-- by displaying a given number of U and/or V isoparametric
--- curves. The isoparametric curves are drawn with respect
-- to a given maximal chordial deviation.
class ShadedSurface;
---Purpose: computes the shading presentation of surfaces.
class ShadedPoleSurface;
-----------------------------------------------
--- deflection drawing classes :
-----------------------------------------------
class WFDeflectionRestrictedFace;
class WFDeflectionShape instantiates WFShape from Prs3d
(WFDeflectionRestrictedFace from StdPrs,
DeflectionCurve from StdPrs,
Vertex from StdPrs);
-----------------------------------------------
--- Instantiations whith no deflection drawing.
-----------------------------------------------
class Curve;
---Purpose: computes the presentation of objects to be
-- seen as curves. The computation will be made
-- whith a constant number of points.
class WFSurface;
---Purpose: computes the wireframe presentation of surfaces
-- by displaying a given number of U and/or V isoparametric
--- curves. The isoparametric curves are drawn with respect
-- to a given number of points.
class WFRestrictedFace instantiates WFRestrictedFace from Prs3d
(Curve from StdPrs,
ToolRFace from StdPrs);
class WFShape instantiates WFShape from Prs3d
(WFRestrictedFace from StdPrs,
Curve from StdPrs,
Vertex from StdPrs);
class ShadedShape instantiates ShadedShape from Prs3d
(Shape from TopoDS,
Face from TopoDS,
Triangle from BRepMesh,
Edge from BRepMesh,
ToolShadedShape from StdPrs);
class HLRShape instantiates HLRShape from Prs3d
(Shape from TopoDS,
HLRToolShape from StdPrs,
Curve from BRepAdaptor,
DeflectionCurve from StdPrs);
class HLRPolyShape;
imported NListOfSequenceOfPnt from Prs3d;
imported NListIteratorOfListOfSequenceOfPnt from Prs3d;
end StdPrs;

149
src/StdPrs/StdPrs_Curve.cdl Executable file
View File

@@ -0,0 +1,149 @@
-- File: StdPrs_Curve.cdl
-- Created: Fri Aug 4 11:17:47 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class Curve from StdPrs
--
---Purpose: A framework to define display of lines, arcs of circles
-- and conic sections.
-- This is done with a fixed number of points, which can be modified.
inherits Root from Prs3d
uses
Curve from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity,
SequenceOfPnt from TColgp
is
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : Curve from Adaptor3d;
aDrawer : Drawer from Prs3d;
drawCurve : Boolean from Standard = Standard_True);
---Purpose: Adds to the presentation aPresentation the drawing of the curve aCurve.
-- The aspect is defined by LineAspect in aDrawer.
-- 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 : Curve from Adaptor3d;
U1,U2 : Real from Standard;
aDrawer : Drawer from Prs3d;
drawCurve : Boolean from Standard = Standard_True);
---Purpose: Adds to the presentation aPresentation the drawing of the curve aCurve.
-- The aspect is defined by LineAspect in aDrawer.
-- The drawing will be limited between the points of parameter U1 and U2.
-- 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 : Curve from Adaptor3d;
aDeflection : Length from Quantity;
aDrawer : Drawer from Prs3d;
Points : out SequenceOfPnt from TColgp;
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve aCurve.
-- The aspect is the current aspect.
-- aDeflection is used in the circle case.
-- 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 : Curve from Adaptor3d;
U1, U2 : Real from Standard;
aDeflection : Length from Quantity;
Points : out SequenceOfPnt from TColgp;
aNbPoints : Integer from Standard = 30;
drawCurve : Boolean from Standard = Standard_True);
---Purpose: adds to the presentation aPresentation the drawing of the curve
-- aCurve.
-- The aspect is the current aspect.
-- The drawing will be limited between the points of parameter
-- U1 and U2.
-- aDeflection is used in the circle case.
-- 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;
aDrawer: Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve is less than aDistance.
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: Curve from Adaptor3d;
aDeflection: Length from Quantity;
aLimit: Real from Standard;
aNbPoints : Integer from Standard)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve is less than aDistance.
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: Curve from Adaptor3d;
U1,U2 : Real from Standard;
aDrawer: Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve aCurve is less than 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;
U1,U2 : Real from Standard;
aDeflection: Length from Quantity;
aNbPoints : Integer from Standard)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve aCurve is less than aDistance.
-- The drawing is considered between the points
-- of parameter U1 and U2;
end Curve from StdPrs;

459
src/StdPrs/StdPrs_Curve.cxx Executable file
View File

@@ -0,0 +1,459 @@
// File: StdPrs_Curve.cxx
// Created: Fri Aug 4 11:21:03 1995
// Author: Modelistation
// <model@metrox>
// Great zoom leads to non-coincidence of
// a point and non-infinite lines passing throught this point:
#define OCC64
#include <StdPrs_Curve.ixx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <Prs3d.hxx>
#include <Bnd_Box.hxx>
#include <Precision.hxx>
#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)
{
First = aCurve.FirstParameter();
Last = aCurve.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
gp_Pnt P1,P2;
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
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);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
}
//==================================================================
// function: DrawCurve
// purpose:
//==================================================================
static void DrawCurve (const Adaptor3d_Curve& aCurve,
const Handle(Graphic3d_Group) aGroup,
const Standard_Integer NbP,
const Standard_Real U1,
const Standard_Real U2,
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:
{
#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
}
break;
default:
{
Standard_Real U;
Standard_Integer N = Max(2, NbP*nbintervals);
Standard_Real DU = (U2-U1) / (N-1);
gp_Pnt p;
if (first) {
myN = N;
first = Standard_False;
}
if (myN == 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);
}
}
}
}
//==================================================================
// function: MatchCurve
// purpose:
//==================================================================
static Standard_Boolean MatchCurve (
const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Quantity_Length TheDeflection,
const Standard_Integer NbP,
const Standard_Real U1,
const Standard_Real U2)
{
Quantity_Length retdist;
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;
}
return Standard_False;
}
return Standard_False;
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
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, V2;
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
TColgp_SequenceOfPnt Pnts;
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());
}
}
//==================================================================
// function: Add
// 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)
{
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real aLimit = aDrawer->MaximalParameterValue();
Standard_Real V1, V2;
FindLimits(aCurve, aLimit, V1, V2);
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) {
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();
TColgp_SequenceOfPnt Pnts;
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());
}
}
//==================================================================
// function: Match
// purpose:
//==================================================================
Standard_Boolean StdPrs_Curve::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Integer NbPoints = aDrawer->Discretisation();
Standard_Real V1, V2;
FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDrawer->MaximalChordialDeviation(), NbPoints,
V1 , V2);
}
//==================================================================
// function: Match
// purpose:
//==================================================================
Standard_Boolean StdPrs_Curve::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Quantity_Length aDeflection,
const Standard_Real aLimit,
const Standard_Integer NbPoints) {
Standard_Real V1, V2;
FindLimits(aCurve, aLimit, V1, V2);
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDeflection, NbPoints,
V1 , V2);
}
//==================================================================
// function: Match
// purpose:
//==================================================================
Standard_Boolean StdPrs_Curve::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 Handle (Prs3d_Drawer)& aDrawer) {
Standard_Real V1 = U1;
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,
aDrawer->MaximalChordialDeviation(),
aDrawer->Discretisation(),
V1 , V2);
}
//==================================================================
// function: Match
// purpose:
//==================================================================
Standard_Boolean StdPrs_Curve::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 Quantity_Length aDeflection,
const Standard_Integer aNbPoints)
{
return MatchCurve(X,Y,Z,aDistance,aCurve,
aDeflection, aNbPoints,
U1 , U2);
}

View File

@@ -0,0 +1,173 @@
-- File: DeflectionCurve.cdl
-- Created: Tue Dec 15 18:12:33 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
class DeflectionCurve from StdPrs
inherits Root from Prs3d
---Purpose: A framework to provide display of any curve with
-- respect to the maximal chordal deviation defined in
-- the Prs3d_Drawer attributes manager.
uses
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity,
Curve from Adaptor3d,
SequenceOfPnt from TColgp
is
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : in out Curve from Adaptor3d;
aDrawer : Drawer from Prs3d;
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
-- by the drawer aDrawer.
-- The aspect is defined by LineAspect in aDrawer.
-- 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;
U1, U2 : Real from Standard;
aDrawer : Drawer from Prs3d;
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
-- by the drawer aDrawer.
-- The aspect is defined by LineAspect in aDrawer.
-- The drawing will be limited between the points of parameter U1 and U2.
-- 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;
aDeflection : Real from Standard;
aLimit : Real from Standard;
anAngle : Real from Standard = 0.2;
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
-- 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;
aDeflection : Real from Standard;
aDrawer : Drawer from Prs3d;
Points : out SequenceOfPnt from TColgp;
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.
-- 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;
U1, U2 : Real from Standard;
aDeflection : Real from Standard;
Points : out SequenceOfPnt from TColgp;
anAngle : Real from Standard = 0.2;
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.
-- 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;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve aCurve with respect of the maximal
-- 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;
U1, U2 : Real from Standard;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing of the curve aCurve with respect of the maximal
-- chordial deviation defined by the drawer aDrawer is less
-- 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;
aDeflection: Real from Standard;
aLimit : Real from Standard;
anAngle : Real from Standard = 0.2)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing with respect of the maximal chordial deviation
-- aDeflection is less then aDistance.
Match(myclass; X, Y, Z : Length from Quantity;
aDistance : Length from Quantity;
aCurve : Curve from Adaptor3d;
U1, U2 : Real from Standard;
aDeflection : Real from Standard;
anAngle : Real from Standard = 0.2)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- drawing with respect of the maximal chordial deviation
-- aDeflection is less then aDistance. The drawing is considered
-- between the points of parameter U1 and U2;
end DeflectionCurve from StdPrs;

View File

@@ -0,0 +1,526 @@
// Great zoom leads to non-coincidence of
// a point and non-infinite lines passing throught this point:
#define OCC64
#include <StdPrs_DeflectionCurve.ixx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <Prs3d.hxx>
#include <Bnd_Box.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <Precision.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
//==================================================================
// function: GetDeflection
// 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();
return TheDeflection;
}
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
{
First = aCurve.FirstParameter();
Last = aCurve.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
gp_Pnt P1,P2;
Standard_Real delta = 1;
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);
} 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);
} 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);
} while (P1.Distance(P2) < aLimit);
}
}
return Standard_True;
}
//==================================================================
// function: DrawCurve
// purpose:
//==================================================================
static void DrawCurve (Adaptor3d_Curve& aCurve,
const Handle(Graphic3d_Group) aGroup,
const Quantity_Length TheDeflection,
const Standard_Real anAngle,
const Standard_Real U1,
const Standard_Real U2,
TColgp_SequenceOfPnt& Points,
const Standard_Boolean drawCurve)
{
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable() && !drawCurve;
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:
{
Standard_Integer nbinter = aCurve.NbIntervals(GeomAbs_C1);
Standard_Integer i, j;
TColStd_Array1OfReal T(1, nbinter+1);
aCurve.Intervals(T, GeomAbs_C1);
Standard_Real theU1, theU2;
Standard_Integer NumberOfPoints;
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);
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());
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());
}
if(!isPrimArrayEnabled)
aGroup->Polyline(VertexArray);
}
}
}
//==================================================================
// function: MatchCurve
// purpose:
//==================================================================
static Standard_Boolean MatchCurve (
const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Quantity_Length TheDeflection,
const Standard_Real anAngle,
const Standard_Real U1,
const Standard_Real U2)
{
Quantity_Length retdist;
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();
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;
}
}
}
return Standard_False;
}
break;
default:
{
GCPnts_TangentialDeflection Algo(aCurve,U1, U2, anAngle, TheDeflection);
gp_Pnt p1,p2;
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;
}
}
return Standard_False;
}
}
return Standard_False;
}
//==================================================================
// function: Add
// purpose:
//==================================================================
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
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) {
DrawCurve(aCurve,
Prs3d_Root::CurrentGroup(aPresentation),
GetDeflection(aCurve, V1, V2, aDrawer),
angle,
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());
}
}
}
//==================================================================
// function: Add
// 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) {
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);
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());
}
}
//==================================================================
// function: Add
// 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)
{
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)
{
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);
}
//================================================================================
// function: Add
// 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)
{
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);
}
//==================================================================
// 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 Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real V1, V2;
Standard_Boolean OK = FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2);
if (OK) {
return MatchCurve(X,Y,Z,aDistance,aCurve,
GetDeflection(aCurve, V1, V2, aDrawer),
aDrawer->DeviationAngle(),
V1 , V2);
}
else {
return Standard_False;
}
}
//==================================================================
// 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 Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real V1 = U1;
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);
}
//==================================================================
// 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) {
return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,anAngle,U1,U2);
}
//==================================================================
// 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 aDeflection,
const Standard_Real aLimit,
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);
}
else {
return Standard_False;
}
}

View File

@@ -0,0 +1,38 @@
-- File: StdPrs_HLRPolyShape.cdl
-- Created: Tue Sep 19 15:38:35 1995
-- Author: Laurent PAINNOT
-- <lpa@metrox>
---Copyright: Matra Datavision 1995
class HLRPolyShape from StdPrs
inherits Root from Prs3d
---Purpose: Instantiates Prs3d_PolyHLRShape to define a
-- display of a shape where hidden and visible lines are
-- identified with respect to a given projection.
-- StdPrs_HLRPolyShape works with a polyhedral
-- simplification of the shape whereas
-- StdPrs_HLRShape takes the shape itself into
-- account. When you use StdPrs_HLRShape, you
-- obtain an exact result, whereas, when you use
-- StdPrs_HLRPolyShape, you reduce computation
-- time but obtain polygonal segments.
uses
Shape from TopoDS,
Presentation from Prs3d,
Drawer from Prs3d,
Projector from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aShape : Shape from TopoDS;
aDrawer : Drawer from Prs3d;
aProjector : Projector from Prs3d);
---Purpose: Defines the hidden line removal display of the
-- topology aShape in the projection defined by
-- aProjector. The shape and the projection are added
-- to the display aPresentation, and the attributes of the
-- elements present in the aPresentation are defined by
-- the attribute manager aDrawer.
end HLRPolyShape from StdPrs;

View File

@@ -0,0 +1,186 @@
// File: StdPrs_HLRPolyShape.cxx
// Created: Tue Sep 19 15:40:22 1995
// Author: Laurent PAINNOT
// <lpa@metrox>
#include <StdPrs_HLRPolyShape.ixx>
#include <StdPrs_WFShape.hxx>
#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>
#include <HLRBRep_PolyAlgo.hxx>
#include <HLRBRep_ListOfBPoint.hxx>
#include <HLRBRep_BiPoint.hxx>
#include <HLRAlgo_EdgeStatus.hxx>
#include <HLRAlgo_EdgeIterator.hxx>
#include <HLRBRep_ListIteratorOfListOfBPoint.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#define PntX1 ((Standard_Real*)Coordinates)[0]
#define PntY1 ((Standard_Real*)Coordinates)[1]
#define PntZ1 ((Standard_Real*)Coordinates)[2]
#define PntX2 ((Standard_Real*)Coordinates)[3]
#define PntY2 ((Standard_Real*)Coordinates)[4]
#define PntZ2 ((Standard_Real*)Coordinates)[5]
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const TopoDS_Shape& aShape,
const Handle (Prs3d_Drawer)& aDrawer,
const Handle (Prs3d_Projector)& aProjector)
{
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
TopExp_Explorer ex;
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
// find vertices not under ancestors.
TopAbs_ShapeEnum E = aShape.ShapeType();
if (E == TopAbs_COMPOUND) {
// il faut presenter les vertex isoles a defaut de les cacher.
for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
StdPrs_WFShape::Add(aPresentation, ex.Current(), aDrawer);
}
}
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();
BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle());
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape);
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;
Standard_Address Coordinates;
TopoDS_Shape S;
HLRBRep_ListOfBPoint BiPntVis, BiPntHid;
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()) {
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));
}
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));
}
}
// stockage dans le groupe:
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);
}
}
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);
}
}
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();
}
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();
}
}
}

View File

@@ -0,0 +1,37 @@
-- File: StdPrs_HLRToolShape.cdl
-- Created: Tue Mar 9 09:41:16 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
class HLRToolShape from StdPrs
uses
Shape from TopoDS,
Curve from BRepAdaptor,
Data from HLRBRep,
EdgeIterator from HLRAlgo,
Projector from HLRAlgo
is
Create (TheShape : Shape from TopoDS;
TheProjector: Projector from HLRAlgo)
returns HLRToolShape from StdPrs;
NbEdges(me) returns Integer from Standard;
InitVisible(me: in out; EdgeNumber: Integer from Standard);
MoreVisible(me) returns Boolean from Standard;
NextVisible(me: in out);
Visible(me: in out ; TheEdge : out Curve from BRepAdaptor;
U1,U2 : out Real from Standard);
InitHidden(me:in out; EdgeNumber: Integer from Standard);
MoreHidden(me) returns Boolean from Standard;
NextHidden(me: in out);
Hidden(me: in out; TheEdge : out Curve from BRepAdaptor;
U1,U2 : out Real from Standard);
fields
MyData : Data from HLRBRep;
myEdgeIterator : EdgeIterator from HLRAlgo;
MyCurrentEdgeNumber : Integer from Standard;
end HLRToolShape from StdPrs;

View File

@@ -0,0 +1,66 @@
#include <StdPrs_HLRToolShape.ixx>
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_Algo.hxx>
#include <HLRBRep_Data.hxx>
StdPrs_HLRToolShape::StdPrs_HLRToolShape (
const TopoDS_Shape& TheShape,
const HLRAlgo_Projector& TheProjector)
{
Handle(HLRBRep_Algo) Hider = new HLRBRep_Algo();
Standard_Integer nbIso = 0; // 5;
Hider->Add(TheShape, nbIso);
Hider->Projector(TheProjector);
Hider->Update();
Hider->Hide();
MyData = Hider->DataStructure();
MyCurrentEdgeNumber = 0;
}
Standard_Integer StdPrs_HLRToolShape::NbEdges() const {
return MyData->NbEdges();
}
void StdPrs_HLRToolShape::InitVisible(const Standard_Integer EdgeNumber) {
myEdgeIterator.InitVisible
(MyData->EDataArray().ChangeValue(EdgeNumber).Status());
MyCurrentEdgeNumber = EdgeNumber;
}
Standard_Boolean StdPrs_HLRToolShape::MoreVisible() const {
return myEdgeIterator.MoreVisible();
}
void StdPrs_HLRToolShape::NextVisible() {
myEdgeIterator.NextVisible();
}
void StdPrs_HLRToolShape::Visible(BRepAdaptor_Curve& TheEdge,
Standard_Real& U1,
Standard_Real& U2) {
TheEdge = MyData->EDataArray()
.ChangeValue(MyCurrentEdgeNumber)
.ChangeGeometry()
.Curve();
Standard_ShortReal t1,t2;
myEdgeIterator.Visible(U1,t1,U2,t2);
}
void StdPrs_HLRToolShape::InitHidden(const Standard_Integer EdgeNumber) {
myEdgeIterator.InitHidden
(MyData->EDataArray().ChangeValue(EdgeNumber).Status());
MyCurrentEdgeNumber = EdgeNumber;
}
Standard_Boolean StdPrs_HLRToolShape::MoreHidden() const {
return myEdgeIterator.MoreHidden();
}
void StdPrs_HLRToolShape::NextHidden() {
myEdgeIterator.NextHidden();
}
void StdPrs_HLRToolShape::Hidden (BRepAdaptor_Curve& TheEdge,
Standard_Real& U1,
Standard_Real& U2) {
TheEdge = MyData->EDataArray()
.ChangeValue(MyCurrentEdgeNumber)
.ChangeGeometry()
.Curve();
Standard_ShortReal t1,t2;
myEdgeIterator.Hidden(U1,t1,U2,t2);
}

41
src/StdPrs/StdPrs_Plane.cdl Executable file
View File

@@ -0,0 +1,41 @@
-- File: StdPrs_Plane.cdl
-- Created: Mon Jul 24 16:39:19 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class Plane from StdPrs
inherits Root from Prs3d
---Purpose: A framework to display infinite planes.
uses
Surface from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d,
TypeOfLinePicking from Prs3d,
Length from Quantity
is
Add(myclass; aPresentation: Presentation from Prs3d;
aPlane : Surface from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Defines display of infinite planes.
-- The infinite plane aPlane is added to the display
-- aPresentation, and the attributes of the display are
-- defined by the attribute manager aDrawer.
Match(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aPlane : Surface from Adaptor3d;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- plane is less than aDistance.
end Plane;

158
src/StdPrs/StdPrs_Plane.cxx Executable file
View File

@@ -0,0 +1,158 @@
// File: StdPrs_Plane.cxx
// Created: Mon Jul 24 16:42:41 1995
// Author: Modelistation
// <model@metrox>
#include <StdPrs_Plane.ixx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Pln.hxx>
#include <gp_Dir.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d.hxx>
#include <Geom_Plane.hxx>
void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Surface& aPlane,
const Handle (Prs3d_Drawer)& aDrawer)
{
// Prs3d_Root::NewGroup(aPresentation);
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
if (aPlane.GetType() != GeomAbs_Plane) return;
Handle(Geom_Plane) thegeom = new Geom_Plane(aPlane.Plane());
Handle(Prs3d_PlaneAspect) theaspect = aDrawer->PlaneAspect();
gp_Pnt p1;
Standard_Real Xmax,Ymax;
Xmax = Standard_Real(theaspect->PlaneXLength())/2.;
Ymax = Standard_Real(theaspect->PlaneYLength())/2.;
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);
}
if (theaspect->DisplayIso()) {
static Graphic3d_Array1OfVertex IsoArray(1,2);
TheGroup->SetPrimitivesAspect(theaspect->IsoAspect()->Aspect());
Standard_Real dist = theaspect->IsoDistance();
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;
}
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;
}
}
gp_Dir norm = thegeom->Pln().Axis().Direction();
gp_Pnt loc;
Quantity_Length siz = theaspect->ArrowsSize();
Quantity_Length len = theaspect->ArrowsLength();
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);
}
if (theaspect->DisplayEdgesArrows()) {
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);
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);
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);
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);
}
}
Standard_Boolean StdPrs_Plane::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Surface& aPlane,
const Handle (Prs3d_Drawer)&)
{
if (aPlane.GetType() == GeomAbs_Plane) {
gp_Pln theplane = aPlane.Plane();
gp_Pnt thepoint (X,Y,Z);
return (Abs(theplane.Distance(thepoint)) <= aDistance);
}
else return Standard_False;
}

59
src/StdPrs/StdPrs_PoleCurve.cdl Executable file
View File

@@ -0,0 +1,59 @@
-- File: StdPrs_PoleCurve.cdl
-- Created: Mon Jul 24 15:08:55 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class PoleCurve from StdPrs
inherits Root from Prs3d
---Purpose: A framework to provide display of Bezier or BSpline curves.
uses
Curve from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity
is
--- Purpose:
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve : Curve from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Defines display of BSpline and Bezier curves.
-- Adds the 3D curve aCurve to the
-- StdPrs_PoleCurve algorithm. This shape is found in
-- the presentation object aPresentation, and its display
-- attributes are set in the attribute manager aDrawer.
-- The curve object from Adaptor3d provides data from
-- a Geom curve. This makes it possible to use the
-- surface in a geometric algorithm.
Match(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aCurve : Curve from Adaptor3d;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
---Purpose: returns true if the distance between the point (X,Y,Z) and the
-- broken line made of the poles is less then aDistance.
Pick(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aCurve : Curve from Adaptor3d;
aDrawer : Drawer from Prs3d)
returns Integer from Standard;
---Purpose: returns the pole the most near of the point (X,Y,Z) and
-- returns its range. The distance between the pole and
-- (X,Y,Z) must be less then aDistance. If no pole corresponds, 0 is returned.
end PoleCurve from StdPrs;

162
src/StdPrs/StdPrs_PoleCurve.cxx Executable file
View File

@@ -0,0 +1,162 @@
// File: StdPrs_PoleCurve.cxx
// Created: Mon Jul 24 15:11:50 1995
// Author: Modelistation
// <model@metrox>
#include <StdPrs_PoleCurve.ixx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_PoleCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer)
{
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
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);
}
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);
}
}
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());
}
}
//=======================================================================
//function : Match
//purpose :
//=======================================================================
Standard_Boolean StdPrs_PoleCurve::Match(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Handle (Prs3d_Drawer)& aDrawer)
{
GeomAbs_CurveType CType = aCurve.GetType();
Standard_Integer i, Nb = 0;
Standard_Real x,y,z;
if (CType == GeomAbs_BezierCurve) {
Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
Nb = Bz->NbPoles();
for (i = 1; i <= Nb; i++) {
Bz->Pole(i).Coord(x,y,z);
if ( Abs(X-x) +Abs(Y-y)+Abs(Z-z) <= aDistance) return Standard_True;
}
return Standard_False;
}
else if (CType == GeomAbs_BSplineCurve) {
Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
Nb = Bs->NbPoles();
for (i = 1; i <= Nb; i++) {
Bs->Pole(i).Coord(x,y,z);
if ( Abs(X-x) +Abs(Y-y)+Abs(Z-z) <= aDistance) return Standard_True;
}
return Standard_False;
}
return Standard_False;
}
//=======================================================================
//function : Pick
//purpose :
//=======================================================================
Standard_Integer StdPrs_PoleCurve::Pick
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Adaptor3d_Curve& aCurve,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Real x, y, z, DistMin = RealLast();
Standard_Integer num = 0, i, Nb = 0;
Standard_Real dist;
GeomAbs_CurveType CType = aCurve.GetType();
if (CType == GeomAbs_BezierCurve) {
Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
Nb = Bz->NbPoles();
for (i = 1; i <= Nb; i++) {
Bz->Pole(i).Coord(x,y,z);
dist = Abs(X-x) +Abs(Y-y)+Abs(Z-z);
if ( dist <= aDistance) {
if (dist < DistMin) {
DistMin = dist;
num = i;
}
}
}
}
else if (CType == GeomAbs_BSplineCurve) {
Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
Nb = Bs->NbPoles();
for (i = 1; i <= Nb; i++) {
Bs->Pole(i).Coord(x,y,z);
dist = Abs(X-x) +Abs(Y-y)+Abs(Z-z);
if (dist <= aDistance) {
if (dist < DistMin) {
DistMin = dist;
num = i;
}
}
}
}
return num;
}

View File

@@ -0,0 +1,33 @@
-- File: StdPrs_ShadedPoleSurface.cdl
-- Created: Mon Jul 5 18:12:33 1993
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
class ShadedPoleSurface from StdPrs
inherits Root from Prs3d
--- Purpose: Draws a surface by drawing the isoparametric curves with respect to
-- a maximal chordial deviation.
-- The number of isoparametric curves to be drawn and their color are
-- controlled by the furnished Drawer.
uses
Presentation from Prs3d,
Surface from Adaptor3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aSurface : Surface from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Adds the surface aSurface to the presentation object aPresentation.
-- The surface's display attributes are set in the attribute manager, aDrawer.
end ShadedPoleSurface;

View File

@@ -0,0 +1,109 @@
// File: StdPrs_ShadedPoleSurface.cxx
// Created: Tue Aug 1 08:38:50 1995
// Author: Modelistation
// <model@metrox>
#define G005 //ATS,GG 04/01/01 Use PrimitiveArray instead Sets of primitives
// for performance improvment
#include <StdPrs_ShadedPoleSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Array2OfVertex.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#ifdef G005
#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
#endif
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_ShadedPoleSurface::Add(
const Handle(Prs3d_Presentation)& aPresentation,
const Adaptor3d_Surface& aSurface,
const Handle (Prs3d_Drawer)& aDrawer)
{
if ( ! aDrawer->ShadingAspectGlobal() ) {
// Si la surface est fermee, on ne tracera pas les faces tournant le dos:
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
Asp->SuppressBackFace();
} else {
Asp->AllowBackFace();
}
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
}
Standard_Integer i,j,n = aSurface.NbUPoles(), m = aSurface.NbVPoles();
if (aSurface.GetType() == GeomAbs_BezierSurface) {
Handle(Geom_BezierSurface) surface = aSurface.Bezier();
#ifdef G005
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
Standard_False,Standard_False,Standard_False,Standard_False);
for ( i=1; i<=n; i++) {
parray->AddBound(m);
for ( j=1; j<=m; j++) {
parray->AddVertex(surface->Pole(i,j));
}
}
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
return;
}
#endif
TColgp_Array2OfPnt A(1,n,1,m);
surface->Poles(A);
Graphic3d_Array2OfVertex V(1,n,1,m);
Standard_Real x,y,z;
for ( i=1; i<=n; i++) {
for ( j=1; j<=m; j++) {
A(i,j).Coord(x,y,z);
V(i,j).SetCoord(x,y,z);
}
}
Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
}
else if (aSurface.GetType() == GeomAbs_BSplineSurface) {
Handle(Geom_BSplineSurface) surface = aSurface.BSpline();
#ifdef G005
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
Standard_False,Standard_False,Standard_False,Standard_False);
for ( i=1; i<=n; i++) {
parray->AddBound(m);
for ( j=1; j<=m; j++) {
parray->AddVertex(surface->Pole(i,j));
}
}
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
return;
}
#endif
TColgp_Array2OfPnt A(1,n,1,m);
surface->Poles(A);
Graphic3d_Array2OfVertex V(1,n,1,m);
Standard_Real x,y,z;
for ( i=1; i<=n; i++) {
for ( j=1; j<=m; j++) {
A(i,j).Coord(x,y,z);
V(i,j).SetCoord(x,y,z);
}
}
Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
}
}

View File

@@ -0,0 +1,32 @@
-- File: StdPrs_ShadedSurface.cdl
-- Created: Thu Jul 27 11:42:59 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class ShadedSurface from StdPrs
inherits Root from Prs3d
--- Purpose: Draws a surface by drawing the isoparametric curves with respect to
-- a maximal chordial deviation.
-- The number of isoparametric curves to be drawn and their color are
-- controlled by the furnished Drawer.
uses
Surface from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aSurface : Surface from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Adds the surface aSurface to the presentation object aPresentation.
-- The surface's display attributes are set in the attribute manager aDrawer.
-- The surface object from Adaptor3d provides data
-- from a Geom surface in order to use the surface in an algorithm.
end ShadedSurface;

View File

@@ -0,0 +1,165 @@
// File: StdPrs_ShadedSurface.cxx
// Created: Thu Jul 27 11:44:57 1995
// Author: Modelistation
// <model@metrox>
#define G005 //ATS,GG 04/01/01 Use PrimitiveArray instead Sets of primitives
// for performance improvment
#include <StdPrs_ShadedSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_VertexN.hxx>
#include <Graphic3d_Array1OfVertexN.hxx>
#include <gp_Vec.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <gp_Pnt.hxx>
#ifdef G005
#include <Graphic3d_ArrayOfTriangleStrips.hxx>
#endif
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_ShadedSurface::Add(const Handle(Prs3d_Presentation)& aPresentation,
const Adaptor3d_Surface& aSurface,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Integer N1 = aDrawer->UIsoAspect()->Number();
Standard_Integer N2 = aDrawer->VIsoAspect()->Number();
N1 = N1 < 3 ? 3 : N1;
N2 = N2 < 3 ? 3 : N2;
if ( ! aDrawer->ShadingAspectGlobal() ) {
// Si la surface est fermee, on ne tracera pas les faces tournant le dos:
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
Asp->SuppressBackFace();
} else {
Asp->AllowBackFace();
}
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
}
Standard_Integer NBUintv = aSurface.NbUIntervals(GeomAbs_C1);
Standard_Integer NBVintv = aSurface.NbVIntervals(GeomAbs_C1);
TColStd_Array1OfReal InterU(1, NBUintv+1);
TColStd_Array1OfReal InterV(1, NBVintv+1);
aSurface.UIntervals(InterU, GeomAbs_C1);
aSurface.VIntervals(InterV, GeomAbs_C1);
Standard_Real U1, U2, V1, V2, DU, DV;
Standard_Integer i,j;
gp_Pnt P1,P2;
gp_Vec D1U,D1V,D1,D2;
#ifdef G005
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
U1 = InterU(NU); U2 = InterU(NU+1);
V1 = InterV(NV); V2 = InterV(NV+1);
U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
DU = (U2-U1)/ N1;
DV = (V2-V1)/ N2;
Handle(Graphic3d_ArrayOfTriangleStrips) parray = new
Graphic3d_ArrayOfTriangleStrips(2*(N1+1)*(N2+1),N1+1,
Standard_True,Standard_False,Standard_False,Standard_False);
for ( i = 1; i<= N1+1; i++) {
parray->AddBound(N2+1);
for (j = 1; j <= N2+1; j++) {
aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),P2,D1U,D1V);
D1 = D1U^D1V;
D1.Normalize();
aSurface.D1(U1 + DU * i, V1 + DV * (j-1),P2,D1U,D1V);
D2 = D1U^D1V;
D2.Normalize();
parray->AddVertex(P1,D1);
parray->AddVertex(P2,D2);
}
}
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
}
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
}
return;
}
#endif
gp_Pnt P;
gp_Vec Normale;
Quantity_Length x,y,z;
Graphic3d_Array1OfVertexN A1 ( 1 , N2+1);
Graphic3d_Array1OfVertexN A2 ( 1 , N2+1);
Graphic3d_Array1OfVertexN TriangleStrip ( 1, 2*(N2+1));
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
U1 = InterU(NU); U2 = InterU(NU+1);
V1 = InterV(NV); V2 = InterV(NV+1);
U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
DU = (U2-U1)/ N1;
DV = (V2-V1)/ N2;
// Calcul de la premiere ligne;
for ( i = 1; i<= N2+1; i++) {
aSurface.D1(U1 , V1 + DV * (i-1),P,D1U,D1V);
P.Coord(x,y,z);
A1(i).SetCoord (x,y,z);
Normale = D1U^D1V;
Normale.Normalize();
Normale.Coord(x,y,z);
A1(i).SetNormal(x,y,z);
}
for ( i = 2; i<= N1+1; i++) {
for (j = 1; j <= N2+1; j++) {
aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),
P,D1U,D1V);
P.Coord(x,y,z);
A2(j).SetCoord (x,y,z);
Normale = D1U^D1V;
Normale.Normalize();
Normale.Coord(x,y,z);
A2(j).SetNormal(x,y,z);
TriangleStrip (2*(j-1) + 1) = A1(j);
TriangleStrip (2*(j-1) + 2) = A2(j);
}
Prs3d_Root::CurrentGroup(aPresentation)->TriangleMesh(TriangleStrip);
for ( j = 1; j <= N2 + 1; j++) { A1(j) = A2(j);}
}
}
}
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
}

14
src/StdPrs/StdPrs_ToolPoint.cdl Executable file
View File

@@ -0,0 +1,14 @@
-- File: StdPrs_ToolPoint.cdl
-- Created: Wed Dec 16 13:36:55 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
class ToolPoint from StdPrs
uses
Length from Quantity,
Point from Geom
is
Coord( myclass; aPoint: Point from Geom; X,Y,Z: out Length from Quantity);
end ToolPoint from StdPrs;

15
src/StdPrs/StdPrs_ToolPoint.cxx Executable file
View File

@@ -0,0 +1,15 @@
// File: StdPrs_ToolPoint.cxx
// Created: Tue Aug 24 12:45:41 1993
// Author: Jean-Louis FRENKEL
// <jlf@stylox>
#include <StdPrs_ToolPoint.ixx>
void StdPrs_ToolPoint::Coord (const Handle(Geom_Point)& aPoint,
Standard_Real& X,
Standard_Real& Y,
Standard_Real& Z) {
aPoint->Coord(X,Y,Z);
}

45
src/StdPrs/StdPrs_ToolRFace.cdl Executable file
View File

@@ -0,0 +1,45 @@
-- File: StdPrs_ToolRFace.cdl
-- Created: Tue Jan 26 15:10:23 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
class ToolRFace from StdPrs
---Purpose:
uses
Curve from Geom2dAdaptor,
Face from TopoDS,
HSurface from BRepAdaptor,
Curve2dPtr from Adaptor2d,
Orientation from TopAbs,
Explorer from TopExp
is
Create returns ToolRFace from StdPrs;
Create ( aSurface :HSurface from BRepAdaptor )
returns ToolRFace from StdPrs;
IsOriented (me) returns Boolean from Standard;
Init(me: in out);
More(me) returns Boolean from Standard;
Next(me: in out);
Value(me) returns Curve2dPtr from Adaptor2d;
Orientation(me) returns Orientation from TopAbs;
fields
myFace : Face from TopoDS;
myExplorer : Explorer from TopExp;
DummyCurve : Curve from Geom2dAdaptor;
end ToolRFace;

115
src/StdPrs/StdPrs_ToolRFace.cxx Executable file
View File

@@ -0,0 +1,115 @@
#include <StdPrs_ToolRFace.ixx>
#include <Geom2d_TrimmedCurve.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <Adaptor2d_Curve2d.hxx>
#define OCC316
//=======================================================================
//function : StdPrs_ToolRFace
//purpose :
//=======================================================================
StdPrs_ToolRFace::StdPrs_ToolRFace()
{
}
//=======================================================================
//function : StdPrs_ToolRFace
//purpose :
//=======================================================================
StdPrs_ToolRFace::StdPrs_ToolRFace(const Handle(BRepAdaptor_HSurface)& aSurface) :
myFace(((BRepAdaptor_Surface*)&(aSurface->Surface()))->Face())
{
myFace.Orientation(TopAbs_FORWARD);
}
//=======================================================================
//function : IsOriented
//purpose :
//=======================================================================
Standard_Boolean StdPrs_ToolRFace::IsOriented () const {
return Standard_True;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void StdPrs_ToolRFace::Init()
{
myExplorer.Init(myFace,TopAbs_EDGE);
if (myExplorer.More()) {
Standard_Real U1,U2;
const Handle(Geom2d_Curve)& C =
BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
myFace,
U1,U2);
DummyCurve.Load(C,U1,U2);
}
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean StdPrs_ToolRFace::More() const
{
return myExplorer.More();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void StdPrs_ToolRFace::Next()
{
myExplorer.Next();
if (myExplorer.More()) {
// skip INTERNAL and EXTERNAL edges
while (myExplorer.More() && (myExplorer.Current().Orientation() == TopAbs_INTERNAL
|| myExplorer.Current().Orientation() == TopAbs_EXTERNAL))
myExplorer.Next();
if (myExplorer.More()) {
Standard_Real U1,U2;
const Handle(Geom2d_Curve)& C =
BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
myFace,
U1,U2);
#ifdef OCC316
if ( !C.IsNull() )
#endif
DummyCurve.Load(C,U1,U2);
}
}
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Adaptor2d_Curve2dPtr StdPrs_ToolRFace::Value() const
{
return (Adaptor2d_Curve2dPtr)&DummyCurve;
}
//=======================================================================
//function : Orientation
//purpose :
//=======================================================================
TopAbs_Orientation StdPrs_ToolRFace::Orientation () const {
return myExplorer.Current().Orientation();
}

View File

@@ -0,0 +1,29 @@
-- File: StdPrs_ToolShadedShape.cdl
-- Created: Wed Oct 27 09:26:37 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class ToolShadedShape from StdPrs inherits ShapeTool from BRepMesh
uses
Shape from TopoDS,
Face from TopoDS,
Array1OfDir from TColgp,
Connect from Poly,
Triangulation from Poly,
Location from TopLoc
is
IsClosed(myclass; aShape: Shape from TopoDS) returns Boolean from Standard;
Triangulation(myclass; aFace: Face from TopoDS;
loc : out Location from TopLoc)
returns Triangulation from Poly;
Normal(myclass; aFace: Face from TopoDS;
PC : in out Connect from Poly;
Nor : out Array1OfDir from TColgp);
end ToolShadedShape from StdPrs;

View File

@@ -0,0 +1,179 @@
// File: StdPrs_ToolShadedShape.cxx
// Created: Wed Oct 27 09:29:14 1993
// Author: Jean-LOuis FRENKEL
// <jlf@stylox>
#include <StdPrs_ToolShadedShape.ixx>
#include <Poly_Triangulation.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Poly_Connect.hxx>
#include <TopAbs_Orientation.hxx>
#include <GeomAbs_SurfaceType.hxx>
//#include <CSLib.hxx>
#include <GeomLib.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TShort_HArray1OfShortReal.hxx>
#include <TShort_Array1OfShortReal.hxx>
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean StdPrs_ToolShadedShape::IsClosed(const TopoDS_Shape& aShape)
{
return aShape.Closed();
}
//=======================================================================
//function : Triangulation
//purpose :
//=======================================================================
Handle(Poly_Triangulation) StdPrs_ToolShadedShape::Triangulation
(const TopoDS_Face& aFace,
TopLoc_Location& loc)
{
return BRep_Tool::Triangulation(aFace, loc);
}
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
void StdPrs_ToolShadedShape::Normal(const TopoDS_Face& aFace,
Poly_Connect& pc,
TColgp_Array1OfDir& Nor)
{
const Handle(Poly_Triangulation)& T = pc.Triangulation();
BRepAdaptor_Surface S;
Standard_Boolean hasUV = T->HasUVNodes();
Standard_Integer i;
TopLoc_Location l;
// move to zero
TopoDS_Face zeroFace = TopoDS::Face(aFace.Located(TopLoc_Location()));
//take in face the surface location
//Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, l);
Handle(Geom_Surface) GS = BRep_Tool::Surface(zeroFace);
if(T->HasNormals()) {
const TColgp_Array1OfPnt& Nodes = T->Nodes();
const TShort_Array1OfShortReal& Normals = T->Normals();
const Standard_ShortReal * arrN = &(Normals.Value(Normals.Lower()));
for( i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
Standard_Integer in = 3*(i-Nodes.Lower());
gp_Dir N(arrN[in + 0], arrN[in + 1], arrN[in + 2]);
Nor(i) = N;
}
if (aFace.Orientation() == TopAbs_REVERSED) {
for( i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
Nor.ChangeValue(i).Reverse();
}
}
}
else if (hasUV && !GS.IsNull()) {
Standard_Integer nbNormVal = T->NbNodes() * 3;
Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, nbNormVal);
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
Standard_Real Tol = Precision::Confusion();
for (i = UVNodes.Lower(); i <= UVNodes.Upper(); i++) {
if(GeomLib::NormEstim(GS, UVNodes(i), Tol, Nor(i)) > 1) {
const TColgp_Array1OfPnt& Nodes = T->Nodes();
Standard_Integer n[3];
const Poly_Array1OfTriangle& triangles = T->Triangles();
gp_XYZ eqPlan(0, 0, 0);
Standard_Real modmax = 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());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
eqPlan += vv/mod;
}
modmax = eqPlan.Modulus();
if(modmax > Tol) Nor(i) = gp_Dir(eqPlan);
else Nor(i) = gp_Dir(0., 0., 1.);
}
Standard_Integer j = (i - UVNodes.Lower()) * 3;
Normals->SetValue(j + 1, Nor(i).X());
Normals->SetValue(j + 2, Nor(i).Y());
Normals->SetValue(j + 3, Nor(i).Z());
if (aFace.Orientation() == TopAbs_REVERSED) (Nor(i)).Reverse();
}
T->SetNormals(Normals);
}
else {
Standard_Integer nbNormVal = T->NbNodes() * 3;
Handle(TShort_HArray1OfShortReal) Normals =
new TShort_HArray1OfShortReal(1, nbNormVal);
const TColgp_Array1OfPnt& Nodes = T->Nodes();
Standard_Integer n[3];
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Real Tol = Precision::Confusion();
for (i = Nodes.Lower(); i <= Nodes.Upper(); 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());
gp_XYZ vv = v1^v2;
Standard_Real mod = vv.Modulus();
if(mod < Tol) continue;
eqPlan += vv/mod;
}
Standard_Real modmax = eqPlan.Modulus();
if(modmax > Tol) Nor(i) = gp_Dir(eqPlan);
else Nor(i) = gp_Dir(0., 0., 1.);
Nor(i) = gp_Dir(eqPlan);
Standard_Integer j = (i - Nodes.Lower()) * 3;
Normals->SetValue(j + 1, Nor(i).X());
Normals->SetValue(j + 2, Nor(i).Y());
Normals->SetValue(j + 3, Nor(i).Z());
if (aFace.Orientation() == TopAbs_REVERSED) (Nor(i)).Reverse();
}
T->SetNormals(Normals);
}
}

View File

@@ -0,0 +1,15 @@
-- File: StdPrs_ToolVertex.cdl
-- Created: Wed May 18 18:06:49 1994
-- Author: Laurent PAINNOT
-- <lpa@metrox>
---Copyright: Matra Datavision 1994
class ToolVertex from StdPrs
uses
Length from Quantity,
Vertex from TopoDS
is
Coord( myclass; aPoint: Vertex from TopoDS; X,Y,Z: out Length from Quantity);
end ToolVertex from StdPrs;

View File

@@ -0,0 +1,18 @@
// File: StdPrs_ToolVertex.cxx
// Created: Tue Mai 18 18:45:41 1993
// Author: Laurent PAINNOT
// <lpa@metrox>
#include <StdPrs_ToolVertex.ixx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
void StdPrs_ToolVertex::Coord (const TopoDS_Vertex& aVertex,
Standard_Real& X,
Standard_Real& Y,
Standard_Real& Z) {
gp_Pnt P = BRep_Tool::Pnt(aVertex);
X = P.X(); Y = P.Y(); Z = P.Z();
}

View File

@@ -0,0 +1,133 @@
-- File: StdPrs_WFDeflectionRestrictedFace.cdl
-- Created: Mon Aug 7 10:18:39 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class WFDeflectionRestrictedFace from StdPrs
inherits Root from Prs3d
---Purpose: A framework to provide display of U and V
-- isoparameters of faces, while allowing you to impose
-- a deflection on them.
uses
HSurface from BRepAdaptor,
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity,
NListOfSequenceOfPnt from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d);
---Purpose: Defines a display featuring U and V isoparameters.
-- Adds the surface aFace to the
-- StdPrs_WFRestrictedFace algorithm. This face is
-- found in a shape in the presentation object
-- aPresentation, and its display attributes - in
-- particular, the number of U and V isoparameters - are
-- set in the attribute manager aDrawer.
-- aFace is BRepAdaptor_HSurface surface created
-- from a face in a topological shape. which is passed
-- as an argument through the
-- BRepAdaptor_HSurface surface created from it.
-- This is what allows the topological face to be treated
-- as a geometric surface.
AddUIso(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d);
---Purpose: Defines a display featuring U isoparameters
-- respectively. Add the surface aFace to the
-- StdPrs_WFRestrictedFace algorithm. This face
-- is found in a shape in the presentation object
-- aPresentation, and its display attributes - in
-- particular, the number of U isoparameters -
-- are set in the attribute manager aDrawer.
-- aFace is BRepAdaptor_HSurface surface
-- created from a face in a topological shape. which
-- is passed to the function as an argument through
-- the BRepAdaptor_HSurface surface created from
-- it. This is what allows the topological face to be
-- treated as a geometric surface.
AddVIso(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d);
---Purpose: Defines a display featuring V isoparameters
-- respectively. Add the surface aFace to the
-- StdPrs_WFRestrictedFace algorithm. This face
-- is found in a shape in the presentation object
-- aPresentation, and its display attributes - in
-- particular, the number of V isoparameters -
-- are set in the attribute manager aDrawer.
-- aFace is BRepAdaptor_HSurface surface
-- created from a face in a topological shape. which
-- is passed to the function as an argument through
-- the BRepAdaptor_HSurface surface created from
-- it. This is what allows the topological face to be
-- treated as a geometric surface.
Add(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
DrawUIso, DrawVIso: Boolean from Standard;
Deflection : Length from Quantity;
NBUiso,NBViso: Integer from Standard;
aDrawer : Drawer from Prs3d;
Curves : out NListOfSequenceOfPnt from Prs3d);
---Purpose: Defines a display of a delection-specified face. The
-- display will feature U and V isoparameters.
-- Adds the topology aShape to the
-- StdPrs_WFRestrictedFace algorithm. This shape is
-- found in the presentation object aPresentation, and
-- its display attributes - except the number of U and V
-- isoparameters - are set in the attribute manager aDrawer.
-- The function sets the number of U and V
-- isoparameters, NBUiso and NBViso, in the shape. To
-- do this, the arguments DrawUIso and DrawVIso must be true.
-- aFace is BRepAdaptor_HSurface surface created
-- from a face in a topological shape. which is passed
-- as an argument through the
-- BRepAdaptor_HSurface surface created from it.
-- This is what allows the topological face to be treated
-- as a geometric surface.
-- Curves give a sequence of face curves, it is used if the PrimitiveArray
-- visualization approach is activated (it is activated by default).
Match(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
MatchUIso(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
MatchVIso(myclass; X,Y,Z : Length from Quantity;
aDistance: Length from Quantity;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d)
returns Boolean from Standard;
Match(myclass;X,Y,Z : Length from Quantity;
aDistance : Length from Quantity;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d;
DrawUIso, DrawVIso: Boolean from Standard;
aDeflection : Length from Quantity;
NBUiso,NBViso: Integer from Standard)
returns Boolean from Standard;
end WFDeflectionRestrictedFace;

View File

@@ -0,0 +1,636 @@
// File: StdPrs_WFDeflectionRestrictedFace.cxx
// Created: Mon Aug 7 10:19:46 1995
// Author: Modelistation
// <model@metrox>
#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>
#include <Prs3d_IsoAspect.hxx>
#include <Adaptor2d_Curve2d.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <StdPrs_DeflectionCurve.hxx>
#include <StdPrs_ToolRFace.hxx>
#include <Bnd_Box2d.hxx>
#include <BndLib_Add2dCurve.hxx>
#include <Precision.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Geom_Surface.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
#ifdef DEB_MESH
#include <OSD_Chronometer.hxx>
extern OSD_Chronometer FFaceTimer1,FFaceTimer2,FFaceTimer3,FFaceTimer4;
#endif
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
static void FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
{
First = Max(aCurve.FirstParameter(), First);
Last = Min(aCurve.LastParameter(), Last);
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
gp_Pnt P1,P2;
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
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);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
}
//=========================================================================
// function: Add
// purpose
//=========================================================================
void StdPrs_WFDeflectionRestrictedFace::Add
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Standard_Boolean DrawUIso,
const Standard_Boolean DrawVIso,
const Quantity_Length Deflection,
const Standard_Integer NBUiso,
const Standard_Integer NBViso,
const Handle(Prs3d_Drawer)& aDrawer,
Prs3d_NListOfSequenceOfPnt& Curves) {
#ifdef DEB_MESH
FFaceTimer1.Start();
#endif
Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable();
StdPrs_ToolRFace ToolRst (aFace);
Standard_Real UF, UL, VF, VL;
UF = aFace->FirstUParameter();
UL = aFace->LastUParameter();
VF = aFace->FirstVParameter();
VL = aFace->LastVParameter();
Standard_Real aLimit = aDrawer->MaximalParameterValue();
// compute bounds of the restriction
Standard_Real UMin,UMax,VMin,VMax;
//Standard_Real u,v,step;
Standard_Integer i;//,nbPoints = 10;
UMin = Max(UF, -aLimit);
UMax = Min(UL, aLimit);
VMin = Max(VF, -aLimit);
VMax = Min(VL, aLimit);
// update min max for the hatcher.
gp_Pnt2d P1,P2;
Standard_Real U1, U2;
gp_Pnt dummypnt;
Standard_Real ddefle= Max(UMax-UMin, VMax-VMin) * aDrawer->DeviationCoefficient();
TColgp_SequenceOfPnt2d tabP;
UMin = VMin = 1.e100;
UMax = VMax = -1.e100;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
if (TheRCurve->GetType() != GeomAbs_Line) {
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, ddefle);
if (UDP.IsDone()) {
Standard_Integer NumberOfPoints = UDP.NbPoints();
if ( NumberOfPoints >= 2 ) {
dummypnt = UDP.Value(1);
P2.SetCoord(dummypnt.X(), dummypnt.Y());
UMin = Min(P2.X(), UMin);
UMax = Max(P2.X(), UMax);
VMin = Min(P2.Y(), VMin);
VMax = Max(P2.Y(), VMax);
for (i = 2; i <= NumberOfPoints; i++) {
P1 = P2;
dummypnt = UDP.Value(i);
P2.SetCoord(dummypnt.X(), dummypnt.Y());
UMin = Min(P2.X(), UMin);
UMax = Max(P2.X(), UMax);
VMin = Min(P2.Y(), VMin);
VMax = Max(P2.Y(), VMax);
if(Orient == TopAbs_FORWARD ) {
//isobuild.Trim(P1,P2);
tabP.Append(P1);
tabP.Append(P2);
}
else {
//isobuild.Trim(P2,P1);
tabP.Append(P2);
tabP.Append(P1);
}
}
}
}
else {
cout << "Cannot evaluate curve on surface"<<endl;
}
}
else {
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
// MSV 17.08.06 OCC13144: U2 occured less than U1, to overcome it
// ensure that distance U2-U1 is not greater than aLimit*2,
// if greater then choose an origin and use aLimit to define
// U1 and U2 anew
Standard_Real aOrigin = 0.;
if (!Precision::IsNegativeInfinite(U1) || !Precision::IsPositiveInfinite(U2)) {
if (Precision::IsNegativeInfinite(U1))
aOrigin = U2 - aLimit;
else if (Precision::IsPositiveInfinite(U2))
aOrigin = U1 + aLimit;
else
aOrigin = (U1 + U2) * 0.5;
}
U1 = Max(aOrigin - aLimit, U1);
U2 = Min(aOrigin + aLimit, U2);
P1 = TheRCurve->Value(U1);
P2 = TheRCurve->Value(U2);
UMin = Min(P1.X(), UMin);
UMax = Max(P1.X(), UMax);
VMin = Min(P1.Y(), VMin);
VMax = Max(P1.Y(), VMax);
UMin = Min(P2.X(), UMin);
UMax = Max(P2.X(), UMax);
VMin = Min(P2.Y(), VMin);
VMax = Max(P2.Y(), VMax);
if(Orient == TopAbs_FORWARD ) {
// isobuild.Trim(P1,P2);
tabP.Append(P1);
tabP.Append(P2);
}
else {
//isobuild.Trim(P2,P1);
tabP.Append(P2);
tabP.Append(P1);
}
}
}
}
#ifdef DEB_MESH
FFaceTimer1.Stop();
FFaceTimer2.Start();
#endif
// load the isos
Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented());
Standard_Boolean UClosed = aFace->IsUClosed();
Standard_Boolean VClosed = aFace->IsVClosed();
if ( ! UClosed ) {
UMin = UMin + ( UMax - UMin) /1000.;
UMax = UMax - ( UMax - UMin) /1000.;
}
if ( ! VClosed ) {
VMin = VMin + ( VMax - VMin) /1000.;
VMax = VMax - ( VMax - VMin) /1000.;
}
if (DrawUIso){
if (NBUiso > 0) {
UClosed = Standard_False; // En attendant un hatcher de course.
Standard_Real du= UClosed ? (UMax-UMin)/NBUiso : (UMax-UMin)/(1+NBUiso);
for (i=1; i<=NBUiso;i++){
isobuild.AddXLine(UMin+du*i);
}
}
}
if (DrawVIso){
if ( NBViso > 0) {
VClosed = Standard_False;
Standard_Real dv= VClosed ?(VMax-VMin)/NBViso : (VMax-VMin)/(1+NBViso);
for (i=1; i<=NBViso;i++){
isobuild.AddYLine(VMin+dv*i);
}
}
}
#ifdef DEB_MESH
FFaceTimer2.Stop();
FFaceTimer3.Start();
#endif
Standard_Integer ll = tabP.Length();
for (i = 1; i <= ll; i+=2) {
isobuild.Trim(tabP(i),tabP(i+1));
}
#ifdef DEB_MESH
FFaceTimer3.Stop();
FFaceTimer4.Start();
#endif
// draw the isos
Adaptor3d_IsoCurve anIso;
anIso.Load(aFace);
Handle(Geom_Curve) BC;
const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(aFace->Surface());
GeomAbs_SurfaceType thetype = aFace->GetType();
Standard_Integer NumberOfLines = isobuild.NbLines();
Handle(Geom_Surface) GB;
if (thetype == GeomAbs_BezierSurface) {
GB = BS.Bezier();
}
else if (thetype == GeomAbs_BSplineSurface){
GB = BS.BSpline();
}
Standard_Real anAngle = aDrawer->DeviationAngle();
for (i = 1; i <= NumberOfLines; i++) {
Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i);
Standard_Real Coord = isobuild.Coordinate(i);
for (Standard_Integer j = 1; j <= NumberOfIntervals; j++) {
Standard_Real b1=isobuild.Start(i,j),b2=isobuild.End(i,j);
if (!GB.IsNull()) {
if (isobuild.IsXLine(i))
BC = GB->UIso(Coord);
else
BC = GB->VIso(Coord);
GeomAdaptor_Curve GC(BC);
FindLimits(GC, aLimit,b1, b2);
if (b2-b1>Precision::Confusion()) {
TColgp_SequenceOfPnt Points;
StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, !isPA);
Curves.Append(Points);
}
}
else {
if (isobuild.IsXLine(i))
anIso.Load(GeomAbs_IsoU,Coord,b1,b2);
else
anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
FindLimits(anIso, aLimit,b1, b2);
if (b2-b1>Precision::Confusion()) {
TColgp_SequenceOfPnt Points;
StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, !isPA);
Curves.Append(Points);
}
}
}
}
#ifdef DEB_MESH
FFaceTimer4.Stop();
#endif
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle(Prs3d_Drawer)& aDrawer,
const Standard_Boolean DrawUIso,
const Standard_Boolean DrawVIso,
const Quantity_Length Deflection,
const Standard_Integer NBUiso,
const Standard_Integer NBViso)
{
StdPrs_ToolRFace ToolRst (aFace);
const Standard_Real aLimit = aDrawer->MaximalParameterValue();
// compute bounds of the restriction
Standard_Real UMin,UMax,VMin,VMax;
Standard_Real u,v,step;
Standard_Integer i,nbPoints = 10;
UMin = VMin = RealLast();
UMax = VMax = RealFirst();
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
u = TheRCurve->FirstParameter();
v = TheRCurve->LastParameter();
step = ( v - u) / nbPoints;
for (i = 0; i <= nbPoints; i++) {
gp_Pnt2d P = TheRCurve->Value(u);
if (P.X() < UMin) UMin = P.X();
if (P.X() > UMax) UMax = P.X();
if (P.Y() < VMin) VMin = P.Y();
if (P.Y() > VMax) VMax = P.Y();
u += step;
}
}
// load the isos
Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented());
Standard_Boolean UClosed = aFace->IsUClosed();
Standard_Boolean VClosed = aFace->IsVClosed();
if ( ! UClosed ) {
UMin = UMin + ( UMax - UMin) /1000.;
UMax = UMax - ( UMax - UMin) /1000.;
}
if ( ! VClosed ) {
VMin = VMin + ( VMax - VMin) /1000.;
VMax = VMax - ( VMax - VMin) /1000.;
}
if (DrawUIso){
if (NBUiso > 0) {
UClosed = Standard_False; // En attendant un hatcher de course.
Standard_Real du= UClosed ? (UMax-UMin)/NBUiso : (UMax-UMin)/(1+NBUiso);
for (i=1; i<=NBUiso;i++){
isobuild.AddXLine(UMin+du*i);
}
}
}
if (DrawVIso){
if ( NBViso > 0) {
VClosed = Standard_False;
Standard_Real dv= VClosed ?(VMax-VMin)/NBViso : (VMax-VMin)/(1+NBViso);
for (i=1; i<=NBViso;i++){
isobuild.AddYLine(VMin+dv*i);
}
}
}
// trim the isos
gp_Pnt2d P1,P2;
gp_Pnt dummypnt;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, Deflection);
if (UDP.IsDone()) {
Standard_Integer NumberOfPoints = UDP.NbPoints();
if ( NumberOfPoints >= 2 ) {
dummypnt = UDP.Value(1);
P2.SetCoord(dummypnt.X(), dummypnt.Y());
for (i = 2; i <= NumberOfPoints; i++) {
P1 = P2;
dummypnt = UDP.Value(i);
P2.SetCoord(dummypnt.X(), dummypnt.Y());
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
}
else {
cout << "Cannot evaluate curve on surface"<<endl;
}
}
}
// draw the isos
Adaptor3d_IsoCurve anIso;
anIso.Load(aFace);
Standard_Integer NumberOfLines = isobuild.NbLines();
Standard_Real anAngle = aDrawer->DeviationAngle();
for (i = 1; i <= NumberOfLines; i++) {
Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i);
Standard_Real Coord = isobuild.Coordinate(i);
for (Standard_Integer j = 1; j <= NumberOfIntervals; j++) {
Standard_Real b1=isobuild.Start(i,j),b2=isobuild.End(i,j);
b1 = b1 == RealFirst() ? - aLimit : b1;
b2 = b2 == RealLast() ? aLimit : b2;
if (isobuild.IsXLine(i))
anIso.Load(GeomAbs_IsoU,Coord,b1,b2);
else
anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
if (StdPrs_DeflectionCurve::Match(X,Y,Z,aDistance,anIso, b1, b2, Deflection, anAngle))
return Standard_True;
}
}
return Standard_False;
}
//=========================================================================
// function: Add
// purpose
//=========================================================================
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();
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (aPresentation,
aFace,
Standard_True,
Standard_True,
Deflection,
finu,
finv,
aDrawer,
Curves);
TheGroup->EndPrimitives();
}
//=========================================================================
// function: AddUIso
// purpose
//=========================================================================
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();
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_False,
Deflection,
finu,
finv,
aDrawer,
Curves);
}
//=========================================================================
// function: AddVIso
// purpose
//=========================================================================
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();
Prs3d_NListOfSequenceOfPnt Curves;
StdPrs_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_False,
Standard_True,
Deflection,
finu,
finv,
aDrawer,
Curves);
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
(const Quantity_Length X,
const Quantity_Length Y,
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();
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_True,
Deflection,
finu,
finv);
}
//=========================================================================
// function: MatchUIso
// purpose
//=========================================================================
Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchUIso
(const Quantity_Length X,
const Quantity_Length Y,
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();
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_False,
Deflection,
finu,
finv);
}
//=========================================================================
// function: MatchVIso
// purpose
//=========================================================================
Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchVIso
(const Quantity_Length X,
const Quantity_Length Y,
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();
return StdPrs_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_False,
Standard_True,
Deflection,
finu,
finv);
}

View File

@@ -0,0 +1,40 @@
-- File: StdPrs_WFDeflectionSurface.cdl
-- Created: Mon Jul 24 17:20:11 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class WFDeflectionSurface from StdPrs
inherits Root from Prs3d
--- Purpose: Draws a surface by drawing the isoparametric curves with respect to
-- a maximal chordial deviation.
-- The number of isoparametric curves to be drawn and their color are
-- controlled by the furnished Drawer.
uses
HSurface from Adaptor3d,
Curve from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aSurface : HSurface from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Adds the surface aSurface to the presentation object
-- aPresentation, and defines its boundaries and isoparameters.
-- The shape's display attributes are set in the attribute
-- manager aDrawer. These include whether deflection
-- is absolute or relative to the size of the shape.
-- The surface aSurface is a surface object from
-- Adaptor, and provides data from a Geom surface.
-- This makes it possible to use the surface in a geometric algorithm.
-- Note that this surface object is manipulated by handles.
end WFDeflectionSurface from StdPrs;

View File

@@ -0,0 +1,210 @@
// File: StdPrs_WFDeflectionSurface.cxx
// Created: Mon Jul 24 17:25:12 1995
// Author: Modelistation
// <model@metrox>
#include <StdPrs_WFDeflectionSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <GeomAbs_IsoType.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Bnd_Box.hxx>
#include <BndLib_AddSurface.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <StdPrs_DeflectionCurve.hxx>
static void FindLimits(const Handle(Adaptor3d_HSurface)& surf ,
const Standard_Real aLimit,
Standard_Real& UFirst,
Standard_Real& ULast,
Standard_Real& VFirst,
Standard_Real& VLast)
{
UFirst = surf->FirstUParameter();
ULast = surf->LastUParameter();
VFirst = surf->FirstVParameter();
VLast = surf->LastVParameter();
Standard_Boolean UfirstInf = Precision::IsNegativeInfinite(UFirst);
Standard_Boolean UlastInf = Precision::IsPositiveInfinite(ULast);
Standard_Boolean VfirstInf = Precision::IsNegativeInfinite(VFirst);
Standard_Boolean VlastInf = Precision::IsPositiveInfinite(VLast);
if (UfirstInf || UlastInf) {
gp_Pnt P1,P2;
Standard_Real v;
if (VfirstInf && VlastInf)
v = 0;
else if (VfirstInf)
v = VLast;
else if (VlastInf)
v = VFirst;
else
v = (VFirst + VLast) / 2;
Standard_Real delta = aLimit * 2;
if (UfirstInf && UlastInf) {
do {
delta /= 2;
UFirst = - delta;
ULast = delta;
surf->D0(UFirst,v,P1);
surf->D0(ULast,v,P2);
} while (P1.Distance(P2) > aLimit);
}
else if (UfirstInf) {
surf->D0(ULast,v,P2);
do {
delta /= 2;
UFirst = ULast - delta;
surf->D0(UFirst,v,P1);
} while (P1.Distance(P2) > aLimit);
}
else if (UlastInf) {
surf->D0(UFirst,v,P1);
do {
delta /= 2;
ULast = UFirst + delta;
surf->D0(ULast,v,P2);
} while (P1.Distance(P2) > aLimit);
}
}
if (VfirstInf || VlastInf) {
gp_Pnt P1,P2;
Standard_Real u = (UFirst + ULast) /2 ;
Standard_Real delta = aLimit * 2;
if (VfirstInf && VlastInf) {
do {
delta /= 2;
VFirst = - delta;
VLast = delta;
surf->D0(u,VFirst,P1);
surf->D0(u,VLast,P2);
} while (P1.Distance(P2) > aLimit);
}
else if (VfirstInf) {
surf->D0(u,VLast,P2);
do {
delta /= 2;
VFirst = VLast - delta;
surf->D0(u,VFirst,P1);
} while (P1.Distance(P2) > aLimit);
}
else if (VlastInf) {
surf->D0(u,VFirst,P1);
do {
delta /= 2;
VLast = VFirst + delta;
surf->D0(u,VLast,P2);
} while (P1.Distance(P2) > aLimit);
}
}
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_WFDeflectionSurface::Add (
const Handle (Prs3d_Presentation)& aPresentation,
const Handle(Adaptor3d_HSurface)& aSurface,
const Handle (Prs3d_Drawer)& aDrawer)
{
Standard_Real U1, U2, V1, V2;
Standard_Real MaxP = aDrawer->MaximalParameterValue();
FindLimits(aSurface, MaxP, U1, U2, V1, V2);
Standard_Boolean UClosed = aSurface->IsUClosed();
Standard_Boolean VClosed = aSurface->IsVClosed();
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_AddSurface::Add(aSurface->Surface(),U1, U2, V1, V2, 0.,Total);
Standard_Real m = aDrawer->MaximalChordialDeviation()/
aDrawer->DeviationCoefficient();
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() ))
m = Min ( m , Abs (aXmax-aXmin));
if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() ))
m = Min ( m , Abs (aYmax-aYmin));
if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() ))
m = Min ( m , Abs (aZmax-aZmin));
TheDeflection = m * aDrawer->DeviationCoefficient();
}
else
TheDeflection = aDrawer->MaximalChordialDeviation();
Adaptor3d_IsoCurve anIso;
anIso.Load(aSurface);
// Trace des frontieres.
// *********************
//
if ( !(UClosed && VClosed) ) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->FreeBoundaryAspect()->Aspect());
if ( !UClosed )
{
anIso.Load(GeomAbs_IsoU,U1,V1,V2);
StdPrs_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
anIso.Load(GeomAbs_IsoU,U2,V1,V2);
StdPrs_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
}
if ( !VClosed )
{
anIso.Load(GeomAbs_IsoV,V1,U1,U2);
StdPrs_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
anIso.Load(GeomAbs_IsoV,V2,U1,U2);
StdPrs_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
}
}
//
// Trace des isoparametriques.
// ***************************
//
Standard_Integer fin = aDrawer->UIsoAspect()->Number();
if ( fin != 0) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->UIsoAspect()->Aspect());
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_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
}
}
fin = aDrawer->VIsoAspect()->Number();
if ( fin != 0) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->VIsoAspect()->Aspect());
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_DeflectionCurve::Add(aPresentation,anIso,TheDeflection, MaxP);
}
}
}

View File

@@ -0,0 +1,33 @@
-- File: StdPrs_WFPoleSurface.cdl
-- Created: Mon Jul 24 16:50:27 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class WFPoleSurface from StdPrs
inherits Root from Prs3d
--- Purpose: The number of lines to be drawn is controlled
-- by the NetworkNumber of the given Drawer.
uses
Surface from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aSurface : Surface from Adaptor3d;
aDrawer : Drawer from Prs3d);
---Purpose: Adds the surface aSurface to the presentation object aPresentation.
-- The shape's display attributes are set in the attribute manager aDrawer.
-- The surface aSurface is a surface object from
-- Adaptor3d, and provides data from a Geom surface.
-- This makes it possible to use the surface in a geometric algorithm.
end WFPoleSurface;

View File

@@ -0,0 +1,82 @@
// File: StdPrs_WFPoleSurface.cxx
// Created: Mon Jul 24 16:52:35 1995
// Author: Modelistation
// <model@metrox>
#include <StdPrs_WFPoleSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Graphic3d_Array1OfVertex.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)
{
Standard_Integer i,j;
Standard_Real x,y,z;
Standard_Integer n = A.ColLength();
Standard_Integer m = A.RowLength();
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
Graphic3d_Array1OfVertex VertexArray1(1,m);
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);
}
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());
Graphic3d_Array1OfVertex VertexArray2(1,n);
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);
}
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_WFPoleSurface::Add (const Handle (Prs3d_Presentation)& aPresentation,
const Adaptor3d_Surface& aSurface,
const Handle (Prs3d_Drawer)& aDrawer)
{
GeomAbs_SurfaceType SType = aSurface.GetType();
if (SType == GeomAbs_BezierSurface || SType == GeomAbs_BSplineSurface) {
Standard_Integer n , m;
if (SType == GeomAbs_BezierSurface) {
Handle(Geom_BezierSurface) B = aSurface.Bezier();
n = aSurface.NbUPoles();
m = aSurface.NbVPoles();
TColgp_Array2OfPnt A(1,n,1,m);
(aSurface.Bezier())->Poles(A);
AddPoles(aPresentation, A, aDrawer);
}
else if (SType == GeomAbs_BSplineSurface) {
Handle(Geom_BSplineSurface) B = aSurface.BSpline();
n = (aSurface.BSpline())->NbUPoles();
m = (aSurface.BSpline())->NbVPoles();
TColgp_Array2OfPnt A(1,n,1,m);
(aSurface.BSpline())->Poles(A);
AddPoles(aPresentation, A, aDrawer);
}
}
}

31
src/StdPrs/StdPrs_WFSurface.cdl Executable file
View File

@@ -0,0 +1,31 @@
-- File: StdPrs_WFSurface.cdl
-- Created: Fri Aug 4 11:30:13 1995
-- Author: Modelistation
-- <model@metrox>
---Copyright: Matra Datavision 1995
class WFSurface from StdPrs
inherits Root from Prs3d
uses
HSurface from Adaptor3d,
Presentation from Prs3d,
Drawer from Prs3d
is
--- Purpose: Draws a surface by drawing the isoparametric curves with respect to
-- a fixed number of points given by the Drawer.
-- The number of isoparametric curves to be drawn and their color are
-- controlled by the furnished Drawer.
Add(myclass; aPresentation: Presentation from Prs3d;
aSurface : HSurface from Adaptor3d;
aDrawer : Drawer from Prs3d);
end WFSurface from StdPrs;

298
src/StdPrs/StdPrs_WFSurface.cxx Executable file
View File

@@ -0,0 +1,298 @@
// File: StdPrs_WFSurface.cxx
// Created: Fri Aug 4 11:32:25 1995
// Author: Modelistation
// <model@metrox>
#include <StdPrs_WFSurface.ixx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <GeomAbs_IsoType.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Bnd_Box.hxx>
#include <Precision.hxx>
#include <BndLib_AddSurface.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <StdPrs_Curve.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <Prs3d_NListOfSequenceOfPnt.hxx>
#include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
static void FindLimits(const Handle(Adaptor3d_HSurface)& surf ,
const Standard_Real aLimit,
Standard_Real& UFirst,
Standard_Real& ULast,
Standard_Real& VFirst,
Standard_Real& VLast)
{
UFirst = surf->FirstUParameter();
ULast = surf->LastUParameter();
VFirst = surf->FirstVParameter();
VLast = surf->LastVParameter();
Standard_Boolean UfirstInf = Precision::IsNegativeInfinite(UFirst);
Standard_Boolean UlastInf = Precision::IsPositiveInfinite(ULast);
Standard_Boolean VfirstInf = Precision::IsNegativeInfinite(VFirst);
Standard_Boolean VlastInf = Precision::IsPositiveInfinite(VLast);
if (UfirstInf || UlastInf) {
gp_Pnt P1,P2;
Standard_Real v;
if (VfirstInf && VlastInf)
v = 0;
else if (VfirstInf)
v = VLast;
else if (VlastInf)
v = VFirst;
else
v = (VFirst + VLast) / 2;
Standard_Real delta = aLimit * 2;
if (UfirstInf && UlastInf) {
do {
delta /= 2;
UFirst = - delta;
ULast = delta;
surf->D0(UFirst,v,P1);
surf->D0(ULast,v,P2);
} while (P1.Distance(P2) > aLimit);
}
else if (UfirstInf) {
surf->D0(ULast,v,P2);
do {
delta /= 2;
UFirst = ULast - delta;
surf->D0(UFirst,v,P1);
} while (P1.Distance(P2) > aLimit);
}
else if (UlastInf) {
surf->D0(UFirst,v,P1);
do {
delta /= 2;
ULast = UFirst + delta;
surf->D0(ULast,v,P2);
} while (P1.Distance(P2) > aLimit);
}
}
if (VfirstInf || VlastInf) {
gp_Pnt P1,P2;
Standard_Real u = (UFirst + ULast) /2 ;
Standard_Real delta = aLimit * 2;
if (VfirstInf && VlastInf) {
do {
delta /= 2;
VFirst = - delta;
VLast = delta;
surf->D0(u,VFirst,P1);
surf->D0(u,VLast,P2);
} while (P1.Distance(P2) > aLimit);
}
else if (VfirstInf) {
surf->D0(u,VLast,P2);
do {
delta /= 2;
VFirst = VLast - delta;
surf->D0(u,VFirst,P1);
} while (P1.Distance(P2) > aLimit);
}
else if (VlastInf) {
surf->D0(u,VFirst,P1);
do {
delta /= 2;
VLast = VFirst + delta;
surf->D0(u,VLast,P2);
} while (P1.Distance(P2) > aLimit);
}
}
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Adaptor3d_HSurface)& aSurface,
const Handle(Prs3d_Drawer)& aDrawer)
{
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;
Prs3d_NListOfSequenceOfPnt UIsoCurves;
Prs3d_NListOfSequenceOfPnt VIsoCurves;
TColgp_SequenceOfPnt Pnts;
Standard_Boolean UClosed = aSurface->IsUClosed();
Standard_Boolean VClosed = aSurface->IsVClosed();
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_AddSurface::Add(aSurface->Surface(),U1, U2, V1, V2, 0.,Total);
Standard_Real m = aDrawer->MaximalChordialDeviation()/
aDrawer->DeviationCoefficient();
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() ))
m = Min ( m , Abs (aXmax-aXmin));
if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() ))
m = Min ( m , Abs (aYmax-aYmin));
if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() ))
m = Min ( m , Abs (aZmax-aZmin));
TheDeflection = m * aDrawer->DeviationCoefficient();
}
else
TheDeflection = aDrawer->MaximalChordialDeviation();
Adaptor3d_IsoCurve anIso;
anIso.Load(aSurface);
// Trace des frontieres.
// *********************
//
if ( !(UClosed && VClosed) ) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->FreeBoundaryAspect()->Aspect());
if ( !UClosed )
{
anIso.Load(GeomAbs_IsoU,U1,V1,V2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
freeCurves.Append(Pnts);
Pnts.Clear();
anIso.Load(GeomAbs_IsoU,U2,V1,V2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
freeCurves.Append(Pnts);
Pnts.Clear();
}
if ( !VClosed )
{
anIso.Load(GeomAbs_IsoV,V1,U1,U2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
freeCurves.Append(Pnts);
Pnts.Clear();
anIso.Load(GeomAbs_IsoV,V2,U1,U2);
StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA);
freeCurves.Append(Pnts);
Pnts.Clear();
}
}
//
// Trace des isoparametriques.
// ***************************
//
Standard_Integer fin = aDrawer->UIsoAspect()->Number();
if ( fin != 0) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->UIsoAspect()->Aspect());
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);
UIsoCurves.Append(Pnts);
Pnts.Clear();
}
}
fin = aDrawer->VIsoAspect()->Number();
if ( fin != 0) {
(Prs3d_Root::CurrentGroup(aPresentation))->SetPrimitivesAspect
(aDrawer->VIsoAspect()->Aspect());
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);
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) {
nbBounds = UIsoCurves.Size();
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(UIsoCurves); It.More(); It.Next())
nbVertices += It.Value().Length();
Handle(Graphic3d_ArrayOfPolylines) UIsoArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for( It.Init(UIsoCurves); It.More(); It.Next()) {
TColgp_SequenceOfPnt Pnts;
Pnts.Assign(It.Value());
UIsoArray->AddBound(Pnts.Length());
for(int i=1; i<=Pnts.Length(); i++)
UIsoArray->AddVertex(Pnts.Value(i));
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(UIsoArray);
TheGroup->EndPrimitives();
}
if(VIsoCurves.Size() > 0) {
nbBounds = VIsoCurves.Size();
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(VIsoCurves); It.More(); It.Next())
nbVertices += It.Value().Length();
Handle(Graphic3d_ArrayOfPolylines) VIsoArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for( It.Init(VIsoCurves); It.More(); It.Next()) {
TColgp_SequenceOfPnt Pnts;
Pnts.Assign(It.Value());
VIsoArray->AddBound(Pnts.Length());
for(int i=1; i<=Pnts.Length(); i++)
VIsoArray->AddVertex(Pnts.Value(i));
}
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();
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(freeCurves); It.More(); It.Next())
nbVertices += It.Value().Length();
Handle(Graphic3d_ArrayOfPolylines) freeArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for( It.Init(freeCurves); It.More(); It.Next()) {
TColgp_SequenceOfPnt Pnts;
Pnts.Assign(It.Value());
freeArray->AddBound(Pnts.Length());
for(int i=1; i<=Pnts.Length(); i++)
freeArray->AddVertex(Pnts.Value(i));
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(freeArray);
TheGroup->EndPrimitives();
}
}