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

2
src/Prs3d/FILES Executable file
View File

@@ -0,0 +1,2 @@
Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx
Prs3d_NListOfSequenceOfPnt.hxx

207
src/Prs3d/Prs3d.cdl Executable file
View File

@@ -0,0 +1,207 @@
-- File: Prs3d.cdl
-- Created: Wed Aug 26 17:38:18 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
package Prs3d
---Purpose: The Prs3d package provides the following services
-- - a presentation object (the context for all
-- modifications to the display, its presentation will be
-- displayed in every view of an active viewer)
-- - an attribute manager governing how objects such
-- as color, width, and type of line are displayed;
-- these are generic objects, whereas those in
-- StdPrs are specific geometries and topologies.
-- - generic algorithms providing default settings for
-- objects such as points, curves, surfaces and shapes
-- - a root object which provides the abstract
-- framework for the DsgPrs definitions at work in
-- display of dimensions, relations and trihedra.
uses
Graphic3d,
Aspect,
Quantity,
MMgt,
Standard,
Adaptor3d,
BRepAdaptor,
Geom,
CPnts,
GCPnts,
TopAbs,
TopLoc,
TopoDS,
TopTools,
TopExp,
HLRAlgo,
TCollection,
TColgp,
Bnd,
gp,
Poly,
TColStd
is
exception InvalidAngle inherits RangeError from Standard;
enumeration TypeOfLinePicking is TOLP_Point,
TOLP_Segment
end TypeOfLinePicking;
class Presentation;
---Purpose: defines the presentation object. This object can be
-- displayed, highlighted, erased, etc... The output
-- of the presentation algorithms are sent in a
-- presentation object. A presentation object is attached
-- to a given Viewer.
---Category: Aspect classes.
---Purpose: The aspect classes qualifies how to represent
-- a given kind of object.
--
deferred class BasicAspect;
class PointAspect;
class LineAspect;
class ShadingAspect;
class TextAspect;
deferred class CompositeAspect;
class IsoAspect;
class PlaneAspect;
class ArrowAspect;
class LengthAspect;
class AngleAspect;
class RadiusAspect;
class DatumAspect;
class Drawer;
---Purpose: qualifies how the presentation algorithms compute
-- the presentation of a specific kind of object.
-- This includes for example color, width and type
-- of lines, maximal chordial deviation, etc...
-- A drawer includes an instance of the Aspect classes
-- with particular default values.
class Projector;
---Purpose: defines the projection parameters for the hidden
-- lines removal algorithm.
class PlaneSet;
---Purpose: defines a set of planes used for a presentation
-- by sections.
--
deferred class Root;
---Purpose: defines the root of the presentation algorithms.
generic class Point;
---Purpose: computes the presentation of objects to be
-- seen as points.
generic class Line;
---Purpose: computes the presentation of objects to be
-- seen as broken lines.
--generic class WFSectionShape;
---Purpose: computes the wireframe presentation of surfaces
-- by displaying planar sections.
generic class WFDeflectionRestrictedFace;
---Purpose: computes the wireframe presentation of faces with
-- restrictions by displaying a given number of U and/or
-- V isoparametric curves. The isoparametric curves are
-- drawn with respect to a maximal chordial deviation.
-- The presentation includes the restriction curves.
generic class WFRestrictedFace;
---Purpose: computes the wireframe presentation of faces with
-- restrictions by displaying a given number of U and/or
-- V isoparametric curves. The isoparametric curves are
-- drawn with a fixed number of points.
-- The presentation includes the restriction curves.
generic class WFShape;
---Purpose: computes the wireframe presentation of compound set
-- of faces, edges and vertices by displaying a given
-- number of U and/or V isoparametric curves.
---Category: Hidden lines removal algorithms.
generic class HLRShape;
---Purpose: computes the presentation of objects with
-- removal of their hidden lines for a specific
-- projector.
--
---Category: Shading algorithms.
generic class SectionShapeTool;
generic class ShadedShape;
---Category: Basis construction elements.
generic class Vector;
generic class Datum;
class LengthPresentation;
class AnglePresentation;
class Text;
---Category: Class signatures.
--
generic class PointTool;
---Purpose: describes the behaviour requested for a point presentation
generic class LineTool;
---Purpose: describes the behaviour requested for a line presentation
generic class CurvePresentation;
generic class RestrictionTool;
---Purpose: describes the behaviour requested for a restricted
-- face presentation.
class ShapeTool;
---Purpose: describes the behaviour requested for a wireframe
-- shape presentation.
generic class HLRShapeTool;
---Purpose: describes the behaviour requested for a shape
-- presentation with hidden lines removal.
deferred generic class VectorTool;
---Purpose: describes the behaviour requested for a vector
-- presentation.
deferred generic class DatumTool;
---Purpose: describes the behaviour requested for a datum
-- presentation.
class Arrow;
---Purpose: draws an arrow at a given location, with respect
-- to a given direction.
imported NListOfSequenceOfPnt;
imported NListIteratorListOfSequenceOfPnt;
MatchSegment(X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
p1,p2: Pnt from gp;
dist: out Length from Quantity)
returns Boolean from Standard;
end Prs3d;

34
src/Prs3d/Prs3d.cxx Executable file
View File

@@ -0,0 +1,34 @@
// File: Prs3d.cxx
// Created: Fri Aug 27 09:48:54 1993
// Author: Jean-Louis FRENKEL
// <jlf@stylox>
#include <Prs3d.ixx>
Standard_Boolean Prs3d::MatchSegment
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const gp_Pnt& P1,
const gp_Pnt& P2,
Quantity_Length& dist) {
Standard_Real X1,Y1,Z1,X2,Y2,Z2;
P1.Coord(X1,Y1,Z1); P2.Coord(X2,Y2,Z2);
Standard_Real DX = X2-X1;
Standard_Real DY = Y2-Y1;
Standard_Real DZ = Z2-Z1;
Standard_Real Dist = DX*DX + DY*DY + DZ*DZ;
if (Dist == 0.) return Standard_False;
Standard_Real Lambda = ((X-X1)*DX + (Y-Y1)*DY + (Z-Z1)*DZ)/Dist;
if ( Lambda < 0. || Lambda > 1. ) return Standard_False;
dist = Abs(X-X1-Lambda*DX) +
Abs(Y-Y1-Lambda*DY) +
Abs(Z-Z1-Lambda*DZ);
return (dist < aDistance);
}

60
src/Prs3d/Prs3d_AngleAspect.cdl Executable file
View File

@@ -0,0 +1,60 @@
-- File: Prs3d_AngleAspect.cdl
-- Created: Thu Jun 3 09:28:46 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class AngleAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: A framework for defining how an angle will be
-- displayed in a presentation. Aspects of angle display include:
-- - display of the arrow pointing to the angle
-- - display of the line making up the shaft of the arrow
-- - display of the text referring to the angle.
-- The definition set by this class is then passed to the
-- attribute manager Prs3d_Drawer.
-- Any object which requires a value for angle aspect as
-- an argument may then be given the attribute manager
-- as a substitute argument in the form of a field such as
-- myDrawer for example.
uses
LineAspect from Prs3d,
TextAspect from Prs3d,
ArrowAspect from Prs3d
is
--
-- Attributes for the lines.
--
Create returns mutable AngleAspect from Prs3d;
LineAspect(me) returns mutable LineAspect from Prs3d;
--- Purpose: Returns the setting determining how the line making
-- up the shaft of the arrow will be displayed.
SetLineAspect(me: mutable; anAspect: LineAspect from Prs3d);
---Purpose: Sets how the line making up the shaft of an arrow will be displayed.
TextAspect(me) returns mutable TextAspect from Prs3d is static;
--- Purpose: Returns the setting determining how text in the
-- presentation of an angle will be displayed.
SetTextAspect(me:mutable; anAspect: TextAspect from Prs3d) is static;
---Purpose: Sets how text in the presentation of an angle will be displayed.
ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static;
---Purpose: Returns the setting determining how an arrow head
-- which points to an angle will be displayed.
SetArrowAspect(me: mutable; anAspect: ArrowAspect from Prs3d) is static;
---Purpose: Sets how an arrow head which points to an angle will be displayed.
Print(me; s: in out OStream from Standard) is static;
fields
myLineAspect: LineAspect from Prs3d;
myArrowAspect: ArrowAspect from Prs3d;
myTextAspect: TextAspect from Prs3d;
end AngleAspect from Prs3d;

39
src/Prs3d/Prs3d_AngleAspect.cxx Executable file
View File

@@ -0,0 +1,39 @@
#include <Prs3d_AngleAspect.ixx>
Prs3d_AngleAspect::Prs3d_AngleAspect() {
myLineAspect = new Prs3d_LineAspect
(Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
myArrowAspect = new Prs3d_ArrowAspect;
myTextAspect = new Prs3d_TextAspect;
}
Handle (Prs3d_LineAspect) Prs3d_AngleAspect::LineAspect () const {
return myLineAspect;}
void Prs3d_AngleAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& anAspect) {
myLineAspect = anAspect;}
Handle(Prs3d_ArrowAspect) Prs3d_AngleAspect::ArrowAspect () const {
return myArrowAspect;}
void Prs3d_AngleAspect::SetArrowAspect (
const Handle(Prs3d_ArrowAspect)& anAspect) {
myArrowAspect = anAspect;
}
Handle(Prs3d_TextAspect) Prs3d_AngleAspect::TextAspect () const {
return myTextAspect;}
void Prs3d_AngleAspect::SetTextAspect (
const Handle(Prs3d_TextAspect)& anAspect) {
myTextAspect = anAspect;
}
void Prs3d_AngleAspect::Print (Standard_OStream& s) const {
s << "AngleAspect: " << endl;
s << " " ; myLineAspect->Print(s); s << endl;
s << " arrow " ; myArrowAspect->Print(s); s << endl;
s << " " ; myTextAspect->Print(s); s << endl;
}

View File

@@ -0,0 +1,33 @@
-- File: Prs3d_AnglePresentation.cdl
-- Created: Tue Feb 22 15:06:49 1994
-- Author: Jean Louis FRENKEL
-- <jlf@pernox>
---Copyright: Matra Datavision 1994
class AnglePresentation from Prs3d inherits Root from Prs3d
---Purpose: A framework to define the display of angles.
uses
Presentation from Prs3d,
Pnt from gp,
Drawer from Prs3d,
ExtendedString from TCollection
is
Draw( myclass; aPresentation: Presentation from Prs3d;
aDrawer: Drawer from Prs3d;
aText: ExtendedString from TCollection;
AttachmentPoint1: Pnt from gp;
AttachmentPoint2: Pnt from gp;
AttachmentPoint3: Pnt from gp;
OffsetPoint: Pnt from gp);
---Purpose: Defines the representation of the angle between the
-- line defined by the points AttachmentPoint1 and
-- AttachmentPoint2 and the line defined by the points
-- AttachmentPoint1 and AttachmentPoint3.
-- The text aText is displayed at the point OffsetPoint,
-- and the drawer aDrawer specifies the display
-- attributes which angles will have.
-- The presentation object aPresentation stores the
-- information defined in this framework.
end AnglePresentation from Prs3d;

View File

@@ -0,0 +1,79 @@
#include <Prs3d_AnglePresentation.ixx>
#include <gp_Lin.hxx>
#include <gp_Dir.hxx>
#include <ElCLib.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_AngleAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Prs3d_Text.hxx>
void Prs3d_AnglePresentation::Draw (
const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Prs3d_Drawer)& aDrawer,
const TCollection_ExtendedString& aText,
const gp_Pnt& AttachmentPoint1,
const gp_Pnt& AttachmentPoint2,
const gp_Pnt& AttachmentPoint3,
const gp_Pnt& OffsetPoint) {
Handle(Prs3d_AngleAspect) AA = aDrawer->AngleAspect();
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AA->LineAspect()->Aspect());
gp_Vec V1 (AttachmentPoint1,AttachmentPoint2);
gp_Vec V2 (AttachmentPoint1,AttachmentPoint3);
Standard_Real alpha = V1.Angle(V2);
Standard_Real ray = AttachmentPoint1.Distance(OffsetPoint);
gp_Dir I (V1);
gp_Dir K = I.Crossed(gp_Dir(V2));
gp_Dir J = K.Crossed(I);
//
Standard_Real xc,yc,zc;
AttachmentPoint1.Coord(xc,yc,zc);
Graphic3d_Array1OfVertex V(1,2);
Standard_Real x1,y1,z1,x2,y2,z2;
AttachmentPoint2.Coord(x1,y1,z1);
AttachmentPoint3.Coord(x2,y2,z2);
Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / PI));
Standard_Real dteta = alpha/(nbp-1);
Standard_Real x,y,z;
gp_Vec u;
for (Standard_Integer i = 1; i<=nbp; i++) {
u = (gp_Vec(I) * Cos ( (i-1) * dteta)
+ gp_Vec(J) * Sin ( (i-1) * dteta)) * ray ;
u.Coord(x,y,z);
if(i == 1) {
V(1).SetCoord( xc + x, yc + y, zc + z);
V(2).SetCoord( x1,y1,z1);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);}
else {
V(2).SetCoord( xc + x, yc + y, zc + z);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
if( i == nbp ) {
Standard_Real a1,b1,c1,a2,b2,c2;
V(1).Coord(a1,b1,c1); gp_Pnt pt1(a1,b1,c1);
V(2).Coord(a2,b2,c2); gp_Pnt pt2(a2,b2,c2);
gp_Dir dir( gp_Vec(pt1 , pt2) );
Prs3d_Arrow::Draw(aPresentation,pt2,dir,AA->ArrowAspect()->Angle(),
AA->ArrowAspect()->Length());
}
V(1)=V(2);
}
}
V(2).SetCoord(x2,y2,z2);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
u = (gp_Vec(I) * Cos ( alpha/2.)
+ gp_Vec(J) * Sin ( alpha/2.)) * ray ;
u.Coord(x,y,z);
Prs3d_Text::Draw(aPresentation,AA->TextAspect(),aText,
gp_Pnt(xc+x,yc+y,zc+z));
}

50
src/Prs3d/Prs3d_Arrow.cdl Executable file
View File

@@ -0,0 +1,50 @@
-- File: Prs3d_Arrow.cdl
-- Created: Thu Apr 15 10:20:58 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
class Arrow from Prs3d
inherits Root from Prs3d
---Purpose: provides class methods to draw an arrow at a given
-- location, along a given direction and using a given
-- angle.
uses
Pnt from gp,
Dir from gp,
PlaneAngle from Quantity,
Length from Quantity,
Presentation from Prs3d
is
Draw(myclass; aPresentation: Presentation from Prs3d;
aLocation: Pnt from gp;
aDirection: Dir from gp;
anAngle: PlaneAngle from Quantity;
aLength: Length from Quantity);
---Purpose: Defines the representation of the arrow defined by
-- the location point aLocation, the direction
-- aDirection and the length aLength.
-- The angle anAngle defines the angle of opening of the arrow head.
-- The presentation object aPresentation stores the
-- information defined in this framework.
Fill(myclass; aPresentation: Presentation from Prs3d;
aLocation: Pnt from gp;
aDirection: Dir from gp;
anAngle: PlaneAngle from Quantity;
aLength: Length from Quantity);
---Purpose: Defines the representation of the arrow defined by
-- the location point aLocation, the direction vector
-- aDirection and the length aLength.
-- The angle anAngle defines the angle of opening of
-- the arrow head, and the drawer aDrawer specifies
-- the display attributes which arrows will have.
-- With this syntax, no presentation object is created.
end Arrow from Prs3d;

80
src/Prs3d/Prs3d_Arrow.cxx Executable file
View File

@@ -0,0 +1,80 @@
#include <Prs3d_Arrow.ixx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
//=======================================================================
//function : Draw
//purpose :
//=======================================================================
void Prs3d_Arrow::Draw(const Handle(Prs3d_Presentation)& aPresentation,
const gp_Pnt& aLocation,
const gp_Dir& aDirection,
const Quantity_PlaneAngle anAngle,
const Quantity_Length aLength) {
Quantity_Length dx,dy,dz; aDirection.Coord(dx,dy,dz);
//
// Pointe de la fleche:
Quantity_Length xo,yo,zo; aLocation.Coord(xo,yo,zo);
// Centre du cercle base de la fleche:
Quantity_Length xc = xo - dx * aLength;
Quantity_Length yc = yo - dy * aLength;
Quantity_Length zc = zo - dz * aLength;
// Construction d'un repere i,j pour le cercle:
Quantity_Length xn=0., yn=0., zn=0.;
if ( Abs(dx) <= Abs(dy) && Abs(dx) <= Abs(dz)) xn=1.;
else if ( Abs(dy) <= Abs(dz) && Abs(dy) <= Abs(dx)) yn=1.;
else zn=1.;
Quantity_Length xi = dy * zn - dz * yn;
Quantity_Length yi = dz * xn - dx * zn;
Quantity_Length zi = dx * yn - dy * xn;
Quantity_Length Norme = sqrt ( xi*xi + yi*yi + zi*zi );
xi = xi / Norme; yi = yi / Norme; zi = zi/Norme;
Quantity_Length xj = dy * zi - dz * yi;
Quantity_Length yj = dz * xi - dx * zi;
Quantity_Length zj = dx * yi - dy * xi;
Standard_Integer NbPoints = 15;
Graphic3d_Array1OfVertex VN(1,NbPoints+1);
Graphic3d_Array1OfVertex V2(1,2);
V2(1).SetCoord(xo,yo,zo);
Quantity_Length x,y,z;
Standard_Real cosinus,sinus, Tg=tan(anAngle);
for (Standard_Integer i = 1 ; i <= NbPoints ; i++) {
cosinus = cos ( 2 * PI / NbPoints * (i-1) );
sinus = sin ( 2 * PI / NbPoints * (i-1) );
x = xc + (cosinus * xi + sinus * xj) * aLength * Tg;
y = yc + (cosinus * yi + sinus * yj) * aLength * Tg;
z = zc + (cosinus * zi + sinus * zj) * aLength * Tg;
VN(i).SetCoord(x,y,z);
if(i==1) VN(NbPoints+1).SetCoord(x,y,z);
V2(2).SetCoord(x,y,z);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
}
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VN);
}
//=======================================================================
//function : Fill
//purpose :
//=======================================================================
void Prs3d_Arrow::Fill(const Handle(Prs3d_Presentation)& /*aPresentation*/,
const gp_Pnt& /*aLocation*/,
const gp_Dir& /*aDirection*/,
const Quantity_PlaneAngle /*anAngle*/,
const Quantity_Length /*aLength*/)
{
}

65
src/Prs3d/Prs3d_ArrowAspect.cdl Executable file
View File

@@ -0,0 +1,65 @@
-- File: Prs3d_ArrowAspect.cdl
-- Created: Fri Jun 11 11:28:18 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
-- Modified GG : GER61351 01/02/00 Add SetColor() & Aspect() methods
---Copyright: Matra Datavision 1993
class ArrowAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: A framework for displaying arrows in representations
-- of dimensions and relations.
uses
Length from Quantity,
PlaneAngle from Quantity,
NameOfColor from Quantity,
Color from Quantity,
AspectLine3d from Graphic3d
raises
InvalidAngle from Prs3d
is
Create returns mutable ArrowAspect from Prs3d;
---Purpose: Constructs an empty framework for displaying arrows
-- in representations of lengths. The lengths displayed
-- are either on their own or in chamfers, fillets,
-- diameters and radii.
Create (anAngle: PlaneAngle from Quantity; aLength: Length from Quantity)
returns mutable ArrowAspect from Prs3d;
--- Purpose: Constructs a framework to display an arrow with a
-- shaft of the length aLength and having a head with
-- sides at the angle anAngle from each other.
SetAngle(me: mutable; anAngle: PlaneAngle from Quantity)
---Purpose: defines the angle of the arrows.
raises InvalidAngle from Prs3d
is static;
Angle(me) returns PlaneAngle from Quantity
---Purpose: returns the current value of the angle used when drawing an arrow.
is static;
SetLength(me: mutable; aLength: Length from Quantity)
---Purpose: defines the length of the arrows.
is static;
Length(me) returns Length from Quantity
---Purpose: returns the current value of the length used when drawing an arrow.
is static;
SetColor(me: mutable; aColor: Color from Quantity);
SetColor(me: mutable; aColor: NameOfColor from Quantity);
Aspect(me) returns AspectLine3d from Graphic3d;
Print( me; s: in out OStream from Standard)
is virtual;
fields
myArrowAspect: AspectLine3d from Graphic3d;
myAngle: PlaneAngle from Quantity;
myLength: Length from Quantity;
end ArrowAspect from Prs3d;

62
src/Prs3d/Prs3d_ArrowAspect.cxx Executable file
View File

@@ -0,0 +1,62 @@
#define IMP120100 //GG 01/01/00 Add SetColor() methods
#include <Prs3d_ArrowAspect.ixx>
Prs3d_ArrowAspect::Prs3d_ArrowAspect ()
: myAngle(PI/180.*10), myLength(1.) {
#ifdef IMP120100
myArrowAspect =
new Graphic3d_AspectLine3d (
Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0);
#endif
}
Prs3d_ArrowAspect::Prs3d_ArrowAspect (const Quantity_PlaneAngle anAngle,
const Quantity_Length aLength)
: myAngle(anAngle), myLength(aLength) {
#ifdef IMP120100
myArrowAspect =
new Graphic3d_AspectLine3d (
Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0);
#endif
}
void Prs3d_ArrowAspect::SetAngle ( const Quantity_PlaneAngle anAngle) {
Prs3d_InvalidAngle_Raise_if ( anAngle <= 0. ||
anAngle >= PI /2. , "");
myAngle = anAngle;
}
Quantity_PlaneAngle Prs3d_ArrowAspect::Angle () const
{
return myAngle;
}
void Prs3d_ArrowAspect::SetLength ( const Quantity_Length aLength)
{
myLength = aLength;
}
Quantity_Length Prs3d_ArrowAspect::Length () const
{
return myLength;
}
void Prs3d_ArrowAspect::Print (Standard_OStream& s) const {
s << "ArrowAspect: Length: " << myLength << " Angle: " << myAngle;
}
#ifdef IMP120100
void Prs3d_ArrowAspect::SetColor(const Quantity_Color &aColor) {
myArrowAspect->SetColor(aColor);
}
void Prs3d_ArrowAspect::SetColor(const Quantity_NameOfColor aColor) {
SetColor(Quantity_Color(aColor));
}
Handle(Graphic3d_AspectLine3d) Prs3d_ArrowAspect::Aspect() const {
return myArrowAspect;
}
#endif

13
src/Prs3d/Prs3d_BasicAspect.cdl Executable file
View File

@@ -0,0 +1,13 @@
-- File: Prs3d_BasicAspect.cdl
-- Created: Thu Feb 15 09:32:13 2000
-- Author: Gerard GRAS
---Copyright: Matra Datavision 2000
---Purpose All basic Prs3d_xxxAspect must inherits from this class
deferred class BasicAspect from Prs3d inherits TShared from MMgt
is
end BasicAspect from Prs3d;

View File

@@ -0,0 +1 @@
#include <Prs3d_BasicAspect.ixx>

View File

@@ -0,0 +1,13 @@
-- File: Prs3d_CompositeAspect.cdl
-- Created: Thu Feb 15 09:32:13 2000
-- Author: Gerard GRAS
---Copyright: Matra Datavision 2000
---Purpose All composite Prs3d_xxxAspect must inherits from this class
deferred class CompositeAspect from Prs3d inherits TShared from MMgt
is
end CompositeAspect from Prs3d;

View File

@@ -0,0 +1 @@
#include <Prs3d_CompositeAspect.ixx>

View File

@@ -0,0 +1,73 @@
-- File: CurvePresentation.cdl
-- Created: Tue Dec 15 18:12:33 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
generic class CurvePresentation from Prs3d
( anyCurve as any;
CurveTool as any) -- as CurveTool from Adaptor3d
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity
is
--- Purpose:
--
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve: anyCurve;
aDrawer: Drawer from Prs3d);
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve: anyCurve;
U1,U2 : Real from Standard;
aDrawer: Drawer from Prs3d);
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve: anyCurve;
aDeflection: Real from Standard);
Add(myclass; aPresentation: Presentation from Prs3d;
aCurve: anyCurve;
U1,U2 : Real from Standard;
aDeflection: Real from Standard);
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: anyCurve;
aDrawer: Drawer from Prs3d)
returns Boolean from Standard;
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: anyCurve;
U1,U2 : Real from Standard;
aDrawer: Drawer from Prs3d)
returns Boolean from Standard;
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: anyCurve;
aDeflection: Real from Standard)
returns Boolean from Standard;
Match(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aCurve: anyCurve;
U1,U2 : Real from Standard;
aDeflection: Real from Standard)
returns Boolean from Standard;
end CurvePresentation from Prs3d;

View File

36
src/Prs3d/Prs3d_Datum.cdl Executable file
View File

@@ -0,0 +1,36 @@
-- File: Prs3d_Point.cdl
-- Created: Fri Apr 16 12:39:30 1993
-- Author: Jean Louis FRENKEL
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
generic class Datum from Prs3d
(anyDatum as any;
DatumTool as any) -- as DatumTool from Prs3d;
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aDatum: anyDatum;
aDrawer: Drawer from Prs3d);
end Datum from Prs3d;

