1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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

51
src/Hatch/Hatch.cdl Executable file
View File

@@ -0,0 +1,51 @@
-- File: Hatch.cdl
-- Created: Tue Aug 18 17:59:54 1992
-- Author: Remi Lequette
-- <rle@phylox>
---Copyright: Matra Datavision 1992
package Hatch
---Purpose: The Hatch package provides algorithm to compute
-- cross-hatchings on a 2D face.
--
-- The Hatcher algorithms stores a set of lines in
-- the 2D plane.
--
-- The user stores lines in the Hatcher and afterward
-- trim them with other lines.
--
-- At any moment when trimming the user can ask for
-- any line if it is intersected and how many
-- intervals are defined on the line by the trim.
uses
Standard,
TCollection,
gp
is
enumeration LineForm is
---Purpose: Form of a trimmed line
XLINE, YLINE, ANYLINE
end LineForm;
private class Parameter;
---Purpose: Used by the Hatcher to store a parameter on a
-- line.
private class SequenceOfParameter instantiates Sequence from TCollection
(Parameter from Hatch);
private class Line;
---Purpose: Used by the Hatcher to store a line.
private class SequenceOfLine instantiates Sequence from TCollection
(Line from Hatch);
class Hatcher;
---Purpose: The Hatching algorithm.
end Hatch;

229
src/Hatch/Hatch_Hatcher.cdl Executable file
View File

