1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +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

107
src/TopExp/TopExp.cdl Executable file
View File

@@ -0,0 +1,107 @@
-- File: TopExp.cdl
-- Created: Thu Dec 20 16:28:01 1990
-- Author: Remi Lequette
-- <rle@topsn3>
---Copyright: Matra Datavision 1990
package TopExp
---Purpose: This package provides basic tools to explore the
-- topological data structures.
--
-- * Explorer : A tool to find all sub-shapes of a given
-- type. e.g. all faces of a solid.
--
-- * Package methods to map sub-shapes of a shape.
--
-- Level : Public
-- All methods of all classes will be public.
uses
TCollection,
TopLoc,
TopAbs,
TopoDS,
TopTools
is
private class StackOfIterator instantiates
Stack from TCollection (Iterator from TopoDS);
pointer Stack to Iterator from TopoDS;
class Explorer;
---Purpose: Tool to explore a topological data structure.
--
-- Package methods
--
MapShapes(S : Shape from TopoDS;
T : ShapeEnum from TopAbs;
M : in out IndexedMapOfShape from TopTools);
---Purpose: Stores in the map <M> all the sub-shapes of <S>
-- of type <T>.
--
-- Warning: The map is not cleared at first.
MapShapes(S : Shape from TopoDS;
M : in out IndexedMapOfShape from TopTools);
---Purpose: Stores in the map <M> all the sub-shapes of <S>.
MapShapesAndAncestors
(S : Shape from TopoDS;
TS : ShapeEnum from TopAbs;
TA : ShapeEnum from TopAbs;
M : in out IndexedDataMapOfShapeListOfShape from TopTools);
---Purpose: Stores in the map <M> all the subshape of <S> of
-- type <TS> for each one append to the list all
-- the ancestors of type <TA>. For example map all
-- the edges and bind the list of faces.
-- Warning: The map is not cleared at first.
FirstVertex(E : Edge from TopoDS;
CumOri : Boolean from Standard = Standard_False)
returns Vertex from TopoDS;
---Purpose: Returns the Vertex of orientation FORWARD in E. If
-- there is none returns a Null Shape.
-- CumOri = True : taking account the edge orientation
LastVertex(E : Edge from TopoDS;
CumOri : Boolean from Standard = Standard_False)
returns Vertex from TopoDS;
---Purpose: Returns the Vertex of orientation REVERSED in E. If
-- there is none returns a Null Shape.
-- CumOri = True : taking account the edge orientation
Vertices(E : Edge from TopoDS; Vfirst, Vlast : out Vertex from TopoDS;
CumOri : Boolean from Standard = Standard_False);
---Purpose: Returns in Vfirst, Vlast the FORWARD and REVERSED
-- vertices of the edge <E>. May be null shapes.
-- CumOri = True : taking account the edge orientation
Vertices(W : Wire from TopoDS; Vfirst, Vlast : out Vertex from TopoDS);
---Purpose: Returns in Vfirst, Vlast the first and last
-- vertices of the open wire <W>. May be null shapes.
-- if <W> is closed Vfirst and Vlast are a same
-- vertex on <W>.
-- if <W> is no manifold. VFirst and VLast are null
-- shapes.
CommonVertex( E1, E2 : Edge from TopoDS;
V : out Vertex from TopoDS)
returns Boolean;
---Purpose: Finds the vertex <V> common to the two edges
-- <E1,E2>, returns True if this vertex exists.
--
-- Warning: <V> has sense only if the value <True> is returned
end TopExp;

222
src/TopExp/TopExp.cxx Executable file
View File