109
src/Prs3d/Prs3d_Datum.gxx Executable file
View File

@@ -0,0 +1,109 @@
#define IMP120100 // YFR/GG 10/01/2000
// Enable to compute the triedhron color texts and arrows.
#include <Graphic3d_Group.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Arrow.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax2.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation,
const anyDatum& aDatum,
const Handle(Prs3d_Drawer)& aDrawer ) {
Handle(Prs3d_DatumAspect) DA = aDrawer->DatumAspect();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W;
DA->FirstAxisAspect()->Aspect()->Values(Col,Tol,W);
Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d
(Aspect_TOM_BALL,Col,.1);
gp_Ax2 Axis = DatumTool::Ax2(aDatum);
gp_Pnt Orig = Axis.Location();
gp_Dir oX = Axis.XDirection();
gp_Dir oY = Axis.YDirection();
gp_Dir oZ = Axis.Direction();
//
// Trace d'une petite sphere au debut du vecteur:
//
Quantity_Length xo,yo,zo,x,y,z;
Orig.Coord(xo,yo,zo);
G->SetPrimitivesAspect(Asp);
G->Marker(Graphic3d_Vertex (xo,yo,zo));
Graphic3d_Array1OfVertex A(1,2);
A(1).SetCoord(xo,yo,zo);
Quantity_Length DS;
#ifdef IMP120100
Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle();
Quantity_Length textHeight = aDrawer->TextAspect()->Height();
#endif
if (DA->DrawFirstAndSecondAxis()) {
oX.Coord(x,y,z);
DS = DA->FirstAxisLength();
x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
A(2).SetCoord(x,y,z);
G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect());
G->Polyline(A);
#ifdef IMP120100
G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,arrowAngle,DS/10.);
G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
G->Text(Standard_CString("X"),A(2),16.);
#else
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,PI/180.*10.,DS/10.);
Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("X"),A(2),1./81.);
#endif
}
if (DA->DrawFirstAndSecondAxis()) {
oY.Coord(x,y,z);
DS = DA->SecondAxisLength();
x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
A(2).SetCoord(x,y,z);
G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect());
G->Polyline(A);
#ifdef IMP120100
G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,arrowAngle,DS/10.);
G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
G->Text(Standard_CString("Y"),A(2),16.);
#else
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,PI/180.*10.,DS/10.);
Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Y"),A(2),1./81.);
#endif
}
if (DA->DrawThirdAxis()) {
oZ.Coord(x,y,z);
DS = DA->ThirdAxisLength();
x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
A(2).SetCoord(x,y,z);
G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect());
G->Polyline(A);
#ifdef IMP120100
G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,arrowAngle,DS/10.);
G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
G->Text(Standard_CString("Z"),A(2),16.);
#else
Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Z"),A(2),1./81.);
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,PI/180.*10.,DS/10.);
#endif
}
}

60
src/Prs3d/Prs3d_DatumAspect.cdl Executable file
View File

@@ -0,0 +1,60 @@
-- File: Prs3d_DatumAspect.cdl
-- Created: Fri Jul 30 09:32:13 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class DatumAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: A framework to define the display of datums.
uses
LineAspect from Prs3d,
Length from Quantity
is
Create returns mutable DatumAspect from Prs3d;
---Purpose: An empty framework to define the display of datums.
FirstAxisAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the attributes for display of the first axis.
SecondAxisAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the attributes for display of the second axis.
ThirdAxisAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the attributes for display of the third axis.
SetDrawFirstAndSecondAxis(me:mutable ; draw: Boolean from Standard);
---Purpose: Sets the DrawFirstAndSecondAxis attributes to active.
DrawFirstAndSecondAxis(me) returns Boolean from Standard;
---Purpose: Returns true if the first and second axes can be drawn.
SetDrawThirdAxis(me:mutable; draw: Boolean from Standard);
---Purpose: Sets the DrawThirdAxis attributes to active.
DrawThirdAxis(me) returns Boolean from Standard;
---Purpose: Returns true if the third axis can be drawn.
SetAxisLength(me:mutable; L1,L2,L3: Real from Standard);
---Purpose: Sets the lengths L1, L2 and L3 of the three axes.
FirstAxisLength(me) returns Length from Quantity;
--- Purpose: Returns the length of the displayed first axis.
SecondAxisLength(me) returns Length from Quantity;
---Purpose: Returns the length of the displayed second axis.
ThirdAxisLength(me) returns Length from Quantity;
---Purpose: Returns the length of the displayed third axis.
Print(me; s: in out OStream from Standard) is static;
fields
myFirstAxisAspect: LineAspect from Prs3d;
mySecondAxisAspect: LineAspect from Prs3d;
myThirdAxisAspect: LineAspect from Prs3d;
myDrawFirstAndSecondAxis: Boolean from Standard;
myDrawThirdAxis: Boolean from Standard;
myFirstAxisLength: Length from Quantity;
mySecondAxisLength: Length from Quantity;
myThirdAxisLength: Length from Quantity;
end DatumAspect from Prs3d;

104
src/Prs3d/Prs3d_DatumAspect.cxx Executable file
View File

@@ -0,0 +1,104 @@
#include <Prs3d_DatumAspect.ixx>
Prs3d_DatumAspect::Prs3d_DatumAspect () {
myFirstAxisAspect = new Prs3d_LineAspect
(Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID,1.);
mySecondAxisAspect = new Prs3d_LineAspect
(Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID,1.);
myThirdAxisAspect = new Prs3d_LineAspect
(Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID,1.);
myDrawFirstAndSecondAxis = Standard_True;
myDrawThirdAxis = Standard_True;
myFirstAxisLength = 10.;
mySecondAxisLength = 10.;
myThirdAxisLength = 10.;
}
Handle(Prs3d_LineAspect) Prs3d_DatumAspect::FirstAxisAspect() const {
return myFirstAxisAspect;
}
Handle(Prs3d_LineAspect) Prs3d_DatumAspect::SecondAxisAspect() const {
return mySecondAxisAspect;
}
Handle(Prs3d_LineAspect) Prs3d_DatumAspect::ThirdAxisAspect() const {
return myThirdAxisAspect;
}
Standard_Boolean Prs3d_DatumAspect::DrawFirstAndSecondAxis () const {
return myDrawFirstAndSecondAxis;
}
void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean draw)
{
myDrawFirstAndSecondAxis = draw;
}
Standard_Boolean Prs3d_DatumAspect::DrawThirdAxis () const {
return myDrawThirdAxis;
}
void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean draw)
{
myDrawThirdAxis = draw;
}
void Prs3d_DatumAspect::SetAxisLength (const Quantity_Length L1,
const Quantity_Length L2,
const Quantity_Length L3) {
myFirstAxisLength = L1;
mySecondAxisLength = L2;
myThirdAxisLength = L3;
}
Quantity_Length Prs3d_DatumAspect::FirstAxisLength () const {
return myFirstAxisLength;
}
Quantity_Length Prs3d_DatumAspect::SecondAxisLength () const {
return mySecondAxisLength;
}
Quantity_Length Prs3d_DatumAspect::ThirdAxisLength () const {
return myThirdAxisLength;
}
void Prs3d_DatumAspect::Print (Standard_OStream& s) const {
s << "DatumAspect: " << endl;
s << " FirstAxis: length " << myFirstAxisLength << " ";
myFirstAxisAspect->Print(s);
s << endl;
s << " SecondAxis: length " << mySecondAxisLength << " ";
mySecondAxisAspect->Print(s);
s << endl;
s << " ThirdAxis: length " << myThirdAxisLength << " ";
myThirdAxisAspect->Print(s);
s << endl;
if (myDrawFirstAndSecondAxis)
s << " Draws first and second axis";
else
s << " Does not draw first and second axis";
if (myDrawThirdAxis)
s << " Draws third axis";
else
s << " Does not draw third axis";
}

14
src/Prs3d/Prs3d_DatumTool.cdl Executable file
View File

@@ -0,0 +1,14 @@
-- File: Prs3d_DatumTool.cdl
-- Created: Fri Apr 16 13:36:55 1993
-- Author: Jean Louis FRENKEL
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
deferred generic class DatumTool from Prs3d ( Datum as any)
uses Ax2 from gp
is
Ax2 ( myclass; aDatum: Datum ) returns Ax2 from gp;
end DatumTool from Prs3d;

0
src/Prs3d/Prs3d_DatumTool.gxx Executable file
View File

531
src/Prs3d/Prs3d_Drawer.cdl Executable file
View File

@@ -0,0 +1,531 @@
-- File: Drawer.cdl
-- Created: Fri Sep 18 15:18:45 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
class Drawer from Prs3d inherits TShared from MMgt
---Purpose: A graphic attribute manager which governs how
-- objects such as color, width, line thickness and
-- deflection are displayed.
-- Prs3d_Drawer is the mother class of AIS_Drawer.
-- As such, it is its set functions which are called to
-- modify display parameters. In the example below we
-- can see that the AIS_Drawer is modified to set the
-- value of the deviation coefficient using a method
-- inherited from Prs3d_Drawer.
uses
DatumAspect from Prs3d,
LineAspect from Prs3d,
TextAspect from Prs3d,
PointAspect from Prs3d,
ShadingAspect from Prs3d,
IsoAspect from Prs3d,
LengthAspect from Prs3d,
AngleAspect from Prs3d,
PlaneAspect from Prs3d,
RadiusAspect from Prs3d,
ArrowAspect from Prs3d,
TypeOfDeflection from Aspect,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity
is
Create returns mutable Drawer from Prs3d;
---Category: deviation definition.
--
-- All drawings of curves or patches are made with respect to a maximal
-- chordial deviation. This deviation is absolute and given through
-- the method: SetMaximalChordialDeviation.
--
-- In the case of drawing shapes, it is allowed to ask for a relative
-- deviation.
-- This deviation will be: SizeOfObject * DeviationCoefficient where
-- DeviationCoefficient can be set through the method: SetDeviationCoefficient.
--
--
-- For drawing algorithms using discretisation, a default number of
-- points has been set to 17. It is possible to use the method SetDiscret
-- to change this number.
--
SetTypeOfDeflection (me:mutable;
aTypeOfDeflection: TypeOfDeflection from Aspect)
---Purpose: Sets the type of chordal deflection.
-- This indicates whether the deflection value is absolute
-- or relative to the size of the object.
is virtual;
TypeOfDeflection(me) returns TypeOfDeflection from Aspect
is virtual;
--- Purpose: Returns the type of chordal deflection.
-- This indicates whether the deflection value is absolute
-- or relative to the size of the object.
SetMaximalChordialDeviation (me: mutable;
aChordialDeviation: Length from Quantity)
---Purpose: Defines the maximal chordial deviation when drawing any curve;
-- Even if the type of deviation is set to TOD_Relative,
-- this value is used by:
--
-- Prs3d_DeflectionCurve
-- Prs3d_WFDeflectionSurface
-- Prs3d_WFDeflectionRestrictedFace
is virtual;
MaximalChordialDeviation (me) returns Length from Quantity
---Purpose: returns the maximal chordial deviation. Default value is 0.1
is virtual;
SetDeviationCoefficient(me: mutable; aCoefficient: Real from Standard)
---Purpose: Sets the deviation coefficient aCoefficient.
is virtual;
DeviationCoefficient(me) returns Real from Standard
is virtual;
---Purpose: Returns the deviation coefficient.
SetHLRDeviationCoefficient(me: mutable; aCoefficient: Real from Standard)
---Purpose: Sets the deviation coefficient aCoefficient for removal
-- of hidden lines created by different viewpoints in
-- different presentations. The Default value is 0.02.
is virtual;
HLRDeviationCoefficient(me) returns Real from Standard
is virtual;
---Purpose: Returns the real number value of the hidden line
-- removal deviation coefficient.
SetHLRAngle(me: mutable; anAngle: Real from Standard)
---Purpose: Sets anAngle, the angle of maximum chordal
-- deviation for removal of hidden lines created by
-- different viewpoints in different presentations. The
-- default value is 20*PI/180.
is virtual;
HLRAngle(me) returns Real from Standard
is virtual;
---Purpose: Returns the real number value of the deviation angle
-- in hidden line removal views. The default value is 20*PI/180.
SetDeviationAngle(me: mutable; anAngle: Real from Standard)
---Purpose: Sets deviation angle
is virtual;
DeviationAngle(me) returns Real from Standard
---Purpose: Returns the value for deviation angle.
is virtual;
SetDiscretisation(me: mutable; d: Integer from Standard)
---Purpose: Sets the discretisation parameter d.
is virtual;
Discretisation(me) returns Integer from Standard
is virtual;
---Purpose: Returns the discretisation setting.
SetMaximalParameterValue(me: mutable; Value: Real from Standard)
---Purpose: defines the maximum value allowed for the first and last
-- parameters of an infinite curve. Default value: 500.
is virtual;
MaximalParameterValue(me) returns Real from Standard
is virtual;
--- Purpose: Sets the maximum value allowed for the first and last
-- parameters of an infinite curve. By default, this value is 500000.
SetIsoOnPlane (me: mutable; OnOff: Boolean from Standard)
---Purpose: Sets IsoOnPlane on or off by setting the parameter
-- OnOff to true or false.
is virtual;
IsoOnPlane(me) returns Boolean from Standard
---Purpose: Returns True if the drawing of isos on planes is enabled.
is virtual;
--
-- Attributes for the U Isoparametric lines of patches.
--
UIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
---Purpose: Defines the attributes which are used when drawing an
-- U isoparametric curve of a face. Defines the number
-- of U isoparametric curves to be drawn for a single face.
-- The LineAspect for U isoparametric lines can be edited
-- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
-- The default values are:
-- COLOR : Quantity_NOC_GRAY75
-- TYPE OF LINE: Aspect_TOL_SOLID
-- WIDTH : 0.5
--
--
-- These attributes are used by the following algorithms:
-- Prs3d_WFDeflectionSurface
-- Prs3d_WFDeflectionRestrictedFace
is virtual;
SetUIsoAspect (me:mutable; anAspect: IsoAspect from Prs3d)
is virtual;
-- Attributes for the V Isoparametric line of patches.
VIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
---Purpose: Defines the attributes which are used when drawing an
-- V isoparametric curve of a face. Defines the number
-- of V isoparametric curves to be drawn for a single face.
-- The LineAspect for V isoparametric lines can be edited
-- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
-- The default values are:
-- COLOR : Quantity_NOC_GRAY82
-- TYPE OF LINE: Aspect_TOL_SOLID
-- WIDTH : 0.5
--
--
-- These attributes are used by the following algorithms:
-- Prs3d_WFDeflectionSurface
-- Prs3d_WFDeflectionRestrictedFace
is virtual;
SetVIsoAspect (me:mutable;anAspect: IsoAspect from Prs3d)
is virtual;
---Purpose: Sets the appearance of V isoparameters - anAspect.
FreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Stores the values for presentation of free boundaries,
-- in other words, boundaries which are not shared.
-- The LineAspect for the free boundaries can be edited.
-- The default values are:
-- Color: Quantity_NOC_GREEN
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the algorithm Prs3d_WFShape
is virtual;
SetFreeBoundaryAspect(me:mutable;anAspect: LineAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for the display of free boundaries.
SetFreeBoundaryDraw (me: mutable; OnOff: Boolean from Standard)
---Purpose: Sets free boundary drawing on or off by setting the
-- parameter OnOff to true or false.
is virtual;
FreeBoundaryDraw(me) returns Boolean from Standard
---Purpose: Returns True if the drawing of the shared boundaries
-- is disabled. True is the default setting.
is virtual;
-- Attributes for the wires
WireAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns wire aspect settings.
-- The LineAspect for the wire can be edited.
-- The default values are:
-- Color: Quantity_NOC_RED
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the algorithm Prs3d_WFShape
is virtual;
SetWireAspect(me:mutable;anAspect: LineAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for display of wires.
SetWireDraw (me: mutable; OnOff: Boolean from Standard)
---Purpose: Sets WireDraw on or off by setting the parameter
-- OnOff to true or false.
is virtual;
WireDraw(me) returns Boolean from Standard
---Purpose: returns True if the drawing of the wire is enabled.
is virtual;
-- Attributes for the unfree boundaries
UnFreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns settings for shared boundary line aspects.
-- The LineAspect for the unfree boundaries can be edited.
-- The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the algorithm Prs3d_WFShape
is virtual;
SetUnFreeBoundaryAspect(me:mutable; anAspect: LineAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for the display of shared boundaries.
SetUnFreeBoundaryDraw (me: mutable; OnOff: Boolean from Standard)
---Purpose: Sets FreeBoundaryDraw on or off by setting the
-- parameter OnOff to true or false.
-- By default the unfree boundaries are drawn.
is virtual;
UnFreeBoundaryDraw(me) returns Boolean from Standard
---Purpose: Returns True if the drawing of the shared boundaries is enabled.
-- True is the default setting.
is virtual;
--
-- Attributes for the lines.
--
LineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns settings for line aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_Curve
-- Prs3d_Line
-- Prs3d_HLRShape
is virtual;
SetLineAspect(me:mutable; anAspect: LineAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for display attributes of lines.
TextAspect(me:mutable) returns mutable TextAspect from Prs3d
--- Purpose: Returns settings for text aspect.
-- These settings can be edited. The default value is:
-- - Color: Quantity_NOC_YELLOW
is virtual;
SetTextAspect(me:mutable; anAspect: TextAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for display attributes of text.
SetLineArrowDraw (me: mutable; OnOff: Boolean from Standard)
---Purpose: enables the drawing of an arrow at the end of each line.
-- By default the arrows are not drawn.
is virtual;
LineArrowDraw(me) returns Boolean from Standard
---Purpose: Sets LineArrowDraw on or off by setting the
-- parameter OnOff to true or false.
is virtual;
ArrowAspect(me:mutable) returns mutable ArrowAspect from Prs3d
is virtual;
---Purpose: Returns the attributes for display of arrows.
SetArrowAspect(me:mutable; anAspect: ArrowAspect from Prs3d)
is virtual ;
---Purpose: Sets the parameter anAspect for display attributes of arrows.
PointAspect(me:mutable) returns mutable PointAspect from Prs3d
---Purpose: Returns the point aspect setting. The default values are
-- Color: Quantity_NOC_YELLOW
-- Type of marker: Aspect_TOM_PLUS
-- Scale: 1.
-- These attributes are used by the algorithms Prs3d_Point.
is virtual;
SetPointAspect(me:mutable; anAspect: PointAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for display attributes of points
ShadingAspect (me:mutable) returns mutable ShadingAspect from Prs3d
is virtual;
---Purpose: Returns settings for shading aspects.
-- These settings can be edited. The default values are:
-- - Color: Quantity_NOC_YELLOW
-- - Material: Graphic3d_NOM_BRASS
-- Shading aspect is obtained through decomposition of
-- 3d faces into triangles, each side of each triangle
-- being a chord of the corresponding curved edge in
-- the face. Reflection of light in each projector
-- perspective is then calculated for each of the
-- resultant triangular planes.
SetShadingAspect(me:mutable; anAspect: ShadingAspect from Prs3d)
is virtual;
---Purpose: Sets the parameter anAspect for display attributes of shading.
SetShadingAspectGlobal(me: mutable; aValue: Boolean from Standard)
---Purpose: indicates that the ShadingAspect will be apply
-- to the whole presentation. This allows to modify
-- the aspect without recomputing the content of the presentation.
is virtual;
ShadingAspectGlobal(me) returns Boolean from Standard
is virtual;
--
-- Attributes for hidden lines removal. These attributes are used when
-- using an algorithm such Prs3d_HLRShape for example.
--
DrawHiddenLine(me) returns Boolean from Standard
---Purpose: returns Standard_True if the hidden lines are to be drawn.
-- By default the hidden lines are not drawn.
is virtual;
EnableDrawHiddenLine(me: mutable)
---Purpose: Enables the DrawHiddenLine function.
is virtual;
DisableDrawHiddenLine(me: mutable)
---Purpose: Disables the DrawHiddenLine function.
is virtual;
HiddenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns settings for hidden line aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_DASH
-- Width: 1.
is virtual;
SetHiddenLineAspect(me:mutable; anAspect: LineAspect from Prs3d)
is virtual;
---Purpose: Sets the parameter anAspect for the display of
-- hidden lines in hidden line removal mode.
SeenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns settings for seen line aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
is virtual;
SetSeenLineAspect(me:mutable; anAspect: LineAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for the display of seen
-- lines in hidden line removal mode.
PlaneAspect(me:mutable) returns mutable PlaneAspect from Prs3d
is virtual;
---Purpose: Returns settings for the appearance of planes.
SetPlaneAspect(me:mutable; anAspect: PlaneAspect from Prs3d)
is virtual;
---Purpose: Sets the parameter anAspect for the display of planes.
VectorAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns settings for the appearance of vectors.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_SKYBLUE
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
is virtual;
SetVectorAspect(me:mutable; anAspect: LineAspect from Prs3d)
is virtual;
---Purpose: Sets the modality anAspect for the display of vectors.
--
-- Attributes for the presentation of a Datum.
--
DatumAspect(me:mutable) returns mutable DatumAspect from Prs3d
---Purpose: Returns settings for the appearance of datums.
-- These settings can be edited. The default values for
-- the three axes are:
-- Color: Quantity_NOC_PEACHPUFF
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
is virtual;
SetDatumAspect(me:mutable; anAspect: DatumAspect from Prs3d)
is virtual;
---Purpose: Sets the modality anAspect for the display of datums.
LengthAspect(me:mutable) returns mutable LengthAspect from Prs3d
---Purpose: Returns settings for the appearance of lengths.
is virtual;
SetLengthAspect(me:mutable; anAspect: LengthAspect from Prs3d)
is virtual;
---Purpose: Sets the modality anAspect for display of lengths.
AngleAspect(me:mutable) returns mutable AngleAspect from Prs3d
---Purpose: Returns settings for lines used to display angles.
is virtual;
SetAngleAspect(me:mutable; anAspect: AngleAspect from Prs3d)
is virtual;
---Purpose: Sets the modality anAspect for the display of angles.
RadiusAspect(me) returns mutable RadiusAspect from Prs3d
---Purpose: Returns settings for lines which serve to display radii.
is virtual;
SetRadiusAspect(me:mutable; anAspect: RadiusAspect from Prs3d)
is virtual;
--- Purpose: Sets the parameter anAspect for display attributes of radii.
SectionAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: The LineAspect for the wire can be edited.
-- The default values are:
-- Color: Quantity_NOC_ORANGE
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the algorithm Prs3d_WFShape
is virtual;
SetSectionAspect(me:mutable;anAspect: LineAspect from Prs3d)
is virtual;
---Purpose: Sets the parameter anAspect for display attributes of sections.
Print (me; s: in out OStream from Standard)
is virtual;
fields
myUIsoAspect: IsoAspect from Prs3d is protected;
myVIsoAspect: IsoAspect from Prs3d is protected;
myNbPoints : Integer from Standard is protected;
myIsoOnPlane: Boolean from Standard is protected;
myFreeBoundaryAspect: LineAspect from Prs3d is protected;
myFreeBoundaryDraw: Boolean from Standard is protected;
myUnFreeBoundaryAspect: LineAspect from Prs3d is protected;
myUnFreeBoundaryDraw: Boolean from Standard is protected;
myWireAspect: LineAspect from Prs3d is protected;
myWireDraw: Boolean from Standard is protected;
myLineAspect: LineAspect from Prs3d is protected;
myTextAspect: TextAspect from Prs3d is protected;
myShadingAspect: ShadingAspect from Prs3d is protected;
myShadingAspectGlobal: Boolean from Standard is protected;
myChordialDeviation: Length from Quantity is protected;
myTypeOfDeflection: TypeOfDeflection from Aspect is protected;
myMaximalParameterValue: Real from Standard is protected;
myDeviationCoefficient: Real from Standard is protected;
myHLRDeviationCoefficient: Real from Standard is protected;
myDeviationAngle: Real from Standard is protected;
myHLRAngle: Real from Standard is protected;
myPointAspect: PointAspect from Prs3d is protected;
myPlaneAspect: PlaneAspect from Prs3d is protected;
myArrowAspect: ArrowAspect from Prs3d is protected;
myLineDrawArrow: Boolean from Standard is protected;
myDrawHiddenLine: Boolean from Standard is protected;
myHiddenLineAspect: LineAspect from Prs3d is protected;
mySeenLineAspect: LineAspect from Prs3d is protected;
myVectorAspect: LineAspect from Prs3d is protected;
myDatumAspect: DatumAspect from Prs3d is protected;
myDatumScale: Real from Standard is protected;
myLengthAspect: LengthAspect from Prs3d is protected;
myAngleAspect: AngleAspect from Prs3d is protected;
myRadiusAspect: RadiusAspect from Prs3d is protected;
mySectionAspect: LineAspect from Prs3d is protected;
end Drawer;

503
src/Prs3d/Prs3d_Drawer.cxx Executable file
View File

@@ -0,0 +1,503 @@
#define BUC60488 //GG_10/10/99 Set correctly all fields
#include <Prs3d_Drawer.ixx>
Prs3d_Drawer::Prs3d_Drawer(): myNbPoints(30),myIsoOnPlane(Standard_False),
myFreeBoundaryDraw(Standard_True),
myUnFreeBoundaryDraw(Standard_True),
myWireDraw(Standard_True),
#ifdef BUC60488
myShadingAspect( new Prs3d_ShadingAspect()),
#endif
myShadingAspectGlobal(Standard_True),
myChordialDeviation(0.0001),
myTypeOfDeflection(Aspect_TOD_RELATIVE),
myMaximalParameterValue(500000.),
myDeviationCoefficient(0.001),
myHLRDeviationCoefficient(0.02),
myDeviationAngle(12*PI/180),
myHLRAngle(20*PI/180),
myLineDrawArrow(Standard_False),
myDrawHiddenLine(Standard_False)
{
}
void Prs3d_Drawer::SetTypeOfDeflection(const Aspect_TypeOfDeflection aTypeOfDeflection){
myTypeOfDeflection = aTypeOfDeflection;}
Aspect_TypeOfDeflection Prs3d_Drawer::TypeOfDeflection() const {
return myTypeOfDeflection;
}
void Prs3d_Drawer::SetIsoOnPlane(const Standard_Boolean OnOff)
{
myIsoOnPlane = OnOff;
}
Standard_Boolean Prs3d_Drawer::IsoOnPlane()const
{
return myIsoOnPlane;
}
Standard_Integer Prs3d_Drawer::Discretisation() const
{
return myNbPoints;
}
void Prs3d_Drawer::SetDiscretisation(const Standard_Integer d)
{
myNbPoints = d;
}
void Prs3d_Drawer::SetMaximalChordialDeviation(
const Quantity_Length aChordialDeviation) {
myChordialDeviation = aChordialDeviation;
}
Quantity_Length Prs3d_Drawer::MaximalChordialDeviation() const {
return myChordialDeviation;
}
//
//=======================================================================
//function : SetDeviationCoefficient
//purpose :
//=======================================================================
void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real aCoefficient) {
myDeviationCoefficient = aCoefficient;
}
//=======================================================================
//function : DeviationCoefficient
//purpose :
//=======================================================================
Standard_Real Prs3d_Drawer::DeviationCoefficient () const {
return myDeviationCoefficient;
}
//=======================================================================
//function : SetHLRDeviationCoefficient
//purpose :
//=======================================================================
void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real aCoefficient) {
myHLRDeviationCoefficient = aCoefficient;
}
//=======================================================================
//function : HLRDeviationCoefficient
//purpose :
//=======================================================================
Standard_Real Prs3d_Drawer::HLRDeviationCoefficient () const {
return myHLRDeviationCoefficient;
}
//=======================================================================
//function : SetHLRAngle
//purpose :
//=======================================================================
void Prs3d_Drawer::SetHLRAngle (const Standard_Real anAngle) {
myHLRAngle = anAngle;
}
//=======================================================================
//function : HLRAngle
//purpose :
//=======================================================================
Standard_Real Prs3d_Drawer::HLRAngle () const {
return myHLRAngle;
}
//=======================================================================
//function : SetDeviationAngle
//purpose :
//=======================================================================
void Prs3d_Drawer::SetDeviationAngle (const Standard_Real anAngle)
{
myDeviationAngle = anAngle;
}
//=======================================================================
//function : DeviationAngle
//purpose :
//=======================================================================
Standard_Real Prs3d_Drawer::DeviationAngle () const
{
return myDeviationAngle;
}
void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real Value) {
myMaximalParameterValue = Value;
}
Standard_Real Prs3d_Drawer::MaximalParameterValue () const {
return myMaximalParameterValue;
}
Handle (Prs3d_IsoAspect) Prs3d_Drawer::UIsoAspect (){
if (myUIsoAspect.IsNull())
myUIsoAspect = new Prs3d_IsoAspect
(Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
return myUIsoAspect;
}
void Prs3d_Drawer::SetUIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
myUIsoAspect = anAspect;
}
Handle (Prs3d_IsoAspect) Prs3d_Drawer::VIsoAspect () {
if (myVIsoAspect.IsNull())
myVIsoAspect = new Prs3d_IsoAspect
(Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
return myVIsoAspect;
}
void Prs3d_Drawer::SetVIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
myVIsoAspect = anAspect;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::FreeBoundaryAspect () {
if (myFreeBoundaryAspect.IsNull())
myFreeBoundaryAspect = new Prs3d_LineAspect
(Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.);
return myFreeBoundaryAspect;
}
void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& anAspect) {
myFreeBoundaryAspect = anAspect;
}
void Prs3d_Drawer::SetFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
myFreeBoundaryDraw = OnOff;
}
Standard_Boolean Prs3d_Drawer::FreeBoundaryDraw () const {
return myFreeBoundaryDraw;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::UnFreeBoundaryAspect (){
if (myUnFreeBoundaryAspect.IsNull())
myUnFreeBoundaryAspect = new Prs3d_LineAspect
(Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
return myUnFreeBoundaryAspect;
}
void Prs3d_Drawer::SetUnFreeBoundaryAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
myUnFreeBoundaryAspect = anAspect;
}
void Prs3d_Drawer::SetUnFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
myUnFreeBoundaryDraw = OnOff;
}
Standard_Boolean Prs3d_Drawer::UnFreeBoundaryDraw () const {
return myUnFreeBoundaryDraw;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::WireAspect () {
if (myWireAspect.IsNull())
myWireAspect = new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_SOLID,1.);
return myWireAspect;
}
void Prs3d_Drawer::SetWireAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
myWireAspect = anAspect;
}
void Prs3d_Drawer::SetWireDraw ( const Standard_Boolean OnOff ) {
myWireDraw = OnOff;
}
Standard_Boolean Prs3d_Drawer::WireDraw () const {
return myWireDraw;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::LineAspect () {
if (myLineAspect.IsNull())
myLineAspect = new Prs3d_LineAspect
(Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
return myLineAspect;
}
void Prs3d_Drawer::SetLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
myLineAspect = anAspect;
}
Handle (Prs3d_TextAspect) Prs3d_Drawer::TextAspect () {
if (myTextAspect.IsNull())
myTextAspect = new Prs3d_TextAspect();
return myTextAspect;
}
void Prs3d_Drawer::SetTextAspect ( const Handle(Prs3d_TextAspect)& anAspect) {
myTextAspect = anAspect;
}
Handle (Prs3d_ShadingAspect) Prs3d_Drawer::ShadingAspect () {
if (myShadingAspect.IsNull())
myShadingAspect = new Prs3d_ShadingAspect();
return myShadingAspect;
}
void Prs3d_Drawer::SetShadingAspect ( const Handle(Prs3d_ShadingAspect)& anAspect) {
myShadingAspect = anAspect;
}
void Prs3d_Drawer::SetShadingAspectGlobal(const Standard_Boolean aValue) {
myShadingAspectGlobal = aValue;
}
Standard_Boolean Prs3d_Drawer::ShadingAspectGlobal() const {
return myShadingAspectGlobal;
}
void Prs3d_Drawer::SetLineArrowDraw ( const Standard_Boolean OnOff ) {
myLineDrawArrow = OnOff;
}
Standard_Boolean Prs3d_Drawer::LineArrowDraw () const {
return myLineDrawArrow;
}
Handle (Prs3d_ArrowAspect) Prs3d_Drawer::ArrowAspect() {
if (myArrowAspect.IsNull())
myArrowAspect = new Prs3d_ArrowAspect;
return myArrowAspect;
}
void Prs3d_Drawer::SetArrowAspect ( const Handle(Prs3d_ArrowAspect)& anAspect) {
myArrowAspect = anAspect;
}
Handle (Prs3d_PointAspect) Prs3d_Drawer::PointAspect() {
if (myPointAspect.IsNull())
myPointAspect = new Prs3d_PointAspect
(Aspect_TOM_PLUS,Quantity_NOC_YELLOW,1.);
return myPointAspect;
}
void Prs3d_Drawer::SetPointAspect ( const Handle(Prs3d_PointAspect)& anAspect) {
myPointAspect = anAspect;
}
Standard_Boolean Prs3d_Drawer::DrawHiddenLine () const {return myDrawHiddenLine;}
void Prs3d_Drawer::EnableDrawHiddenLine () {myDrawHiddenLine=Standard_True;}
void Prs3d_Drawer::DisableDrawHiddenLine () {myDrawHiddenLine=Standard_False;}
Handle (Prs3d_LineAspect) Prs3d_Drawer::HiddenLineAspect () {
if (myHiddenLineAspect.IsNull())
myHiddenLineAspect = new Prs3d_LineAspect
(Quantity_NOC_YELLOW,Aspect_TOL_DASH,0.5);
return myHiddenLineAspect;
}
void Prs3d_Drawer::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
myHiddenLineAspect = anAspect;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::SeenLineAspect () {
if (mySeenLineAspect.IsNull())
mySeenLineAspect = new Prs3d_LineAspect
(Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
return mySeenLineAspect;
}
void Prs3d_Drawer::SetSeenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
mySeenLineAspect = anAspect;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::VectorAspect () {
if (myVectorAspect.IsNull())
myVectorAspect = new Prs3d_LineAspect
(Quantity_NOC_SKYBLUE,Aspect_TOL_SOLID,1.);
return myVectorAspect;
}
void Prs3d_Drawer::SetVectorAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
myVectorAspect = anAspect;
}
Handle (Prs3d_DatumAspect) Prs3d_Drawer::DatumAspect () {
if (myDatumAspect.IsNull())
myDatumAspect = new Prs3d_DatumAspect;
return myDatumAspect;
}
void Prs3d_Drawer::SetDatumAspect ( const Handle(Prs3d_DatumAspect)& anAspect) {
myDatumAspect = anAspect;
}
Handle (Prs3d_PlaneAspect) Prs3d_Drawer::PlaneAspect () {
if (myPlaneAspect.IsNull())
myPlaneAspect = new Prs3d_PlaneAspect;
return myPlaneAspect;
}
void Prs3d_Drawer::SetPlaneAspect ( const Handle(Prs3d_PlaneAspect)& anAspect) {
myPlaneAspect = anAspect;
}
Handle (Prs3d_LengthAspect) Prs3d_Drawer::LengthAspect () {
if (myLengthAspect.IsNull())
myLengthAspect = new Prs3d_LengthAspect;
return myLengthAspect;
}
void Prs3d_Drawer::SetLengthAspect ( const Handle(Prs3d_LengthAspect)& anAspect) {
myLengthAspect = anAspect;
}
Handle (Prs3d_AngleAspect) Prs3d_Drawer::AngleAspect () {
if (myAngleAspect.IsNull())
myAngleAspect = new Prs3d_AngleAspect;
return myAngleAspect;
}
void Prs3d_Drawer::SetAngleAspect ( const Handle(Prs3d_AngleAspect)& anAspect) {
myAngleAspect = anAspect;
}
Handle (Prs3d_RadiusAspect) Prs3d_Drawer::RadiusAspect () const {
return myRadiusAspect;
}
void Prs3d_Drawer::SetRadiusAspect ( const Handle(Prs3d_RadiusAspect)& anAspect) {
myRadiusAspect = anAspect;
}
Handle (Prs3d_LineAspect) Prs3d_Drawer::SectionAspect () {
if (mySectionAspect.IsNull())
mySectionAspect = new Prs3d_LineAspect
(Quantity_NOC_ORANGE,Aspect_TOL_SOLID,1.);
return mySectionAspect;
}
void Prs3d_Drawer::SetSectionAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
mySectionAspect = anAspect;
}
void Prs3d_Drawer::Print (Standard_OStream& s) const {
s << "Drawer: " << endl;
s << "UIsoAspect: " ;
myUIsoAspect->Print(s);
s << endl;
s << "VIsoAspect: " ;
myVIsoAspect->Print(s);
s << endl;
s << "LineAspect: " ;
myLineAspect->Print(s);
s << endl;
if (myDrawHiddenLine)
s << "draws hidden lines" << endl;
else
s << "does not draw hidden lines" << endl;
s << "HiddenLineAspect: ";
myHiddenLineAspect->Print(s);
s << endl ;
s << "SeenLineAspect: ";
mySeenLineAspect->Print(s);
s << endl;
s << "WireAspect: ";
myWireAspect->Print(s);
s << endl;
s << "FreeBoundaryAspect: ";
myFreeBoundaryAspect->Print(s);
s << endl;
s << "UnFreeBoundaryAspect: ";
myUnFreeBoundaryAspect->Print(s);
s << endl;
s << "SectionAspect: ";
mySectionAspect->Print(s);
s << endl;
s << "DatumAspect: ";
myDatumAspect->Print(s);
s << endl;
s << "VectorAspect: ";
myVectorAspect->Print(s);
s << endl;
s << "PointAspect: ";
myPointAspect->Print(s);
s << endl;
s << "TextAspect: ";
myTextAspect->Print(s);
s << endl;
s << "ArrowAspect: ";
myArrowAspect->Print(s);
s << endl;
s << "LengthAspect: ";
myLengthAspect->Print(s);
s << "AngleAspect: ";
myAngleAspect->Print(s);
if (myTypeOfDeflection == Aspect_TOD_RELATIVE)
s << "TypeOfDeflection: TOD_Relative; Coefficient: " << myDeviationCoefficient << endl;
else
s << "TypeOfDeflection: TOD_Absolute; Maximal chordial deviation: " << myChordialDeviation << endl;
s << "HLRAngle: " << myHLRAngle;
}

25
src/Prs3d/Prs3d_HLRShape.cdl Executable file
View File

@@ -0,0 +1,25 @@
-- File: Prs3d_HLRShape.cdl
-- Created: Tue Mar 9 09:35:13 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
generic class HLRShape from Prs3d (anyShape as any;
HLRShapeTool as any;
anyCurve as any;
CurvePresentation as any) -- as Curve from Prs3d
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d,
Projector from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aShape : anyShape;
aDrawer : Drawer from Prs3d;
aProjector : Projector from Prs3d);
end HLRShape from Prs3d;

49
src/Prs3d/Prs3d_HLRShape.gxx Executable file
View File

@@ -0,0 +1,49 @@
#include <Graphic3d_Group.hxx>
#include <Prs3d_LineAspect.hxx>
#include <TColgp_SequenceOfPnt.hxx>
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Prs3d_HLRShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const anyShape& aShape,
const Handle (Prs3d_Drawer)& aDrawer,
const Handle (Prs3d_Projector)& aProjector)
{
HLRShapeTool Tool(aShape,aProjector->Projector());
Standard_Integer NbEdge = Tool.NbEdges();
Standard_Integer i;
Standard_Real U1,U2;
anyCurve TheCurve;
Standard_Real def = aDrawer->MaximalChordialDeviation();
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->BeginPrimitives();
Standard_Real anAngle = aDrawer->DeviationAngle();
TColgp_SequenceOfPnt Points;
for (i=1;i<=NbEdge;i++){
for(Tool.InitVisible(i);Tool.MoreVisible();Tool.NextVisible()){
Tool.Visible(TheCurve,U1,U2);
CurvePresentation::Add(aPresentation,TheCurve,U1,U2,def, Points, anAngle);
}
}
aGroup->EndPrimitives();
if(aDrawer->DrawHiddenLine()){
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->BeginPrimitives();
for (i=1;i<=NbEdge;i++){
for(Tool.InitHidden(i);Tool.MoreHidden();Tool.NextHidden()){
Tool.Hidden(TheCurve,U1,U2);
CurvePresentation::Add(aPresentation,TheCurve,U1,U2,def, Points, anAngle);
}
}
aGroup->EndPrimitives();
}
}