@@ -0,0 +1,229 @@
-- File: Hatcher.cdl
-- Created: Wed Aug 19 10:00:20 1992
-- Author: Modelistation
-- <model@phylox>
---Copyright: Matra Datavision 1992
class Hatcher from Hatch
---Purpose: The Hatcher is an algorithm to compute cross
-- hatchings in a 2d plane. It is mainly dedicated to
-- display purpose.
--
-- Computing cross hatchings is a 3 steps process :
--
-- 1. The users stores in the Hatcher a set of 2d
-- lines to be trimmed. Methods in the "Lines"
-- category.
--
-- 2. The user trims the lines with a boundary. The
-- inside of a boundary is on the left side. Methods
-- in the "Trimming" category.
--
-- 3. The user reads back the trimmed lines. Methods
-- in the "Results" category.
--
-- The result is a set of parameter intervals on the
-- line. The first parameter of an Interval may be
-- RealFirst() and the last may be RealLast().
--
-- A line can be a line parallel to the axis (X or Y
-- line or a 2D line.
--
-- The Hatcher has two modes :
--
-- * The "Oriented" mode, where the orientation of
-- the trimming curves is considered. The hatch are
-- kept on the left of the trimming curve. In this
-- mode infinite hatch can be computed.
--
-- * The "UnOriented" mode, where the hatch are
-- always finite.
--
---Overview: Lines, Trimming, Results
uses
Boolean from Standard,
Integer from Standard,
Real from Standard,
Lin2d from gp,
Pnt2d from gp,
Dir2d from gp,
LineForm from Hatch,
SequenceOfLine from Hatch
raises
OutOfRange from Standard
is
Create(Tol : Real from Standard;
Oriented : Boolean = Standard_True) returns Hatcher from Hatch;
---Purpose: Returns a empty hatcher. <Tol> is the tolerance
-- for intersections.
Tolerance(me : in out; Tol : Real from Standard)
---C++: inline
is static;
Tolerance(me) returns Real from Standard
---C++: inline
is static;
AddLine(me : in out; L : Lin2d from gp;
T : LineForm from Hatch = Hatch_ANYLINE)
---Purpose: Add a line <L> to be trimmed. <T> the type is
-- only kept from information. It is not used in the
-- computation.
--
---Category: Lines
is static;
AddLine(me : in out; D : Dir2d from gp; Dist : Real from Standard)
---Purpose: Add an infinite line on direction <D> at distance
-- <Dist> from the origin to be trimmed. <Dist> may
-- be negative.
--
-- If O is the origin of the 2D plane, and V the
-- vector perpendicular to D (in the direct direction).
--
-- A point P is on the line if :
-- OP dot V = Dist
-- The parameter of P on the line is
-- OP dot D
--
---Category: Lines
is static;
AddXLine(me : in out; X : Real from Standard)
---Purpose: Add an infinite line parallel to the Y-axis at
-- abciss <X>.
--
---Category: Lines
is static;
AddYLine(me : in out; Y : Real from Standard)
---Purpose: Add an infinite line parallel to the X-axis at
-- ordinate <Y>.
--
---Category: Lines
is static;
Trim(me : in out; L : Lin2d from gp;
Index : Integer from Standard = 0)
---Purpose: Trims the lines at intersections with <L>.
--
--Category: Trimming
is static;
Trim(me : in out; L : Lin2d from gp;
Start, End : Real from Standard;
Index : Integer from Standard = 0)
---Purpose: Trims the lines at intersections with <L> in the
-- parameter range <Start>, <End>
--
--Category: Trimming
is static;
Trim(me : in out; P1, P2 : Pnt2d from gp;
Index : Integer from Standard = 0)
---Purpose: Trims the line at intersection with the oriented
-- segment P1,P2.
--
--Category: Trimming
is static;
NbIntervals(me) returns Integer from Standard
---Purpose: Returns the total number of intervals on all the
-- lines.
---Category : Results
raises OutOfRange
is static;
NbLines(me) returns Integer from Standard
---Purpose: Returns the number of lines.
---Category : Results
is static;
Line(me; I : Integer from Standard) returns Lin2d from gp
---Purpose: Returns the line of index <I>.
---C++: return const &
---Category : Results
raises OutOfRange
is static;
LineForm(me; I : Integer from Standard) returns LineForm from Hatch
---Purpose: Returns the type of the line of index <I>.
---Category : Results
raises OutOfRange
is static;
IsXLine(me; I : Integer from Standard) returns Boolean from Standard
---Purpose: Returns True if the line of index <I> has a
-- constant X value.
---Category : Results
---C++: inline
raises OutOfRange
is static;
IsYLine(me; I : Integer from Standard) returns Boolean from Standard
---Purpose: Returns True if the line of index <I> has a
-- constant Y value.
---Category : Results
---C++: inline
raises OutOfRange
is static;
Coordinate(me; I : Integer from Standard) returns Real from Standard
---Purpose: Returns the X or Y coordinate of the line of index
-- <I> if it is a X or a Y line.
---Category : Results
raises OutOfRange
is static;
NbIntervals(me; I : Integer from Standard) returns Integer from Standard
---Purpose: Returns the number of intervals on line of index <I>.
---Category : Results
raises OutOfRange
is static;
Start(me; I,J : Integer from Standard) returns Real from Standard
---Purpose: Returns the first parameter of interval <J> on
-- line <I>.
---Category : Results
raises OutOfRange
is static;
StartIndex(me; I,J : Integer from Standard;
Index : out Integer from Standard;
Par2 : out Real from Standard)
---Purpose: Returns the first Index and Par2 of interval <J> on
-- line <I>.
---Category : Results
raises OutOfRange
is static;
End(me; I,J : Integer) returns Real from Standard
---Purpose: Returns the last parameter of interval <J> on
-- line <I>.
---Category : Results
raises OutOfRange
is static;
EndIndex(me; I,J : Integer from Standard;
Index : out Integer from Standard;
Par2 : out Real from Standard)
---Purpose: Returns the last Index and Par2 of interval <J> on
-- line <I>.
---Category : Results
raises OutOfRange
is static;
fields
myToler : Real;
myLines : SequenceOfLine from Hatch;
myOrient : Boolean;
end Hatcher;

339
src/Hatch/Hatch_Hatcher.cxx Executable file
View File

@@ -0,0 +1,339 @@
// File: Hatch_Hatcher.cxx
// Created: Wed Aug 19 12:45:04 1992
// Author: Modelistation
// <model@phylox>
#include <Hatch_Hatcher.ixx>
#include <Hatch_Line.hxx>
#include <IntAna2d_IntPoint.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <Hatch_Parameter.hxx>
#include <gp_Vec2d.hxx>
#include <Standard_OutOfRange.hxx>
//=======================================================================
//function : Hatch_Hatcher
//purpose :
//=======================================================================
Hatch_Hatcher::Hatch_Hatcher(const Standard_Real Tol,
const Standard_Boolean Oriented) :
myToler(Tol),
myOrient(Oriented)
{
}
//=======================================================================
//function : AddLine
//purpose :
//=======================================================================
void Hatch_Hatcher::AddLine(const gp_Lin2d& L, const Hatch_LineForm T)
{
Hatch_Line HL(L,T);
myLines.Append(HL);
}
//=======================================================================
//function : AddLine
//purpose :
//=======================================================================
void Hatch_Hatcher::AddLine(const gp_Dir2d& D,
const Standard_Real Dist)
{
Standard_Real X = D.X();
Standard_Real Y = D.Y();
gp_Pnt2d O(-Y * Dist, X * Dist);
gp_Lin2d L(O,D);
AddLine(L,Hatch_ANYLINE);
}
//=======================================================================
//function : AddXLine
//purpose :
//=======================================================================
void Hatch_Hatcher::AddXLine(const Standard_Real X)
{
gp_Pnt2d O(X,0);
gp_Dir2d D(0,1);
gp_Lin2d L(O,D);
AddLine(L,Hatch_XLINE);
}
//=======================================================================
//function : AddYLine
//purpose :
//=======================================================================
void Hatch_Hatcher::AddYLine(const Standard_Real Y)
{
gp_Pnt2d O(0,Y);
gp_Dir2d D(1,0);
gp_Lin2d L(O,D);
AddLine(L,Hatch_YLINE);
}
//=======================================================================
//function : Trim
//purpose :
//=======================================================================
void Hatch_Hatcher::Trim
(const gp_Lin2d& L,
const Standard_Integer Index)
{
Trim(L,RealFirst(),RealLast(),Index);
}
//=======================================================================
//function : Trim
//purpose :
//=======================================================================
void Hatch_Hatcher::Trim
(const gp_Lin2d& L,
const Standard_Real Start,
const Standard_Real End,
const Standard_Integer Index)
{
IntAna2d_IntPoint Pinter;
IntAna2d_AnaIntersection Inters;
Standard_Integer iLine;
for (iLine = 1; iLine <= myLines.Length(); iLine++) {
Inters.Perform(myLines(iLine).myLin,L);
if (Inters.IsDone()) {
if (!Inters.IdenticalElements() && !Inters.ParallelElements()) {
// we have got something
Pinter = Inters.Point(1);
Standard_Real linePar = Pinter.ParamOnSecond();
if (linePar - Start < - myToler) continue;
if (linePar - End > myToler) continue;
Standard_Real norm = L.Direction() ^ myLines(iLine).myLin.Direction();
if (linePar - Start < myToler) {
// on the limit of the trimming segment
// accept if the other extremity is on the left
if (norm < 0) continue;
}
if (linePar - End > -myToler) {
// on the limit of the trimming segment
// accept if the other extremity is on the left
if (norm > 0) continue;
}
// insert the parameter
myLines(iLine).AddIntersection (Pinter.ParamOnFirst(),
norm > 0,
Index,
Pinter.ParamOnSecond(),
myToler);
}
}
}
}
//=======================================================================
//function : Trim
//purpose :
//=======================================================================
void Hatch_Hatcher::Trim
(const gp_Pnt2d& P1,
const gp_Pnt2d& P2,
const Standard_Integer Index)
{
gp_Vec2d V(P1,P2);
if (Abs(V.X()) > .9 * RealLast())
V.Multiply(1/V.X());
else if (Abs(V.Y()) > .9 * RealLast())
V.Multiply(1/V.Y());
if (V.Magnitude() > myToler) {
gp_Dir2d D(V);
gp_Lin2d L(P1,D);
Trim(L,0,P1.Distance(P2),Index);
}
}
//=======================================================================
//function : NbIntervals
//purpose :
//=======================================================================
Standard_Integer Hatch_Hatcher::NbIntervals() const
{
Standard_Integer i, nb = 0;
for (i = 1; i <= myLines.Length(); i++)
nb += NbIntervals(i);
return nb;
}
//=======================================================================
//function : NbLines
//purpose :
//=======================================================================
Standard_Integer Hatch_Hatcher::NbLines() const
{
return myLines.Length();
}
//=======================================================================
//function : Line
//purpose :
//=======================================================================
const gp_Lin2d& Hatch_Hatcher::Line(const Standard_Integer I) const
{
return myLines(I).myLin;
}
//=======================================================================
//function : LineForm
//purpose :
//=======================================================================
Hatch_LineForm Hatch_Hatcher::LineForm(const Standard_Integer I) const
{
return myLines(I).myForm;
}
//=======================================================================
//function : Coordinate
//purpose :
//=======================================================================
Standard_Real Hatch_Hatcher::Coordinate(const Standard_Integer I) const
{
switch (myLines(I).myForm) {
case Hatch_XLINE :
return myLines(I).myLin.Location().X();
case Hatch_YLINE :
return myLines(I).myLin.Location().Y();
case Hatch_ANYLINE :
Standard_OutOfRange::Raise("Hatcher : not an X or Y line");
return 0.;
}
return 0.;
}
//=======================================================================
//function : NbIntervals
//purpose :
//=======================================================================
Standard_Integer Hatch_Hatcher::NbIntervals(const Standard_Integer I) const
{
Standard_Integer l = myLines(I).myInters.Length();
if (l == 0)
l = myOrient ? 1 : 0;
else {
l = l/2;
if (myOrient) if (!myLines(I).myInters(1).myStart) l++;
}
return l;
}
//=======================================================================
//function : Start
//purpose :
//=======================================================================
Standard_Real Hatch_Hatcher::Start(const Standard_Integer I,
const Standard_Integer J) const
{
if (myLines(I).myInters.IsEmpty()) {
if (J != 1 || !myOrient) Standard_OutOfRange::Raise();
return RealFirst();
}
else {
Standard_Integer jj = 2*J - 1;
if (!myLines(I).myInters(1).myStart && myOrient) jj--;
if (jj == 0) return RealFirst();
return myLines(I).myInters(jj).myPar1;
}
}
//=======================================================================
//function : StartIndex
//purpose :
//=======================================================================
void Hatch_Hatcher::StartIndex
(const Standard_Integer I,
const Standard_Integer J,
Standard_Integer& Index,
Standard_Real& Par2) const
{
if (myLines(I).myInters.IsEmpty()) {
if (J != 1) Standard_OutOfRange::Raise();
Index = 0;
Par2 = 0;
}
else {
Standard_Integer jj = 2*J - 1;
if (!myLines(I).myInters(1).myStart && myOrient) jj--;
if (jj == 0) {
Index = 0;
Par2 = 0;
}
else {
Index = myLines(I).myInters(jj).myIndex;
Par2 = myLines(I).myInters(jj).myPar2;
}
}
}
//=======================================================================
//function : End
//purpose :
//=======================================================================
Standard_Real Hatch_Hatcher::End(const Standard_Integer I,
const Standard_Integer J) const
{
if (myLines(I).myInters.IsEmpty()) {
if (J != 1 || !myOrient) Standard_OutOfRange::Raise();
return RealLast();
}
else {
Standard_Integer jj = 2*J;
if (!myLines(I).myInters(1).myStart && myOrient) jj--;
if (jj > myLines(I).myInters.Length()) return RealLast();
return myLines(I).myInters(jj).myPar1;
}
}
//=======================================================================
//function : EndIndex
//purpose :
//=======================================================================
void Hatch_Hatcher::EndIndex
(const Standard_Integer I,
const Standard_Integer J,
Standard_Integer& Index,
Standard_Real& Par2) const
{
if (myLines(I).myInters.IsEmpty()) {
if (J != 1) Standard_OutOfRange::Raise();
Index = 0;
Par2 = 0;
}
else {
Standard_Integer jj = 2*J;
if (!myLines(I).myInters(1).myStart && myOrient) jj--;
if (jj > myLines(I).myInters.Length()) {
Index = 0;
Par2 = 0;
}
else {
Index = myLines(I).myInters(jj).myIndex;
Par2 = myLines(I).myInters(jj).myPar2;
}
}
}

36
src/Hatch/Hatch_Hatcher.lxx Executable file
View File

@@ -0,0 +1,36 @@
// File: Hatch_Hatcher.lxx
// Created: Wed Aug 19 15:41:25 1992
// Author: Modelistation
// <model@phylox>
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
inline void Hatch_Hatcher::Tolerance(const Standard_Real Tol)
{
myToler = Tol;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
inline Standard_Real Hatch_Hatcher::Tolerance() const
{
return myToler;
}
inline Standard_Boolean Hatch_Hatcher::IsXLine(const Standard_Integer I) const
{
return LineForm(I) == Hatch_XLINE;
}
inline Standard_Boolean Hatch_Hatcher::IsYLine(const Standard_Integer I) const
{
return LineForm(I) == Hatch_YLINE;
}

53
src/Hatch/Hatch_Line.cdl Executable file
View File

@@ -0,0 +1,53 @@
-- File: Line.cdl
-- Created: Tue Aug 18 19:56:50 1992
-- Author: Modelistation
-- <model@phylox>
---Copyright: Matra Datavision 1992
private class Line from Hatch
---Purpose: Stores a Line in the Hatcher. Represented by :
--
-- * A Lin2d from gp, the geometry of the line.
--
-- * Bounding parameters for the line.
--
-- * A sorted List of Parameters, the intersections
-- on the line.
uses
Real from Standard,
Integer from Standard,
Boolean from Standard,
Lin2d from gp,
LineForm from Hatch,
SequenceOfParameter from Hatch
is
Create;
Create(L : Lin2d from gp; T : LineForm from Hatch)
returns Line from Hatch;
AddIntersection(me : in out;
Par1 : Real from Standard;
Start : Boolean from Standard;
Index : Integer from Standard;
Par2 : Real from Standard;
theToler : Real from Standard)
---Purpose: Insert a new intersection in the sorted list.
is static;
fields
myLin : Lin2d from gp;
myForm : LineForm from Hatch;
myInters : SequenceOfParameter from Hatch;
friends
class Hatcher from Hatch
end Line;

59
src/Hatch/Hatch_Line.cxx Executable file
View File

@@ -0,0 +1,59 @@
// File: Hatch_Line.cxx
// Created: Wed Aug 19 15:43:22 1992
// Author: Modelistation
// <model@phylox>
#include <Hatch_Line.ixx>
#include <Hatch_Parameter.hxx>
//=======================================================================
//function : Hatch_Line
//purpose :
//=======================================================================
Hatch_Line::Hatch_Line()
{
}
//=======================================================================
//function : Hatch_Line
//purpose :
//=======================================================================
Hatch_Line::Hatch_Line(const gp_Lin2d& L,
const Hatch_LineForm T) :
myLin(L),
myForm(T)
{
}
//=======================================================================
//function : AddIntersection
//purpose :
//=======================================================================
void Hatch_Line::AddIntersection
(const Standard_Real Par1,
const Standard_Boolean Start,
const Standard_Integer Index,
const Standard_Real Par2,
const Standard_Real theToler)
{
Hatch_Parameter P(Par1,Start,Index,Par2);
Standard_Integer i;
for (i = 1; i <= myInters.Length(); i++) {
Standard_Real dfIntPar1 = myInters(i).myPar1;
// akm OCC109 vvv : Two intersections too close
if (Abs(Par1-dfIntPar1) < theToler)
{
myInters.Remove(i);
return;
}
// akm OCC109 ^^^
if (Par1 < dfIntPar1) {
myInters.InsertBefore(i,P);
return;
}
}
myInters.Append(P);
}

42
src/Hatch/Hatch_Parameter.cdl Executable file
View File

@@ -0,0 +1,42 @@
-- File: Parameter.cdl
-- Created: Tue Aug 18 19:43:39 1992
-- Author: Modelistation
-- <model@phylox>
---Copyright: Matra Datavision 1992
private class Parameter from Hatch
---Purpose: Stores an intersection on a line represented by :
--
-- * A Real parameter.
--
-- * A flag True when the parameter starts an interval.
--
uses
Real from Standard,
Integer from Standard,
Boolean from Standard
is
Create;
Create( Par1 : Real from Standard;
Start : Boolean from Standard;
Index : Integer from Standard = 0;
Par2 : Real from Standard = 0)
returns Parameter from Hatch;
fields
myPar1 : Real from Standard;
myStart : Boolean from Standard;
myIndex : Integer from Standard;
myPar2 : Real from Standard;
friends
class Line from Hatch,
class Hatcher from Hatch
end Parameter;

29
src/Hatch/Hatch_Parameter.cxx Executable file
View File

@@ -0,0 +1,29 @@
// File: Hatch_Parameter.cxx
// Created: Wed Aug 19 11:10:07 1992
// Author: Modelistation
// <model@phylox>
#include <Hatch_Parameter.ixx>
//=======================================================================
//function : Hatch_Parameter
//purpose :
//=======================================================================
Hatch_Parameter::Hatch_Parameter()
{
}
//=======================================================================
//function : Hatch_Parameter
//purpose :
//=======================================================================
Hatch_Parameter::Hatch_Parameter
(const Standard_Real Par1,
const Standard_Boolean Start,
const Standard_Integer Index,
const Standard_Real Par2) :
myPar1(Par1), myStart(Start), myIndex(Index), myPar2(Par2)
{
}