@@ -0,0 +1,222 @@
// File: TopExp.cxx
// Created: Tue Jan 19 20:20:00 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#define No_Standard_NoMoreObject
#define No_Standard_NoSuchObject
#define No_Standard_TypeMismatch
#include <TopExp.ixx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
//=======================================================================
//function : MapShapes
//purpose :
//=======================================================================
void TopExp::MapShapes(const TopoDS_Shape& S,
const TopAbs_ShapeEnum T,
TopTools_IndexedMapOfShape& M)
{
TopExp_Explorer Ex(S,T);
while (Ex.More()) {
M.Add(Ex.Current());
Ex.Next();
}
}
//=======================================================================
//function : MapShapes
//purpose :
//=======================================================================
void TopExp::MapShapes(const TopoDS_Shape& S,
TopTools_IndexedMapOfShape& M)
{
M.Add(S);
TopoDS_Iterator It(S);
while (It.More()) {
MapShapes(It.Value(),M);
It.Next();
}
}
//=======================================================================
//function : MapShapesAndAncestors
//purpose :
//=======================================================================
void TopExp::MapShapesAndAncestors
(const TopoDS_Shape& S,
const TopAbs_ShapeEnum TS,
const TopAbs_ShapeEnum TA,
TopTools_IndexedDataMapOfShapeListOfShape& M)
{
TopTools_ListOfShape empty;
// visit ancestors
TopExp_Explorer exa(S,TA);
while (exa.More()) {
// visit shapes
const TopoDS_Shape& anc = exa.Current();
TopExp_Explorer exs(anc,TS);
while (exs.More()) {
Standard_Integer index = M.FindIndex(exs.Current());
if (index == 0) index = M.Add(exs.Current(),empty);
M(index).Append(anc);
exs.Next();
}
exa.Next();
}
// visit shapes not under ancestors
TopExp_Explorer ex(S,TS,TA);
while (ex.More()) {
Standard_Integer index = M.FindIndex(ex.Current());
if (index == 0) index = M.Add(ex.Current(),empty);
ex.Next();
}
}
//=======================================================================
//function : FirstVertex
//purpose :
//=======================================================================
TopoDS_Vertex TopExp::FirstVertex(const TopoDS_Edge& E,
const Standard_Boolean CumOri)
{
TopoDS_Iterator ite(E,CumOri);
while (ite.More()) {
if (ite.Value().Orientation() == TopAbs_FORWARD)
return TopoDS::Vertex(ite.Value());
ite.Next();
}
return TopoDS_Vertex();
}
//=======================================================================
//function : LastVertex
//purpose :
//=======================================================================
TopoDS_Vertex TopExp::LastVertex(const TopoDS_Edge& E,
const Standard_Boolean CumOri)
{
TopoDS_Iterator ite(E,CumOri);
while (ite.More()) {
if (ite.Value().Orientation() == TopAbs_REVERSED)
return TopoDS::Vertex(ite.Value());
ite.Next();
}
return TopoDS_Vertex();
}
//=======================================================================
//function : Vertices
//purpose :
//=======================================================================
void TopExp::Vertices(const TopoDS_Edge& E,
TopoDS_Vertex& Vfirst,
TopoDS_Vertex& Vlast,
const Standard_Boolean CumOri)
{
Vfirst = Vlast = TopoDS_Vertex(); // nullify
TopoDS_Iterator ite(E,CumOri);
while (ite.More()) {
if (ite.Value().Orientation() == TopAbs_FORWARD)
Vfirst = TopoDS::Vertex(ite.Value());
else if (ite.Value().Orientation() == TopAbs_REVERSED)
Vlast = TopoDS::Vertex(ite.Value());
ite.Next();
}
}
//=======================================================================
//function : Vertices
//purpose :
//=======================================================================
void TopExp::Vertices(const TopoDS_Wire& W,
TopoDS_Vertex& Vfirst,
TopoDS_Vertex& Vlast)
{
Vfirst = Vlast = TopoDS_Vertex(); // nullify
TopTools_MapOfShape vmap;
TopoDS_Iterator it(W);
TopoDS_Vertex V1,V2;
while (it.More()) {
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
if (E.Orientation() == TopAbs_REVERSED)
TopExp::Vertices(E,V2,V1);
else
TopExp::Vertices(E,V1,V2);
// add or remove in the vertex map
V1.Orientation(TopAbs_FORWARD);
V2.Orientation(TopAbs_REVERSED);
if (!vmap.Add(V1)) vmap.Remove(V1);
if (!vmap.Add(V2)) vmap.Remove(V2);
it.Next();
}
if (vmap.IsEmpty()) { // closed
TopoDS_Shape aLocalShape = V2.Oriented(TopAbs_FORWARD);
Vfirst = TopoDS::Vertex(aLocalShape);
aLocalShape = V2.Oriented(TopAbs_REVERSED);
Vlast = TopoDS::Vertex(aLocalShape);
// Vfirst = TopoDS::Vertex(V2.Oriented(TopAbs_FORWARD));
// Vlast = TopoDS::Vertex(V2.Oriented(TopAbs_REVERSED));
}
else if (vmap.Extent() == 2) { //open
TopTools_MapIteratorOfMapOfShape ite(vmap);
while (ite.More() && ite.Key().Orientation() != TopAbs_FORWARD)
ite.Next();
if (ite.More()) Vfirst = TopoDS::Vertex(ite.Key());
ite.Initialize(vmap);
while (ite.More() && ite.Key().Orientation() != TopAbs_REVERSED)
ite.Next();
if (ite.More()) Vlast = TopoDS::Vertex(ite.Key());
}
}
//=======================================================================
//function : CommonVertex
//purpose :
//=======================================================================
Standard_Boolean TopExp::CommonVertex(const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
TopoDS_Vertex& V)
{
TopoDS_Vertex firstVertex1, lastVertex1, firstVertex2, lastVertex2;
TopExp::Vertices(E1, firstVertex1, lastVertex1);
TopExp::Vertices(E2, firstVertex2, lastVertex2);
if (firstVertex1.IsSame(firstVertex2) ||
firstVertex1.IsSame(lastVertex2)) {
V = firstVertex1;
return Standard_True;
}
if (lastVertex1.IsSame(firstVertex2) ||
lastVertex1.IsSame(lastVertex2)) {
V = lastVertex1;
return Standard_True;
}
return Standard_False;
} // CommonVertex