View File

@@ -0,0 +1,23 @@
-- File: Prs3d_HLRShapeTool.cdl
-- Created: Tue Mar 9 09:41:16 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
generic class HLRShapeTool from Prs3d ( Shape as any ; Curve as any)
uses
Projector from HLRAlgo
is
Create (TheShape: Shape; TheProjector: Projector from HLRAlgo)
returns HLRShapeTool from Prs3d;
NbEdges(me) returns Integer from Standard;
InitVisible(me; EdgeNumber: Integer from Standard);
MoreVisible(me) returns Boolean from Standard;
NextVisible(me);
Visible(me; TheCurve: out Curve; U1,U2: out Real from Standard);
InitHidden(me; EdgeNumber: Integer from Standard);
MoreHidden(me) returns Boolean from Standard;
NextHidden(me);
Hidden(me; TheCurve: out Curve; U1,U2: out Real from Standard);
end HLRShapeTool from Prs3d;

View File

57
src/Prs3d/Prs3d_IsoAspect.cdl Executable file
View File

@@ -0,0 +1,57 @@
-- File: Prs3d_IsoAspect.cdl
-- Created: Mon Apr 26 19:04:20 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1993
class IsoAspect from Prs3d inherits LineAspect from Prs3d
---Purpose: A framework to define the display attributes of isoparameters.
-- This framework can be used to modify the default
-- setting for isoparameters in AIS_Drawer.
uses
NameOfColor from Quantity,
Color from Quantity,
TypeOfLine from Aspect
is
Create (aColor: NameOfColor from Quantity;
aType: TypeOfLine from Aspect;
aWidth: Real from Standard;
aNumber: Integer from Standard)
returns mutable IsoAspect from Prs3d;
---Purpose: Constructs a framework to define display attributes of isoparameters.
-- These include:
-- - the color attribute aColor
-- - the type of line aType
-- - the width value aWidth
-- - aNumber, the number of isoparameters to be displayed.
Create (aColor: Color from Quantity;
aType: TypeOfLine from Aspect;
aWidth: Real from Standard;
aNumber: Integer from Standard)
returns mutable IsoAspect from Prs3d;
SetNumber (me: mutable; aNumber: Integer from Standard)
---Purpose: defines the number of U or V isoparametric curves
-- to be drawn for a single face.
-- Default value: 10
is static;
Number (me) returns Integer from Standard
---Purpose: returns the number of U or V isoparametric curves drawn for a single face.
is static;
Print(me; s: in out OStream from Standard) is redefined;
fields
myNumber: Integer from Standard;
end IsoAspect from Prs3d;

34
src/Prs3d/Prs3d_IsoAspect.cxx Executable file
View File

@@ -0,0 +1,34 @@
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <Prs3d_IsoAspect.ixx>
#ifdef GER61351
Prs3d_IsoAspect::Prs3d_IsoAspect(const Quantity_Color &aColor,
const Aspect_TypeOfLine aType,
const Standard_Real aWidth,
const Standard_Integer aNumber)
:Prs3d_LineAspect (aColor,aType,aWidth) {
myNumber = aNumber;
}
#endif
Prs3d_IsoAspect::Prs3d_IsoAspect(const Quantity_NameOfColor aColor,
const Aspect_TypeOfLine aType,
const Standard_Real aWidth,
const Standard_Integer aNumber)
:Prs3d_LineAspect (aColor,aType,aWidth) {
myNumber = aNumber;
}
void Prs3d_IsoAspect::SetNumber (const Standard_Integer aNumber) {
myNumber = aNumber;
}
Standard_Integer Prs3d_IsoAspect::Number () const {return myNumber;}
void Prs3d_IsoAspect::Print(Standard_OStream& s) const {
s << "IsoAspect: " << myNumber << " ";
Prs3d_LineAspect::Print(s);
}

View File

@@ -0,0 +1,73 @@
-- File: Prs3d_LengthAspect.cdl
-- Created: Thu Jun 3 09:28:46 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class LengthAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: defines the attributes when drawing a Length Presentation.
uses
AspectLine3d from Graphic3d,
ArrowAspect from Prs3d,
LineAspect from Prs3d,
TextAspect from Prs3d,
NameOfColor from Quantity,
TypeOfLine from Aspect,
PlaneAngle from Quantity
is
--
-- Attributes for the lines.
--
Create returns mutable LengthAspect from Prs3d;
--- Purpose: Constructs an empty framework to define the display of lengths.
LineAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the settings for the display of lines used in presentation of lengths.
SetLineAspect(me: mutable; anAspect: LineAspect from Prs3d);
---Purpose: Sets the display attributes of lines used in presentation of lengths.
Arrow1Aspect(me) returns mutable ArrowAspect from Prs3d is static;
--- Purpose: Returns the settings for displaying a right-pointing arrow.
SetArrow1Aspect(me: mutable; anAspect: ArrowAspect from Prs3d) is static;
---Purpose: Sets the display attributes of the first arrow used in presentation of lengths.
Arrow2Aspect(me) returns mutable ArrowAspect from Prs3d is static;
--- Purpose: Returns the settings for displaying a left-pointing arrow.
SetArrow2Aspect(me: mutable ; anAspect: ArrowAspect from Prs3d) is static;
---Purpose: Sets the display attributes of the second arrow used in presentation of lengths.
TextAspect(me) returns mutable TextAspect from Prs3d is static;
--- Purpose: Returns the settings for the display of text used in presentation of lengths.
SetTextAspect(me:mutable; anAspect: TextAspect from Prs3d) is static;
---Purpose: Sets the display attributes of text used in presentation of lengths.
SetDrawFirstArrow(me: mutable; draw: Boolean from Standard) is static;
--- Purpose: Sets the DrawFirstArrow attributes to active.
DrawFirstArrow(me) returns Boolean from Standard is static;
---Purpose: Returns true if the first arrow can be drawn.
SetDrawSecondArrow(me: mutable; draw: Boolean from Standard) is static;
---Purpose: Sets the DrawSecondArrow attributes to active.
DrawSecondArrow(me) returns Boolean from Standard is static;
---Purpose: Returns true if the second arrow can be drawn.
Print(me; s: in out OStream from Standard) is static;
fields
myLineAspect: LineAspect from Prs3d;
myArrow1Aspect: ArrowAspect from Prs3d;
myArrow2Aspect: ArrowAspect from Prs3d;
myTextAspect: TextAspect from Prs3d;
myDrawFirstArrow: Boolean from Standard;
myDrawSecondArrow: Boolean from Standard;
end LengthAspect from Prs3d;

View File

@@ -0,0 +1,62 @@
#include <Prs3d_LengthAspect.ixx>
Prs3d_LengthAspect::Prs3d_LengthAspect() {
myLineAspect = new Prs3d_LineAspect
(Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
myArrow1Aspect = new Prs3d_ArrowAspect;
myArrow2Aspect = new Prs3d_ArrowAspect;
myTextAspect = new Prs3d_TextAspect;
myDrawFirstArrow = Standard_True;
myDrawSecondArrow = Standard_True;
}
Handle (Prs3d_LineAspect) Prs3d_LengthAspect::LineAspect () const {
return myLineAspect;}
void Prs3d_LengthAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& anAspect) {
myLineAspect = anAspect;}
Handle(Prs3d_ArrowAspect) Prs3d_LengthAspect::Arrow1Aspect () const {
return myArrow1Aspect;}
void Prs3d_LengthAspect::SetArrow1Aspect (
const Handle(Prs3d_ArrowAspect)& anAspect) {
myArrow1Aspect = anAspect;
}
Handle(Prs3d_ArrowAspect) Prs3d_LengthAspect::Arrow2Aspect () const {
return myArrow2Aspect;}
void Prs3d_LengthAspect::SetArrow2Aspect (
const Handle(Prs3d_ArrowAspect)& anAspect) {
myArrow2Aspect = anAspect;
}
Handle(Prs3d_TextAspect) Prs3d_LengthAspect::TextAspect () const {
return myTextAspect;}
void Prs3d_LengthAspect::SetTextAspect (
const Handle(Prs3d_TextAspect)& anAspect) {
myTextAspect = anAspect;
}
void Prs3d_LengthAspect::SetDrawFirstArrow (const Standard_Boolean draw) {
myDrawFirstArrow = draw;
}
Standard_Boolean Prs3d_LengthAspect::DrawFirstArrow () const {
return myDrawFirstArrow;
}
void Prs3d_LengthAspect::SetDrawSecondArrow (const Standard_Boolean draw) {
myDrawSecondArrow = draw;
}
Standard_Boolean Prs3d_LengthAspect::DrawSecondArrow () const {
return myDrawSecondArrow;
}
void Prs3d_LengthAspect::Print (Standard_OStream& s) const {
s << "LengthAspect: " << endl;
s << " " ; myLineAspect->Print(s); s << endl;
s << " First arrow " ; myArrow1Aspect->Print(s); s << endl;
s << " Second arrow " ; myArrow2Aspect->Print(s); s << endl;
s << " " ; myTextAspect->Print(s); s << endl;
}

View File

@@ -0,0 +1,31 @@
-- File: Prs3d_LengthPresentation.cdl
-- Created: Thu Jun 3 09:41:39 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class LengthPresentation from Prs3d inherits Root from Prs3d
---Purpose: A framework to define the display of lengths.
uses
Presentation from Prs3d,
Pnt from gp,
Drawer from Prs3d,
ExtendedString from TCollection
is
Draw( myclass; aPresentation: Presentation from Prs3d;
aDrawer: Drawer from Prs3d;
aText: ExtendedString from TCollection;
AttachmentPoint1: Pnt from gp;
AttachmentPoint2: Pnt from gp;
OffsetPoint: Pnt from gp);
---Purpose: Defines the display of the length between the points
-- AttachmentPoint1 and AttachmentPoint2.
-- The text aText is displayed at the point OffsetPoint,
-- and the drawer aDrawer specifies the display
-- attributes which lengths will have.
-- The presentation object aPresentation stores the
-- information defined in this framework.
end LengthPresentation from Prs3d;

View File

@@ -0,0 +1,71 @@
#include <Prs3d_LengthPresentation.ixx>
#include <gp_Lin.hxx>
#include <gp_Dir.hxx>
#include <ElCLib.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Prs3d_Text.hxx>
void Prs3d_LengthPresentation::Draw (
const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Prs3d_Drawer)& aDrawer,
const TCollection_ExtendedString& aText,
const gp_Pnt& AttachmentPoint1,
const gp_Pnt& AttachmentPoint2,
const gp_Pnt& OffsetPoint) {
Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
gp_Dir D (gp_Vec(AttachmentPoint1,AttachmentPoint2));
gp_Lin L (OffsetPoint,D);
gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint1),L);
gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint2),L);
Graphic3d_Array1OfVertex V(1,2);
Quantity_Length X,Y,Z;
Proj1.Coord(X,Y,Z);
V(1).SetCoord(X,Y,Z);
AttachmentPoint1.Coord(X,Y,Z);
V(2).SetCoord(X,Y,Z);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
Proj2.Coord(X,Y,Z);
V(2).SetCoord(X,Y,Z);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
AttachmentPoint2.Coord(X,Y,Z);
V(1).SetCoord(X,Y,Z);
Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
Proj1.Coord(X,Y,Z);
if (LA->DrawFirstArrow()) {
Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(),
LA->Arrow1Aspect()->Angle(),
LA->Arrow1Aspect()->Length());
}
Quantity_Length X2,Y2,Z2;
Proj2.Coord(X2,Y2,Z2);
if (LA->DrawSecondArrow()) {
Prs3d_Arrow::Draw(aPresentation,Proj2,D,
LA->Arrow2Aspect()->Angle(),
LA->Arrow2Aspect()->Length());
}
gp_Pnt p;
p.SetCoord( (X+X2)/2. , (Y+Y2)/2. , (Z+Z2)/2.);
Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,p);
}

58
src/Prs3d/Prs3d_Line.cdl Executable file
View File

@@ -0,0 +1,58 @@
-- File: Prs3d_Line.cdl
-- Created: Wed Dec 16 12:39:30 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
generic class Line from Prs3d
(anyLine as any;
LineTool as any) -- as LineTool from Prs3d
inherits Root from Prs3d
---Purpose: draws a broken line.
--
uses
Presentation from Prs3d,
Drawer from Prs3d,
TypeOfLinePicking from Prs3d,
Length from Quantity
is
Add(myclass; aPresentation: Presentation from Prs3d;
aLine: anyLine;
aDrawer: Drawer from Prs3d);
---Purpose: adds to the presentation aPresentation the drawing of the
-- broken line aLine.
-- The aspect is defined by LineAspect in aDrawer.
Add(myclass; aPresentation: Presentation from Prs3d;
aLine: anyLine);
---Purpose: adds to the presentation aPresentation the drawing of the
-- broken line aLine.
-- The aspect is the current aspect.
Pick(myclass; X,Y,Z: Length from Quantity;
aDistance: Length from Quantity;
aLine: anyLine;
aDrawer: Drawer from Prs3d;
TypeOfPicking: TypeOfLinePicking from Prs3d)
returns Integer from Standard;
---Purpose: if TypeOfLinePicking is set to Prs3d_TOLP_Point
-- returns the number of the point the most near of the
-- point (X,Y,Z). The distance between the point and
-- (X,Y,Z) must be less then aDistance. If no point corresponds,
-- 0 is returned.
-- if TypeOfLinePicking is set to Prs3d_TOLP_Segment returns
-- the number of the segment the most near of the point (X,Y,Z).
-- The distance between the segment and (X,Y,Z) must be less
-- then aDistance. If no segment corresponds, 0 is returned.
end Line;

110
src/Prs3d/Prs3d_Line.gxx Executable file
View File

@@ -0,0 +1,110 @@
#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_Dir.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d.hxx>
static void DrawLine (const anyLine& aLine,
const Handle(Graphic3d_Group)& aGroup) {
Standard_Integer Count=0;
Quantity_Length x,y,z;
Standard_Integer Lower = LineTool::Lower(aLine);
Standard_Integer Upper = LineTool::Upper(aLine);
Graphic3d_Array1OfVertex VertexArray(1,Upper-Lower+1);
for (Standard_Integer i=Lower;i<=Upper;i++){
LineTool::Coord(aLine,i,x,y,z);
VertexArray(++Count).SetCoord(x,y,z);
}
aGroup->Polyline(VertexArray);
}
void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation,
const anyLine& aLine,
const Handle (Prs3d_Drawer)& aDrawer){
// Prs3d_Root::NewGroup(aPresentation);
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
DrawLine(aLine,TheGroup);
if (aDrawer->LineArrowDraw()) {
Standard_Integer Lower = LineTool::Lower(aLine);
Standard_Integer Upper = LineTool::Upper(aLine);
if ( Upper > Lower ){
Quantity_Length x1,y1,z1,x2,y2,z2;
LineTool::Coord(aLine,Upper-1,x1,y1,z1);
LineTool::Coord(aLine,Upper,x2,y2,z2);
Prs3d_Arrow::Draw(aPresentation,
gp_Pnt(x2,y2,z2),
gp_Dir(x2-x1,y2-y1,z2-z1),
aDrawer->ArrowAspect()->Angle(),
aDrawer->ArrowAspect()->Length());
}
}
}
void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation,
const anyLine& aLine){
DrawLine (aLine,Prs3d_Root::CurrentGroup(aPresentation));
}
Standard_Integer Prs3d_Line::Pick
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const anyLine& aLine,
const Handle (Prs3d_Drawer)& aDrawer,
const Prs3d_TypeOfLinePicking TypeOfPicking){
Standard_Integer Lower = LineTool::Lower(aLine);
Standard_Integer Upper = LineTool::Upper(aLine);
Standard_Integer num = 0;
Quantity_Length X1,Y1,Z1,X2,Y2,Z2,dist;
Standard_Real DistMin = RealLast();
for (Standard_Integer i=Lower;i<=Upper;i++){
LineTool::Coord(aLine,i,X2,Y2,Z2);
switch (TypeOfPicking) {
case Prs3d_TOLP_Point: {
dist = Abs(X-X2)+Abs(Y-Y2)+ Abs(Z-Z2);
if(dist < aDistance) {
if (dist < DistMin) {
DistMin = dist;
num = i;
}
}
}
break;
case Prs3d_TOLP_Segment: {
if (i > 1) {
if (Prs3d::MatchSegment
(X,Y,Z,aDistance,gp_Pnt(X1,Y1,Z1),gp_Pnt(X2,Y2,Z2),dist)){
if(dist < aDistance) {
if (dist < DistMin) {
DistMin = dist;
num = i;
}
}
}
}
X1=X2;Y1=Y2;Z1=Z2;
}
break;
}
}
return num;
}

76
src/Prs3d/Prs3d_LineAspect.cdl Executable file
View File

@@ -0,0 +1,76 @@
-- File: Prs3d_LineAspect.cdl
-- Created: Mon Apr 26 16:18:12 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1993
class LineAspect from Prs3d inherits BasicAspect from Prs3d
---Purpose: A framework for defining how a line will be displayed
-- in a presentation. Aspects of line display include
-- width, color and type of line.
-- The definition set by this class is then passed to the
-- attribute manager Prs3d_Drawer.
-- Any object which requires a value for line aspect as
-- an argument may then be given the attribute manager
-- as a substitute argument in the form of a field such as myDrawer for example.
uses
AspectLine3d from Graphic3d,
NameOfColor from Quantity,
Color from Quantity,
TypeOfLine from Aspect
is
--
-- Attributes for the lines.
--
Create (aColor: NameOfColor from Quantity;
aType: TypeOfLine from Aspect;
aWidth: Real from Standard)
returns mutable LineAspect from Prs3d;
---Purpose: Constructs a framework for line aspect defined by
-- - the color aColor
-- - the type of line aType and
-- - the line thickness aWidth.
-- Type of line refers to whether the line is solid or dotted, for example.
Create (aColor: Color from Quantity;
aType: TypeOfLine from Aspect;
aWidth: Real from Standard)
returns mutable LineAspect from Prs3d;
SetColor (me: mutable; aColor: Color from Quantity) is static;
SetColor (me: mutable; aColor: NameOfColor from Quantity)
---Purpose: Sets the line color defined at the time of construction.
-- Default value: Quantity_NOC_YELLOW
is static;
SetTypeOfLine (me: mutable; aType: TypeOfLine from Aspect)
---Purpose: Sets the type of line defined at the time of construction.
-- This could, for example, be solid, dotted or made up of dashes.
-- Default value: Aspect_TOL_SOLID
is static;
SetWidth (me: mutable; aWidth: Real from Standard)
---Purpose: Sets the line width defined at the time of construction.
-- Default value: 1.
is static;
Aspect(me) returns AspectLine3d from Graphic3d
is static;
--- Purpose: Returns the line aspect. This is defined as the set of
-- color, type and thickness attributes.
Print( me; s: in out OStream from Standard)
is virtual;
fields
myAspect: AspectLine3d from Graphic3d;
end LineAspect from Prs3d;

67
src/Prs3d/Prs3d_LineAspect.cxx Executable file
View File

@@ -0,0 +1,67 @@
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <Prs3d_LineAspect.ixx>
#ifdef GER61351
Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_Color &aColor,
const Aspect_TypeOfLine aType,
const Standard_Real aWidth) {
myAspect = new Graphic3d_AspectLine3d(aColor,aType,aWidth);
}
#endif
Prs3d_LineAspect::Prs3d_LineAspect (const Quantity_NameOfColor aColor,
const Aspect_TypeOfLine aType,
const Standard_Real aWidth) {
myAspect = new Graphic3d_AspectLine3d
(Quantity_Color(aColor),aType,aWidth);
}
#ifdef GER61351
void Prs3d_LineAspect::SetColor(const Quantity_Color &aColor) {
myAspect->SetColor(aColor);
}
#endif
void Prs3d_LineAspect::SetColor(const Quantity_NameOfColor aColor) {
myAspect->SetColor(Quantity_Color(aColor));
}
void Prs3d_LineAspect::SetTypeOfLine(const Aspect_TypeOfLine aType){
myAspect->SetType(aType);
}
void Prs3d_LineAspect::SetWidth(const Standard_Real aWidth){
myAspect->SetWidth(aWidth);
}
Handle (Graphic3d_AspectLine3d) Prs3d_LineAspect::Aspect () const {
return myAspect;
}
void Prs3d_LineAspect::Print (Standard_OStream& s) const {
Quantity_Color C;
Aspect_TypeOfLine T;
Standard_Real W;
myAspect->Values(C,T,W);
switch (T) {
case Aspect_TOL_SOLID:
s << "LineAspect: " << Quantity_Color::StringName(C.Name()) << " SOLID " << W;
break;
case Aspect_TOL_DASH:
s << "LineAspect: " << Quantity_Color::StringName(C.Name()) << " DASH " << W;
break;
case Aspect_TOL_DOT:
s << "LineAspect: " << Quantity_Color::StringName(C.Name()) << " DOT " << W;
break;
case Aspect_TOL_DOTDASH:
s << "LineAspect: " << Quantity_Color::StringName(C.Name()) << " DOTDASH " << W;
break;
case Aspect_TOL_USERDEFINED:
s << "LineAspect: " << Quantity_Color::StringName(C.Name()) << " USERDEFINED " << W;
break;
}
}

18
src/Prs3d/Prs3d_LineTool.cdl Executable file
View File

@@ -0,0 +1,18 @@
-- File: Prs3d_LineTool.cdl
-- Created: Wed Dec 16 13:36:55 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
generic class LineTool from Prs3d ( Line as any)
uses
Length from Quantity
is
Lower(myclass; aLine: Line) returns Integer from Standard;
Upper(myclass; aLine: Line) returns Integer from Standard;
Coord(myclass; aLine: Line;
Index: Integer from Standard;
X,Y,Z: out Length from Quantity);
end LineTool from Prs3d;

0
src/Prs3d/Prs3d_LineTool.gxx Executable file
View File

View File

@@ -0,0 +1,15 @@
// File: Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx
// Created: Thu Apr 20 16:16:59 2006
// Author: Sergey Kochetkov
#ifndef Prs3d_NListIteratorOfListOfSequenceOfPnt_HeaderFile
#define Prs3d_NListIteratorOfListOfSequenceOfPnt_HeaderFile
#include <Prs3d_NListOfSequenceOfPnt.hxx>
typedef Prs3d_NListOfSequenceOfPnt::Iterator Prs3d_NListIteratorOfListOfSequenceOfPnt;
#endif

View File

@@ -0,0 +1,23 @@
// File: Prs3d_NListOfSequenceOfPnt.hxx
// Created: Thu Apr 20 14:53:27 2006
// Author: Sergey Kochetkov
#ifndef Prs3d_NListOfSequenceOfPnt_HeaderFile
#define Prs3d_NListOfSequenceOfPnt_HeaderFile
#include <TColgp_SequenceOfPnt.hxx>
#include <NCollection_DefineList.hxx>
#include <NCollection_DefineBaseCollection.hxx>
DEFINE_BASECOLLECTION(Prs3d_BaseCollListOfSequenceOfPnt,
TColgp_SequenceOfPnt)
DEFINE_LIST (Prs3d_NListOfSequenceOfPnt,
Prs3d_BaseCollListOfSequenceOfPnt,
TColgp_SequenceOfPnt)
#endif

95
src/Prs3d/Prs3d_PlaneAspect.cdl Executable file
View File

@@ -0,0 +1,95 @@
-- File: Prs3d_PlaneAspect.cdl
-- Created: Mon Jan 17 14:29:30 1994
-- Author: Modelistation
-- <model@mastox>
---Copyright: Matra Datavision 1994
class PlaneAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: A framework to define the display of planes.
uses
LineAspect from Prs3d,
Length from Quantity,
PlaneAngle from Quantity
is
Create returns mutable PlaneAspect from Prs3d;
---Purpose: Constructs an empty framework for the display of planes.
EdgesAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the attributes of displayed edges involved in the presentation of planes.
IsoAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the attributes of displayed isoparameters involved in the presentation of planes.
ArrowAspect(me) returns mutable LineAspect from Prs3d;
---Purpose: Returns the settings for displaying an arrow.
SetArrowsLength(me:mutable; L : Length from Quantity);
ArrowsLength(me) returns Length from Quantity;
--- Purpose: Returns the length of the arrow shaft used in the display of arrows.
SetArrowsSize(me:mutable; L : Length from Quantity);
---Purpose: Sets the angle of the arrowhead used in the display of planes.
ArrowsSize(me) returns Length from Quantity;
---Purpose: Returns the size of arrows used in the display of planes.
SetArrowsAngle(me:mutable; ang : PlaneAngle from Quantity);
---Purpose: Sets the angle of the arrowhead used in the display
-- of arrows involved in the presentation of planes.
ArrowsAngle(me) returns PlaneAngle from Quantity;
---Purpose: Returns the angle of the arrowhead used in the
-- display of arrows involved in the presentation of planes.
SetDisplayCenterArrow(me:mutable ; draw: Boolean from Standard);
---Purpose: Sets the display attributes defined in DisplayCenterArrow to active.
DisplayCenterArrow(me) returns Boolean from Standard;
---Purpose: Returns true if the display of center arrows is allowed.
SetDisplayEdgesArrows(me:mutable ; draw: Boolean from Standard);
---Purpose: Sets the display attributes defined in DisplayEdgesArrows to active.
DisplayEdgesArrows(me) returns Boolean from Standard;
--- Purpose: Returns true if the display of edge arrows is allowed.
SetDisplayEdges(me:mutable ; draw: Boolean from Standard);
DisplayEdges(me) returns Boolean from Standard;
SetDisplayIso(me:mutable ; draw: Boolean from Standard);
---Purpose: Sets the display attributes defined in DisplayIso to active.
DisplayIso(me) returns Boolean from Standard;
--- Purpose: Returns true if the display of isoparameters is allowed.
SetPlaneLength(me:mutable; LX,LY: Length from Quantity);
PlaneXLength(me) returns Length from Quantity;
--- Purpose: Returns the length of the x axis used in the display of planes.
PlaneYLength(me) returns Length from Quantity;
---Purpose: Returns the length of the y axis used in the display of planes.
SetIsoDistance(me:mutable; L: Length from Quantity);
---Purpose: Sets the distance L between isoparameters used in the display of planes.
IsoDistance(me) returns Length from Quantity;
---Purpose: Returns the distance between isoparameters used in the display of planes.
fields
myEdgesAspect: LineAspect from Prs3d;
myIsoAspect: LineAspect from Prs3d;
myArrowAspect: LineAspect from Prs3d;
myArrowsLength: Length from Quantity;
myArrowsSize: Length from Quantity;
myArrowsAngle: PlaneAngle from Quantity;
myDrawCenterArrow: Boolean from Standard;
myDrawEdgesArrows: Boolean from Standard;
myDrawEdges: Boolean from Standard;
myDrawIso: Boolean from Standard;
myPlaneXLength : Length from Quantity;
myPlaneYLength : Length from Quantity;
myIsoDistance: Length from Quantity;
end PlaneAspect from Prs3d;

142
src/Prs3d/Prs3d_PlaneAspect.cxx Executable file
View File

@@ -0,0 +1,142 @@
#include <Prs3d_PlaneAspect.ixx>
Prs3d_PlaneAspect::Prs3d_PlaneAspect()
{
myEdgesAspect = new Prs3d_LineAspect(Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.);
myIsoAspect = new Prs3d_LineAspect(Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5);
myArrowAspect = new Prs3d_LineAspect(Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID,1.);
myDrawCenterArrow = Standard_False;
myDrawEdgesArrows = Standard_False;
myDrawEdges = Standard_True;
myDrawIso = Standard_False;
myIsoDistance = 0.5;
myPlaneXLength= 1.;
myPlaneYLength= 1.;
myArrowsLength= 0.02;
myArrowsSize=0.1;
myArrowsAngle=PI/8.;
}
Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::EdgesAspect() const
{
return myEdgesAspect;
}
Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::IsoAspect() const
{
return myIsoAspect;
}
Handle(Prs3d_LineAspect) Prs3d_PlaneAspect::ArrowAspect() const
{
return myArrowAspect;
}
void Prs3d_PlaneAspect::SetDisplayCenterArrow(const Standard_Boolean draw)
{
myDrawCenterArrow = draw;
}
void Prs3d_PlaneAspect::SetDisplayEdgesArrows(const Standard_Boolean draw)
{
myDrawEdgesArrows = draw;
}
void Prs3d_PlaneAspect::SetDisplayEdges(const Standard_Boolean draw)
{
myDrawEdges = draw;
}
void Prs3d_PlaneAspect::SetDisplayIso(const Standard_Boolean draw)
{
myDrawIso = draw;
}
Standard_Boolean Prs3d_PlaneAspect::DisplayCenterArrow() const
{
return myDrawCenterArrow;
}
Standard_Boolean Prs3d_PlaneAspect::DisplayEdgesArrows() const
{
return myDrawEdgesArrows;
}
Standard_Boolean Prs3d_PlaneAspect::DisplayEdges() const
{
return myDrawEdges;
}
Standard_Boolean Prs3d_PlaneAspect::DisplayIso() const
{
return myDrawIso;
}
void Prs3d_PlaneAspect::SetPlaneLength(const Quantity_Length lX,
const Quantity_Length lY)
{
myPlaneXLength = lX;
myPlaneYLength = lY;
}
Quantity_Length Prs3d_PlaneAspect::PlaneXLength() const
{
return myPlaneXLength;
}
Quantity_Length Prs3d_PlaneAspect::PlaneYLength() const
{
return myPlaneYLength;
}
void Prs3d_PlaneAspect::SetIsoDistance(const Quantity_Length l)
{
myIsoDistance = l;
}
Quantity_Length Prs3d_PlaneAspect::IsoDistance() const
{
return myIsoDistance;
}
void Prs3d_PlaneAspect::SetArrowsLength(const Quantity_Length L)
{
myArrowsLength = L;
}
Quantity_Length Prs3d_PlaneAspect::ArrowsLength() const
{
return myArrowsLength;
}
void Prs3d_PlaneAspect::SetArrowsSize(const Quantity_Length L)
{
myArrowsSize = L;
}
Quantity_Length Prs3d_PlaneAspect::ArrowsSize() const
{
return myArrowsSize;
}
void Prs3d_PlaneAspect::SetArrowsAngle(const Quantity_PlaneAngle ang)
{
myArrowsAngle = ang;
}
Quantity_Length Prs3d_PlaneAspect::ArrowsAngle() const
{
return myArrowsAngle;
}

34
src/Prs3d/Prs3d_PlaneSet.cdl Executable file
View File

@@ -0,0 +1,34 @@
-- File: Prs3d_PlaneSet.cdl
-- Created: Wed Oct 20 12:52:03 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class PlaneSet from Prs3d inherits TShared from MMgt
uses
Length from Quantity,
Pln from gp
is
Create( Xdir,Ydir,Zdir: Real from Standard;
Xloc,Yloc,Zloc: Length from Quantity;
anOffset: Length from Quantity)
returns mutable PlaneSet from Prs3d;
SetDirection(me: mutable; X,Y,Z: Real from Standard);
SetLocation(me: mutable; X,Y,Z: Length from Quantity);
SetOffset(me: mutable; anOffset: Length from Quantity);
Plane(me) returns Pln from gp;
Offset(me) returns Length from Quantity;
Location(me; X,Y,Z: out Length from Quantity);
Direction(me; X,Y,Z: out Length from Quantity);
fields
myPlane: Pln from gp;
myOffset: Length from Quantity;
end PlaneSet from Prs3d;

65
src/Prs3d/Prs3d_PlaneSet.cxx Executable file
View File

@@ -0,0 +1,65 @@
// File: Prs3d_PlaneSet.cxx
// Created: Wed Oct 20 13:04:21 1993
// Author: Isabelle VERDURON
// <isa@stylox>
#include <Prs3d_PlaneSet.ixx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
Prs3d_PlaneSet::Prs3d_PlaneSet(const Standard_Real Xdir,
const Standard_Real Ydir,
const Standard_Real Zdir,
const Standard_Real Xloc,
const Standard_Real Yloc,
const Standard_Real Zloc,
const Quantity_Length anOffset)
: myPlane(gp_Pln(gp_Pnt(Xloc,Yloc,Zloc),gp_Dir(Xdir,Ydir,Zdir))),
myOffset(anOffset) {
}
void Prs3d_PlaneSet::SetDirection(const Standard_Real X,
const Standard_Real Y,
const Standard_Real Z) {
myPlane = gp_Pln(myPlane.Location(),gp_Dir(X,Y,Z));
}
void Prs3d_PlaneSet::SetLocation(const Standard_Real X,
const Standard_Real Y,
const Standard_Real Z) {
myPlane.SetLocation(gp_Pnt(X,Y,Z));
}
void Prs3d_PlaneSet::SetOffset(const Quantity_Length anOffset) {
myOffset = anOffset;
}
gp_Pln Prs3d_PlaneSet::Plane() const {
return myPlane;
}
Quantity_Length Prs3d_PlaneSet::Offset () const {
return myOffset;
}
void Prs3d_PlaneSet::Location(Quantity_Length& X,Quantity_Length& Y,Quantity_Length& Z) const {
myPlane.Location().Coord(X,Y,Z);
}
void Prs3d_PlaneSet::Direction(Quantity_Length& X,Quantity_Length& Y,Quantity_Length& Z) const {
myPlane.Axis().Direction().Coord(X,Y,Z);
}

46
src/Prs3d/Prs3d_Point.cdl Executable file
View File

@@ -0,0 +1,46 @@
-- File: Prs3d_Point.cdl
-- Created: Wed Dec 16 12:39:30 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
generic class Point from Prs3d
(anyPoint as any;
PointTool as any) -- as PointTool from Prs3d;
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity
is
Add(myclass; aPresentation: Presentation from Prs3d;
aPoint: anyPoint;
aDrawer: Drawer from Prs3d);
Add(myclass; aPresentation: Presentation from Prs3d;
aPoint: anyPoint);
Match(myclass; aPoint: anyPoint;
X,Y,Z: Length from Quantity;
aDistance: Length from Quantity)
returns Boolean from Standard;
end Point;

40
src/Prs3d/Prs3d_Point.gxx Executable file
View File

@@ -0,0 +1,40 @@
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_PointAspect.hxx>
static void DrawPoint (const anyPoint& aPoint,
const Handle(Graphic3d_Group) aGroup) {
Quantity_Length x,y,z;
PointTool::Coord(aPoint,x,y,z);
Graphic3d_Vertex Vertex(x,y,z);
aGroup->Marker(Vertex);
}
void Prs3d_Point::Add (const Handle (Prs3d_Presentation)& aPresentation,
const anyPoint& aPoint,
const Handle (Prs3d_Drawer)& aDrawer){
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect());
DrawPoint(aPoint,TheGroup);
}
void Prs3d_Point::Add (const Handle (Prs3d_Presentation)& aPresentation,
const anyPoint& aPoint){
DrawPoint(aPoint,Prs3d_Root::CurrentGroup(aPresentation));
}
Standard_Boolean Prs3d_Point::Match (const anyPoint& aPoint,
const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance) {
Quantity_Length x,y,z;
PointTool::Coord(aPoint,x,y,z);
return Sqrt( (X-x)*(X-x) + (Y-y)*(Y-y) + (Z-z)*(Z-z) ) <= aDistance;
}