165
src/TopExp/TopExp_Explorer.cdl Executable file
View File

@@ -0,0 +1,165 @@
-- File: TopExp_Explorer.cdl
-- Created: Thu Jan 14 17:30:37 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
class Explorer from TopExp
---Purpose: An Explorer is a Tool to visit a Topological Data
-- Structure form the TopoDS package.
--
-- An Explorer is built with :
--
-- * The Shape to explore.
--
-- * The type of Shapes to find : e.g VERTEX, EDGE.
-- This type cannot be SHAPE.
--
-- * The type of Shapes to avoid. e.g SHELL, EDGE.
-- By default this type is SHAPE which means no
-- restriction on the exploration.
--
--
-- The Explorer visits all the structure to find
-- shapes of the requested type which are not
-- contained in the type to avoid.
--
-- Example to find all the Faces in the Shape S :
--
-- TopExp_Explorer Ex;
-- for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
-- ProcessFace(Ex.Current());
-- }
--
-- // an other way
-- TopExp_Explorer Ex(S,TopAbs_FACE);
-- while (Ex.More()) {
-- ProcessFace(Ex.Current());
-- Ex.Next();
-- }
--
-- To find all the vertices which are not in an edge :
--
-- for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
--
--
-- To find all the faces in a SHELL, then all the
-- faces not in a SHELL :
--
-- TopExp_Explorer Ex1, Ex2;
--
-- for (Ex1.Init(S,TopAbs_SHELL),...) {
-- // visit all shells
-- for (Ex2.Init(Ex1.Current(),TopAbs_FACE),...) {
-- // visit all the faces of the current shell
-- }
-- }
--
-- for (Ex1.Init(S,TopAbs_FACE,TopAbs_SHELL),...) {
-- // visit all faces not in a shell
-- }
--
--
-- If the type to avoid is the same or is less
-- complex than the type to find it has no effect.
--
-- For example searching edges not in a vertex does
-- not make a difference.
--
uses
ShapeEnum from TopAbs,
Shape from TopoDS,
Stack from TopExp
raises
NoMoreObject from Standard,
NoSuchObject from Standard
is
Create returns Explorer from TopExp;
---Purpose: Creates an empty explorer, becomes usefull after Init.
Create(S : Shape from TopoDS;
ToFind : ShapeEnum from TopAbs;
ToAvoid : ShapeEnum from TopAbs = TopAbs_SHAPE)
returns Explorer from TopExp;
---Purpose: Creates an Explorer on the Shape <S>.
--
-- <ToFind> is the type of shapes to search.
-- TopAbs_VERTEX, TopAbs_EDGE, ...
--
-- <ToAvoid> is the type of shape to skip in the
-- exploration. If <ToAvoid> is equal or less
-- complex than <ToFind> or if <ToAVoid> is SHAPE it
-- has no effect on the exploration.
--
Init(me : in out; S : Shape from TopoDS;
ToFind : ShapeEnum from TopAbs;
ToAvoid : ShapeEnum from TopAbs = TopAbs_SHAPE)
---Purpose: Resets this explorer on the shape S. It is initialized to
-- search the shape S, for shapes of type ToFind, that
-- are not part of a shape ToAvoid.
-- If the shape ToAvoid is equal to TopAbs_SHAPE, or
-- if it is the same as, or less complex than, the shape
-- ToFind it has no effect on the search.
is static;
More(me) returns Boolean
---Purpose: Returns True if there are more shapes in the
-- exploration.
---C++: inline
is static;
Next(me : in out)
---Purpose: Moves to the next Shape in the exploration.
-- Exceptions
-- Standard_NoMoreObject if there are no more shapes to explore.
raises
NoMoreObject
is static;
Current(me) returns Shape from TopoDS
---Purpose: Returns the current shape in the exploration.
-- Exceptions
-- Standard_NoSuchObject if this explorer has no more shapes to explore.
raises NoSuchObject from Standard
---C++: return const &
is static;
ReInit(me : in out)
---Purpose: Reinitialize the exploration with the original
-- arguments.
is static;
Depth(me) returns Integer
---Purpose: Returns the current depth of the exploration. 0 is
-- the shape to explore itself.
---C++: inline
is static;
Clear(me : in out)
---Purpose: Clears the content of the explorer. It will return
-- False on More().
---C++: inline
is static;
-- private implementation methods
Destroy(me : in out);
---C++: alias ~
fields
myStack : Stack from TopExp;
myTop : Integer from Standard;
mySizeOfStack : Integer from Standard;
myShape : Shape from TopoDS;
hasMore : Boolean from Standard;
toFind : ShapeEnum from TopAbs;
toAvoid : ShapeEnum from TopAbs;
end Explorer;