85
src/Prs3d/Prs3d_PointAspect.cdl Executable file
View File

@@ -0,0 +1,85 @@
-- File: Prs3d_PointAspect.cdl
-- Created: Mon Apr 26 16:18:12 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1993
class PointAspect from Prs3d inherits BasicAspect from Prs3d
---Purpose: This class defines attributes for the points
-- The points are drawn using markers, whose size does not depend on
-- the zoom value of the views.
uses
AspectMarker3d from Graphic3d,
NameOfColor from Quantity,
Color from Quantity,
TypeOfMarker from Aspect,
HArray1OfByte from TColStd
is
Create ( aType: TypeOfMarker from Aspect;
aColor: Color from Quantity;
aScale: Real from Standard)
returns mutable PointAspect from Prs3d;
Create ( aType: TypeOfMarker from Aspect;
aColor: NameOfColor from Quantity;
aScale: Real from Standard)
returns mutable PointAspect from Prs3d;
Create ( AColor : Color from Quantity;
AnId : Real from Standard;
AWidth : Integer from Standard;
AHeight : Integer from Standard;
ATexture : HArray1OfByte from TColStd)
returns mutable PointAspect from Prs3d;
---Purpose: defines only the urer defined marker point.
SetColor (me: mutable; aColor: Color from Quantity) is static;
SetColor (me: mutable; aColor: NameOfColor from Quantity)
---Purpose: defines the color to be used when drawing a point.
-- Default value: Quantity_NOC_YELLOW
is static;
SetTypeOfMarker (me: mutable; aType: TypeOfMarker from Aspect)
---Purpose: defines the type of representation to be used when drawing a point.
-- Default value: Aspect_TOM_PLUS
is static;
SetScale (me: mutable; aScale: Real from Standard)
---Purpose: defines the size of the marker used when drawing a point.
-- Default value: 1.
is static;
Aspect(me) returns AspectMarker3d from Graphic3d
is static;
Print( me; s: in out OStream from Standard);
GetTextureSize (me:mutable; AWidth : out Integer from Standard;
AHeight : out Integer from Standard);
---Level: Public
---Purpose: Returns marker's texture size.
GetTexture (me:mutable)
returns HArray1OfByte from TColStd;
---Level: Public
---Purpose: Returns marker's texture.
---C++: return const &
fields
myAspect: AspectMarker3d from Graphic3d;
end PointAspect from Prs3d;

114
src/Prs3d/Prs3d_PointAspect.cxx Executable file
View File

@@ -0,0 +1,114 @@
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <Prs3d_PointAspect.ixx>
#ifdef GER61351
Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker aType,
const Quantity_Color &aColor,
const Standard_Real aScale) {
myAspect = new Graphic3d_AspectMarker3d(aType,aColor,aScale);
}
#endif
Prs3d_PointAspect::Prs3d_PointAspect (const Aspect_TypeOfMarker aType,
const Quantity_NameOfColor aColor,
const Standard_Real aScale) {
myAspect = new Graphic3d_AspectMarker3d
(aType,Quantity_Color(aColor),aScale);
}
Prs3d_PointAspect::Prs3d_PointAspect (const Quantity_Color &aColor,
const Standard_Real anId,
const Standard_Integer aWidth,
const Standard_Integer aHeight,
const Handle(TColStd_HArray1OfByte)& aTexture
)
{
myAspect = new Graphic3d_AspectMarker3d
(Aspect_TOM_USERDEFINED,aColor,anId,aWidth,aHeight,aTexture);
}
#ifdef GER61351
void Prs3d_PointAspect::SetColor(const Quantity_Color &aColor) {
myAspect->SetColor(aColor);
}
#endif
void Prs3d_PointAspect::SetColor(const Quantity_NameOfColor aColor) {
myAspect->SetColor(Quantity_Color(aColor));
}
void Prs3d_PointAspect::SetTypeOfMarker(const Aspect_TypeOfMarker aType){
myAspect->SetType(aType);
}
void Prs3d_PointAspect::SetScale(const Standard_Real aScale){
myAspect->SetScale(aScale);
}
Handle (Graphic3d_AspectMarker3d) Prs3d_PointAspect::Aspect () const {
return myAspect;
}
void Prs3d_PointAspect::Print (Standard_OStream& s) const {
Quantity_Color C;
Aspect_TypeOfMarker T;
Standard_Real S;
myAspect->Values(C,T,S);
switch (T) {
case Aspect_TOM_POINT:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " POINT " << S;
break;
case Aspect_TOM_PLUS:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " PLUS " << S;
break;
case Aspect_TOM_STAR:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " STAR " << S;
break;
case Aspect_TOM_O:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " O " << S;
break;
case Aspect_TOM_X:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " X " << S;
break;
case Aspect_TOM_O_POINT:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " O_POINT " << S;
break;
case Aspect_TOM_O_PLUS:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " O_PLUS " << S;
break;
case Aspect_TOM_O_STAR:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " O_STAR " << S;
break;
case Aspect_TOM_O_X:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " O_X " << S;
break;
case Aspect_TOM_BALL:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " BALL " << S;
break;
case Aspect_TOM_RING1:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " RING1 " << S;
break;
case Aspect_TOM_RING2:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " RING2 " << S;
break;
case Aspect_TOM_RING3:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " RING3 " << S;
break;
case Aspect_TOM_USERDEFINED:
s << "PointAspect: " << Quantity_Color::StringName(C.Name()) << " USERDEFINED " << S;
break;
default:
break;
}
}
void Prs3d_PointAspect::GetTextureSize(Standard_Integer& AWidth, Standard_Integer& AHeight)
{
myAspect->GetTextureSize( AWidth, AHeight);
}
const Handle(TColStd_HArray1OfByte)& Prs3d_PointAspect::GetTexture()
{
return myAspect->GetTexture();
}

13
src/Prs3d/Prs3d_PointTool.cdl Executable file
View File

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

0
src/Prs3d/Prs3d_PointTool.gxx Executable file
View File

126
src/Prs3d/Prs3d_Presentation.cdl Executable file
View File

@@ -0,0 +1,126 @@
-- File: Presentation.cdl
-- Created: Wed Aug 26 17:37:40 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
-- Modified: GG IMP020200 Add Transformation() method
---Copyright: Matra Datavision 1992
class Presentation from Prs3d inherits Structure from Graphic3d
---Purpose: Defines a presentation object which can be displayed,
-- highlighted or erased.
-- The presentation object stores the results of the
-- presentation algorithms as defined in the StdPrs
-- classes and the Prs3d classes inheriting Prs3d_Root.
-- This presentation object is used to give display
-- attributes defined at this level to
-- ApplicationInteractiveServices classes at the level above.
uses
Array2OfReal from TColStd,
DataStructureManager from Graphic3d,
Structure from Graphic3d,
StructureManager from Graphic3d,
Group from Graphic3d,
Transformation from Geom,
NameOfColor from Quantity,
Length from Quantity,
ShadingAspect from Prs3d
is
Create (aStructureManager: StructureManager from Graphic3d;
Init: Boolean from Standard = Standard_True)
---Purpose: Constructs a presentation object
-- if <Init> is false, no color initialization is done.
returns mutable Presentation from Prs3d;
Compute(me : mutable; aProjector: DataStructureManager from Graphic3d)
returns Structure from Graphic3d
is redefined virtual;
Compute ( me : mutable;
aProjector : DataStructureManager from Graphic3d;
AMatrix : Array2OfReal from TColStd )
returns Structure from Graphic3d is redefined virtual;
---Level: Advanced
---Purpose: Returns the new Structure defined for the new visualization
---Category: Methods to modify the class definition
Compute ( me : mutable;
aProjector : DataStructureManager from Graphic3d;
aStructure : in out Structure from Graphic3d )
is redefined virtual;
---Level: Advanced
---Purpose: Returns the new Structure defined for the new visualization
---Category: Methods to modify the class definition
Compute ( me : mutable;
aProjector : DataStructureManager from Graphic3d;
AMatrix : Array2OfReal from TColStd;
aStructure : in out Structure from Graphic3d )
is redefined virtual;
---Level: Advanced
---Purpose: Returns the new Structure defined for the new visualization
---Category: Methods to modify the class definition
---Category: Highlighting methods.
--
Highlight(me: mutable) is static;
---Purpose: displays the whole content of the presentation in white.
Color(me: mutable; aColor: NameOfColor from Quantity) is static;
---Purpose: displays the whole content of the presentation in the specified color.
BoundBox(me: mutable) is static;
Display ( me : mutable ) is redefined static;
---Category: Global modification methods.
SetShadingAspect(me: mutable; aShadingAspect: ShadingAspect from Prs3d);
---Category: Inquire methods.
IsPickable(me) returns Boolean from Standard;
---Category: Transformation methods.
Transform (me: mutable; aTransformation: Transformation from Geom);
Place (me: mutable; X,Y,Z: Length from Quantity);
Multiply (me: mutable; aTransformation: Transformation from Geom);
Move (me: mutable; X,Y,Z: Length from Quantity);
Transformation (me) returns Transformation from Geom;
Clear(me:mutable; WithDestruction: Boolean from Standard = Standard_True)
is redefined;
---Purpose: removes the whole content of the presentation.
-- Does not remove the other connected presentations.
-- if WithDestruction == Standard_False then
-- clears all the groups of primitives in the structure.
Connect(me: mutable; aPresentation: Presentation from Prs3d);
Remove (me: mutable; aPresentation: Presentation from Prs3d);
RemoveAll (me: mutable);
SetPickable(me: mutable) is static;
SetUnPickable(me: mutable) is static;
CurrentGroup(me) returns mutable Group from Graphic3d is static private;
NewGroup(me:mutable) returns mutable Group from Graphic3d is static private;
fields
myStruct : Structure from Graphic3d;
myCurrentGroup: Group from Graphic3d;
--
friends
class Root from Prs3d
end Presentation;

341
src/Prs3d/Prs3d_Presentation.cxx Executable file
View File

@@ -0,0 +1,341 @@
// Modified: 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
#define IMP020200 //GG Add Transformation() method
#include <Prs3d_Presentation.ixx>
#include <TColStd_Array2OfReal.hxx>
#include <Graphic3d_Structure.hxx>
#include <Aspect_TypeOfHighlightMethod.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <Standard_Real.hxx>
#include <Aspect_InteriorStyle.hxx>
#include <Aspect_TypeOfLine.hxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
#include <Aspect_PolygonOffsetMode.hxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
#include <Graphic3d_NameOfMaterial.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
static void MakeGraphicTrsf (const Handle(Geom_Transformation)& aGeomTrsf,
TColStd_Array2OfReal& Array){
for (Standard_Integer i=1; i<=3; i++){
for (Standard_Integer j=1; j<=4; j++){
Array.SetValue(i,j,aGeomTrsf->Value(i,j));
}
}
Array.SetValue(4,1,0.);
Array.SetValue(4,2,0.);
Array.SetValue(4,3,0.);
Array.SetValue(4,4,1.);
}
//=======================================================================
//function : Prs3d_Presentation
//purpose :
//=======================================================================
Prs3d_Presentation::Prs3d_Presentation
(const Handle(Graphic3d_StructureManager)& aViewer,
const Standard_Boolean Init):
Graphic3d_Structure(aViewer)
{
if (Init) {
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
Quantity_Color Col;
// Ceci permet de recuperer la couleur associee
// au materiau defini par defaut.
//POP pour K4L
Col = aMat.AmbientColor ();
// Col = aMat.Color ();
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
// It is necessary to set default polygon offsets for a new presentation
Handle(Graphic3d_AspectFillArea3d) aDefAspect =
new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
Col,
Col,
Aspect_TOL_SOLID,
1.0,
Graphic3d_NOM_BRASS,
Graphic3d_NOM_BRASS);
aDefAspect->SetPolygonOffsets( Aspect_POM_Fill, 1., 0. );
SetPrimitivesAspect( aDefAspect );
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
}
// myStruct = Handle(Graphic3d_Structure)::DownCast(This ());
// myCurrentGroup = new Graphic3d_Group(myStruct);
}
//=======================================================================
//function : Highlight
//purpose :
//=======================================================================
void Prs3d_Presentation::Highlight()
{
SetHighlightColor(Quantity_Color(Quantity_NOC_GRAY99));
Aspect_TypeOfHighlightMethod Method = Aspect_TOHM_COLOR;
Graphic3d_Structure::Highlight(Method);
}
//=======================================================================
//function : Color
//purpose :
//=======================================================================
void Prs3d_Presentation::Color(const Quantity_NameOfColor aColor)
{
SetHighlightColor(Quantity_Color(aColor));
Graphic3d_Structure::Highlight(Aspect_TOHM_COLOR);
}
//=======================================================================
//function : BoundBox
//purpose :
//=======================================================================
void Prs3d_Presentation::BoundBox()
{
SetHighlightColor(Quantity_Color(Quantity_NOC_GRAY99));
Graphic3d_Structure::Highlight(Aspect_TOHM_BOUNDBOX);
}
//=======================================================================
//function : SetShadingAspect
//purpose :
//=======================================================================
void Prs3d_Presentation::SetShadingAspect(const Handle(Prs3d_ShadingAspect)& aShadingAspect)
{
SetPrimitivesAspect(aShadingAspect->Aspect());
}
//=======================================================================
//function : IsPickable
//purpose :
//=======================================================================
Standard_Boolean Prs3d_Presentation::IsPickable () const
{
return Graphic3d_Structure::IsSelectable();
}
//=======================================================================
//function : SetPickable
//purpose :
//=======================================================================
void Prs3d_Presentation::SetPickable()
{
SetPick(Standard_True);
}
//=======================================================================
//function : SetUnPickable
//purpose :
//=======================================================================
void Prs3d_Presentation::SetUnPickable()
{
SetPick(Standard_False);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Prs3d_Presentation::Transform(const Handle(Geom_Transformation)& aTransformation)
{
TColStd_Array2OfReal Array (1,4,1,4);
MakeGraphicTrsf(aTransformation, Array);
SetTransform(Array, Graphic3d_TOC_REPLACE);
}
#ifdef IMP020200
//=======================================================================
//function : Transformation
//purpose :
//=======================================================================
Handle(Geom_Transformation) Prs3d_Presentation::Transformation() const {
TColStd_Array2OfReal matrix(1,4,1,4);
Graphic3d_Structure::Transform(matrix);
gp_Trsf trsf;
trsf.SetValues(
matrix.Value(1,1),matrix.Value(1,2),matrix.Value(1,3),matrix.Value(1,4),
matrix.Value(2,1),matrix.Value(2,2),matrix.Value(2,3),matrix.Value(2,4),
matrix.Value(3,1),matrix.Value(3,2),matrix.Value(3,3),matrix.Value(3,4),
0.001,0.0001);
Handle(Geom_Transformation) gtrsf = new Geom_Transformation(trsf);
return gtrsf;
}
#endif
//=======================================================================
//function : Place
//purpose :
//=======================================================================
void Prs3d_Presentation::Place (const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z)
{
Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
aTransformation->SetTranslation(gp_Vec(X,Y,Z));
TColStd_Array2OfReal Array (1,4,1,4);
MakeGraphicTrsf(aTransformation, Array);
SetTransform(Array, Graphic3d_TOC_REPLACE);
}
//=======================================================================
//function : Multiply
//purpose :
//=======================================================================
void Prs3d_Presentation::Multiply(const Handle(Geom_Transformation)& aTransformation)
{
TColStd_Array2OfReal Array (1,4,1,4);
MakeGraphicTrsf(aTransformation, Array);
SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
}
//=======================================================================
//function : Move
//purpose :
//=======================================================================
void Prs3d_Presentation::Move (const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z)
{
Handle(Geom_Transformation) aTransformation = new Geom_Transformation;
aTransformation->SetTranslation(gp_Vec(X,Y,Z));
TColStd_Array2OfReal Array (1,4,1,4);
MakeGraphicTrsf(aTransformation, Array);
SetTransform(Array, Graphic3d_TOC_POSTCONCATENATE);
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Prs3d_Presentation::Clear(const Standard_Boolean WithDestruction)
{
Graphic3d_Structure::Clear(WithDestruction);
// myCurrentGroup.Nullify();
myCurrentGroup = NULL;
}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void Prs3d_Presentation::Connect
( const Handle(Prs3d_Presentation)& aPresentation)
{
Graphic3d_Structure::Connect(aPresentation, Graphic3d_TOC_DESCENDANT);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void Prs3d_Presentation::Remove (const Handle(Prs3d_Presentation)& aPresentation)
{
Disconnect(aPresentation);
}
//=======================================================================
//function : RemoveAll
//purpose :
//=======================================================================
void Prs3d_Presentation::RemoveAll ()
{
DisconnectAll(Graphic3d_TOC_DESCENDANT);
}
//=======================================================================
//function : CurrentGroup
//purpose :
//=======================================================================
Handle(Graphic3d_Group) Prs3d_Presentation::CurrentGroup () const
{
if(myCurrentGroup.IsNull()){
void *ptr = (void*) this;
Prs3d_Presentation* p = (Prs3d_Presentation *)ptr;
p->NewGroup();
}
return myCurrentGroup;
}
//=======================================================================
//function : NewGroup
//purpose :
//=======================================================================
Handle(Graphic3d_Group) Prs3d_Presentation::NewGroup ()
{
myCurrentGroup = new Graphic3d_Group(this);
return myCurrentGroup;
}
//=======================================================================
//function : Display
//purpose :
//=======================================================================
void Prs3d_Presentation::Display ()
{
Graphic3d_Structure::Display();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
Handle(Graphic3d_Structure) Prs3d_Presentation::
Compute(const Handle(Graphic3d_DataStructureManager)& /*aProjector*/)
{
return this;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void Prs3d_Presentation::Compute(const Handle_Graphic3d_DataStructureManager& aDataStruct,
Handle_Graphic3d_Structure& aStruct)
{
Graphic3d_Structure::Compute(aDataStruct,aStruct );
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
Handle_Graphic3d_Structure Prs3d_Presentation::Compute(const Handle_Graphic3d_DataStructureManager& aDataStruc,
const TColStd_Array2OfReal& anArray)
{
return Graphic3d_Structure::Compute(aDataStruc,anArray);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void Prs3d_Presentation::Compute(const Handle_Graphic3d_DataStructureManager& aDataStruc,
const TColStd_Array2OfReal& anArray,
Handle_Graphic3d_Structure& aStruc)
{
Graphic3d_Structure::Compute(aDataStruc,anArray,aStruc);
}

46
src/Prs3d/Prs3d_Projector.cdl Executable file
View File

@@ -0,0 +1,46 @@
-- File: Prs3d_Projector.cdl
-- Created: Fri Mar 19 09:51:20 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
class Projector from Prs3d inherits TShared from MMgt
---Purpose: A projector object.
-- This object defines the parameters of a view for a
-- visualization algorithm. It is, for example, used by the
-- hidden line removal algorithms.
uses
Projector from HLRAlgo,
Length from Quantity
is
Create(Pr: Projector from HLRAlgo)
returns mutable Projector from Prs3d;
Create ( Pers: Boolean from Standard;
Focus: Length from Quantity;
DX, DY, DZ: Length from Quantity; -- Projection Vector
XAt, YAt , ZAt: Length from Quantity; -- View Point
XUp, YUp, ZUp: Length from Quantity) -- High Point Direction
returns mutable Projector from Prs3d;
--- Purpose: Constructs a projector framework from the following parameters
-- - Pers is true if the view is a perspective view and
-- false if it is an axonometric one;
-- - Focus is the focal length if a perspective view is defined;
-- - DX, DY and DZ are the coordinates of the
-- projection vector;
-- - XAt, YAt and ZAt are the coordinates of the view point;
-- - XUp, YUp and ZUp are the coordinates of the
-- vertical direction vector.
Projector(me) returns Projector from HLRAlgo
is static;
---Purpose: Returns a projector object for use in a hidden line removal algorithm.
fields
MyProjector: Projector from HLRAlgo;
end Projector;

39
src/Prs3d/Prs3d_Projector.cxx Executable file
View File

@@ -0,0 +1,39 @@
#include <Prs3d_Projector.ixx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
Prs3d_Projector::Prs3d_Projector (const HLRAlgo_Projector& HLPr): MyProjector(HLPr)
{}
Prs3d_Projector::Prs3d_Projector (const Standard_Boolean Pers,
const Quantity_Length Focus,
const Quantity_Length DX,
const Quantity_Length DY,
const Quantity_Length DZ,
const Quantity_Length XAt,
const Quantity_Length YAt,
const Quantity_Length ZAt,
const Quantity_Length XUp,
const Quantity_Length YUp,
const Quantity_Length ZUp)
{
gp_Pnt At (XAt,YAt,ZAt);
gp_Dir Zpers (DX,DY,DZ);
gp_Dir Ypers (XUp,YUp,ZUp);
gp_Dir Xpers = Ypers.Crossed(Zpers);
gp_Ax3 Axe (At, Zpers, Xpers);
gp_Trsf T;
T.SetTransformation(Axe);
MyProjector = HLRAlgo_Projector(T,Pers,Focus);
}
HLRAlgo_Projector Prs3d_Projector::Projector () const
{
return MyProjector;
}

View File

@@ -0,0 +1,32 @@
-- File: Prs3d_RadiusAspect.cdl
-- Created: Thu Jun 3 09:28:46 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class RadiusAspect from Prs3d inherits CompositeAspect from Prs3d
---Purpose: defines the attributes when drawing a Radius Presentation.
uses
AspectLine3d from Graphic3d,
NameOfColor from Quantity,
TypeOfLine from Aspect
is
--
-- Attributes for the lines.
--
Create (aColor: NameOfColor from Quantity;
aType: TypeOfLine from Aspect;
aWidth: Real from Standard)
returns mutable RadiusAspect from Prs3d;
---Purpose: Constructs the framework to define the display of radii.
-- This consists of the attributes:
-- - the color aColor
-- - the type of line aType and
-- - the width aWidth of the line.
end RadiusAspect from Prs3d;

View File

@@ -0,0 +1,6 @@
#include <Prs3d_RadiusAspect.ixx>
Prs3d_RadiusAspect::Prs3d_RadiusAspect(const Quantity_NameOfColor aColor,
const Aspect_TypeOfLine aType,
const Standard_Real aWidth) {
}

View File

@@ -0,0 +1,30 @@
-- File: Prs3d_RestrictionTool.cdl
-- Created: Mon Feb 15 11:20:54 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
generic class RestrictionTool from Prs3d ( Patch as any; Curve2d as any)
uses
Orientation from TopAbs
is
Create returns RestrictionTool;
Create ( ThePatch: Patch ) returns RestrictionTool;
IsOriented (me) returns Boolean from Standard;
Init(me: in out);
More(me) returns Boolean from Standard;
Next(me: in out);
Value(me) returns Curve2d;
Orientation(me) returns Orientation from TopAbs;
end RestrictionTool from Prs3d;

View File

30
src/Prs3d/Prs3d_Root.cdl Executable file
View File

@@ -0,0 +1,30 @@
-- File: Prs3d_Root.cdl
-- Created: Tue Dec 15 18:07:36 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
deferred class Root from Prs3d
---Purpose: A root class for the standard presentation algorithms
-- of the StdPrs package.
--
uses
Presentation from Prs3d,
Structure from Graphic3d,
Group from Graphic3d
is
CurrentGroup(myclass; Prs3d: Presentation from Prs3d) returns Group from Graphic3d;
---Purpose: Returns the current group of primititves inside graphic
-- objects in the display.
-- A group also contains the attributes whose ranges are
-- limited to the primitives in it.
NewGroup (myclass; Prs3d: Presentation from Prs3d ) returns Group from Graphic3d ;
---Purpose: Returns the new group of primitives inside graphic
-- objects in the display.
-- A group also contains the attributes whose ranges are limited to the primitives in it.
end Root from Prs3d;

10
src/Prs3d/Prs3d_Root.cxx Executable file
View File

@@ -0,0 +1,10 @@
#include <Prs3d_Root.ixx>
Handle (Graphic3d_Group) Prs3d_Root::CurrentGroup (const Handle (Prs3d_Presentation)& Prs3d)
{
return Prs3d->CurrentGroup();
}
Handle (Graphic3d_Group) Prs3d_Root::NewGroup (const Handle (Prs3d_Presentation)& Prs3d)
{
return Prs3d->NewGroup();
}

View File

@@ -0,0 +1,23 @@
-- File: Prs3d_SectionShapeTool.cdl
-- Created: Wed Oct 20 12:58:38 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
generic class SectionShapeTool from Prs3d ( anyShape as any;
anyEdge as any)
uses
Pln from gp
is
Create ( TheShape: anyShape ) returns SectionShapeTool from Prs3d;
Load(me: in out; aPlane: Pln from gp);
InitEdge (me);
MoreEdge (me) returns Boolean from Standard;
NextEdge (me);
GetEdge(me) returns anyEdge;
end SectionShapeTool from Prs3d;

View File

28
src/Prs3d/Prs3d_ShadedShape.cdl Executable file
View File

@@ -0,0 +1,28 @@
-- File: ShadedShape.cdl
-- Created: Thu Sep 23 18:12:33 1993
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
generic class ShadedShape from Prs3d(anyShape as any;
anyTopFace as any;
anyMeshTriangle as any;
anyMeshEdge as any;
anyShadedShapeTool as any
)
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aShape : anyShape;
aDrawer : Drawer from Prs3d);
---Purpose: Shades <aShape>.
end ShadedShape from Prs3d;

337
src/Prs3d/Prs3d_ShadedShape.gxx Executable file
View File

@@ -0,0 +1,337 @@
// File: Prs3d_ShadedShape.gxx
// Created: Thu Sep 23 18:47:22 1993
// Author: Jean-Louis FRENKEL
// <jlf@stylox>
//#define BUC60488//GG_081199 Enable the SuppressBackface() ShadingAspect attribute
#define G005 //ATS,GG 04/01/01 Use ArrayOfPrimitives instead Sets of primitives
// for performance improvment
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_VertexN.hxx>
#include <Graphic3d_Array1OfVertexN.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Aspect_Edge.hxx>
#include <Aspect_Array1OfEdge.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Graphic3d_Group.hxx>
#include <Aspect_TypeOfEdge.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfDir.hxx>
#include <Poly_Connect.hxx>
#include <TopAbs_Orientation.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <BRepMesh_FactoryError.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <BRepMesh_DiscretFactory.hxx>
#include <BRepMesh_PDiscretRoot.hxx>
#include <gp_Vec.hxx>
#include <StdPrs_WFShape.hxx>
#include <BRepBndLib.hxx>
#include <Precision.hxx>
#ifdef G005
#include <Graphic3d_ArrayOfTriangles.hxx>
#endif
#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
static Standard_Real GetDeflection(const anyShape& aShape,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Real aDeflection;
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
Bnd_Box B;
BRepBndLib::Add(aShape, B);
if ( ! B.IsVoid() )
{
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
* aDrawer->DeviationCoefficient()*4;
}
else
aDeflection = aDrawer->MaximalChordialDeviation();
}
else
aDeflection = aDrawer->MaximalChordialDeviation();
return aDeflection;
}
static Standard_Boolean ShadeFromShape(const anyShape& aShape,
const Standard_Real /*defle*/,
const Standard_Boolean /*share*/,
const Handle (Prs3d_Presentation)& aPresentation,
const Handle (Prs3d_Drawer)& aDrawer)
{
anyShadedShapeTool SST;
Handle(Poly_Triangulation) T;
TopLoc_Location loc;
gp_Pnt p;
Standard_Integer i,j,k,decal ;
Standard_Integer t[3], n[3];
Standard_Integer nbTriangles = 0, nbVertices = 0;
// precision for compare square distances
double dPreci = Precision::Confusion()*Precision::Confusion();
if ( !aDrawer->ShadingAspectGlobal() ) {
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
if(anyShadedShapeTool::IsClosed(aShape)) {
Asp->SuppressBackFace();
} else {
Asp->AllowBackFace();
}
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
}
#ifdef G005
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
nbTriangles += T->NbTriangles();
nbVertices += T->NbNodes();
}
}
if (nbVertices > 2 && nbTriangles > 0) {
Handle(Graphic3d_ArrayOfTriangles) parray =
new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
Standard_True,Standard_False,Standard_False,Standard_True);
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
const gp_Trsf& trsf = loc.Transformation();
Poly_Connect pc(T);
// Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& Nodes = T->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
SST.Normal(F, pc, NORMAL);
decal = parray->VertexNumber();
for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
p = Nodes(i);
if( !loc.IsIdentity() ) {
p.Transform(trsf);
NORMAL(i).Transform(trsf);
}
parray->AddVertex(p,NORMAL(i));
}
// Fill parray with vertex and edge visibillity info
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= T->NbTriangles(); i++) {
pc.Triangles(i,t[0],t[1],t[2]);
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(i).Get(n[0],n[2],n[1]);
else
triangles(i).Get(n[0],n[1],n[2]);
gp_Pnt P1 = Nodes(n[0]);
gp_Pnt P2 = Nodes(n[1]);
gp_Pnt P3 = Nodes(n[2]);
gp_Vec V1(P1,P2);
if ( V1.SquareMagnitude() > dPreci ) {
gp_Vec V2(P2,P3);
if ( V2.SquareMagnitude() > dPreci ) {
gp_Vec V3(P3,P1);
if ( V3.SquareMagnitude() > dPreci ) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if ( V1.SquareMagnitude() > dPreci ) {
parray->AddEdge(n[0]+decal,t[0] == 0);
parray->AddEdge(n[1]+decal,t[1] == 0);
parray->AddEdge(n[2]+decal,t[2] == 0);
}
}
}
}
}
}
}
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
}
return Standard_True;
}
#endif
// phase de comptage:
Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
static Standard_Integer plus1mod3[3] = {1, 2, 0};
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
nnn = T->NbTriangles();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (nt = 1; nt <= nnn; nt++) {
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(nt).Get(n1,n3,n2);
else
triangles(nt).Get(n1,n2,n3);
const gp_Pnt& P1 = Nodes(n1);
const gp_Pnt& P2 = Nodes(n2);
const gp_Pnt& P3 = Nodes(n3);
gp_Vec V1(P1,P2);
if ( V1.SquareMagnitude() > dPreci ) {
gp_Vec V2(P2,P3);
if (V2.SquareMagnitude() > dPreci ) {
gp_Vec V3(P3,P1);
if (V3.SquareMagnitude() > dPreci ) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if (V1.SquareMagnitude() > dPreci ) {
nbTriangles++;
}
}
}
}
}
nbVertices += T->NbNodes();
}
}
if (nbVertices > 2 && nbTriangles > 0) {
Graphic3d_Array1OfVertexN AVN(1, nbVertices);
Aspect_Array1OfEdge AE(1, 3*nbTriangles);
EI = 1;
nnv = 1;
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
Poly_Connect pc(T);
// 1- les noeuds.
const TColgp_Array1OfPnt& Nodes = T->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
SST.Normal(F, pc, NORMAL);
decal = nnv-1;
for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
p = Nodes(j).Transformed(loc.Transformation());
AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
nnv++;
}
// 2- les edges.
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(i).Get(n[0],n[2],n[1]);
else
triangles(i).Get(n[0],n[1],n[2]);
const gp_Pnt& P1 = Nodes(n[0]);
const gp_Pnt& P2 = Nodes(n[1]);
const gp_Pnt& P3 = Nodes(n[2]);
gp_Vec V1(P1,P2);
if (V1.SquareMagnitude() > 1.e-10) {
gp_Vec V2(P2,P3);
if (V2.SquareMagnitude() > 1.e-10) {
gp_Vec V3(P3,P1);
if (V3.SquareMagnitude() > 1.e-10) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if (V1.SquareMagnitude() > 1.e-10) {
for (j = 0; j < 3; j++) {
k = plus1mod3[j];
if (t[j] == 0)
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
else
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
EI++;
}
}
}
}
}
}
}
}
Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
}
return Standard_True;
}
void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const anyShape& aShape,
const Handle (Prs3d_Drawer)& aDrawer)
{
if (aShape.IsNull()) return;
TopAbs_ShapeEnum E = aShape.ShapeType();
if (E == TopAbs_COMPOUND) {
TopExp_Explorer ex;
ex.Init(aShape, TopAbs_FACE);
if (ex.More()) {
TopoDS_Compound CO;
BRep_Builder B;
B.MakeCompound(CO);
Standard_Boolean haselement = Standard_False;
// il faut presenter les edges isoles.
for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
haselement = Standard_True;
B.Add(CO, ex.Current());
}
// il faut presenter les vertex isoles.
for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
haselement = Standard_True;
B.Add(CO, ex.Current());
}
if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
}
else {
StdPrs_WFShape::Add(aPresentation, aShape, aDrawer);
}
}
Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
//using of plugin
BRepMesh_PDiscretRoot pAlgo;
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape,
aDeflection,
aDrawer->HLRAngle());
if (pAlgo)
pAlgo->Perform();
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
}

View File

@@ -0,0 +1,82 @@
-- File: Prs3d_ShadingAspect.cdl
-- Created: Mon Apr 26 16:18:12 1993
-- Author: Jean-Louis Frenkel
-- <jlf@phylox>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
-- Parameters the color model rule (not especially the front & back side)
-- Add the SetTransparency() method.
-- Add the Color(),Material() and Transparency() methods
---Copyright: Matra Datavision 1993
class ShadingAspect from Prs3d inherits BasicAspect from Prs3d
---Purpose: A framework to define the display of shading.
-- The attributes which make up this definition include:
-- - fill aspect
-- - color, and
-- - material
uses
TypeOfFacingModel from Aspect,
AspectFillArea3d from Graphic3d,
NameOfColor from Quantity,
Color from Quantity,
NameOfMaterial from Graphic3d,
--NameOfMaterialPhysic from Graphic3d,
MaterialAspect from Graphic3d,
TypeOfLine from Aspect
is
Create
---Purpose: Constructs an empty framework to display shading.
returns mutable ShadingAspect from Prs3d;
SetColor (me: mutable; aColor: Color from Quantity;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE)
is static;
--- Purpose: Change the polygons interior color and material ambient color.
SetColor (me: mutable; aColor: NameOfColor from Quantity;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE)
is static;
--- Purpose: Change the polygons interior color and material ambient color.
SetMaterial(me: mutable; aMaterial: MaterialAspect from Graphic3d;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE)
is static;
--- Purpose: Change the polygons material aspect.
SetMaterial(me: mutable; aMaterial: NameOfMaterial from Graphic3d;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE)
is static;
SetTransparency(me: mutable; aValue: Real from Standard;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE)
is static;
--- Purpose: Change the polygons transparency value.
-- Warning : aValue must be in the range 0,1. 0 is the default (NO transparent)
SetAspect(me:mutable; Asp : AspectFillArea3d from Graphic3d);
--- Purpose: Change the polygons aspect properties.
Color (me; aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_FRONT_SIDE)
returns Color from Quantity is static;
--- Purpose: Returns the polygons color.
Material (me; aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_FRONT_SIDE)
returns MaterialAspect from Graphic3d is static;
--- Purpose: Returns the polygons material aspect.
Transparency (me; aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_FRONT_SIDE)
returns Real from Standard is static;
--- Purpose: Returns the polygons transparency value.
Aspect (me) returns AspectFillArea3d from Graphic3d;
--- Purpose: Returns the polygons aspect properties.
fields
myAspect: AspectFillArea3d from Graphic3d;
end ShadingAspect from Prs3d;

225
src/Prs3d/Prs3d_ShadingAspect.cxx Executable file
View File

@@ -0,0 +1,225 @@
#define BUC60488 //GG_23/09/99 Updates correctly the Material after
// any change.
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
// Enable to change separatly the front and back color.
#define OCC1174 //SAV_080103 Added back face interior color management
#include <Prs3d_ShadingAspect.ixx>
//=======================================================================
//function : Prs3d_ShadingAspect
//purpose :
//=======================================================================
Prs3d_ShadingAspect::Prs3d_ShadingAspect () {
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
Quantity_Color Col;
// Ceci permet de recuperer la couleur associee
// au materiau defini par defaut.
//POP K4L
Col = aMat.AmbientColor ();
// Col = aMat.Color ();
myAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
Col,
Col,
Aspect_TOL_SOLID,
1.0,
aMat,
aMat);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
#ifdef GER61351
void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor,
const Aspect_TypeOfFacingModel aModel) {
SetColor(Quantity_Color(aColor),aModel);
}
void Prs3d_ShadingAspect::SetColor(const Quantity_Color &aColor,
const Aspect_TypeOfFacingModel aModel) {
#ifndef OCC1174
myAspect->SetInteriorColor(aColor);
#endif
if( aModel != Aspect_TOFM_BOTH_SIDE ) {
myAspect->SetDistinguishOn();
}
if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
front.SetColor(aColor);
myAspect->SetFrontMaterial(front);
#ifdef OCC1174
myAspect->SetInteriorColor( aColor );
#endif
}
if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
Graphic3d_MaterialAspect back = myAspect->BackMaterial();
back.SetColor(aColor);
myAspect->SetBackMaterial(back);
#ifdef OCC1174
myAspect->SetBackInteriorColor( aColor );
#endif
}
}
Quantity_Color Prs3d_ShadingAspect::Color( const Aspect_TypeOfFacingModel aModel ) const {
Quantity_Color myReturn ;
switch (aModel) {
default:
case Aspect_TOFM_BOTH_SIDE:
case Aspect_TOFM_FRONT_SIDE:
myReturn = myAspect->FrontMaterial().Color();
break;
case Aspect_TOFM_BACK_SIDE:
myReturn = myAspect->BackMaterial().Color();
break;
}
return myReturn ;
}
#else
void Prs3d_ShadingAspect::SetColor(const Quantity_NameOfColor aColor) {
myAspect->SetInteriorColor(aColor);
#ifdef OCC1174
myAspect->SetBackInteriorColor( aColor );
#endif
myAspect->FrontMaterial().SetAmbientColor(Quantity_Color(aColor));
myAspect->BackMaterial().SetAmbientColor(Quantity_Color(aColor));
// myAspect->FrontMaterial().SetColor(Quantity_Color(aColor));
// myAspect->BackMaterial().SetColor(Quantity_Color(aColor));
}
#endif
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
#ifdef GER61351
void Prs3d_ShadingAspect::SetMaterial(
const Graphic3d_NameOfMaterial aMaterial,
const Aspect_TypeOfFacingModel aModel ) {
SetMaterial(Graphic3d_MaterialAspect(aMaterial),aModel);
}
#else
void Prs3d_ShadingAspect::SetMaterial(
// const Graphic3d_NameOfPhysicalMaterial aMaterial) {
const Graphic3d_NameOfMaterial aMaterial) {
Graphic3d_MaterialAspect TheMaterial(aMaterial);
myAspect->SetFrontMaterial (TheMaterial);
myAspect->SetBackMaterial (TheMaterial);
}
#endif
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
#ifdef GER61351
void Prs3d_ShadingAspect::SetMaterial(
const Graphic3d_MaterialAspect& aMaterial,
const Aspect_TypeOfFacingModel aModel ) {
if( aModel != Aspect_TOFM_BOTH_SIDE ) {
myAspect->SetDistinguishOn();
}
if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
myAspect->SetFrontMaterial(aMaterial);
}
if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
myAspect->SetBackMaterial(aMaterial);
}
}
Graphic3d_MaterialAspect Prs3d_ShadingAspect::Material(
const Aspect_TypeOfFacingModel aModel ) const {
Graphic3d_MaterialAspect myReturn ;
switch (aModel) {
default:
case Aspect_TOFM_BOTH_SIDE:
case Aspect_TOFM_FRONT_SIDE:
myReturn = myAspect->FrontMaterial();
break;
case Aspect_TOFM_BACK_SIDE:
myReturn = myAspect->BackMaterial();
break;
}
return myReturn ;
}
#else
void Prs3d_ShadingAspect::SetMaterial(
const Graphic3d_MaterialAspect& aMaterial)
{
myAspect->SetFrontMaterial (aMaterial);
myAspect->SetBackMaterial (aMaterial);
}
#endif
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
#ifdef GER61351
void Prs3d_ShadingAspect::SetTransparency(const Standard_Real aValue,
const Aspect_TypeOfFacingModel aModel ) {
if( aModel != Aspect_TOFM_BOTH_SIDE ) {
myAspect->SetDistinguishOn();
}
if( aModel == Aspect_TOFM_FRONT_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
Graphic3d_MaterialAspect front = myAspect->FrontMaterial();
front.SetTransparency(aValue);
myAspect->SetFrontMaterial(front);
}
if( aModel == Aspect_TOFM_BACK_SIDE || aModel == Aspect_TOFM_BOTH_SIDE ) {
Graphic3d_MaterialAspect back = myAspect->BackMaterial();
back.SetTransparency(aValue);
myAspect->SetBackMaterial(back);
}
}
Standard_Real Prs3d_ShadingAspect::Transparency(const Aspect_TypeOfFacingModel aModel ) const {
Standard_Real aValue(0.);
switch (aModel) {
case Aspect_TOFM_BOTH_SIDE:
case Aspect_TOFM_FRONT_SIDE:
aValue = myAspect->FrontMaterial().Transparency();
case Aspect_TOFM_BACK_SIDE:
aValue = myAspect->BackMaterial().Transparency();
}
return aValue;
}
#endif
//=======================================================================
//function : SetAspect
//purpose :
//=======================================================================
void Prs3d_ShadingAspect::SetAspect(const Handle(Graphic3d_AspectFillArea3d)& Asp)
{
myAspect=Asp;
}
Handle (Graphic3d_AspectFillArea3d) Prs3d_ShadingAspect::Aspect () const {
return myAspect;
}

78
src/Prs3d/Prs3d_ShapeTool.cdl Executable file
View File

@@ -0,0 +1,78 @@
-- File: Prs3d_ShapeTool.cdl
-- Created: Wed Jan 27 14:23:39 1993
-- Author: Jean-Louis Frenkel
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
class ShapeTool from Prs3d
uses
Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
HSequenceOfShape from TopTools,
Box from Bnd,
Location from TopLoc,
Triangulation from Poly,
PolygonOnTriangulation from Poly,
Polygon3D from Poly,
HArray1OfInteger from TColStd,
Explorer from TopExp,
IndexedDataMapOfShapeListOfShape from TopTools,
IndexedMapOfShape from TopTools
---Purpose:
is
Create ( TheShape: Shape from TopoDS) returns ShapeTool from Prs3d;
InitFace (me: in out);
MoreFace (me) returns Boolean from Standard;
NextFace (me: in out);
GetFace(me) returns Face from TopoDS;
---C++: return const&
FaceBound(me) returns Box from Bnd;
IsPlanarFace(me) returns Boolean from Standard;
InitCurve (me: in out);
MoreCurve (me) returns Boolean from Standard;
NextCurve (me: in out);
GetCurve(me) returns Edge from TopoDS;
---C++: return const&
CurveBound(me) returns Box from Bnd;
Neighbours(me) returns Integer from Standard;
FacesOfEdge(me) returns HSequenceOfShape from TopTools;
InitVertex(me: in out);
MoreVertex(me) returns Boolean from Standard;
NextVertex(me: in out);
GetVertex(me) returns Vertex from TopoDS;
---C++: return const&
HasSurface(me) returns Boolean;
CurrentTriangulation(me; l: out Location from TopLoc)
returns Triangulation from Poly;
HasCurve(me) returns Boolean;
PolygonOnTriangulation(me; Indices: out PolygonOnTriangulation from Poly;
T: out Triangulation from Poly;
l: out Location from TopLoc);
Polygon3D(me; l: out Location from TopLoc)
returns Polygon3D from Poly;
fields
myShape: Shape from TopoDS;
myFaceExplorer: Explorer from TopExp;
myEdgeMap: IndexedDataMapOfShapeListOfShape from TopTools;
myVertexMap: IndexedMapOfShape from TopTools;
myEdge : Integer from Standard;
myVertex : Integer from Standard;
end ShapeTool from Prs3d;

344
src/Prs3d/Prs3d_ShapeTool.cxx Executable file
View File

@@ -0,0 +1,344 @@
// File: Prs3d_ShapeTool.cxx
// Created: Mon Aug 7 10:48:43 1995
// Author: Modelistation
// <model@metrox>
#define OCC215 //SAV: 01/04/02 vertex exploring is done for all types of shape.
#define OCC598 //SAV: 22/10/02 searching for internal vertices.
#include <Prs3d_ShapeTool.ixx>
#include <BRepTools.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <BRepBndLib.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Bnd_Box.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Plane.hxx>
//=======================================================================
//function : Prs3d_ShapeTool
//purpose :
//=======================================================================
Prs3d_ShapeTool::Prs3d_ShapeTool(const TopoDS_Shape& TheShape):
myShape (TheShape)
{
myEdgeMap.Clear();
myVertexMap.Clear();
TopExp::MapShapesAndAncestors(TheShape,TopAbs_EDGE,TopAbs_FACE,myEdgeMap);
#ifndef OCC215
// find vertices not under ancestors.
TopAbs_ShapeEnum E = TheShape.ShapeType();
// this check were done to reduce the number of selectable objects
// in a local context. By now, there's no noticeable performance improvement.
if (E != TopAbs_SOLID && E != TopAbs_SHELL)
#endif
{
TopExp_Explorer ex(TheShape,TopAbs_VERTEX, TopAbs_EDGE);
while (ex.More()) {
const TopoDS_Shape& aV=ex.Current();
myVertexMap.Add(aV);
ex.Next();
}
}
#ifdef OCC598
TopExp_Explorer edges( TheShape, TopAbs_EDGE );
while( edges.More() ) {
//xf
const TopoDS_Shape& aE= edges.Current();
TopoDS_Iterator aIt(aE, Standard_False, Standard_True);
while( aIt.More() ) {
const TopoDS_Shape& aV=aIt.Value();
if (aV.Orientation()==TopAbs_INTERNAL) {
myVertexMap.Add(aV);
}
aIt.Next();
}
/*
TopExp_Explorer vertices( edges.Current(), TopAbs_VERTEX );
while( vertices.More() ) {
TopoDS_Vertex current = TopoDS::Vertex( vertices.Current() );
if ( current.Orientation() == TopAbs_INTERNAL )
myVertexMap.Add( current );
vertices.Next();
}
*/
//xt
edges.Next();
}
#endif
}
//=======================================================================
//function : InitFace
//purpose :
//=======================================================================
void Prs3d_ShapeTool::InitFace()
{
myFaceExplorer.Init(myShape,TopAbs_FACE);
}
//=======================================================================
//function : MoreFace
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::MoreFace() const
{
return myFaceExplorer.More();
}
//=======================================================================
//function : NextFace
//purpose :
//=======================================================================
void Prs3d_ShapeTool::NextFace()
{
myFaceExplorer.Next();
}
//=======================================================================
//function : GetFace
//purpose :
//=======================================================================
const TopoDS_Face& Prs3d_ShapeTool::GetFace () const
{
return TopoDS::Face(myFaceExplorer.Current());
}
//=======================================================================
//function : FaceBound
//purpose :
//=======================================================================
Bnd_Box Prs3d_ShapeTool::FaceBound() const
{
const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current());
Bnd_Box B;
BRepBndLib::Add(F, B);
return B;
}
//=======================================================================
//function : IsPlanarFace
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::IsPlanarFace() const
{
TopLoc_Location l;
const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current());
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F, l);
Handle(Standard_Type) TheType = S->DynamicType();
if (TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
Handle(Geom_RectangularTrimmedSurface)
RTS = *((Handle(Geom_RectangularTrimmedSurface)*)&S);
TheType = RTS->BasisSurface()->DynamicType();
}
return (TheType == STANDARD_TYPE(Geom_Plane));
}
//=======================================================================
//function : InitCurve
//purpose :
//=======================================================================
void Prs3d_ShapeTool::InitCurve()
{
myEdge = 1;
}
//=======================================================================
//function : MoreCurve
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::MoreCurve() const
{
return myEdge <= myEdgeMap.Extent();
}
//=======================================================================
//function : NextCurve
//purpose :
//=======================================================================
void Prs3d_ShapeTool::NextCurve()
{
myEdge++;
}
//=======================================================================
//function : GetCurve
//purpose :
//=======================================================================
const TopoDS_Edge& Prs3d_ShapeTool::GetCurve () const
{
return TopoDS::Edge(myEdgeMap.FindKey(myEdge));
}
//=======================================================================
//function : CurveBound
//purpose :
//=======================================================================
Bnd_Box Prs3d_ShapeTool::CurveBound () const
{
const TopoDS_Edge& E = TopoDS::Edge(myEdgeMap.FindKey(myEdge));
Bnd_Box B;
BRepBndLib::Add(E, B);
return B;
}
//=======================================================================
//function : Neighbours
//purpose :
//=======================================================================
Standard_Integer Prs3d_ShapeTool::Neighbours () const
{
const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
return L.Extent();
}
//=======================================================================
//function : FacesOfEdge
//purpose :
//=======================================================================
Handle(TopTools_HSequenceOfShape) Prs3d_ShapeTool::FacesOfEdge () const
{
Handle(TopTools_HSequenceOfShape) H = new TopTools_HSequenceOfShape;
const TopTools_ListOfShape& L = myEdgeMap.FindFromIndex(myEdge);
TopTools_ListIteratorOfListOfShape LI;
for (LI.Initialize(L); LI.More(); LI.Next()) H->Append(LI.Value());
return H;
}
//=======================================================================
//function : InitVertex
//purpose :
//=======================================================================
void Prs3d_ShapeTool::InitVertex()
{
myVertex = 1;
}
//=======================================================================
//function : MoreVertex
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::MoreVertex() const
{
return myVertex <= myVertexMap.Extent();
}
//=======================================================================
//function : NextVertex
//purpose :
//=======================================================================
void Prs3d_ShapeTool::NextVertex()
{
myVertex++;
}
//=======================================================================
//function : GetVertex
//purpose :
//=======================================================================
const TopoDS_Vertex& Prs3d_ShapeTool::GetVertex () const
{
return TopoDS::Vertex(myVertexMap.FindKey(myVertex));
}
//=======================================================================
//function : HasSurface
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::HasSurface() const
{
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(GetFace(), l);
return (!S.IsNull());
}
//=======================================================================
//function : CurrentTriangulation
//purpose :
//=======================================================================
Handle(Poly_Triangulation) Prs3d_ShapeTool::CurrentTriangulation(TopLoc_Location& l) const
{
return BRep_Tool::Triangulation(GetFace(), l);
}
//=======================================================================
//function : HasCurve
//purpose :
//=======================================================================
Standard_Boolean Prs3d_ShapeTool::HasCurve() const
{
return (BRep_Tool::IsGeometric(GetCurve()));
}
//=======================================================================
//function : PolygonOnTriangulation
//purpose :
//=======================================================================
void Prs3d_ShapeTool::PolygonOnTriangulation
(Handle(Poly_PolygonOnTriangulation)& Indices,
Handle(Poly_Triangulation)& T,
TopLoc_Location& l) const
{
BRep_Tool::PolygonOnTriangulation(GetCurve(), Indices, T, l);
}
//=======================================================================
//function : Polygon3D
//purpose :
//=======================================================================
Handle(Poly_Polygon3D) Prs3d_ShapeTool::Polygon3D(TopLoc_Location& l) const
{
return BRep_Tool::Polygon3D(GetCurve(), l);
}