236
src/TopExp/TopExp_Explorer.cxx Executable file
View File

@@ -0,0 +1,236 @@
// File: TopExp_Explorer.cxx
// Created: Mon Jan 18 18:04:49 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#define No_Standard_NoMoreObject
#define No_Standard_NoSuchObject
#include <TopExp_Explorer.ixx>
#include <TopoDS_Iterator.hxx>
#include <TopAbs.hxx>
#include <Standard.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
// macro to compare two types of shapes
// always True if the first one is SHAPE
#define SAMETYPE(x,y) ((x) == (y))
#define AVOID(x,y) (((x) == TopAbs_SHAPE) ? Standard_False : (x) == (y))
#define LESSCOMPLEX(x,y) ((x) > (y))
static const Standard_Integer theStackSize = 20;
//=======================================================================
//function : TopExp_Explorer
//purpose :
//=======================================================================
TopExp_Explorer::TopExp_Explorer() :
myStack(0L),myTop(-1),hasMore(Standard_False)
{
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
mySizeOfStack = theStackSize;
}
//=======================================================================
//function : TopExp_Explorer
//purpose :
//=======================================================================
TopExp_Explorer::TopExp_Explorer(const TopoDS_Shape& S,
const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid):
myStack(0L),myTop(-1),hasMore(Standard_False)
{
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
mySizeOfStack = theStackSize;
Init(S,ToFind,ToAvoid);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TopExp_Explorer::Init(const TopoDS_Shape& S,
const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid)
{
if(myTop >=0) {
for(int i=0;i<= myTop; i++)
myStack[i].~TopoDS_Iterator();
}
myTop = -1;
myShape = S;
toFind = ToFind;
toAvoid = ToAvoid;
if (S.IsNull()) {
hasMore = Standard_False;
return;
}
#if 0
// for SOLID, FACE, EDGE ignores the initial orientation
TopAbs_ShapeEnum T = myShape.ShapeType();
if ((T == TopAbs_SOLID) || (T == TopAbs_FACE) || (T == TopAbs_EDGE))
myShape.Orientation(TopAbs_FORWARD);
#endif
if (toFind == TopAbs_SHAPE)
hasMore = Standard_False;
else {
TopAbs_ShapeEnum ty = S.ShapeType();
if (LESSCOMPLEX(ty,toFind)) {
// the first Shape is less complex, nothing to find
hasMore = Standard_False;
}
else if (!SAMETYPE(ty,toFind)) {
// type is more complex search inside
hasMore = Standard_True;
Next();
}
else {
// type is found
hasMore = Standard_True;
}
}
}
//=======================================================================
//function : Current
//purpose :
//=======================================================================
const TopoDS_Shape& TopExp_Explorer::Current()const
{
Standard_NoSuchObject_Raise_if(!hasMore,"TopExp_Explorer::Current");
if (myTop >= 0) {
const TopoDS_Shape& S = myStack[myTop].Value();
return S;
}
else
return myShape;
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
#ifdef WNT
#pragma warning(push)
#pragma warning(disable: 4291) // to avoid warning when using new(buffer) syntax
#endif
void TopExp_Explorer::Next()
{
Standard_Integer NewSize;
TopoDS_Shape ShapTop;
TopAbs_ShapeEnum ty;
Standard_NoMoreObject_Raise_if(!hasMore,"TopExp_Explorer::Next");
if (myTop < 0) {
// empty stack. Entering the initial shape.
ty = myShape.ShapeType();
if (SAMETYPE(toFind,ty)) {
// already visited once
hasMore = Standard_False;
return;
}
else if (AVOID(toAvoid,ty)) {
// avoid the top-level
hasMore = Standard_False;
return;
}
else {
// push and try to find
if(++myTop >= mySizeOfStack) {
NewSize = mySizeOfStack + theStackSize;
TopExp_Stack newStack = (TopoDS_Iterator*)Standard::Allocate(NewSize*sizeof(TopoDS_Iterator));
Standard_Integer i;
for ( i =0; i < myTop; i++) {
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
myStack[i].~TopoDS_Iterator();
}
Standard::Free((Standard_Address&)myStack);
mySizeOfStack = NewSize;
myStack = newStack;
}
new (&myStack[myTop]) TopoDS_Iterator(myShape);
}
}
else myStack[myTop].Next();
for (;;) {
if (myStack[myTop].More()) {
ShapTop = myStack[myTop].Value();
ty = ShapTop.ShapeType();
if (SAMETYPE(toFind,ty)) {
hasMore = Standard_True;
return;
}
else if (LESSCOMPLEX(toFind,ty) && !AVOID(toAvoid,ty)) {
if(++myTop >= mySizeOfStack) {
NewSize = mySizeOfStack + theStackSize;
TopExp_Stack newStack = (TopoDS_Iterator*)Standard::Allocate(NewSize*sizeof(TopoDS_Iterator));
Standard_Integer i;
for (i =0; i < myTop; i++) {
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
myStack[i].~TopoDS_Iterator();
}
Standard::Free((Standard_Address&)myStack);
mySizeOfStack = NewSize;
myStack = newStack;
}
new (&myStack[myTop]) TopoDS_Iterator(ShapTop);
}
else {
myStack[myTop].Next();
}
}
else {
myStack[myTop].~TopoDS_Iterator();
myTop--;
if(myTop < 0) break;
myStack[myTop].Next();
}
}
hasMore = Standard_False;
}
#ifdef WNT
#pragma warning(pop)
#endif
//=======================================================================
//function : ReInit
//purpose :
//=======================================================================
void TopExp_Explorer::ReInit()
{
Init(myShape,toFind,toAvoid);
}
void TopExp_Explorer::Destroy()
{
if (myStack)
{
for(int i=0;i<= myTop; i++)myStack[i].~TopoDS_Iterator();
Standard::Free((Standard_Address&)myStack);
}
mySizeOfStack = 0;
myStack = 0L;
}

43
src/TopExp/TopExp_Explorer.lxx Executable file
View File

@@ -0,0 +1,43 @@
// File: TopExp_Explorer.lxx
// Created: Mon Jan 18 18:05:05 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <TopoDS_Iterator.hxx>
//=======================================================================
//function : More
//purpose :
//=======================================================================
inline Standard_Boolean TopExp_Explorer::More()const
{
return hasMore;
}
//=======================================================================
//function : Depth
//purpose :
//=======================================================================
inline Standard_Integer TopExp_Explorer::Depth()const
{
return myTop;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
inline void TopExp_Explorer::Clear()
{
hasMore = Standard_False;
if(myTop >0) {
for(int i=1;i<= myTop; i++)
myStack[i].~TopoDS_Iterator();
}
myTop = 0;
}