47
src/Prs3d/Prs3d_Text.cdl Executable file
View File

@@ -0,0 +1,47 @@
-- File: Prs3d_Text.cdl
-- Created: Tue Sep 14 12:58:46 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
---Copyright: Matra Datavision 1993
class Text from Prs3d inherits Root from Prs3d
--- Purpose: A framework to define the display of texts.
uses
Presentation from Prs3d,
Pnt from gp,
Drawer from Prs3d,
TextAspect from Prs3d,
ExtendedString from TCollection
is
Draw(myclass; aPresentation: Presentation from Prs3d;
aDrawer: Drawer from Prs3d;
aText: ExtendedString from TCollection;
AttachmentPoint: Pnt from gp);
---Purpose: Defines the display of the text aText at the point AttachmentPoint.
-- The drawer aDrawer specifies the display attributes which texts will have.
-- The presentation object aPresentation stores the
-- information defined in this framework.
-- static void Draw (const Handle(Prs3d_Presentation)&
-- aPresentation, const Handle(Prs3d_TextAspect)&
-- anAspect, const TCollection_ExtendedString& aText,
-- const gp_Pnt& AttachmentPoint);
Draw(myclass; aPresentation: Presentation from Prs3d;
anAspect: TextAspect from Prs3d;
aText: ExtendedString from TCollection;
AttachmentPoint: Pnt from gp);
---Purpose: Defines the display of the text aText at the point
-- AttachmentPoint.
-- The text aspect object anAspect specifies the display
-- attributes which texts will have.
-- The presentation object aPresentation stores the
-- information defined in this framework.
-- This syntax could be used if you had not already
-- defined text display attributes in a drawer or if you
-- wanted to exceptionally overide the definition
-- provided in your drawer.
end Text from Prs3d;

46
src/Prs3d/Prs3d_Text.cxx Executable file
View File

@@ -0,0 +1,46 @@
// File: Prs3d_Text.cxx
// Created: Tue Sep 14 14:52:34 1993
// Author: Jean-Louis FRENKEL
// <jlf@stylox>
#include <Prs3d_Text.ixx>
#include <Graphic3d_Vertex.hxx>
#include <Prs3d_TextAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_Group.hxx>
void Prs3d_Text::Draw (
const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Prs3d_TextAspect)& anAspect,
const TCollection_ExtendedString& aText,
const gp_Pnt& AttachmentPoint) {
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(anAspect->Aspect());
Standard_Real x,y,z;
AttachmentPoint.Coord(x,y,z);
// POP Graphic3d_Grup accepte de l'extended
Prs3d_Root::CurrentGroup(aPresentation)->Text(
// TCollection_AsciiString(aText).ToCString(),
aText,
Graphic3d_Vertex(x,y,z),
anAspect->Height(),
anAspect->Angle(),
anAspect->Orientation(),
anAspect->HorizontalJustification(),
anAspect->VerticalJustification());
}
void Prs3d_Text::Draw (
const Handle(Prs3d_Presentation)& aPresentation,
const Handle(Prs3d_Drawer)& aDrawer,
const TCollection_ExtendedString& aText,
const gp_Pnt& AttachmentPoint) {
Prs3d_Text::Draw(aPresentation,aDrawer->TextAspect(),aText,AttachmentPoint);
}

111
src/Prs3d/Prs3d_TextAspect.cdl Executable file
View File

@@ -0,0 +1,111 @@
-- File: Prs3d_TextAspect.cdl
-- Created: Tue Sep 14 12:56:09 1993
-- Author: Jean-Louis FRENKEL
-- <jlf@stylox>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1993
class TextAspect from Prs3d inherits BasicAspect from Prs3d
---Purpose: Defines the attributes when displaying a text.
uses
NameOfColor from Quantity,
Color from Quantity,
AspectText3d from Graphic3d,
PlaneAngle from Quantity,
HorizontalTextAlignment from Graphic3d,
VerticalTextAlignment from Graphic3d,
TextPath from Graphic3d,
Length from Quantity
is
Create returns mutable TextAspect from Prs3d;
--- Purpose: Constructs an empty framework for defining display attributes of text.
SetColor(me: mutable; aColor: Color from Quantity);
SetColor(me: mutable; aColor: NameOfColor from Quantity);
--- Purpose: Sets the color of the type used in text display.
SetFont(me: mutable; aFont: CString from Standard);
--- Purpose: Sets the font used in text display.
SetHeightWidthRatio(me: mutable; aRatio: Real from Standard);
--- Purpose: Returns the height-width ratio, also known as the expansion factor.
SetSpace(me :mutable; aSpace: Length from Quantity);
---Purpose: Sets the length of the box which text will occupy.
SetHeight(me: mutable; aHeight: Real from Standard);
--- Purpose: Sets the height of the text.
SetAngle(me: mutable; anAngle: PlaneAngle from Quantity);
--- Purpose: Sets the angle
Height(me) returns Real from Standard;
---Purpose: Returns the height of the text box.
Angle(me) returns PlaneAngle from Quantity;
---Purpose: Returns the angle
SetHorizontalJustification(me: mutable; aJustification: HorizontalTextAlignment from Graphic3d);
--- Purpose: Sets horizontal alignment of text.
SetVerticalJustification(me: mutable; aJustification: VerticalTextAlignment from Graphic3d);
--- Purpose: Sets the vertical alignment of text.
SetOrientation(me: mutable; anOrientation: TextPath from Graphic3d);
---Purpose: Sets the orientation of text.
HorizontalJustification(me) returns HorizontalTextAlignment from Graphic3d;
--- Purpose: Returns the horizontal alignment of the text.
-- The range of values includes:
-- - left
-- - center
-- - right, and
-- - normal (justified).
VerticalJustification(me) returns VerticalTextAlignment from Graphic3d;
--- Purpose: Returns the vertical alignment of the text.
-- The range of values includes:
-- - normal
-- - top
-- - cap
-- - half
-- - base
-- - bottom
Orientation(me) returns TextPath from Graphic3d;
--- Purpose: Returns the orientation of the text.
-- Text can be displayed in the following directions:
-- - up
-- - down
-- - left, or
-- - right
Aspect(me) returns AspectText3d from Graphic3d;
---Purpose: Returns the purely textual attributes used in the display of text.
-- These include:
-- - color
-- - font
-- - height/width ratio, that is, the expansion factor, and
-- - space between characters.
Print( me; s: in out OStream from Standard);
fields
myTextAspect: AspectText3d from Graphic3d;
myAngle: PlaneAngle from Quantity;
myHeight: Real from Standard;
myHorizontalJustification: HorizontalTextAlignment from Graphic3d;
myVerticalJustification: VerticalTextAlignment from Graphic3d;
myOrientation: TextPath from Graphic3d;
end TextAspect from Prs3d;

101
src/Prs3d/Prs3d_TextAspect.cxx Executable file
View File

@@ -0,0 +1,101 @@
// File: Prs3d_TextAspect.cxx
// Created: Tue Sep 14 14:43:19 1993
// Author: Jean-Louis FRENKEL
// <isa@stylox>
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <Prs3d_TextAspect.ixx>
#include <Quantity_Color.hxx>
#include <Graphic3d_NameOfFont.hxx>
Prs3d_TextAspect::Prs3d_TextAspect ()
: myAngle(0.),
myHeight(16.),
myHorizontalJustification(Graphic3d_HTA_LEFT),
myVerticalJustification(Graphic3d_VTA_BOTTOM),
myOrientation(Graphic3d_TP_RIGHT) {
myTextAspect = new Graphic3d_AspectText3d (
Quantity_Color(Quantity_NOC_YELLOW),
Graphic3d_NOF_ASCII_TRIPLEX,
1.,
0.);
}
#ifdef GER61351
void Prs3d_TextAspect::SetColor(const Quantity_Color &aColor) {
myTextAspect->SetColor(aColor);
}
#endif
void Prs3d_TextAspect::SetColor(const Quantity_NameOfColor aColor) {
myTextAspect->SetColor(Quantity_Color(aColor));
}
void Prs3d_TextAspect::SetFont(const Standard_CString aFont) {
myTextAspect->SetFont(aFont);
}
void Prs3d_TextAspect::SetHeightWidthRatio(const Standard_Real aRatio) {
myTextAspect->SetExpansionFactor(aRatio);
}
void Prs3d_TextAspect::SetSpace(const Quantity_Length aSpace) {
myTextAspect->SetSpace(aSpace);
}
void Prs3d_TextAspect::SetHeight(const Standard_Real aHeight) {
myHeight = aHeight;
}
void Prs3d_TextAspect::SetAngle(const Quantity_PlaneAngle anAngle) {
myAngle = anAngle;
}
void Prs3d_TextAspect::SetHorizontalJustification(const Graphic3d_HorizontalTextAlignment aJustification) {
myHorizontalJustification = aJustification;
}
void Prs3d_TextAspect::SetVerticalJustification(const Graphic3d_VerticalTextAlignment aJustification) {
myVerticalJustification = aJustification;
}
void Prs3d_TextAspect::SetOrientation(const Graphic3d_TextPath anOrientation) {
myOrientation = anOrientation;
}
Standard_Real Prs3d_TextAspect::Height () const {return myHeight;}
Quantity_PlaneAngle Prs3d_TextAspect::Angle () const {return myAngle;}
Graphic3d_HorizontalTextAlignment Prs3d_TextAspect::HorizontalJustification () const { return myHorizontalJustification;}
Graphic3d_VerticalTextAlignment Prs3d_TextAspect::VerticalJustification () const { return myVerticalJustification;}
Graphic3d_TextPath Prs3d_TextAspect::Orientation () const {return myOrientation;}
Handle(Graphic3d_AspectText3d) Prs3d_TextAspect::Aspect() const {
return myTextAspect;
}
void Prs3d_TextAspect::Print (Standard_OStream& s) const {
Quantity_Color C;
Standard_CString F;
Standard_Real Ratio;
Standard_Real Space;
myTextAspect->Values(C,F,Ratio,Space);
Standard_CString FontName;
strcpy((char*)FontName,(char*)F);
s << "TextAspect:" << Quantity_Color::StringName(C.Name()) << " Font: " << FontName << " Ratio: " << Ratio << " Space: " << Space;
}

36
src/Prs3d/Prs3d_Vector.cdl Executable file
View File

@@ -0,0 +1,36 @@
-- File: Prs3d_Point.cdl
-- Created: Fri Apr 16 12:39:30 1993
-- Author: Jean Louis FRENKEL
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
generic class Vector from Prs3d
(anyVector as any;
VectorTool as any) -- as VectorTool from Prs3d;
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aVector: anyVector;
aDrawer: Drawer from Prs3d);
end Vector from Prs3d;

49
src/Prs3d/Prs3d_Vector.gxx Executable file
View File

@@ -0,0 +1,49 @@
#include <Graphic3d_Group.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Arrow.hxx>
#include <gp_Dir.hxx>
#include <Prs3d_LineAspect.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
void Prs3d_Vector::Add(const Handle(Prs3d_Presentation)& aPresentation,
const anyVector& aVector,
const Handle(Prs3d_Drawer)& aDrawer )
{
gp_Pnt Pnt = VectorTool::Location(aVector);
gp_Vec Vec = VectorTool::Vec(aVector);
Quantity_Length x1,y1,z1,dx,dy,dz;
Pnt.Coord(x1,y1,z1);
Vec.Coord(dx,dy,dz);
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
G->SetPrimitivesAspect(aDrawer->VectorAspect()->Aspect());
Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W;
aDrawer->VectorAspect()->Aspect()->Values(Col,Tol,W);
Graphic3d_Array1OfVertex A(1,2);
//
// Trace d'une petite sphere au debut du vecteur:
//
Graphic3d_Vertex VTX;
VTX.SetCoord(x1,y1,z1);
Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d
(Aspect_TOM_BALL,Col,1.);
G->SetPrimitivesAspect(Asp);
G->Marker(VTX);
A(1).SetCoord(x1,y1,z1);
A(2).SetCoord(x1+dx,y1+dy,z1+dz);
G->Polyline(A);
Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x1+dx,y1+dy,z1+dz),gp_Dir(Vec),
PI/180.*10.,Sqrt(dx*dx+dy*dy+dz*dz)/10.);
}

17
src/Prs3d/Prs3d_VectorTool.cdl Executable file
View File

@@ -0,0 +1,17 @@
-- File: Prs3d_VectorTool.cdl
-- Created: Fri Apr 16 13:36:55 1993
-- Author: Jean Louis FRENKEL
-- <jlf@phylox>
---Copyright: Matra Datavision 1993
deferred generic class VectorTool from Prs3d ( Vector as any)
--- template for drawing a vector.
uses
Vec from gp,
Pnt from gp
is
Location (myclass; aVector: Vector) returns Pnt from gp;
Vec ( myclass; aVector: Vector ) returns Vec from gp;
end VectorTool from Prs3d;

0
src/Prs3d/Prs3d_VectorTool.gxx Executable file
View File

View File

@@ -0,0 +1,76 @@
-- File: Prs3d_WFDeflectionRestrictedFace.cdl
-- Created: Mon Jan 18 18:27:19 1993
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1993
generic class WFDeflectionRestrictedFace from Prs3d
(DrawFaceIso as any;
RestrictionTool as any)
inherits Root from Prs3d
---Purpose:
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);
AddUIso(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d);
AddVIso(myclass; aPresentation: Presentation from Prs3d;
aFace : HSurface from BRepAdaptor;
aDrawer : Drawer from Prs3d);
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);
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,495 @@
#include <Hatch_Hatcher.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Group.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Adaptor2d_Curve2d.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#ifdef DEBUG
#include <OSD_Timer.hxx>
extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4;
#endif
//=========================================================================
// function: Add
// purpose
//=========================================================================
void Prs3d_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 DEBUG
RestrictedFaceTimer1.Start();
#endif
RestrictionTool ToolRst (aFace);
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();
gp_Pnt2d P;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
u = TheRCurve->FirstParameter();
v = TheRCurve->LastParameter();
if (TheRCurve->GetType() != GeomAbs_Line) {
step = ( v - u) / nbPoints;
for (i = 0; i <= nbPoints; i++) {
TheRCurve->D0(u, P);
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;
}
}
else {
TheRCurve->D0(u, P);
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();
TheRCurve->D0(v, P);
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();
}
}
#ifdef DEBUG
RestrictedFaceTimer1.Stop();
RestrictedFaceTimer2.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 DEBUG
RestrictedFaceTimer2.Stop();
RestrictedFaceTimer3.Start();
#endif
// trim the isos
gp_Pnt2d P1,P2;
Standard_Real U1, U2;
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();
if (TheRCurve->GetType() != GeomAbs_Line) {
GCPnts_UniformDeflection UDP(*TheRCurve, Deflection, Standard_False);
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;
}
}
else {
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
P1 = TheRCurve->Value(U1);
P2 = TheRCurve->Value(U2);
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
}
#ifdef DEBUG
RestrictedFaceTimer3.Stop();
RestrictedFaceTimer4.Start();
#endif
// draw the isos
Adaptor3d_IsoCurve anIso;
anIso.Load(aFace);
Standard_Integer NumberOfLines = isobuild.NbLines();
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);
DrawFaceIso::Add(aPresentation,anIso,Deflection, aLimit);
}
}
#ifdef DEBUG
RestrictedFaceTimer4.Stop();
#endif
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean Prs3d_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)
{
RestrictionTool 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_UniformDeflection UDP(*TheRCurve, Deflection, Standard_False);
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();
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 (DrawFaceIso::Match(X,Y,Z,aDistance,anIso,Deflection, aLimit))
return Standard_True;
}
}
return Standard_False;
}
//=========================================================================
// function: Add
// purpose
//=========================================================================
void Prs3d_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_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_True,
Deflection,
finu,
finv,
aDrawer);
TheGroup->EndPrimitives();
}
//=========================================================================
// function: AddUIso
// purpose
//=========================================================================
void Prs3d_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_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_False,
Deflection,
finu,
finv,
aDrawer);
}
//=========================================================================
// function: AddVIso
// purpose
//=========================================================================
void Prs3d_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_WFDeflectionRestrictedFace::Add (
aPresentation,
aFace,
Standard_False,
Standard_True,
Deflection,
finu,
finv,
aDrawer);
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean Prs3d_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 Prs3d_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_True,
Deflection,
finu,
finv);
}
//=========================================================================
// function: MatchUIso
// purpose
//=========================================================================
Standard_Boolean Prs3d_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 Prs3d_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_True,
Standard_False,
Deflection,
finu,
finv);
}
//=========================================================================
// function: MatchVIso
// purpose
//=========================================================================
Standard_Boolean Prs3d_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 Prs3d_WFDeflectionRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
aDrawer,
Standard_False,
Standard_True,
Deflection,
finu,
finv);
}

View File

@@ -0,0 +1,77 @@
-- File: Prs3d_WFRestrictedFace.cdl
-- Created: Fri Jun 10 11:29:05 1994
-- Author: Laurent PAINNOT
-- <lpa@metrox>
---Copyright: Matra Datavision 1994
generic class WFRestrictedFace from Prs3d
(DrawFaceIso as any;
RestrictionTool as any)
inherits Root from Prs3d
---Purpose:
uses
HSurface from BRepAdaptor,
Presentation from Prs3d,
Drawer from Prs3d,
NListOfSequenceOfPnt from Prs3d,
Length from Quantity
-- Description of the isoparametric curves:
--
is
Add(myclass; aPresentation: Presentation from Prs3d;
aFace: HSurface from BRepAdaptor;
aDrawer: Drawer from Prs3d);
AddUIso(myclass; aPresentation: Presentation from Prs3d;
aFace: HSurface from BRepAdaptor;
aDrawer: Drawer from Prs3d);
AddVIso(myclass; aPresentation: Presentation from Prs3d;
aFace: HSurface from BRepAdaptor;
aDrawer: Drawer from Prs3d);
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);
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;
DrawUIso, DrawVIso: Boolean from Standard;
Deflection: Length from Quantity;
NBUiso,NBViso: Integer from Standard;
aDrawer: Drawer from Prs3d)
returns Boolean from Standard;
end WFRestrictedFace;

View File

@@ -0,0 +1,534 @@
// File: Prs3d_WFRestrictedFace.gxx
// Created: Fri Jun 10 11:31:42 1994
// Author: Laurent PAINNOT
// <lpa@metrox>
#ifdef DEBUG
#include <OSD_Timer.hxx>
extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4;
#endif
#include <Hatch_Hatcher.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_Group.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Adaptor3d_IsoCurve.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>
//=========================================================================
// function: Add
// purpose
//=========================================================================
void Prs3d_WFRestrictedFace::Add
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Standard_Boolean DrawUIso,
const Standard_Boolean DrawVIso,
const Quantity_Length aDeflection,
const Standard_Integer NBUiso,
const Standard_Integer NBViso,
const Handle(Prs3d_Drawer)& aDrawer,
Prs3d_NListOfSequenceOfPnt& Curves)
{
Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable();
Standard_Real aLimit = aDrawer->MaximalParameterValue();
Standard_Integer nbPoints = aDrawer->Discretisation();
#ifdef DEBUG
RestrictedFaceTimer1.Start();
#endif
RestrictionTool ToolRst (aFace);
// compute bounds of the restriction
Standard_Real UMin,UMax,VMin,VMax;
// Standard_Real u,v,step;
// Standard_Integer i, nbp= 10;
Standard_Integer i;
gp_Pnt2d P1,P2;
Bnd_Box2d B;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
BndLib_Add2dCurve::Add(*TheRCurve, Precision::PConfusion(), B);
}
if ( ! B.IsVoid() )
B.Get(UMin, VMin, UMax, VMax);
else
{ // no pcurves -- take natural bounds
UMin = aFace->Surface().FirstUParameter();
VMin = aFace->Surface().FirstVParameter();
UMax = aFace->Surface().LastUParameter();
VMax = aFace->Surface().LastVParameter();
}
#ifdef DEBUG
RestrictedFaceTimer1.Stop();
RestrictedFaceTimer2.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 DEBUG
RestrictedFaceTimer2.Stop();
RestrictedFaceTimer3.Start();
#endif
// trim the isos
Standard_Real U1, U2, U, DU;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
if (TheRCurve->GetType() != GeomAbs_Line) {
DU = (U2-U1)/(nbPoints-1);
P2 = TheRCurve->Value(U1);
for (i = 2; i <= nbPoints; i++) {
U = U1 + (i-1)*DU;
P1 = P2;
P2 = TheRCurve->Value(U);
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
else {
P1 = TheRCurve->Value(U1);
P2 = TheRCurve->Value(U2);
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
}
#ifdef DEBUG
RestrictedFaceTimer3.Stop();
RestrictedFaceTimer4.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();
}
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(b1 == RealFirst() || b2 == RealLast())
continue;
//b1 = b1 == RealFirst() ? - aLimit : b1;
//b2 = b2 == RealLast() ? aLimit : b2;
TColgp_SequenceOfPnt Pnts;
if (!GB.IsNull()) {
if (isobuild.IsXLine(i))
BC = GB->UIso(Coord);
else
BC = GB->VIso(Coord);
//Note that the isos are the part of the shape, it will be displayed after a computation the whole shape
//NbPoints = 30 - default parameter for computation of such curves
DrawFaceIso::Add(aPresentation,GeomAdaptor_Curve(BC), b1, b2, aDeflection, Pnts, 30, !isPA);
Curves.Append(Pnts);
}
else {
if (isobuild.IsXLine(i))
anIso.Load(GeomAbs_IsoU,Coord,b1,b2);
else
anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
DrawFaceIso::Add(aPresentation,anIso, aDeflection, aDrawer, Pnts, !isPA);
Curves.Append(Pnts);
}
}
}
#ifdef DEBUG
RestrictedFaceTimer4.Stop();
#endif
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean Prs3d_WFRestrictedFace::Match
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const Handle(BRepAdaptor_HSurface)& aFace,
const Standard_Boolean DrawUIso,
const Standard_Boolean DrawVIso,
const Quantity_Length aDeflection,
const Standard_Integer NBUiso,
const Standard_Integer NBViso,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Real aLimit = aDrawer->MaximalParameterValue();
Standard_Integer nbPoints = aDrawer->Discretisation();
RestrictionTool ToolRst (aFace);
// compute bounds of the restriction
Standard_Real UMin,UMax,VMin,VMax;
Standard_Real u,v,step;
Standard_Integer i,nbP = 10;
UMin = VMin = RealLast();
UMax = VMax = RealFirst();
gp_Pnt2d P1,P2;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
u = TheRCurve->FirstParameter();
v = TheRCurve->LastParameter();
if (TheRCurve->GetType() != GeomAbs_Line) {
step = ( v - u) / nbP;
for (i = 0; i <= nbP; 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;
}
}
else {
P1 = TheRCurve->Value(u);
if (P1.X() < UMin) UMin = P1.X();
if (P1.X() > UMax) UMax = P1.X();
if (P1.Y() < VMin) VMin = P1.Y();
if (P1.Y() > VMax) VMax = P1.Y();
P2 = TheRCurve->Value(v);
if (P2.X() < UMin) UMin = P2.X();
if (P2.X() > UMax) UMax = P2.X();
if (P2.Y() < VMin) VMin = P2.Y();
if (P2.Y() > VMax) VMax = P2.Y();
}
}
// 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
Standard_Real U1, U2, U, DU;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
if (TheRCurve->GetType() != GeomAbs_Line) {
DU = (U2-U1)/(nbPoints-1);
P2 = TheRCurve->Value(U1);
for (i = 2; i <= nbPoints; i++) {
U = U1 + (i-1)*DU;
P1 = P2;
P2 = TheRCurve->Value(U);
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
else {
P1 = TheRCurve->Value(U1);
P2 = TheRCurve->Value(U2);
if(Orient == TopAbs_FORWARD )
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
}
}
}
// draw the isos
Adaptor3d_IsoCurve anIso;
anIso.Load(aFace);
Standard_Integer NumberOfLines = isobuild.NbLines();
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 (DrawFaceIso::Match(X,Y,Z,aDistance,anIso,
aDeflection, aLimit, nbPoints))
return Standard_True;
}
}
return Standard_False;
}
//=========================================================================
// function: Add
// purpose
//=========================================================================
void Prs3d_WFRestrictedFace::Add
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer){
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
TheGroup->BeginPrimitives();
Prs3d_NListOfSequenceOfPnt Curves;
Prs3d_WFRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_True,
aDeflection,
finu,
finv,
aDrawer,
Curves);
TheGroup->EndPrimitives();
}
//=========================================================================
// function: AddUIso
// purpose
//=========================================================================
void Prs3d_WFRestrictedFace::AddUIso
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
Prs3d_NListOfSequenceOfPnt Curves;
Prs3d_WFRestrictedFace::Add (
aPresentation,
aFace,
Standard_True,
Standard_False,
aDeflection,
finu,
finv,
aDrawer,
Curves);
}
//=========================================================================
// function: AddVIso
// purpose
//=========================================================================
void Prs3d_WFRestrictedFace::AddVIso
(const Handle (Prs3d_Presentation)& aPresentation,
const Handle(BRepAdaptor_HSurface)& aFace,
const Handle (Prs3d_Drawer)& aDrawer) {
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
Prs3d_NListOfSequenceOfPnt Curves;
Prs3d_WFRestrictedFace::Add (
aPresentation,
aFace,
Standard_False,
Standard_True,
aDeflection,
finu,
finv,
aDrawer,
Curves);
}
//=========================================================================
// function: Match
// purpose
//=========================================================================
Standard_Boolean Prs3d_WFRestrictedFace::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){
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
return Prs3d_WFRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
Standard_True,
Standard_True,
aDeflection,
finu,
finv,
aDrawer);
}
//=========================================================================
// function: MatchUIso
// purpose
//=========================================================================
Standard_Boolean Prs3d_WFRestrictedFace::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) {
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
return Prs3d_WFRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
Standard_True,
Standard_False,
aDeflection,
finu,
finv,
aDrawer);
}
//=========================================================================
// function: MatchVIso
// purpose
//=========================================================================
Standard_Boolean Prs3d_WFRestrictedFace::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) {
Standard_Integer finu = aDrawer->UIsoAspect()->Number();
Standard_Integer finv = aDrawer->VIsoAspect()->Number();
Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation();
return Prs3d_WFRestrictedFace::Match (
X,Y,Z,aDistance,
aFace,
Standard_False,
Standard_True,
aDeflection,
finu,
finv,
aDrawer);
}

42
src/Prs3d/Prs3d_WFShape.cdl Executable file
View File

@@ -0,0 +1,42 @@
-- File: WFShape.cdl
-- Created: Tue Dec 15 18:12:33 1992
-- Author: Jean Louis FRENKEL
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
generic class WFShape from Prs3d
(FacePresentation as any; -- as WFRestrictedFace from Prs3d
CurvePresentation as any; -- as Curve from Prs3d
PointPresentation as any) -- as Point from Prs3d
inherits Root from Prs3d
uses
Shape from TopoDS,
HSequenceOfShape from TopTools,
Presentation from Prs3d,
Drawer from Prs3d,
Length from Quantity
is
Add(myclass; aPresentation: Presentation from Prs3d;
aShape : Shape from TopoDS;
aDrawer : Drawer from Prs3d);
PickCurve(myclass; X,Y,Z : Length from Quantity;
aDistance : Length from Quantity;
aShape : Shape from TopoDS;
aDrawer : Drawer from Prs3d)
returns HSequenceOfShape from TopTools;
PickPatch(myclass; X,Y,Z : Length from Quantity;
aDistance : Length from Quantity;
aShape : Shape from TopoDS;
aDrawer : Drawer from Prs3d)
returns HSequenceOfShape from TopTools;
end WFShape from Prs3d;

866
src/Prs3d/Prs3d_WFShape.gxx Executable file
View File

@@ -0,0 +1,866 @@
#include <Standard_ErrorHandler.hxx>
#include <Graphic3d_Group.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Prs3d_ShapeTool.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Poly_Connect.hxx>
#include <BRepBndLib.hxx>
#include <Precision.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <gp_Circ.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <Prs3d_NListOfSequenceOfPnt.hxx>
#include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
#ifdef DEB_MESH
#include <OSD_Timer.hxx>
extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4;
extern OSD_Timer ShapeTimer;
extern OSD_Timer FaceExplorerTimer, CurveExplorerTimer;
extern OSD_Timer UIsoTimer,VIsoTimer,WireTimer,FreeBoundaryTimer,UnFreeBoundaryTimer;
#endif
static Standard_Boolean IsSame(const Handle(Graphic3d_AspectLine3d)& UAspect,
const Handle(Graphic3d_AspectLine3d)& VAspect)
{
Standard_Boolean same = Standard_True;
Quantity_Color CU, CV;
Aspect_TypeOfLine TlU, TlV;
Standard_Real WU, WV;
UAspect->Values(CU, TlU, WU);
VAspect->Values(CV, TlV, WV);
if (CU != CV || TlU != TlV || WU != WV) {
same = Standard_False;
}
return same;
}
static Standard_Boolean AddPolygon(const TopoDS_Edge& E,
Handle(Graphic3d_Group)& TheGroup,
const Standard_Real deflection,
const Handle (Prs3d_Drawer)& ,
TColgp_SequenceOfPnt& Pnts)
{
TopLoc_Location l;
gp_Pnt P;
Standard_Boolean result = Standard_False;
Standard_Boolean IsPrimArray = Graphic3d_ArrayOfPrimitives::IsEnable();
Standard_Boolean OK;
Standard_Real fi, la;
Handle(Poly_Polygon3D) Polyg;
Handle(Geom_Curve) CC3d = BRep_Tool::Curve(E, fi, la);
Polyg = BRep_Tool::Polygon3D(E, l);
if (!Polyg.IsNull()) {
OK = Polyg->Deflection() <= deflection;
OK = OK || (CC3d.IsNull());
if (OK) {
result = Standard_True;
const TColgp_Array1OfPnt& Points = Polyg->Nodes();
Graphic3d_Array1OfVertex V(1, Points.Length());
Standard_Integer po, ii = 1;
if (l.IsIdentity()) {
for (po = Points.Lower(); po <= Points.Upper(); po++) {
P = Points.Value(po);
V(ii).SetCoord(P.X(), P.Y(), P.Z());
Pnts.Append(P);
ii++;
}
}
else {
for (po = Points.Lower(); po <= Points.Upper(); po++) {
P = Points.Value(po).Transformed(l);
V(ii).SetCoord(P.X(), P.Y(), P.Z());
Pnts.Append(P);
ii++;
}
}
if(!IsPrimArray)
TheGroup->Polyline(V);
return result;
}
}
Handle(Poly_Triangulation) Tr;
Handle(Poly_PolygonOnTriangulation) HIndices;
BRep_Tool::PolygonOnTriangulation(E, HIndices, Tr, l);
if (!HIndices.IsNull()) {
OK = HIndices->Deflection() <= deflection;
OK = OK || (CC3d.IsNull());
if (OK) {
result = Standard_True;
const TColStd_Array1OfInteger& Indices = HIndices->Nodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
Graphic3d_Array1OfVertex V(1, Indices.Length());
Standard_Integer po, ii = 1;
if (l.IsIdentity()) {
for (po = Indices.Lower(); po <= Indices.Upper(); po++) {
P = Nodes(Indices(po));
V(ii).SetCoord(P.X(), P.Y(), P.Z());
Pnts.Append(P);
ii++;
}
}
else {
for (po = Indices.Lower(); po <= Indices.Upper(); po++) {
P = Nodes(Indices(po)).Transformed(l);
V(ii).SetCoord(P.X(), P.Y(), P.Z());
Pnts.Append(P);
ii++;
}
}
if(!IsPrimArray)
TheGroup->Polyline(V);
return result;
}
}
return result;
}
//=========================================================================
// function: Add
// purpose
//=========================================================================
void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const TopoDS_Shape& aShape,
const Handle (Prs3d_Drawer)& aDrawer)
{
if (aShape.IsNull()) return;
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
#ifdef DEB_MESH
RestrictedFaceTimer1.Reset();
RestrictedFaceTimer2.Reset();
RestrictedFaceTimer3.Reset();
RestrictedFaceTimer4.Reset();
#endif
#ifdef DEB_MESH
ShapeTimer.Start();
#endif
Prs3d_ShapeTool Tool(aShape);
TopTools_ListOfShape LFree, LUnFree, LWire;
for (Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve())
{
const TopoDS_Edge& E = Tool.GetCurve();
switch (Tool.Neighbours())
{
case 0: LWire.Append(E); break;
case 1: LFree.Append(E); break;
default: LUnFree.Append(E);
}
}
#ifdef DEB_MESH
ShapeTimer.Stop();
#endif
#ifdef DEB_MESH
RestrictedFaceTimer1.Start();
#endif
Standard_Real aDeflection;
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
{
// On calcule la fleche en fonction des min max globaux de la piece:
Bnd_Box B;
BRepBndLib::Add(aShape, B);
if ( ! B.IsVoid() )
{
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin)) *
aDrawer->DeviationCoefficient();
}
else
aDeflection = aDrawer->MaximalChordialDeviation();
}
else
aDeflection = aDrawer->MaximalChordialDeviation();
#ifdef DEB_MESH
RestrictedFaceTimer1.Stop();
#endif
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
Prs3d_NListOfSequenceOfPnt UIsoCurves;
Prs3d_NListOfSequenceOfPnt VIsoCurves;
Prs3d_NListOfSequenceOfPnt WireCurves;
Prs3d_NListOfSequenceOfPnt FreeCurves;
Prs3d_NListOfSequenceOfPnt UnFreeCurves;
TColgp_SequenceOfPnt ShapePoints;
if (IsSame(aDrawer->UIsoAspect()->Aspect(), aDrawer->VIsoAspect()->Aspect()))
{
const Standard_Integer isoU = aDrawer->UIsoAspect()->Number();
const Standard_Integer isoV = aDrawer->VIsoAspect()->Number();
#ifdef DEB_MESH
UIsoTimer.Start();
#endif
if (isoU || isoV)
{
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
}
BRepAdaptor_Surface S;
for (Tool.InitFace();Tool.MoreFace();Tool.NextFace())
{
if (Tool.HasSurface())
{
if (!Tool.IsPlanarFace() || aDrawer->IsoOnPlane())
{
S.Initialize(Tool.GetFace());
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(S);
try {
OCC_CATCH_SIGNALS
Prs3d_NListOfSequenceOfPnt CurUIsoCurves;
FacePresentation::Add(aPresentation, HS,
isoU, isoV,
aDeflection,
isoU, isoV,
aDrawer,
CurUIsoCurves);
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(CurUIsoCurves); It.More(); It.Next())
UIsoCurves.Append(It.Value());
}
catch (Standard_Failure)
{
#ifdef DEB_MESH
const TopoDS_Face& FF = S.Face();
cout <<"probleme pour les isos de la face "<< (void*) &(*(FF).TShape()) << endl;
#endif
}
}
}
}
if(!isPrimArrayEnabled)
TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
UIsoTimer.Stop();
#endif
}
else
{
const Standard_Integer isoU = aDrawer->UIsoAspect()->Number();
const Standard_Integer isoV = aDrawer->VIsoAspect()->Number();
#ifdef DEB_MESH
UIsoTimer.Start();
#endif
if (isoU)
{
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
}
BRepAdaptor_Surface S;
for (Tool.InitFace();Tool.MoreFace();Tool.NextFace())
{
if (Tool.HasSurface())
{
if (!Tool.IsPlanarFace() || aDrawer->IsoOnPlane())
{
S.Initialize(Tool.GetFace());
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(S);
try
{
OCC_CATCH_SIGNALS
Prs3d_NListOfSequenceOfPnt CurUIsoCurves;
FacePresentation::Add(aPresentation, HS,
isoU, Standard_False,
aDeflection,
isoU, 0,
aDrawer,
CurUIsoCurves);
}
catch (Standard_Failure)
{
#ifdef DEB
const TopoDS_Face& FF = S.Face();
cout <<"probleme pour les isos de la face "<< (void*) &(*(FF).TShape()) << endl;
#endif
}
}
}
}
if(!isPrimArrayEnabled)
TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
UIsoTimer.Stop();
VIsoTimer.Start();
#endif
if (isoV)
{
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
}
BRepAdaptor_Surface S;
for (Tool.InitFace();Tool.MoreFace();Tool.NextFace())
{
if (Tool.HasSurface())
{
if (!Tool.IsPlanarFace() || aDrawer->IsoOnPlane())
{
S.Initialize(Tool.GetFace());
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(S);
try
{
OCC_CATCH_SIGNALS
Prs3d_NListOfSequenceOfPnt CurUIsoCurves;
FacePresentation::Add(aPresentation, HS,
Standard_False, isoV,
aDeflection,
0, isoV,
aDrawer,
CurUIsoCurves);
}
catch (Standard_Failure)
{
#ifdef DEB
const TopoDS_Face& FF = S.Face();
cout <<"probleme pour les isos de la face "<< (void*) &(*(FF).TShape()) << endl;
#endif
}
}
}
}
if (!isPrimArrayEnabled) TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
VIsoTimer.Stop();
#endif
}
Standard_Integer nbVertices = 0, nbBounds = 0;
if(isPrimArrayEnabled) {
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();
}
}
#ifdef DEB_MESH
WireTimer.Start();
#endif
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
TheGroup->BeginPrimitives();
}
gp_Pnt P;
TopLoc_Location l;
Graphic3d_Vertex V1, V2;
Standard_Integer i, j, n[3];
Standard_Boolean DispTriangles = Standard_False;
const char* var = getenv("DEBUG_TRIANGLES");
if (var != 0L) {
DispTriangles = (atol(var) != 0);
}
TColgp_SequenceOfPnt SurfPnts;
for (Tool.InitFace();Tool.MoreFace();Tool.NextFace())
{
if (!Tool.HasSurface() || DispTriangles)
{
Handle(Poly_Triangulation) T = Tool.CurrentTriangulation(l);
if (!T.IsNull())
{
const TColgp_Array1OfPnt& Nodes = T->Nodes();
// Build the connect tool
Poly_Connect pc(T);
Standard_Integer nFree, nInternal, nbTriangles = T->NbTriangles();
Standard_Integer t[3];
// count the free edges
nFree = 0;
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
for (j = 0; j < 3; j++)
if (t[j] == 0) nFree++;
}
// allocate the arrays
TColStd_Array1OfInteger Free(1,2*nFree);
nInternal = (3*nbTriangles - nFree) / 2;
TColStd_Array1OfInteger Internal(0,2*nInternal);
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(n[0],n[1],n[2]);
for (j = 0; j < 3; j++) {
Standard_Integer k = (j+1) % 3;
if (t[j] == 0) {
Free(fr) = n[j];
Free(fr+1) = n[k];
fr += 2;
}
// internal edge if this triangle has a lower index than the adjacent
else if (i < t[j]) {
Internal(in) = n[j];
Internal(in+1) = n[k];
in += 2;
}
}
}
if(!Tool.HasSurface()) {
// free edges
Standard_Integer nn;
nn = Free.Length() / 2;
for (i = 1; i <= nn; i++) {
gp_Pnt P1 = Nodes(Free(2*i-1)).Transformed(l);
gp_Pnt P2 = Nodes(Free(2*i)).Transformed(l);
SurfPnts.Append(P1);
SurfPnts.Append(P2);
if(!isPrimArrayEnabled) {
V1.SetCoord(P1.X(), P1.Y(), P1.Z());
V2.SetCoord(P2.X(), P2.Y(), P2.Z());
TheGroup->Polyline(V1, V2);
}
}
}
if(DispTriangles) {
for (i = 1; i <= nInternal; i++) {
gp_Pnt P1 = Nodes(Internal(2*i-1)).Transformed(l);
gp_Pnt P2 = Nodes(Internal(2*i)).Transformed(l);
SurfPnts.Append(P1);
SurfPnts.Append(P2);
if(!isPrimArrayEnabled) {
V1.SetCoord(P1.X(), P1.Y(), P1.Z());
V2.SetCoord(P2.X(), P2.Y(), P2.Z());
TheGroup->Polyline(V1, V2);
}
}
}
}
}
}
if(!isPrimArrayEnabled)
TheGroup->EndPrimitives();
if(isPrimArrayEnabled && SurfPnts.Length()>0){
nbVertices = SurfPnts.Length();
nbBounds = (Standard_Integer)nbVertices / 2;
Handle(Graphic3d_ArrayOfPolylines) SurfArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for(i=1; i<=nbVertices; i+=2) {
SurfArray->AddBound(2);
SurfArray->AddVertex(SurfPnts.Value(i));
SurfArray->AddVertex(SurfPnts.Value(i+1));
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
if(DispTriangles && Tool.HasSurface()) {
TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
}
else {
TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect());
}
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(SurfArray);
TheGroup->EndPrimitives();
}
TopTools_ListIteratorOfListOfShape It;
if (aDrawer->WireDraw())
{
// Wire (without any neighbour)
TheGroup->SetPrimitivesAspect(aDrawer->WireAspect()->Aspect());
TheGroup->BeginPrimitives();
for (It.Initialize(LWire); It.More(); It.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(It.Value());
try
{
OCC_CATCH_SIGNALS
TColgp_SequenceOfPnt Pnts;
if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) {
if (BRep_Tool::IsGeometric(E)) {
BRepAdaptor_Curve C(E);
CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled);
WireCurves.Append(Pnts);
}
}
else
WireCurves.Append(Pnts);
}
catch(Standard_Failure)
{
#ifdef DEB
cout <<"probleme sur l'edge "<< (void*) &(*(E).TShape()) << endl;
#endif
}
}
TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
WireTimer.Stop();
FreeBoundaryTimer.Start();
#endif
if (aDrawer->FreeBoundaryDraw())
{
// Free boundaries;
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect());
TheGroup->BeginPrimitives();
}
for (It.Initialize(LFree); It.More(); It.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(It.Value());
if (!BRep_Tool::Degenerated(E)) {
try {
OCC_CATCH_SIGNALS
TColgp_SequenceOfPnt Pnts;
if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) {
if (BRep_Tool::IsGeometric(E)) {
BRepAdaptor_Curve C(E);
CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled);
FreeCurves.Append(Pnts);
}
}
else
FreeCurves.Append(Pnts);
}
catch(Standard_Failure)
{
#ifdef DEB
cout <<"probleme sur l'edge "<< (void*) &(*(E).TShape()) << endl;
#endif
}
}
}
if(!isPrimArrayEnabled)
TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
FreeBoundaryTimer.Stop();
UnFreeBoundaryTimer.Start();
#endif
if (aDrawer->UnFreeBoundaryDraw()) {
// Unfree boundaries;
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->UnFreeBoundaryAspect()->Aspect());
TheGroup->BeginPrimitives();
}
for (It.Initialize(LUnFree); It.More(); It.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(It.Value());
try
{
OCC_CATCH_SIGNALS
TColgp_SequenceOfPnt Pnts;
if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) {
if (BRep_Tool::IsGeometric(E)) {
BRepAdaptor_Curve C(E);
CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled);
UnFreeCurves.Append(Pnts);
}
}
else
UnFreeCurves.Append(Pnts);
}
catch(Standard_Failure)
{
#ifdef DEB
cout <<"probleme sur l'edge "<< (void*) &(*(E).TShape()) << endl;
#endif
}
}
if(!isPrimArrayEnabled)
TheGroup->EndPrimitives();
}
if(isPrimArrayEnabled) {
if(WireCurves.Size() > 0) {
nbBounds = WireCurves.Size();
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(WireCurves); It.More(); It.Next())
nbVertices += It.Value().Length();
Handle(Graphic3d_ArrayOfPolylines) WireArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for( It.Init(WireCurves); It.More(); It.Next()) {
TColgp_SequenceOfPnt Pnts;
Pnts.Assign(It.Value());
WireArray->AddBound(Pnts.Length());
for(i=1; i<=Pnts.Length(); i++)
WireArray->AddVertex(Pnts.Value(i));
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->WireAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(WireArray);
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(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();
}
if(UnFreeCurves.Size() > 0) {
nbBounds = UnFreeCurves.Size();
Prs3d_NListIteratorOfListOfSequenceOfPnt It;
for( It.Init(UnFreeCurves); It.More(); It.Next())
nbVertices += It.Value().Length();
Handle(Graphic3d_ArrayOfPolylines) UnFreeArray =
new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
for( It.Init(UnFreeCurves); It.More(); It.Next()) {
TColgp_SequenceOfPnt Pnts;
Pnts.Assign(It.Value());
UnFreeArray->AddBound(Pnts.Length());
for(i=1; i<=Pnts.Length(); i++)
UnFreeArray->AddVertex(Pnts.Value(i));
}
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->UnFreeBoundaryAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->AddPrimitiveArray(UnFreeArray);
TheGroup->EndPrimitives();
}
}
// Points
Standard_Boolean theFirst = Standard_True;
for(Tool.InitVertex();Tool.MoreVertex();Tool.NextVertex()){
if(theFirst){
theFirst = Standard_False;
if(!isPrimArrayEnabled) {
TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect());
TheGroup->BeginPrimitives();
}
}
TopoDS_Vertex V = Tool.GetVertex();
if(!isPrimArrayEnabled)
PointPresentation::Add(aPresentation,V);
ShapePoints.Append(BRep_Tool::Pnt(V));
}
if (!theFirst) TheGroup->EndPrimitives();
nbVertices = ShapePoints.Length();
if(isPrimArrayEnabled && nbVertices > 0) {
Graphic3d_Array1OfVertex PointArray(1, nbVertices);
for(i=1; i<=nbVertices; i++)
PointArray.SetValue(i, Graphic3d_Vertex(ShapePoints.Value(i).X(), ShapePoints.Value(i).Y(), ShapePoints.Value(i).Z()));
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect());
TheGroup->BeginPrimitives();
TheGroup->MarkerSet(PointArray);
TheGroup->EndPrimitives();
}
#ifdef DEB_MESH
UnFreeBoundaryTimer.Stop();
// cout << "Restrictions Min Max computation " ;
// RestrictedFaceTimer1.Show();
// cout << "Iso loading " ;
// RestrictedFaceTimer2.Show();
// cout << "Iso hatching " ;
// RestrictedFaceTimer3.Show();
// cout << "Iso drawing " ;
// RestrictedFaceTimer4.Show();
#endif
}
//=========================================================================
// function: PickCurve
// purpose
//=========================================================================
Handle(TopTools_HSequenceOfShape) Prs3d_WFShape::PickCurve
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const TopoDS_Shape& aShape,
const Handle (Prs3d_Drawer)& aDrawer)
{
Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
Prs3d_ShapeTool Tool(aShape);
Standard_Integer i;
Standard_Boolean contain;
for(Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve()){
Bnd_Box B = Tool.CurveBound();
B.Enlarge(aDistance);
if ( ! B.IsOut(gp_Pnt(X,Y,Z))) {
if(CurvePresentation::Match(X,Y,Z,aDistance,BRepAdaptor_Curve(Tool.GetCurve()),aDrawer)) {
contain = Standard_False;
for (i = 1; i <= aSeq->Length(); i++) {
if (aSeq->Value(i) == (Tool.GetCurve())) {
contain = Standard_True;
break;
}
}
if (!contain) aSeq->Append(Tool.GetCurve());
}
}
}
return aSeq;
}
//=========================================================================
// function: PickPatch
// purpose
//=========================================================================
Handle(TopTools_HSequenceOfShape) Prs3d_WFShape::PickPatch
(const Quantity_Length X,
const Quantity_Length Y,
const Quantity_Length Z,
const Quantity_Length aDistance,
const TopoDS_Shape& aShape,
const Handle(Prs3d_Drawer)& aDrawer) {
Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
Prs3d_ShapeTool Tool(aShape);
Standard_Boolean rba1 = aDrawer->UIsoAspect()->Number() != 0;
Standard_Boolean rba2 = aDrawer->VIsoAspect()->Number() != 0;
Standard_Integer i, j;
Standard_Boolean contain;
if ( rba1 || rba2 ) {
BRepAdaptor_Surface S;
for(Tool.InitFace();Tool.MoreFace();Tool.NextFace()){
Bnd_Box B = Tool.FaceBound();
B.Enlarge(aDistance);
if ( ! B.IsOut(gp_Pnt(X,Y,Z))) {
S.Initialize(Tool.GetFace());
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(S);
if(FacePresentation::Match
(X,Y,Z,aDistance, HS, aDrawer)){
contain = Standard_False;
for (i = 1; i <= aSeq->Length(); i++) {
if (aSeq->Value(i) == (Tool.GetFace())) {
contain = Standard_True;
break;
}
}
if (!contain) aSeq->Append(Tool.GetFace());
}
}
}
}
for(Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve()){
Bnd_Box B = Tool.CurveBound();
B.Enlarge(aDistance);
if ( ! B.IsOut(gp_Pnt(X,Y,Z))) {
if(CurvePresentation::Match(X,Y,Z,aDistance,BRepAdaptor_Curve(Tool.GetCurve()),aDrawer)) {
Handle(TopTools_HSequenceOfShape) aS = Tool.FacesOfEdge();
for (i=1; i<= aS->Length(); i ++) {
contain = Standard_False;
for (j = 1; j <= aSeq->Length(); j++) {
if (aSeq->Value(j) == (aS->Value(i))) {
contain = Standard_True;
break;
}
}
if (!contain) aSeq->Append(aS->Value(i));
}
}
}
}
return aSeq;
}