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

36
src/TopOpeBRepBuild/FILES Executable file
View File

@@ -0,0 +1,36 @@
TopOpeBRepBuild.cxx
TopOpeBRepBuild_Builder1_1.cxx
TopOpeBRepBuild_Builder1_2.cxx
TopOpeBRepBuild_Tools_1.cxx
TopOpeBRepBuild_trace.cxx
TopOpeBRepBuild_End.cxx
TopOpeBRepBuild_Merge.cxx
TopOpeBRepBuild_BuildEdges.cxx
TopOpeBRepBuild_BuildFaces.cxx
TopOpeBRepBuild_BuildVertices.cxx
TopOpeBRepBuild_SplitEdge.hxx
TopOpeBRepBuild_SplitFace.hxx
TopOpeBRepBuild_SplitSolid.hxx
TopOpeBRepBuild_SplitShapes.hxx
TopOpeBRepBuild_Fill.hxx
TopOpeBRepBuild_KPart.cxx
TopOpeBRepBuild_Griddump.cxx
TopOpeBRepBuild_Grid.cxx
TopOpeBRepBuild_GridSS.cxx
TopOpeBRepBuild_GridFF.cxx
TopOpeBRepBuild_GridEE.cxx
TopOpeBRepBuild_Section.cxx
TopOpeBRepBuild_FREGU.cxx
TopOpeBRepBuild_SREGU.cxx
TopOpeBRepBuild_define.hxx
TopOpeBRepBuild_on.cxx
TopOpeBRepBuild_keep.cxx
TopOpeBRepBuild_makesolids.cxx
TopOpeBRepBuild_makefaces.cxx
TopOpeBRepBuild_makeedges.cxx
TopOpeBRepBuild_kpkole.cxx
TopOpeBRepBuild_kpresu.hxx
TopOpeBRepBuild_ffsfs.cxx
TopOpeBRepBuild_BuilderON2d.cxx
TopOpeBRepBuild_fctwes.cxx
TopOpeBRepBuild_ffwesk.cxx

View File

@@ -0,0 +1,108 @@
-- File: TopOpeBRepBuild.cdl
-- Created: Thu Jun 17 09:59:51 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
package TopOpeBRepBuild
---Purpose:
-- This package describes algorithms and dedicated tools
-- involved in topological operation on BRep shapes.
-- These "builders" works on a data structure that must have been
-- previously filled (by a "filler") according to the
-- topological operation rules defined in class DataStructure
-- from TopOpeBRepDS.
-- The DSFiller must be considered as a "linking" tool
-- dealing with geometric data as an input and a DS as an
-- output.
-- These geometric data may be seen as the result of 3D
-- intersection between BRep shapes.
uses
Standard, MMgt, TCollection, TColStd,
gp, Geom, Geom2d, Geom2dInt,
TopAbs, TopoDS, TopTools, TopExp,
BRepClass, BRep,
TopOpeBRepDS, TopOpeBRepTool,
--modified by NIZNHY-PKV Thu Feb 10 11:51:54 2000 f
Bnd
--modified by NIZNHY-PKV Thu Feb 10 11:51:57 2000 t
is
class Loop;
class ListOfLoop instantiates List from TCollection(Loop);
class LoopSet;
deferred class LoopClassifier;
enumeration LoopEnum is ANYLOOP,BOUNDARY,BLOCK end LoopEnum;
class ListOfListOfLoop instantiates List from TCollection(ListOfLoop);
class AreaBuilder;
class Pave;
class ListOfPave instantiates List from TCollection(Pave);
class PaveSet;
class PaveClassifier;
class Area1dBuilder;
class EdgeBuilder;
--modified by NIZHNY-MZV Mon Sep 20 15:43:24 1999
class Tools;
-- class LoopTreeNode;
-- class ListOfLoopTreeNode instantiates List from TCollection (LoopTreeNode);
-- class IndexedDataMapOfLoopListOfLoop instantiates IndexedDataMap from TCollection
-- (Transient from Standard, ListOfLoop from TopOpeBRepBuild, MapTransientHasher from TColStd);
class ShapeSet;
class WireEdgeSet;pointer PWireEdgeSet to WireEdgeSet from TopOpeBRepBuild;
class ShellFaceSet;
class BlockIterator;
class BlockBuilder;
deferred class CompositeClassifier;
class WireEdgeClassifier;
class ShellFaceClassifier;
class Area2dBuilder;
class FaceAreaBuilder;
class FaceBuilder;
class Area3dBuilder;
class SolidAreaBuilder;
class SolidBuilder;
class ShapeListOfShape;
class ListOfShapeListOfShape instantiates List from TCollection(ShapeListOfShape);
class DataMapOfShapeListOfShapeListOfShape
instantiates DataMap from TCollection
(Shape from TopoDS,ListOfShapeListOfShape,ShapeMapHasher from TopTools);
class GTopo; pointer PGTopo to GTopo from TopOpeBRepBuild;
class GIter;
class GTool;
class Builder; pointer PBuilder to Builder from TopOpeBRepBuild;
--modified by NIZHNY-MZV Wed Sep 29 09:33:20 1999
class Builder1;
class BuilderON;
class HBuilder;
class WireToFace;
class ShellToSolid;
class FuseFace;
--modified by NIZNHY-PKV Thu Feb 10 11:25:15 2000 from
class CorrectFace2d;
class VertexInfo;
class Tools2d;
class IndexedDataMapOfShapeVertexInfo instantiates
IndexedDataMap from TCollection (Shape from TopoDS,
VertexInfo from TopOpeBRepBuild,
ShapeMapHasher from TopTools);
--modified by NIZNHY-PKV Thu Feb 10 11:25:19 2000 to
end TopOpeBRepBuild;

View File

@@ -0,0 +1,5 @@
// File: TopOpeBRepBuild.cxx
// Created: Fri Jan 6 10:15:03 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>

View File

@@ -0,0 +1,56 @@
-- File: TopOpeBRepBuild_Area1dBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class Area1dBuilder from TopOpeBRepBuild
inherits AreaBuilder from TopOpeBRepBuild
uses
PaveSet from TopOpeBRepBuild,
PaveClassifier from TopOpeBRepBuild,
Loop from TopOpeBRepBuild,
ListOfLoop from TopOpeBRepBuild,
ListIteratorOfListOfLoop from TopOpeBRepBuild,
ListOfListOfLoop from TopOpeBRepBuild,
ListIteratorOfListOfListOfLoop from TopOpeBRepBuild,
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild,
LoopEnum from TopOpeBRepBuild
is
Create returns Area1dBuilder;
Create(LS : in out PaveSet; LC : in out PaveClassifier;
ForceClass : Boolean = Standard_False) returns Area1dBuilder;
---Purpose: Creates a Area1dBuilder to find the areas of
-- the shapes described by <LS> using the classifier <LC>.
InitAreaBuilder(me : in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False)
---Purpose: Sets a Area1dBuilder to find the areas of
-- the shapes described by <LS> using the classifier <LC>.
is redefined;
ADD_Loop_TO_LISTOFLoop(me; L : Loop;
LOL : in out ListOfLoop;
s : Address = NULL) is redefined;
REM_Loop_FROM_LISTOFLoop(me; ITLOL : in out ListIteratorOfListOfLoop;
LOL : in out ListOfLoop;
s : Address = NULL) is redefined;
ADD_LISTOFLoop_TO_LISTOFLoop(me; LOL1 : in out ListOfLoop;
LOL2 : in out ListOfLoop;
s : Address = NULL;
s1 : Address = NULL;
s2 : Address = NULL) is redefined;
DumpList(myclass; L:ListOfLoop);
end Area1dBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,345 @@
// File: TopOpeBRepBuild_Area1dBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
// Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_Area1dBuilder.ixx>
#include <TopOpeBRepBuild_Pave.hxx>
#include <TopOpeBRepBuild_LoopEnum.hxx>
#include <Standard_DomainError.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopAbs.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceAREA();
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
#endif
//=======================================================================
//function : DumpList
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area1dBuilder::DumpList(const TopOpeBRepBuild_ListOfLoop& LOL)
{
#ifdef DEB
Standard_Integer iLOL;
TopOpeBRepBuild_ListIteratorOfListOfLoop itLOL;
for (iLOL = 0, itLOL.Initialize(LOL); itLOL.More(); iLOL++, itLOL.Next()) {
if (iLOL) cout<<" ";
else cout<<"DUMP_AREA : ";
const Handle(TopOpeBRepBuild_Loop)& L = itLOL.Value();
L->Dump();cout<<endl;
}
#endif
}
//=======================================================================
//function : TopOpeBRepBuild_Area1dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area1dBuilder::TopOpeBRepBuild_Area1dBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_Area1dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area1dBuilder::TopOpeBRepBuild_Area1dBuilder
(TopOpeBRepBuild_PaveSet& LS,
TopOpeBRepBuild_PaveClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : InitAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
(TopOpeBRepBuild_LoopSet& LS,
TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
TopAbs_State state;
Standard_Boolean Loopinside;
Standard_Boolean loopoutside;
TopOpeBRepBuild_ListIteratorOfListOfListOfLoop AreaIter;
TopOpeBRepBuild_ListIteratorOfListOfLoop LoopIter;
// boundaryloops : list of boundary loops out of the areas.
TopOpeBRepBuild_ListOfLoop boundaryloops;
myArea.Clear(); // Clear the list of Area to be built
for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) {
// process a new loop : L is the new current Loop
const Handle(TopOpeBRepBuild_Loop)& L = LS.Loop();
Standard_Boolean boundaryL = L->IsShape();
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
cout<<"++++ new loop : "; L->Dump();
if (boundaryL) cout<<" is bound"; else cout<<" is not bound";
cout<<endl;
}
#endif
// L = shape et ForceClass : on traite L comme un block
// L = shape et !ForceClass : on traite L comme un pur shape
// L = !shape : on traite L comme un block
Standard_Boolean traitercommeblock = !boundaryL || ForceClass;
if ( ! traitercommeblock ) {
// the loop L is a boundary loop :
// - try to insert it in an existing area, such as L is inside all
// the block loops. Only block loops of the area are compared.
// - if L could not be inserted, store it in list of boundary loops.
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = ( state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
ADD_Loop_TO_LISTOFLoop(L,boundaryloops,(void*)("! IN, to boundaryloops"));
}
} // end of boundary loop
else {
// the loop L is a block loop
// if L is IN theArea :
// - stop area scan, insert L in theArea.
// - remove from the area all the loops outside L
// - make a new area with them, unless they are all boundary
// - if they are all boundary put them back in boundaryLoops
// else :
// - create a new area with L.
// - insert boundary loops that are IN the new area
// (and remove them from 'boundaryloops')
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = (state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
while (LoopIter.More()) {
state = LC.Compare(LoopIter.Value(),L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); // not OUT
loopoutside = ( state == TopAbs_OUT );
if ( loopoutside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
// remove the loop from the area
ADD_Loop_TO_LISTOFLoop
(curL,removedLoops,(void*)("loopoutside = 1, area = removedLoops"));
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
(LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
}
}
// insert the loop in the area
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("area = current"));
if ( ! removedLoops.IsEmpty() ) {
if ( allShape ) {
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,boundaryloops,
(void*)("allShape = 1"),(void*)("removedLoops"),(void*)("boundaryloops"));
}
else {
// make a new area with the removed loops
TopOpeBRepBuild_ListOfLoop thelist;
myArea.Append(thelist);
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,myArea.Last(),
(void*)("allShape = 0"),(void*)("removedLoops"),(void*)("new area"));
}
}
} // Loopinside == True
else {
Standard_Integer ashapeinside,ablockinside;
TopOpeBRepBuild_ListOfLoop thelist1;
myArea.Append(thelist1);
TopOpeBRepBuild_ListOfLoop& newArea0 = myArea.Last();
ADD_Loop_TO_LISTOFLoop(L,newArea0,(void*)("new area"));
LoopIter.Initialize(boundaryloops);
while ( LoopIter.More() ) {
ashapeinside = ablockinside = Standard_False;
state = LC.Compare(LoopIter.Value(),L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ashapeinside = (state == TopAbs_IN);
if (ashapeinside) {
state = LC.Compare(L,LoopIter.Value());
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ablockinside = (state == TopAbs_IN);
}
if ( ashapeinside && ablockinside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
ADD_Loop_TO_LISTOFLoop
(curL,newArea0,(void*)("ashapeinside && ablockinside, new area"));
REM_Loop_FROM_LISTOFLoop
(LoopIter,boundaryloops,(void*)("loop of boundaryloops, boundaryloops"));
}
else {
LoopIter.Next();
}
} // end of boundaryloops scan
} // Loopinside == False
} // end of block loop
} // end of LoopSet LS scan
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
if ( ! myArea.IsEmpty() ) {
cout<<"------- Areas -------"<<endl;
for (AreaIter.Initialize(myArea);AreaIter.More();AreaIter.Next())
DumpList(AreaIter.Value());
cout<<"---------------------"<<endl;
}
}
#endif
InitArea();
}
//=======================================================================
//function : ADD_Loop_TO_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area1dBuilder::ADD_Loop_TO_LISTOFLoop
(const Handle(TopOpeBRepBuild_Loop)& L,
TopOpeBRepBuild_ListOfLoop& LOL,
const Standard_Address ss) const
{
#ifdef DEB
char* s = (char*)ss;
#endif
LOL.Append(L);
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
cout<<"--------------------- add area loop to area : ";
L->Dump(); cout<<endl;
if (s != NULL) cout<<s<<endl;
DumpList(LOL);
cout<<"---------------------"<<endl;
}
#endif
}
//=======================================================================
//function : REM_Loop_FROM_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area1dBuilder::REM_Loop_FROM_LISTOFLoop
(TopOpeBRepBuild_ListIteratorOfListOfLoop& ITA,
TopOpeBRepBuild_ListOfLoop& A,
const Standard_Address ss) const
{
#ifdef DEB
char* s = (char*)ss;
#endif
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
if (ITA.More()) {
cout<<"--------------------- remove area loop from area : ";
ITA.Value()->Dump(); cout<<endl;
if (s != NULL) cout<<s<<endl;
}
}
#endif
A.Remove(ITA);
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
DumpList(A);
cout<<"---------------------"<<endl;
}
#endif
}
//=======================================================================
//function : ADD_LISTOFLoop_TO_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area1dBuilder::ADD_LISTOFLoop_TO_LISTOFLoop
(TopOpeBRepBuild_ListOfLoop& A1,
TopOpeBRepBuild_ListOfLoop& A2,
const Standard_Address ss,
const Standard_Address ss1,
const Standard_Address ss2) const
{
#ifdef DEB
char* s = (char*)ss;
char* s1 = (char*)ss1;
char* s2 = (char*)ss2;
if (TopOpeBRepBuild_GettraceAREA()) {
cout<<"--------------------- add area 1 to area 2 : ";
if (s != NULL) cout<<s; cout<<endl;
cout<<"1 : "; if (s1 != NULL) cout<<s1; cout<<endl;
DumpList(A1);
}
#endif
A2.Append(A1);
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA()) {
cout<<"2 : "; if (s2 != NULL) cout<<s2; cout<<endl;
DumpList(A2);
cout<<"---------------------"<<endl;
}
#endif
}

View File

@@ -0,0 +1,41 @@
-- File: TopOpeBRepBuild_Area2dBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class Area2dBuilder from TopOpeBRepBuild
inherits AreaBuilder from TopOpeBRepBuild
---Purpose:
-- The Area2dBuilder algorithm is used to construct Faces from a LoopSet,
-- where the Loop is the composite topological object of the boundary,
-- here wire or block of edges.
-- The LoopSet gives an iteration on Loops.
-- For each Loop it indicates if it is on the boundary (wire) or if it
-- results from an interference (block of edges).
-- The result of the Area2dBuilder is an iteration on areas.
-- An area is described by a set of Loops.
uses
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild
is
Create returns Area2dBuilder;
Create(LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) returns Area2dBuilder;
---Purpose: Creates a Area2dBuilder to build faces on
-- the (wires,blocks of edge) of <LS>, using the classifier <LC>.
InitAreaBuilder(me : in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False)
---Purpose: Sets a Area1dBuilder to find the areas of
-- the shapes described by <LS> using the classifier <LC>.
is redefined;
end Area2dBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,207 @@
// File: TopOpeBRepBuild_Area2dBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
//Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_Area2dBuilder.ixx>
#include <TopOpeBRepBuild_Loop.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceAREA();
#endif
//=======================================================================
//function : TopOpeBRepBuild_Area2dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area2dBuilder::TopOpeBRepBuild_Area2dBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_Area2dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area2dBuilder::TopOpeBRepBuild_Area2dBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : InitAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
(TopOpeBRepBuild_LoopSet& LS,
TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
TopAbs_State state;
Standard_Boolean Loopinside;
Standard_Boolean loopoutside;
TopOpeBRepBuild_ListIteratorOfListOfListOfLoop AreaIter;
TopOpeBRepBuild_ListIteratorOfListOfLoop LoopIter;
// boundaryloops : list of boundary loops out of the areas.
TopOpeBRepBuild_ListOfLoop boundaryloops;
myArea.Clear(); // Clear the list of Area to be built
for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) {
// process a new loop : L is the new current Loop
const Handle(TopOpeBRepBuild_Loop)& L = LS.Loop();
Standard_Boolean boundaryL = L->IsShape();
// L = shape et ForceClass : on traite L comme un block
// L = shape et !ForceClass : on traite L comme un pur shape
// L = !shape : on traite L comme un block
Standard_Boolean traitercommeblock = (!boundaryL) || ForceClass;
if ( ! traitercommeblock ) {
// the loop L is a boundary loop :
// - try to insert it in an existing area, such as L is inside all
// the block loops. Only block loops of the area are compared.
// - if L could not be inserted, store it in list of boundary loops.
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = ( state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
ADD_Loop_TO_LISTOFLoop(L,boundaryloops,(void*)("! IN, to boundaryloops"));
}
} // end of boundary loop
else {
// the loop L is a block loop
// if L is IN theArea :
// - stop area scan, insert L in theArea.
// - remove from the area all the loops outside L
// - make a new area with them, unless they are all boundary
// - if they are all boundary put them back in boundaryLoops
// else :
// - create a new area with L.
// - insert boundary loops that are IN the new area
// (and remove them from 'boundaryloops')
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = (state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
while (LoopIter.More()) {
state = LC.Compare(LoopIter.Value(),L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); // not OUT
loopoutside = ( state == TopAbs_OUT );
if ( loopoutside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
// remove the loop from the area
ADD_Loop_TO_LISTOFLoop
(curL,removedLoops,(void*)("loopoutside = 1, area = removedLoops"));
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
(LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
}
}
// insert the loop in the area
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("area = current"));
if ( ! removedLoops.IsEmpty() ) {
if ( allShape ) {
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,boundaryloops,
(void*)("allShape = 1"),(void*)("removedLoops"),(void*)("boundaryloops"));
}
else {
// make a new area with the removed loops
TopOpeBRepBuild_ListOfLoop thelist;
myArea.Append(thelist);
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,myArea.Last(),
(void*)("allShape = 0"),(void*)("removedLoops"),(void*)("new area"));
}
}
} // Loopinside == True
else {
Standard_Integer ashapeinside,ablockinside;
TopOpeBRepBuild_ListOfLoop thelist1;
myArea.Append(thelist1);
TopOpeBRepBuild_ListOfLoop& newArea0 = myArea.Last();
ADD_Loop_TO_LISTOFLoop(L,newArea0,(void*)("new area"));
LoopIter.Initialize(boundaryloops);
while ( LoopIter.More() ) {
ashapeinside = ablockinside = Standard_False;
const Handle(TopOpeBRepBuild_Loop)& lb = LoopIter.Value();
state = LC.Compare(lb,L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ashapeinside = (state == TopAbs_IN);
if (ashapeinside) {
state = LC.Compare(L,lb);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ablockinside = (state == TopAbs_IN);
}
if ( ashapeinside && ablockinside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
ADD_Loop_TO_LISTOFLoop
(curL,newArea0,(void*)("ashapeinside && ablockinside, new area"));
REM_Loop_FROM_LISTOFLoop
(LoopIter,boundaryloops,(void*)("loop of boundaryloops, boundaryloops"));
}
else {
LoopIter.Next();
}
} // end of boundaryloops scan
} // Loopinside == False
} // end of block loop
} // end of LoopSet LS scan
if ( ! boundaryloops.IsEmpty() ) {
if ( myArea.IsEmpty() ) {
#ifdef DEB
if (TopOpeBRepBuild_GettraceAREA())
cout<<"---"<<endl<<"--- purge"<<endl<<"---"<<endl;
#endif
TopOpeBRepBuild_ListOfLoop newArea3;
newArea3.Append(boundaryloops);
myArea.Append(newArea3);
}
}
InitArea();
}

View File

@@ -0,0 +1,41 @@
-- File: TopOpeBRepBuild_Area3dBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class Area3dBuilder from TopOpeBRepBuild
inherits AreaBuilder from TopOpeBRepBuild
---Purpose:
-- The Area3dBuilder algorithm is used to construct Solids from a LoopSet,
-- where the Loop is the composite topological object of the boundary,
-- here wire or block of edges.
-- The LoopSet gives an iteration on Loops.
-- For each Loop it indicates if it is on the boundary (wire) or if it
-- results from an interference (block of edges).
-- The result of the Area3dBuilder is an iteration on areas.
-- An area is described by a set of Loops.
uses
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild
is
Create returns Area3dBuilder;
Create(LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) returns Area3dBuilder;
---Purpose: Creates a Area3dBuilder to build Solids on
-- the (shells,blocks of face) of <LS>, using the classifier <LC>.
InitAreaBuilder(me : in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False)
---Purpose: Sets a Area1dBuilder to find the areas of
-- the shapes described by <LS> using the classifier <LC>.
is redefined;
end Area3dBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,201 @@
// File: TopOpeBRepBuild_Area3dBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
//Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_Area3dBuilder.ixx>
#include <TopOpeBRepBuild_Loop.hxx>
//=======================================================================
//function : TopOpeBRepBuild_Area3dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area3dBuilder::TopOpeBRepBuild_Area3dBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_Area3dBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Area3dBuilder::TopOpeBRepBuild_Area3dBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : InitAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
(TopOpeBRepBuild_LoopSet& LS,
TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
TopAbs_State state;
Standard_Boolean Loopinside;
Standard_Boolean loopoutside;
TopOpeBRepBuild_ListIteratorOfListOfListOfLoop AreaIter;
TopOpeBRepBuild_ListIteratorOfListOfLoop LoopIter;
// boundaryloops : list of boundary loops out of the areas.
TopOpeBRepBuild_ListOfLoop boundaryloops;
myArea.Clear(); // Clear the list of Area to be built
for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) {
// process a new loop : L is the new current Loop
const Handle(TopOpeBRepBuild_Loop)& L = LS.Loop();
Standard_Boolean boundaryL = L->IsShape();
// L = shape et ForceClass : on traite L comme un block
// L = shape et !ForceClass : on traite L comme un pur shape
// L = !shape : on traite L comme un block
Standard_Boolean traitercommeblock = (!boundaryL) || ForceClass;
if ( ! traitercommeblock ) {
// the loop L is a boundary loop :
// - try to insert it in an existing area, such as L is inside all
// the block loops. Only block loops of the area are compared.
// - if L could not be inserted, store it in list of boundary loops.
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = ( state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
ADD_Loop_TO_LISTOFLoop(L,boundaryloops,(void*)("! IN, to boundaryloops"));
}
} // end of boundary loop
else {
// the loop L is a block loop
// if L is IN theArea :
// - stop area scan, insert L in theArea.
// - remove from the area all the loops outside L
// - make a new area with them, unless they are all boundary
// - if they are all boundary put them back in boundaryLoops
// else :
// - create a new area with L.
// - insert boundary loops that are IN the new area
// (and remove them from 'boundaryloops')
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = (state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
while (LoopIter.More()) {
const Handle(TopOpeBRepBuild_Loop)& LLI1 = LoopIter.Value();
state = LC.Compare(LLI1,L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); // not OUT
loopoutside = ( state == TopAbs_OUT );
if ( loopoutside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
// remove the loop from the area
ADD_Loop_TO_LISTOFLoop
(curL,removedLoops,(void*)("loopoutside = 1, area = removedLoops"));
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
(LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
}
}
// insert the loop in the area
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("area = current"));
if ( ! removedLoops.IsEmpty() ) {
if ( allShape ) {
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,boundaryloops,(void*)(
"allShape = 1"),(void*)("removedLoops"),(void*)("boundaryloops"));
}
else {
// make a new area with the removed loops
TopOpeBRepBuild_ListOfLoop thelist;
myArea.Append(thelist);
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,myArea.Last(),
(void*)("allShape = 0"),(void*)("removedLoops"),(void*)("new area"));
}
}
} // Loopinside == True
else {
Standard_Integer ashapeinside,ablockinside;
TopOpeBRepBuild_ListOfLoop thelist1;
myArea.Append( thelist1);
TopOpeBRepBuild_ListOfLoop& newArea0 = myArea.Last();
ADD_Loop_TO_LISTOFLoop(L,newArea0,(void*)("new area"));
LoopIter.Initialize(boundaryloops);
while ( LoopIter.More() ) {
ashapeinside = ablockinside = Standard_False;
const Handle(TopOpeBRepBuild_Loop)& LLI2 = LoopIter.Value();
state = LC.Compare(LLI2,L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ashapeinside = (state == TopAbs_IN);
if (ashapeinside) {
const Handle(TopOpeBRepBuild_Loop)& LLI3 = LoopIter.Value();
state = LC.Compare(L,LLI3);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ablockinside = (state == TopAbs_IN);
}
if ( ashapeinside && ablockinside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
ADD_Loop_TO_LISTOFLoop
(curL,newArea0,(void*)("ashapeinside && ablockinside, new area"));
REM_Loop_FROM_LISTOFLoop
(LoopIter,boundaryloops,(void*)("loop of boundaryloops, boundaryloops"));
}
else {
LoopIter.Next();
}
} // end of boundaryloops scan
} // Loopinside == False
} // end of block loop
} // end of LoopSet LS scan
InitArea();
}

View File

@@ -0,0 +1,103 @@
-- File: TopOpeBRepBuild_AreaBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class AreaBuilder from TopOpeBRepBuild
---Purpose:
-- The AreaBuilder algorithm is used to
-- reconstruct complex topological objects as Faces
-- or Solids.
-- * Loop is the composite topological object of
-- the boundary. Wire for a Face. Shell for a Solid.
-- * LoopSet is a tool describing the object to
-- build. It gives an iteration on Loops. For each
-- Loop it tells if it is on the boundary or if it is
-- an interference.
-- * LoopClassifier is an algorithm used to test
-- if a Loop is inside another Loop.
-- The result of the reconstruction is an iteration
-- on the reconstructed areas. An area is described
-- by a set of Loops.
-- A AreaBuilder is built with :
-- - a LoopSet describing the object to reconstruct.
-- - a LoopClassifier providing the classification algorithm.
uses
State from TopAbs,
Loop from TopOpeBRepBuild,
ListOfLoop from TopOpeBRepBuild,
ListIteratorOfListOfLoop from TopOpeBRepBuild,
ListOfListOfLoop from TopOpeBRepBuild,
ListIteratorOfListOfListOfLoop from TopOpeBRepBuild,
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild,
LoopEnum from TopOpeBRepBuild
is
Create returns AreaBuilder;
Create(LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) returns AreaBuilder;
---Purpose: Creates a AreaBuilder to build the areas on
-- the shapes described by <LS> using the classifier <LC>.
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_AreaBuilder(){Delete() ; }"
InitAreaBuilder(me : in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean from Standard = Standard_False)
---Purpose: Sets a AreaBuilder to find the areas on
-- the shapes described by <LS> using the classifier <LC>.
is virtual;
CompareLoopWithListOfLoop(me;
LC : in out LoopClassifier;
L : Loop;
LOL : ListOfLoop;
le : LoopEnum)
returns State from TopAbs is static protected;
Atomize(me;state : in out State from TopAbs; newstate : State from TopAbs)
is static protected;
InitArea(me : in out) returns Integer from Standard is static;
---Purpose: Initialize iteration on areas.
MoreArea(me) returns Boolean from Standard is static;
NextArea(me : in out) is static;
InitLoop(me : in out) returns Integer from Standard is static;
---Purpose: Initialize iteration on loops of current Area.
MoreLoop(me) returns Boolean from Standard is static;
NextLoop(me : in out) is static;
Loop(me) returns Loop from TopOpeBRepBuild is static;
---Purpose: Returns the current Loop in the current area.
---C++: return const&
ADD_Loop_TO_LISTOFLoop(me; L : Loop;
LOL : in out ListOfLoop;
s : Address = NULL) is virtual;
REM_Loop_FROM_LISTOFLoop(me; ITLOL : in out ListIteratorOfListOfLoop;
LOL : in out ListOfLoop;
s : Address = NULL) is virtual;
ADD_LISTOFLoop_TO_LISTOFLoop(me; LOL1 : in out ListOfLoop;
LOL2 : in out ListOfLoop;
s : Address = NULL;
s1 : Address = NULL;
s2 : Address = NULL) is virtual;
fields
myArea : ListOfListOfLoop is protected;
myAreaIterator : ListIteratorOfListOfListOfLoop is protected;
myLoopIterator : ListIteratorOfListOfLoop is protected;
myUNKNOWNRaise : Boolean is protected;
end AreaBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,399 @@
// File: TopOpeBRepBuild_AreaBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
//Copyright: Matra Datavision 1995
// " Voyager, c'est bien utile, ca fait travailler l'imagination.
// Tout le reste n'est que deceptions et fatigues. Notre voyage
// a nous est entierement imaginaire. Voila sa force. "
// Celine
// Voyage au bout de la nuit
#include <TopOpeBRepBuild_AreaBuilder.ixx>
#include <Standard_DomainError.hxx>
#include <TopAbs.hxx>
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
//=======================================================================
//function : TopOpeBRepBuild_AreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_AreaBuilder::TopOpeBRepBuild_AreaBuilder() :
myUNKNOWNRaise(Standard_False) // no raise if UNKNOWN state found
{
}
//=======================================================================
//function : TopOpeBRepBuild_AreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_AreaBuilder::TopOpeBRepBuild_AreaBuilder
(TopOpeBRepBuild_LoopSet& LS,
TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass) :
myUNKNOWNRaise(Standard_False) // no raise if UNKNOWN state found
{
InitAreaBuilder(LS,LC,ForceClass);
}
void TopOpeBRepBuild_AreaBuilder::Delete()
{}
//=======================================================================
//function : CompareLoopWithListOfLoop
//purpose : Compare position of the Loop <L> with the Area <LOL>
// using the Loop Classifier <LC>.
// According to <whattotest>, Loops of <LOL> are selected or not
// during <LOL> exploration.
//result : TopAbs_OUT if <LOL> is empty
// TopAbs_UNKNOWN if position undefined
// TopAbs_IN if <L> is inside all the selected Loops of <LOL>
// TopAbs_OUT if <L> is outside one of the selected Loops of <LOL>
// TopAbs_ON if <L> is on one of the selected Loops of <LOL>
//=======================================================================
TopAbs_State TopOpeBRepBuild_AreaBuilder::CompareLoopWithListOfLoop
(TopOpeBRepBuild_LoopClassifier &LC,
const Handle(TopOpeBRepBuild_Loop)& L,
const TopOpeBRepBuild_ListOfLoop &LOL,
const TopOpeBRepBuild_LoopEnum what) const
{
TopAbs_State state = TopAbs_UNKNOWN;
Standard_Boolean totest; // L must or not be tested
TopOpeBRepBuild_ListIteratorOfListOfLoop LoopIter;
if ( LOL.IsEmpty() ) return TopAbs_OUT;
for ( LoopIter.Initialize(LOL); LoopIter.More(); LoopIter.Next() ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
switch ( what ) {
case TopOpeBRepBuild_ANYLOOP : totest = Standard_True;break;
case TopOpeBRepBuild_BOUNDARY : totest = curL->IsShape();break;
case TopOpeBRepBuild_BLOCK : totest = !curL->IsShape();break;
default : totest = Standard_False;
}
if ( totest ) {
state = LC.Compare(L,curL);
if (state == TopAbs_OUT)
// <L> is out of at least one Loop of <LOL> : stop to explore
break;
}
}
return state;
}
//=======================================================================
//function : Atomize
//purpose : myUNKNOWNRaise = True --> raise if <state> = UNKNOWN
// myUNKNOWNRaise = False--> assign a new value <newstate> to <state>
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::Atomize(TopAbs_State& state,
const TopAbs_State newstate) const
{
if (myUNKNOWNRaise) {
Standard_DomainError_Raise_if((state == TopAbs_UNKNOWN),
"AreaBuilder : Position Unknown");
}
else {
#ifdef DEB
if ( TopOpeBRepDS_GettraceSTRANGE() ) {
cout<<"AreaBuilder : state "; TopAbs::Print(state,cout);
cout<<" taken as "; TopAbs::Print(newstate,cout); cout<<endl;
}
#endif
state = newstate;
}
}
//=======================================================================
//function : InitAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
(TopOpeBRepBuild_LoopSet& LS,
TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
TopAbs_State state;
Standard_Boolean Loopinside;
Standard_Boolean loopoutside;
TopOpeBRepBuild_ListIteratorOfListOfListOfLoop AreaIter;
TopOpeBRepBuild_ListIteratorOfListOfLoop LoopIter;
// boundaryloops : list of boundary loops out of the areas.
TopOpeBRepBuild_ListOfLoop boundaryloops;
myArea.Clear(); // Clear the list of Area to be built
for (LS.InitLoop(); LS.MoreLoop(); LS.NextLoop()) {
// process a new loop : L is the new current Loop
const Handle(TopOpeBRepBuild_Loop)& L = LS.Loop();
Standard_Boolean boundaryL = L->IsShape();
// L = Shape et ForceClass : on traite L comme un block
// L = Shape et !ForceClass : on traite L comme un pur Shape
// L = !Shape : on traite L comme un block
Standard_Boolean traitercommeblock = (!boundaryL) || ForceClass;
if ( ! traitercommeblock ) {
// the loop L is a boundary loop :
// - try to insert it in an existing area, such as L is inside all
// the block loops. Only block loops of the area are compared.
// - if L could not be inserted, store it in list of boundary loops.
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = ( state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
ADD_Loop_TO_LISTOFLoop(L,boundaryloops,(void*)("! IN, to boundaryloops"));
}
} // end of boundary loop
else {
// the loop L is a block loop
// if L is IN theArea :
// - stop area scan, insert L in theArea.
// - remove from the area all the loops outside L
// - make a new area with them, unless they are all boundary
// - if they are all boundary put them back in boundaryLoops
// else :
// - create a new area with L.
// - insert boundary loops that are IN the new area
// (and remove them from 'boundaryloops')
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
Loopinside = (state == TopAbs_IN);
if ( Loopinside ) break;
} // end of Area scan
if ( Loopinside) {
TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
while (LoopIter.More()) {
state = LC.Compare(LoopIter.Value(),L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN); // not OUT
loopoutside = ( state == TopAbs_OUT );
if ( loopoutside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
// remove the loop from the area
ADD_Loop_TO_LISTOFLoop
(curL,removedLoops,(void*)("loopoutside = 1, area = removedLoops"));
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
(LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
}
}
// insert the loop in the area
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("area = current"));
if ( ! removedLoops.IsEmpty() ) {
if ( allShape ) {
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,boundaryloops,
(void*)("allShape = 1"),(void*)("removedLoops"),(void*)("boundaryloops"));
}
else {
// make a new area with the removed loops
TopOpeBRepBuild_ListOfLoop thelist;
myArea.Append(thelist);
ADD_LISTOFLoop_TO_LISTOFLoop
(removedLoops,myArea.Last(),
(void*)("allShape = 0"),(void*)("removedLoops"),(void*)("new area"));
}
}
} // Loopinside == True
else {
Standard_Integer ashapeinside,ablockinside;
TopOpeBRepBuild_ListOfLoop thelist1;
myArea.Append(thelist1);
TopOpeBRepBuild_ListOfLoop& newArea0 = myArea.Last();
ADD_Loop_TO_LISTOFLoop(L,newArea0,(void*)("new area"));
LoopIter.Initialize(boundaryloops);
while ( LoopIter.More() ) {
ashapeinside = ablockinside = Standard_False;
state = LC.Compare(LoopIter.Value(),L);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ashapeinside = (state == TopAbs_IN);
if (ashapeinside) {
state = LC.Compare(L,LoopIter.Value());
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
ablockinside = (state == TopAbs_IN);
}
if ( ashapeinside && ablockinside ) {
const Handle(TopOpeBRepBuild_Loop)& curL = LoopIter.Value();
ADD_Loop_TO_LISTOFLoop
(curL,newArea0,(void*)("ashapeinside && ablockinside, new area"));
REM_Loop_FROM_LISTOFLoop
(LoopIter,boundaryloops,(void*)("loop of boundaryloops, boundaryloops"));
}
else {
LoopIter.Next();
}
} // end of boundaryloops scan
} // Loopinside == False
} // end of block loop
} // end of LoopSet LS scan
InitArea();
}
//=======================================================================
//function : InitArea
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_AreaBuilder::InitArea()
{
myAreaIterator.Initialize(myArea);
InitLoop();
Standard_Integer n = myArea.Extent();
return n;
}
//=======================================================================
//function : MoreArea
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_AreaBuilder::MoreArea() const
{
Standard_Boolean b = myAreaIterator.More();
return b;
}
//=======================================================================
//Function : NextArea
//Purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::NextArea()
{
myAreaIterator.Next();
InitLoop();
}
//=======================================================================
//function : InitLoop
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_AreaBuilder::InitLoop()
{
Standard_Integer n = 0;
if (myAreaIterator.More()) {
const TopOpeBRepBuild_ListOfLoop& LAL = myAreaIterator.Value();
myLoopIterator.Initialize(LAL);
n = LAL.Extent();
}
else { // Create an empty ListIteratorOfListOfLoop
myLoopIterator = TopOpeBRepBuild_ListIteratorOfListOfLoop();
}
return n;
}
//=======================================================================
//function : MoreLoop
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_AreaBuilder::MoreLoop() const
{
Standard_Boolean b = myLoopIterator.More();
return b;
}
//=======================================================================
//function : NextLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::NextLoop()
{
myLoopIterator.Next();
}
//=======================================================================
//function : Loop
//purpose :
//=======================================================================
const Handle(TopOpeBRepBuild_Loop)& TopOpeBRepBuild_AreaBuilder::Loop() const
{
const Handle(TopOpeBRepBuild_Loop)& L = myLoopIterator.Value();
return L;
}
//=======================================================================
//function : ADD_Loop_TO_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::ADD_Loop_TO_LISTOFLoop
(const Handle(TopOpeBRepBuild_Loop)& L,
TopOpeBRepBuild_ListOfLoop& LOL,
const Standard_Address /*ss*/) const
{
LOL.Append(L);
}
//=======================================================================
//function : REM_Loop_FROM_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::REM_Loop_FROM_LISTOFLoop
(TopOpeBRepBuild_ListIteratorOfListOfLoop& ITA,
TopOpeBRepBuild_ListOfLoop& A,
const Standard_Address /*ss*/) const
{
A.Remove(ITA);
}
//=======================================================================
//function : ADD_LISTOFLoop_TO_LISTOFLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_AreaBuilder::ADD_LISTOFLoop_TO_LISTOFLoop
(TopOpeBRepBuild_ListOfLoop& A1,
TopOpeBRepBuild_ListOfLoop& A2,
const Standard_Address /*ss*/,
const Standard_Address /*ss1*/,
const Standard_Address /*ss2*/) const
{
A2.Append(A1);
}

View File

@@ -0,0 +1,60 @@
-- File: TopOpeBRepBuild_BlockBuilder.cdl
-- Created: Thu Feb 25 15:16:42 1993
-- Author: Jean Yves LEBEY
-- <jyl@phylox>
---Copyright: Matra Datavision 1993
class BlockBuilder from TopOpeBRepBuild
uses
Shape from TopoDS, -- Face,Edge
ShapeSet from TopOpeBRepBuild,
IndexedMapOfOrientedShape from TopTools,
BlockIterator from TopOpeBRepBuild,
SequenceOfInteger from TColStd,
DataMapOfIntegerInteger from TColStd
is
Create returns BlockBuilder;
-- creation of the blocks buildable from a ShapeSet
Create(SS : in out ShapeSet) returns BlockBuilder;
MakeBlock(me : in out; SS : in out ShapeSet) is static;
-- Iteration on blocks made by MakeBlock
InitBlock(me : in out) is static;
MoreBlock(me) returns Boolean from Standard is static;
NextBlock(me : in out) is static;
-- Iteration on shapes of current block
BlockIterator(me) returns BlockIterator is static;
Element(me; BI : BlockIterator) returns Shape from TopoDS is static;
---Purpose: Returns the current element of <BI>.
---C++: return const &
Element(me; I : Integer) returns Shape from TopoDS is static;
---C++: return const &
Element(me; S : Shape from TopoDS) returns Integer;
ElementIsValid(me; BI : BlockIterator) returns Boolean;
ElementIsValid(me; I : Integer) returns Boolean;
AddElement(me : in out; S : Shape from TopoDS) returns Integer;
SetValid(me : in out; BI : BlockIterator; isvalid : Boolean);
SetValid(me : in out; I : Integer; isvalid : Boolean);
CurrentBlockIsRegular(me : in out) returns Boolean from Standard;
fields
myOrientedShapeMapIsValid : DataMapOfIntegerInteger from TColStd;
myOrientedShapeMap : IndexedMapOfOrientedShape from TopTools;
myBlocks : SequenceOfInteger from TColStd;
myBlockIndex : Integer from Standard;
myIsDone : Boolean from Standard;
myBlocksIsRegular : SequenceOfInteger from TColStd;
end BlockBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,312 @@
// File: TopOpeBRepBuild_BlockBuilder.cxx
// Created: Thu Mar 11 12:56:30 1993
// Author: Jean Yves LEBEY
// <jyl@sdsun2>
// Copyright: Matra Datavision
#include <TopOpeBRepBuild_BlockBuilder.ixx>
#include <Standard_Failure.hxx>
//=======================================================================
//function : TopOpeBRepBuild_BlockBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_BlockBuilder::TopOpeBRepBuild_BlockBuilder()
:myIsDone(Standard_False)
{
}
//=======================================================================
//function : TopOpeBRepBuild_BlockBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_BlockBuilder::TopOpeBRepBuild_BlockBuilder
(TopOpeBRepBuild_ShapeSet& SS)
:myIsDone(Standard_False)
{
MakeBlock(SS);
}
//=======================================================================
//function : MakeBlock
//purpose :
//=======================================================================
void TopOpeBRepBuild_BlockBuilder::MakeBlock(TopOpeBRepBuild_ShapeSet& SS)
{
// Compute the set of connexity blocks of elements of element set SS
//
// Logic :
// - A block is a set of connex elements of SS
// - We assume that any element of SS appears in only 1 connexity block.
//
// Implementation :
// - All the elements of all the blocks are stored in map myOrientedShapeMap(M).
// - A connexity block is a segment [f,l] of element indices of M.
// - myBlocks is a sequence of integer; each integer is the index of the
// first element (in M) of a connexity block.
// - Bounds [f,l] of a connexity block are :
// f = myBlocks(i)
// l = myBlocks(i+1) - 1
myOrientedShapeMap.Clear();
myOrientedShapeMapIsValid.Clear();
myBlocks.Clear();
myBlocksIsRegular.Clear();
Standard_Boolean IsRegular;
Standard_Integer CurNei;
Standard_Integer Mextent;
Standard_Integer Eindex;
for (SS.InitStartElements();SS.MoreStartElements();SS.NextStartElement()) {
const TopoDS_Shape& E = SS.StartElement();
Mextent = myOrientedShapeMap.Extent();
Eindex = AddElement(E);
// E = current element of the element set SS
// Mextent = index of last element stored in map M, before E is added.
// Eindex = index of E added to M : Eindex > Mextent => E is new in M
Standard_Boolean EnewinM = (Eindex > Mextent);
if (EnewinM) {
// make a new block starting at element Eindex
myBlocks.Append(Eindex);
IsRegular = Standard_True; CurNei = 0;
// put in current block all the elements connex to E :
// while an element E has been added to M
// - compute neighbours of E : N(E)
// - add each element N of N(E) to M
Mextent = myOrientedShapeMap.Extent();
Standard_Boolean searchneighbours = (Eindex <= Mextent);
while (searchneighbours) {
// E = element of M on which neighbours must be searched
// first step : Eindex = index of starting element of SS
// next steps : Eindex = index of neighbours of starting element of SS
const TopoDS_Shape& E1 = myOrientedShapeMap(Eindex);
CurNei = SS.MaxNumberSubShape(E1);
Standard_Boolean condregu = Standard_True;
if (CurNei > 2) condregu = Standard_False;
IsRegular = IsRegular && condregu;
// compute neighbours of E : add them to M to increase M.Extent().
SS.InitNeighbours(E1);
for (; SS.MoreNeighbours(); SS.NextNeighbour()) {
const TopoDS_Shape& N = SS.Neighbour();
AddElement(N);
}
Eindex++;
Mextent = myOrientedShapeMap.Extent();
searchneighbours = (Eindex <= Mextent);
} // while (searchneighbours)
Standard_Integer iiregu = IsRegular ? 1 : 0;
myBlocksIsRegular.Append(iiregu);
} // if (EnewinM)
} // for ()
// To value the l bound of the last connexity block created above,
// we create an artificial block of value = myOrientedShapeMap.Extent() + 1
// The real number of connexity blocks is myBlocks.Length() - 1
Mextent = myOrientedShapeMap.Extent();
myBlocks.Append(Mextent + 1);
myIsDone = Standard_True;
#if 0
// version seche
myOrientedShapeMap.Clear();
myOrientedShapeMapIsValid.Clear();
myBlocks.Clear();
while (SS.MoreStartElements()) {
Standard_Integer last = myOrientedShapeMap.Extent();
Standard_Integer index =AddElement(SS.StartElement());
if (index > last) {
myBlocks.Append(index);
while (index <= myOrientedShapeMap.Extent()) {
for (SS.InitNeighbours(myOrientedShapeMap(index));
SS.MoreNeighbours();
SS.NextNeighbour()) {
AddElement(SS.Neighbour());
}
index++;
}
}
SS.NextStartElement();
}
myBlocks.Append(myOrientedShapeMap.Extent()+1);
myBlockIndex = 1;
#endif
}
//=======================================================================
//function : InitBlock
//purpose :
//=======================================================================
void TopOpeBRepBuild_BlockBuilder::InitBlock()
{
myBlockIndex = 1;
}
//=======================================================================
//function : MoreBlock
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_BlockBuilder::MoreBlock() const
{
// the length of myBlocks is 1 + number of connexity blocks
Standard_Integer l = myBlocks.Length();
Standard_Boolean b = (myBlockIndex < l);
return b;
}
//=======================================================================
//function : NextBlock
//purpose :
//=======================================================================
void TopOpeBRepBuild_BlockBuilder::NextBlock()
{
myBlockIndex++;
}
//=======================================================================
//function : BlockIterator
//purpose :
//=======================================================================
TopOpeBRepBuild_BlockIterator TopOpeBRepBuild_BlockBuilder::BlockIterator() const
{
Standard_Integer lower = myBlocks(myBlockIndex);
Standard_Integer upper = myBlocks(myBlockIndex+1)-1;
return TopOpeBRepBuild_BlockIterator(lower,upper);
}
//=======================================================================
//function : Element
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_BlockBuilder::Element
(const TopOpeBRepBuild_BlockIterator& BI) const
{
Standard_Boolean isbound = BI.More();
if (!isbound) Standard_Failure::Raise("OutOfRange");
Standard_Integer index = BI.Value();
const TopoDS_Shape& E = myOrientedShapeMap(index);
return E;
}
const TopoDS_Shape& TopOpeBRepBuild_BlockBuilder::Element
(const Standard_Integer index) const
{
Standard_Boolean isbound = myOrientedShapeMapIsValid.IsBound(index);
if (!isbound) Standard_Failure::Raise("OutOfRange");
const TopoDS_Shape& E = myOrientedShapeMap(index);
return E;
}
Standard_Integer TopOpeBRepBuild_BlockBuilder::Element
(const TopoDS_Shape& E) const
{
Standard_Boolean isbound = myOrientedShapeMap.Contains(E);
if (!isbound) Standard_Failure::Raise("OutOfRange");
Standard_Integer I = myOrientedShapeMap.FindIndex(E);
return I;
}
//=======================================================================
//function : ElementIsValid
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_BlockBuilder::ElementIsValid
(const TopOpeBRepBuild_BlockIterator& BI) const
{
Standard_Boolean isbound = BI.More();
if (!isbound) return Standard_False;
Standard_Integer Sindex = BI.Value();
Standard_Integer isb = myOrientedShapeMapIsValid.Find(Sindex);
Standard_Boolean isvalid = (isb == 1)? Standard_True: Standard_False;
return isvalid;
}
Standard_Boolean TopOpeBRepBuild_BlockBuilder::ElementIsValid
(const Standard_Integer Sindex) const
{
Standard_Boolean isbound = myOrientedShapeMapIsValid.IsBound(Sindex);
if (!isbound) return Standard_False;
Standard_Integer isb = myOrientedShapeMapIsValid.Find(Sindex);
Standard_Boolean isvalid = (isb == 1)? Standard_True: Standard_False;
return isvalid;
}
//=======================================================================
//function : AddElement
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_BlockBuilder::AddElement(const TopoDS_Shape& S)
{
Standard_Integer Sindex = myOrientedShapeMap.Add(S);
myOrientedShapeMapIsValid.Bind(Sindex, 1);
return Sindex;
}
//=======================================================================
//function : SetValid
//purpose :
//=======================================================================
void TopOpeBRepBuild_BlockBuilder::SetValid
(const TopOpeBRepBuild_BlockIterator& BI,
const Standard_Boolean isvalid)
{
Standard_Boolean isbound = BI.More();
if (!isbound) return;
Standard_Integer Sindex = BI.Value();
Standard_Integer i = (isvalid) ? 1 : 0;
myOrientedShapeMapIsValid.Bind(Sindex,i);
}
void TopOpeBRepBuild_BlockBuilder::SetValid
(const Standard_Integer Sindex,
const Standard_Boolean isvalid)
{
Standard_Boolean isbound = myOrientedShapeMapIsValid.IsBound(Sindex);
if (!isbound) return;
Standard_Integer i = (isvalid) ? 1 : 0;
myOrientedShapeMapIsValid.Bind(Sindex,i);
}
//=======================================================================
//function : CurrentBlockIsRegular
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_BlockBuilder::CurrentBlockIsRegular()
{
Standard_Boolean b = Standard_False;
Standard_Integer i = myBlocksIsRegular.Value(myBlockIndex);
if(i == 1)
b = Standard_True;
return b;
}

View File

@@ -0,0 +1,38 @@
-- File: TopOpeBRepBuild_BlockIterator.cdl
-- Created: Thu Feb 25 18:01:55 1993
-- Author: Jean Yves LEBEY
-- <jyl@phylox>
---Copyright: Matra Datavision 1993
class BlockIterator from TopOpeBRepBuild
---Purpose: Iterator on the elements of a block.
raises
NoMoreObject from Standard
is
Create returns BlockIterator from TopOpeBRepBuild;
Create(Lower,Upper : Integer from Standard)
returns BlockIterator from TopOpeBRepBuild;
Initialize(me : in out) is static;
---C++: inline
More(me) returns Boolean from Standard is static;
---C++: inline
Next(me : in out) raises NoMoreObject is static;
---C++: inline
Value(me) returns Integer from Standard is static;
---C++: inline
Extent(me) returns Integer from Standard is static;
---C++: inline
fields
myLower : Integer from Standard;
myUpper : Integer from Standard;
myValue : Integer from Standard;
end BlockIterator from TopOpeBRepBuild;

View File

@@ -0,0 +1,32 @@
// File: TopOpeBRepBuild_BlockIterator.cxx
// Created: Tue Mar 23 15:37:30 1993
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepBuild_BlockIterator.ixx>
//=======================================================================
//function : TopOpeBRepBuild_BlockIterator
//purpose :
//=======================================================================
TopOpeBRepBuild_BlockIterator::TopOpeBRepBuild_BlockIterator() :
myLower(0),
myUpper(0),
myValue(1)
{
}
//=======================================================================
//function : TopOpeBRepBuild_BlockIterator
//purpose :
//=======================================================================
TopOpeBRepBuild_BlockIterator::TopOpeBRepBuild_BlockIterator
(const Standard_Integer Lower, const Standard_Integer Upper) :
myLower(Lower),
myUpper(Upper),
myValue(Lower)
{
}

View File

@@ -0,0 +1,62 @@
// File: TopOpeBRepBuild_BlockIterator.lxx
// Created: Mon Mar 8 16:17:52 1993
// Author: Jean Yves LEBEY
// <jyl@sdsun1>
// Copyright: Matra Datavision
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
inline void TopOpeBRepBuild_BlockIterator::Initialize()
{
myValue = myLower;
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
inline Standard_Boolean TopOpeBRepBuild_BlockIterator::More() const
{
Standard_Boolean b = (myValue <= myUpper);
return b;
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
inline void TopOpeBRepBuild_BlockIterator::Next()
{
myValue++;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
inline Standard_Integer TopOpeBRepBuild_BlockIterator::Value() const
{
return myValue;
}
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
inline Standard_Integer TopOpeBRepBuild_BlockIterator::Extent() const
{
if (myLower != 0) {
Standard_Integer n = myUpper - myLower + 1;
return n;
}
return 0;
}

View File

@@ -0,0 +1,150 @@
// File: TopOpeBRepBuild_BuildEdges.cxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_Builder.jxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TopOpeBRepDS_CurveExplorer.hxx>
#include <TopOpeBRepDS_Curve.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCU();
#endif
//=======================================================================
//function : BuildEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::BuildEdges(const Standard_Integer iC,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
#ifdef DEB
if (TopOpeBRepBuild_GettraceCU()) cout<<"\nBuildEdges on C "<<iC<<endl;
#endif
const TopOpeBRepDS_Curve& C = HDS->Curve(iC);
const Handle(Geom_Curve)& C3D = C.Curve();
const Handle(TopOpeBRepDS_Interference)& I1 = C.GetSCI1();
const Handle(TopOpeBRepDS_Interference)& I2 = C.GetSCI2();
Standard_Boolean nnn = C3D.IsNull() && I1.IsNull() && I2.IsNull();
if (nnn) {
return;
}
TopoDS_Shape anEdge;
const TopOpeBRepDS_Curve& curC = HDS->Curve(iC);
myBuildTool.MakeEdge(anEdge,curC,HDS->DS());
TopOpeBRepBuild_PaveSet PVS(anEdge);
TopOpeBRepDS_PointIterator CPIT(HDS->CurvePoints(iC));
FillVertexSet(CPIT,TopAbs_IN,PVS);
TopOpeBRepBuild_PaveClassifier VCL(anEdge);
Standard_Boolean equalpar = PVS.HasEqualParameters();
if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
Standard_Boolean closvert = PVS.ClosedVertices();
VCL.ClosedVertices(closvert);
PVS.InitLoop();
if ( !PVS.MoreLoop() ) {
return;
}
TopOpeBRepBuild_EdgeBuilder EDBU(PVS,VCL);
TopTools_ListOfShape& EL = ChangeNewEdges(iC);
MakeEdges(anEdge,EDBU,EL);
TopTools_ListIteratorOfListOfShape It(EL);
Standard_Integer inewC = -1;
for (; It.More(); It.Next()) {
TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
myBuildTool.RecomputeCurves(curC,TopoDS::Edge(anEdge),newEdge,inewC,HDS);
if (inewC != -1) ChangeNewEdges(inewC).Append(newEdge);
}
if (inewC != -1) {
HDS->RemoveCurve(iC);
}
else {
for (It.Initialize(EL);It.More();It.Next()) {
TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
myBuildTool.UpdateEdge(anEdge,newEdge);
}
}
}
//=======================================================================
//function : BuildEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::BuildEdges(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
myNewEdges.Clear();
Standard_Integer nc = BDS.NbCurves();
TopOpeBRepDS_CurveExplorer cex;
Standard_Integer ick = 0;
for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) {
Standard_Integer ic = cex.Index();
Standard_Boolean ck = cex.IsCurveKeep(ic);
Standard_Integer im = cex.Curve(ic).Mother();
if (ck == 1 && im != 0 && ick == 0) { ick = ic; break; }
}
if (ick) {
for (cex.Init(BDS,Standard_True); cex.More(); cex.Next()) {
Standard_Integer ic = cex.Index();
BDS.RemoveCurve(ic);
}
BDS.ChangeNbCurves(ick-1);
}
nc = BDS.NbCurves();
for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) {
Standard_Integer ic = cex.Index();
Standard_Integer im = cex.Curve(ic).Mother();
if (im != 0 ) continue;
BuildEdges(ic,HDS);
}
Standard_Integer ip, np = HDS->NbPoints();
TColStd_HArray1OfInteger tp(0,np,0);
for (cex.Init(BDS); cex.More(); cex.Next()) {
#ifdef DEB
// const TopOpeBRepDS_Curve& C = cex.Curve();
#endif
Standard_Integer ic = cex.Index();
TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.CurveInterferences(ic));
for(;it.More();it.Next()) {
const Handle(TopOpeBRepDS_Interference)& I = it.Value();
{
Standard_Integer ig = I->Geometry();
TopOpeBRepDS_Kind kg = I->GeometryType();
if (kg == TopOpeBRepDS_POINT && ig <= np) tp.ChangeValue(ig) = tp.Value(ig) + 1;
}
{
Standard_Integer is = I->Support();
TopOpeBRepDS_Kind ks = I->SupportType();
if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is) = tp.Value(is) + 1;
}
}
}
Standard_Integer is, ns = BDS.NbShapes();
for (is = 1; is <= ns; is++ ) {
const TopoDS_Shape& S = BDS.Shape(is);
if(S.IsNull()) continue;
Standard_Boolean test = (S.ShapeType() == TopAbs_EDGE);
if ( !test ) continue;
TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.ShapeInterferences(is));
for(;it.More();it.Next()) {
const Handle(TopOpeBRepDS_Interference)& I = it.Value();
{
Standard_Integer ig = I->Geometry();
TopOpeBRepDS_Kind kg = I->GeometryType();
if (kg == TopOpeBRepDS_POINT) tp.ChangeValue(ig) = tp.Value(ig) + 1;
}
{
Standard_Integer is1 = I->Support();
TopOpeBRepDS_Kind ks = I->SupportType();
if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is1) = tp.Value(is1) + 1;
}
}
}
for (ip = 1; ip <= np; ip++) if (tp.Value(ip) == 0) BDS.RemovePoint(ip);
}

View File

@@ -0,0 +1,69 @@
// File: TopOpeBRepBuild_Builder.hxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_Builder.jxx>
#include <TopOpeBRepBuild_WireEdgeSet.hxx>
#include <TopOpeBRepBuild_FaceBuilder.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCU();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCUV();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPF();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPS();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextSF2();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSHEX();
#endif
//=======================================================================
//function : BuildFaces
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::BuildFaces(const Standard_Integer iS,
const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
TopoDS_Shape aFace;
myBuildTool.MakeFace(aFace,HDS->Surface(iS));
TopOpeBRepBuild_WireEdgeSet WES(aFace,this);
#ifdef DEB
Standard_Boolean tSE = TopOpeBRepBuild_GettraceSPF();
Standard_Boolean tCU = TopOpeBRepBuild_GettraceCU();
Standard_Boolean NtCUV = !TopOpeBRepBuild_GettraceCUV();
#endif
for (TopOpeBRepDS_CurveIterator SCurves(HDS->SurfaceCurves(iS));
SCurves.More(); SCurves.Next()) {
Standard_Integer iC = SCurves.Current();
const TopOpeBRepDS_Curve& CDS = HDS->Curve(iC);
#ifdef DEB
if (tSE) cout<<endl<<"BuildFaces : C "<<iC<<" on S "<<iS<<endl;
if (tCU) { CDS.Dump(cout,iC,NtCUV); cout<<endl; }
#endif
TopoDS_Shape anEdge;
for (TopTools_ListIteratorOfListOfShape Iti(NewEdges(iC));
Iti.More();
Iti.Next()) {
anEdge = Iti.Value();
TopAbs_Orientation ori = SCurves.Orientation(TopAbs_IN);
myBuildTool.Orientation(anEdge,ori);
const Handle(Geom2d_Curve)& PC = SCurves.PCurve();
myBuildTool.PCurve(aFace,anEdge,CDS,PC);
WES.AddStartElement(anEdge);
}
}
TopOpeBRepBuild_FaceBuilder FABU(WES,aFace);
TopTools_ListOfShape& FaceList = ChangeNewFaces(iS);
MakeFaces(aFace,FABU,FaceList);
}
//=======================================================================
//function : BuildFaces
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::BuildFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
Standard_Integer iS, n = HDS->NbSurfaces();
myNewFaces = new TopTools_HArray1OfListOfShape(0,n);
for (iS = 1; iS <= n; iS++) BuildFaces(iS,HDS);
}

View File

@@ -0,0 +1,24 @@
// File: TopOpeBRepBuild_BuildVertices.hxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_Builder.jxx>
#include <TopOpeBRepDS_Point.hxx>
#include <gp_Pnt.hxx>
//=======================================================================
//function : BuildVertices
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::BuildVertices(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
Standard_Integer iP, n = HDS->NbPoints();
myNewVertices = new TopTools_HArray1OfShape(0, n);
for (iP = 1; iP <= n; iP++) {
const TopOpeBRepDS_Point& aTBSPoint=HDS->Point(iP);
myBuildTool.MakeVertex(ChangeNewVertex(iP), aTBSPoint);
}
}

View File

@@ -0,0 +1,630 @@
-- File: TopOpeBRepBuild_Builder.cdl
-- Created: Mon Jun 14 10:23:56 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class Builder from TopOpeBRepBuild
---Purpose: The Builder algorithm constructs topological
-- objects from an existing topology and new
-- geometries attached to the topology. It is used to
-- construct the result of a topological operation;
-- the existing topologies are the parts involved in
-- the topological operation and the new geometries
-- are the intersection lines and points.
uses
State from TopAbs,
ShapeEnum from TopAbs,
Orientation from TopAbs,
MapOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
IndexedMapOfOrientedShape from TopTools,
IndexedMapOfShape from TopTools,
HArray1OfShape from TopTools,
DataMapOfIntegerListOfShape from TopTools,
DataMapOfIntegerShape from TopTools,
HArray1OfListOfShape from TopTools,
DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS,
DataMapOfShapeInteger from TopTools,
DataMapOfShapeShape from TopTools,
IndexedDataMapOfShapeShape from TopTools,
ShapeSet from TopOpeBRepBuild,
EdgeBuilder from TopOpeBRepBuild,
FaceBuilder from TopOpeBRepBuild,
SolidBuilder from TopOpeBRepBuild,
WireEdgeSet from TopOpeBRepBuild,
ShellFaceSet from TopOpeBRepBuild,
ListOfShape from TopTools,
Shape from TopoDS,
Solid from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
ShapeExplorer from TopOpeBRepTool,
ShapeClassifier from TopOpeBRepTool,
BuildTool from TopOpeBRepDS,
PaveSet from TopOpeBRepBuild,
GTopo from TopOpeBRepBuild,
HDataStructure from TopOpeBRepDS,
SurfaceIterator from TopOpeBRepDS,
PointIterator from TopOpeBRepDS,
CurveIterator from TopOpeBRepDS,
Interference from TopOpeBRepDS,
Config from TopOpeBRepDS,
Pnt from gp,
AsciiString from TCollection
raises
NoSuchObject from Standard
is
Create(BT:BuildTool)
returns Builder from TopOpeBRepBuild;
--modified by NIZHNY-MZV Sat May 6 09:53:22 2000
Destroy(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_Builder() { Destroy() ; }"
ChangeBuildTool(me:in out) returns BuildTool from TopOpeBRepDS;
---C++: return &
BuildTool(me) returns BuildTool from TopOpeBRepDS;
---C++: return const &
Perform (me:in out;HDS:mutable HDataStructure) is virtual;
---Purpose: Stores the data structure <HDS>,
-- Create shapes from the new geometries.
--modified by NIZHNY-MZV Thu Nov 4 13:20:25 1999
Perform (me:in out;HDS:mutable HDataStructure;S1,S2:Shape) is virtual;
---Purpose: Stores the data structure <HDS>,
-- Create shapes from the new geometries,
-- Evaluates if an operation performed on shapes S1,S2
-- is a particular case.
DataStructure(me) returns HDataStructure;
---Purpose: returns the DS handled by this builder
--modified by NIZHNY-MZV Tue Apr 18 15:32:13 2000
Clear(me:in out) is virtual;
---Purpose: Removes all splits and merges already performed.
-- Does NOT clear the handled DS.
MergeEdges(me:in out;
L1:ListOfShape;TB1:State;
L2:ListOfShape;TB2:State;
onA:Boolean = Standard_False;
onB:Boolean = Standard_False;
onAB:Boolean = Standard_False);
---Purpose: Merges the two edges <S1> and <S2> keeping the
-- parts in each edge of states <TB1> and <TB2>.
-- Booleans onA, onB, onAB indicate wheter parts of edges
-- found as state ON respectively on first, second, and both
-- shapes must be (or not) built.
MergeFaces(me:in out;
S1:ListOfShape;TB1:State;S2:ListOfShape;TB2:State;
onA:Boolean = Standard_False;
onB:Boolean = Standard_False;
onAB:Boolean = Standard_False);
---Purpose: Merges the two faces <S1> and <S2> keeping the
-- parts in each face of states <TB1> and <TB2>.
MergeSolids(me:in out;
S1:Shape;TB1:State;S2:Shape;TB2:State);
---Purpose: Merges the two solids <S1> and <S2> keeping the
-- parts in each solid of states <TB1> and <TB2>.
MergeShapes(me:in out;
S1:Shape;TB1:State;
S2:Shape;TB2:State);
---Purpose: Merges the two shapes <S1> and <S2> keeping the
-- parts of states <TB1>,<TB2> in <S1>,<S2>.
End(me:in out);
-- LocOpe use
Classify(me) returns Boolean;
ChangeClassify(me:in out; B:Boolean);
MergeSolid(me:in out;S:Shape;TB:State);
---Purpose: Merges the solid <S> keeping the
-- parts of state <TB>.
NewVertex(me;I:Integer) returns Shape;
---Purpose: Returns the vertex created on point <I>.
---C++: return const &
NewEdges(me;I:Integer) returns ListOfShape;
---Purpose: Returns the edges created on curve <I>.
---C++: return const &
NewFaces(me;I:Integer) returns ListOfShape;
---Purpose: Returns the faces created on surface <I>.
---C++: return const &
IsSplit(me;S:Shape;TB:State) returns Boolean;
---Purpose: Returns True if the shape <S> has been split.
Splits(me;S:Shape;TB:State) returns ListOfShape
---Purpose: Returns the split parts <TB> of shape <S>.
---C++: return const &
raises NoSuchObject from Standard; -- if S is not IsSplit()
IsMerged(me;S:Shape;TB:State) returns Boolean;
---Purpose: Returns True if the shape <S> has been merged.
Merged(me;S:Shape;TB:State) returns ListOfShape
---Purpose: Returns the merged parts <TB> of shape <S>.
---C++: return const &
raises NoSuchObject from Standard; -- if <S> is not IsMerged()
InitSection(me:in out);
SplitSectionEdges (me:in out);
---Purpose: create parts ON solid of section edges
--modified by NIZHNY-MZV Wed Feb 23 12:54:11 2000
SplitSectionEdge (me:in out; E:Shape from TopoDS) is virtual;
---Purpose: create parts ON solid of section edges
SectionCurves(me:in out; L:in out ListOfShape);
---Purpose: return the section edges built on new curves.
SectionEdges(me:in out; L:in out ListOfShape);
---Purpose: return the parts of edges found ON the boundary
-- of the two arguments S1,S2 of Perform()
FillSecEdgeAncestorMap(me; aShapeRank: Integer; aMapON: MapOfShape;
anAncMap: out DataMapOfShapeShape);
---Purpose: Fills anAncMap with pairs (edge,ancestor edge) for each
-- split from the map aMapON for the shape object identified
-- by ShapeRank
Section(me:in out; L:in out ListOfShape);
---Purpose: return all section edges.
Section(me:in out) returns ListOfShape;
---C++: return const &
BuildVertices (me:in out;DS:mutable HDataStructure);
---Purpose: update the DS by creating new geometries.
-- create vertices on DS points.
BuildEdges (me:in out;DS:mutable HDataStructure);
---Purpose: update the DS by creating new geometries.
-- create shapes from the new geometries.
MSplit(me;s:State from TopAbs)
returns DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS;
---C++: return const &
ChangeMSplit(me:in out;s:State from TopAbs)
returns DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS;
---C++: return &
-------
-- private
-------
BuildEdges (me:in out;iC:Integer;DS:mutable HDataStructure) is protected;
---Purpose: update the DS by creating new geometries.
-- create edges on the new curve <Icurv>.
BuildFaces (me:in out;iS:Integer;DS:mutable HDataStructure) is protected;
---Purpose: update the DS by creating new geometries.
-- create faces on the new surface <ISurf>.
BuildFaces (me:in out;DS:mutable HDataStructure) is protected;
---Purpose: update the DS by creating new geometries.
-- create shapes from the new geometries.
SplitEdge(me:in out;E1:Shape;TB1,TB2:State) is protected;
---Purpose: Split <E1> keeping the parts of state <TB1>.
SplitEdge1(me:in out;E1:Shape;TB1,TB2:State) is protected;
---Purpose: Split <E1> keeping the parts of state <TB1>.
SplitEdge2(me:in out;E1:Shape;TB1,TB2:State) is protected;
---Purpose: Split <E1> keeping the parts of state <TB1>.
SplitFace(me:in out;F1:Shape;TB1,TB2:State) is protected;
---Purpose: Split <F1> keeping the parts of state <TB1>.
-- Merge faces with same domain, keeping parts of
-- state <TB2>.
SplitFace1(me:in out;F1:Shape;TB1,TB2:State) is protected;
SplitFace2(me:in out;F1:Shape;TB1,TB2:State) is protected;
SplitSolid(me:in out;S1:Shape;TB1,TB2:State) is protected;
---Purpose: Split <S1> keeping the parts of state <TB1>.
SplitShapes(me:in out;Ex:in out ShapeExplorer from TopOpeBRepTool;
TB1,TB2:State;
SS:in out ShapeSet;RevOri:Boolean) is protected;
---Purpose: Explore shapes of given by explorer <Ex> to split them.
-- Store new shapes in the set <SS>.
-- According to RevOri, reverse or not their orientation.
MakeEdges(me:in out;E:Shape;B:in out EdgeBuilder;
L:in out ListOfShape);
MakeFaces(me:in out;F:Shape;B:in out FaceBuilder;
L:in out ListOfShape);
MakeSolids(me:in out;B:in out SolidBuilder;
L:in out ListOfShape);
MakeShells(me:in out;B:in out SolidBuilder;
L:in out ListOfShape);
FillFace(me:in out;F1:Shape;TB1:State;
LF2:ListOfShape;TB2:State;
WES:in out WireEdgeSet;RevOri:Boolean) is protected;
---Purpose: Split edges of <F1> and store wires and edges in
-- the set <WES>. According to RevOri, reverse (or not) orientation.
FillSolid(me:in out;S1:Shape;TB1:State;
LS2:ListOfShape;TB2:State;
SS:in out ShapeSet;RevOri:Boolean) is protected;
---Purpose: Split faces of <S1> and store shells and faces in
-- the set <SS>. According to RevOri, reverse (or not) orientation.
FillShape(me:in out;S1:Shape;TB1:State;
LS2:ListOfShape;TB2:State;
SS:in out ShapeSet;RevOri:Boolean) is protected;
---Purpose: Split subshapes of <S1> and store subshapes in
-- the set <SS>. According to RevOri, reverse (or not) orientation.
FillVertexSet(me;IT:in out PointIterator;
TB:State;PVS:in out PaveSet) is protected;
---Purpose: fills the vertex set PVS with the point iterator IT.
-- IT accesses a list of interferences which geometry is a point or a vertex.
-- TB indicates the orientation to give to the geometries
-- found in interference list accessed by IT.
FillVertexSetOnValue(me;IT:PointIterator;
TB:State;PVS:in out PaveSet) is protected;
---Purpose: fills vertex set PVS with the current value of IT.
-- I geometry is a point or a vertex.
-- TB indicates the orientation to give to geometries found I
ToSplit(me;S:Shape;TB:State) returns Boolean is protected;
---Purpose: Returns True if the shape <S> has not already been split
--modified by NIZHNY-MZV Thu Sep 30 10:29:53 1999
MarkSplit(me:in out;S:Shape;TB:State;B:Boolean=Standard_True) is protected;
---Purpose: add the shape <S> to the map of split shapes.
-- mark <S> as split/not split on <state>, according to B value.
ChangeSplit(me:in out;S:Shape;TB:State) returns ListOfShape;
---Purpose: Returns a ref.on the list of shapes connected to <S> as
-- <TB> split parts of <S>.
-- Mark <S> as split in <TB> parts.
---C++: return &
ChangeMerged(me:in out;S:Shape;TB:State) returns ListOfShape is protected;
---Purpose: Returns a ref. on the list of shapes connected to <S> as
-- <TB> merged parts of <S>.
---C++: return &
ChangeNewVertex(me:in out;I:Integer) returns Shape is protected;
---Purpose: Returns a ref. on the vertex created on point <I>.
---C++: return &
ChangeNewEdges(me:in out;I:Integer) returns ListOfShape is protected;
---Purpose: Returns a ref. on the list of edges created on curve <I>.
---C++: return &
ChangeNewFaces(me:in out;I:Integer) returns ListOfShape is protected;
---Purpose: Returns a ref. on the list of faces created on surface <I>.
---C++: return &
AddIntersectionEdges(me;F:in out Shape;TB:State;
RevOri:Boolean;ES:in out ShapeSet) is protected;
Opec12(me) returns Boolean;
Opec21(me) returns Boolean;
Opecom(me) returns Boolean;
Opefus(me) returns Boolean;
ShapePosition(me:in out;S:Shape;LS:ListOfShape) returns State;
KeepShape(me:in out;S:Shape;LS:ListOfShape;T:State) returns Boolean;
TopType(myclass;S:Shape) returns ShapeEnum;
Reverse(myclass;T1,T2:State) returns Boolean;
Orient(myclass;O:Orientation;R:Boolean) returns Orientation;
FindSameDomain(me;L1,L2:in out ListOfShape);
FindSameDomainSameOrientation(me;LSO,LDO:in out ListOfShape);
MapShapes(me:in out;S1,S2:Shape);
ClearMaps(me:in out);
FindSameRank(me;L1:ListOfShape;R:Integer;L2:in out ListOfShape);
ShapeRank(me;S:Shape) returns Integer;
IsShapeOf(me;S:Shape;I12:Integer) returns Boolean;
Contains(myclass;S:Shape;L:ListOfShape) returns Boolean;
UpdateSplitAndMerged(me : in out; mle :DataMapOfIntegerListOfShape from TopTools;
mre :DataMapOfIntegerShape from TopTools;
mlf :DataMapOfShapeShape from TopTools;
state :State from TopAbs)
is protected;
-- KPart Builder
FindIsKPart(me:in out) returns Integer;
IsKPart(me) returns Integer;
--Begin modified by NIZHNY-MZV Mon Feb 7 17:18:40 2000
MergeKPart(me:in out) is virtual;
MergeKPart(me:in out;TB1,TB2:State) is virtual;
--End modified by NIZHNY-MZV Mon Feb 7 17:18:45 2000
MergeKPartiskole(me:in out);
MergeKPartiskoletge(me:in out);
MergeKPartisdisj(me:in out);
MergeKPartisfafa(me:in out);
MergeKPartissoso(me:in out);
KPiskole(me:in out) returns Integer;
KPiskoletge(me:in out) returns Integer;
KPisdisj(me:in out) returns Integer;
KPisfafa(me:in out) returns Integer;
KPissoso(me:in out) returns Integer;
KPClearMaps(me:in out);
KPlhg(me;S:Shape;T:ShapeEnum;L:out ListOfShape) returns Integer;
KPlhg(me;S:Shape;T:ShapeEnum) returns Integer;
KPlhsd(me;S:Shape;T:ShapeEnum;L:out ListOfShape) returns Integer;
KPlhsd(me;S:Shape;T:ShapeEnum) returns Integer;
KPclasSS(me:in out;S1:Shape;exceptLS1:ListOfShape;S2:Shape) returns State;
KPclasSS(me:in out;S1,exceptS1,S2:Shape) returns State;
KPclasSS(me:in out;S1,S2:Shape) returns State;
KPiskolesh(me;S:Shape;LS,LF:out ListOfShape) returns Boolean;
KPiskoletgesh(me;S:Shape;LS,LF:out ListOfShape) returns Boolean;
KPSameDomain(me;L1:in out ListOfShape;L2:out ListOfShape);
KPisdisjsh(me;S:Shape) returns Integer;
KPisfafash(me;S:Shape) returns Integer;
KPissososh(me;S:Shape) returns Integer;
KPiskoleanalyse(me;FT1,FT2,ST1,ST2:State;I,I1,I2:out Integer);
KPiskoletgeanalyse(me;Conf:Config;ST1,ST2:State;I:out Integer);
KPisdisjanalyse(me;ST1,ST2:State;I,IC1,IC2:out Integer);
KPls(myclass;S:Shape;T:ShapeEnum;L:out ListOfShape) returns Integer;
KPls(myclass;S:Shape;T:ShapeEnum) returns Integer;
-- les methodes suivantes sont in out er non myclass
-- car elles modifient myShapeClassifier
KPclassF(me:in out;F1,F2:Shape) returns State;
KPclassFF(me:in out;F1,F2:Shape;T1,T2:out State);
KPiskoleFF(me:in out;F1,F2:Shape;T1,T2:out State) returns Boolean;
KPContains(myclass;S:Shape;L:ListOfShape) returns Boolean;
KPmakeface(me:in out;F1:Shape;LF2:ListOfShape;T1,T2:State;R1,R2:Boolean)
returns Shape;
KPreturn(myclass;KP:Integer) returns Integer;
--
SplitEvisoONperiodicF(me:in out);
-- solid
--modified by NIZHNY-MZV Wed Sep 29 09:46:48 1999
GMergeSolids(me:in out;LSO1,LSO2:ListOfShape;G:GTopo);
GFillSolidsSFS(me:in out;LSO1,LSO2:ListOfShape;G:GTopo;SFS:in out ShellFaceSet);
GFillSolidSFS(me:in out;SO1:Shape;LSO2:ListOfShape;G:GTopo;SFS:in out ShellFaceSet) is virtual;
GFillSurfaceTopologySFS(me:in out;SO1:Shape;G:GTopo;SFS:in out ShellFaceSet);
GFillSurfaceTopologySFS(me;IT:SurfaceIterator;G:GTopo;SFS:in out ShellFaceSet);
--modified by NIZHNY-MZV Thu Sep 30 09:55:31 1999
GFillShellSFS(me:in out;SH1:Shape;LSO2:ListOfShape;G:GTopo;SFS:in out ShellFaceSet) is virtual;
GFillFaceSFS(me:in out;F1:Shape;LSO2:ListOfShape;G:GTopo;SFS:in out ShellFaceSet);
GSplitFaceSFS(me:in out;F1:Shape;LSclass:ListOfShape;G:GTopo;SFS:in out ShellFaceSet);
GMergeFaceSFS(me:in out;F:Shape;G:GTopo;SFS:out ShellFaceSet);
GSplitFace(me:in out;F:Shape;G:GTopo;LSclass:ListOfShape);
AddONPatchesSFS(me:in out;G:GTopo;SFS:out ShellFaceSet);
FillOnPatches(me:in out;anEdgesON:ListOfShape; aBaseFace:Shape;
avoidMap:IndexedMapOfOrientedShape);
FindFacesTouchingEdge(me;aFace,anEdge:Shape; aShRank:Integer; aFaces:out ListOfShape);
-- face
GMergeFaces(me:in out;LF1,LF2:ListOfShape;G:GTopo);
GFillFacesWES(me:in out;LF1,LF2:ListOfShape;G:GTopo;WES:out WireEdgeSet);
GFillFacesWESK(me:in out;LF1,LF2:ListOfShape;G:GTopo;WES:out WireEdgeSet;K:Integer);
GFillFacesWESMakeFaces(me:in out;LF1,LF2,LSO:ListOfShape;G:GTopo);
GFillFaceWES(me:in out;F:Shape;LF2:ListOfShape;G:GTopo;WES:in out WireEdgeSet);
GFillCurveTopologyWES(me:in out;F:Shape;G:GTopo;WES:in out WireEdgeSet);
GFillCurveTopologyWES(me;IT:CurveIterator;G:GTopo;WES:in out WireEdgeSet);
GFillONPartsWES(me:in out;F:Shape;G:GTopo;LSclass:ListOfShape;WES:in out WireEdgeSet);
GFillWireWES(me:in out;W:Shape;LF2:ListOfShape;G:GTopo;WES:in out WireEdgeSet);
GFillEdgeWES(me:in out;E:Shape;LF2:ListOfShape;G:GTopo;WES:in out WireEdgeSet);
GSplitEdgeWES(me:in out;E:Shape;LF2:ListOfShape;G:GTopo;WES:in out WireEdgeSet);
GMergeEdgeWES(me:in out;E:Shape;G:GTopo;WES:in out WireEdgeSet);
GSplitEdge(me:in out;E:Shape;G:GTopo;LSclass:ListOfShape);
-- edge
GMergeEdges(me:in out;LE1,LE2:ListOfShape;G:GTopo);
GFillEdgesPVS(me:in out;LE1,LE2:ListOfShape;G:GTopo;PVS:in out PaveSet);
GFillEdgePVS(me:in out;E:Shape;LE2:ListOfShape;G:GTopo;PVS:in out PaveSet);
GFillPointTopologyPVS(me:in out;E:Shape;G:GTopo;PVS:in out PaveSet);
GFillPointTopologyPVS(me;E:Shape;IT:PointIterator;G:GTopo;PVS:in out PaveSet);
GParamOnReference(me;V:Vertex;E:Edge;P:out Real) returns Boolean;
-- other
GKeepShape(me:in out;S:Shape;Lref:ListOfShape;T:State) returns Boolean;
GKeepShape1(me:in out;S:Shape;Lref:ListOfShape;T:State;pos:out State) returns Boolean;
---Purpose: return True if S is classified <T> / Lref shapes
GKeepShapes(me:in out ;S:Shape;Lref:ListOfShape;T:State;
Lin:ListOfShape;Lou:in out ListOfShape);
---Purpose: add to Lou the shapes of Lin classified <T> / Lref shapes.
-- Lou is not cleared. (S is a dummy trace argument)
GSFSMakeSolids(me:in out;SOF:Shape;SFS:in out ShellFaceSet;LOSO:in out ListOfShape);
GSOBUMakeSolids(me:in out;SOF:Shape;SOBU:in out SolidBuilder;LOSO:in out ListOfShape);
--modified by NIZHNY-MZV Mon Dec 6 14:53:21 1999
GWESMakeFaces(me:in out;FF:Shape;WES:in out WireEdgeSet;LOF:in out ListOfShape) is virtual;
GFABUMakeFaces(me:in out;FF:Shape;FABU:in out FaceBuilder;LOF:in out ListOfShape;
MWisOld:out DataMapOfShapeInteger from TopTools);
RegularizeFaces(me:in out;FF:Shape;lnewFace:ListOfShape;LOF:in out ListOfShape);
RegularizeFace(me:in out;FF:Shape;newFace:Shape;LOF:in out ListOfShape);
-- regularize face newFace issued from face SS.
-- regularized faces are returned in the list of shape LOF
RegularizeSolids(me:in out;SS:Shape;lnewSolid:ListOfShape;LOS:in out ListOfShape);
RegularizeSolid(me:in out;SS:Shape;newSolid:Shape;LOS:in out ListOfShape);
-- regularize solid newSolid issued from solid SS.
-- regularized solids are returned in the list of shape LOS
GPVSMakeEdges(me;EF:Shape;PVS:in out PaveSet;LOE:in out ListOfShape);
GEDBUMakeEdges(me;EF:Shape;EDBU:in out EdgeBuilder;LOE:in out ListOfShape);
GToSplit(me;S:Shape;TB:State) returns Boolean;
GToMerge(me;S:Shape) returns Boolean;
GTakeCommonOfSame(myclass;G:GTopo) returns Boolean;
GTakeCommonOfDiff(myclass;G:GTopo) returns Boolean;
-- NYI:GFindxxx methods:should be provided by the DS
GFindSamDom(me;S:Shape;L1,L2:in out ListOfShape);
GFindSamDom(me;L1,L2:in out ListOfShape);
GFindSamDomSODO(me;S:Shape;LSO,LDO:in out ListOfShape);
GFindSamDomSODO(me;LSO,LDO:in out ListOfShape);
GMapShapes(me:in out;S1,S2:Shape);
GClearMaps(me:in out);
GFindSameRank(me;L1:ListOfShape;R:Integer;L2:in out ListOfShape);
GShapeRank(me;S:Shape) returns Integer;
GIsShapeOf(me;S:Shape;I12:Integer) returns Boolean;
GContains(myclass;S:Shape;L:ListOfShape) returns Boolean;
GCopyList(myclass;Lin:ListOfShape;i1,i2:Integer;Lou:out ListOfShape);
GCopyList(myclass;Lin:ListOfShape;Lou:out ListOfShape);
-- dump
GdumpLS(me;L:ListOfShape);
GdumpPNT(myclass;P:Pnt);
GdumpORIPARPNT(myclass;o:Orientation;p:Real;Pnt:Pnt);
GdumpSHA(me;S:Shape;str:Address=NULL);
GdumpSHAORI(me;S:Shape;str:Address=NULL);
GdumpSHAORIGEO(me;S:Shape;str:Address=NULL);
GdumpSHASTA(me;iS:Integer;T:State;
a:AsciiString="";b:AsciiString="");
GdumpSHASTA(me;S:Shape;T:State;
a:AsciiString="";b:AsciiString="");
GdumpSHASTA(me;iS:Integer;T:State;SS:ShapeSet;
a:AsciiString="";b:AsciiString="";c:AsciiString="\n");
GdumpEDG(me;S:Shape;str:Address=NULL);
GdumpEDGVER(me;E,V:Shape;str:Address=NULL);
GdumpSAMDOM(me;L:ListOfShape;str:Address=NULL);
GdumpEXP(me;E:ShapeExplorer);
GdumpSOBU(me;SB:in out SolidBuilder);
GdumpFABU(me;FB:in out FaceBuilder);
GdumpEDBU(me;EB:in out EdgeBuilder);
GtraceSPS(me;iS:Integer) returns Boolean;
GtraceSPS(me;iS,jS:Integer) returns Boolean;
GtraceSPS(me;S:Shape) returns Boolean;
GtraceSPS(me;S:Shape;IS:out Integer) returns Boolean;
GdumpSHASETreset(me:in out);
GdumpSHASETindex(me:in out) returns Integer;
PrintGeo(myclass;S:Shape);
PrintSur(myclass;F:Face);
PrintCur(myclass;E:Edge);
PrintPnt(myclass;V:Vertex);
PrintOri(myclass;S:Shape);
StringState(myclass;S:State) returns AsciiString from TCollection;
GcheckNBOUNDS(myclass;E:Shape) returns Boolean;
fields
myState1,myState2:State from TopAbs is protected;
myShape1,myShape2:Shape from TopoDS is protected;
myDataStructure:HDataStructure from TopOpeBRepDS is protected;
myBuildTool:BuildTool from TopOpeBRepDS is protected;
myNewVertices:HArray1OfShape from TopTools is protected;
myNewEdges:DataMapOfIntegerListOfShape from TopTools is protected;
myNewFaces:HArray1OfListOfShape from TopTools is protected;
mySplitIN :DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
mySplitON :DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
mySplitOUT:DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
myMergedIN :DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
myMergedON :DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
myMergedOUT:DataMapOfShapeListOfShapeOn1State from TopOpeBRepDS is protected;
myEmptyShapeList:ListOfShape from TopTools is protected;
myListOfSolid:ListOfShape from TopTools is protected;
myListOfFace:ListOfShape from TopTools is protected;
myListOfEdge:ListOfShape from TopTools is protected;
-- new faces to split with their splits
myFSplits:DataMapOfShapeListOfShape is protected;
-- new edges to split with their splits
myESplits:DataMapOfShapeListOfShape is protected;
-- section data
mySectionDone:Boolean from Standard is protected;
mySplitSectionEdgesDone:Boolean from Standard is protected;
mySection:ListOfShape from TopTools is protected;
-- grid data
mySolidReference:Solid from TopoDS is protected;
mySolidToFill:Solid from TopoDS is protected;
myFaceAvoid:ListOfShape from TopTools is protected;
myFaceReference:Face from TopoDS is protected;
myFaceToFill:Face from TopoDS is protected;
myEdgeAvoid:ListOfShape from TopTools is protected;
myEdgeReference:Edge from TopoDS is protected;
myEdgeToFill:Edge from TopoDS is protected;
myVertexAvoid:ListOfShape from TopTools is protected;
myMAP1,myMAP2:IndexedMapOfShape from TopTools is protected;
-- KPart Builder
myIsKPart:Integer from Standard is protected;
myKPMAPf1f2:DataMapOfShapeListOfShape from TopTools is protected;
-- trace
mySHASETindex:Integer is protected;
-- special cases
myClassifyDef:Boolean is protected;
myClassifyVal:Boolean is protected;
myShapeClassifier:ShapeClassifier from TopOpeBRepTool is protected;
--- Regularization
myMemoSplit : MapOfShape from TopTools is protected;
myEmptyAS : AsciiString from TCollection is protected; -- BUG extraction hxx WOK
-- for building of ON patches from coinciding faces not same domain
myProcessON: Boolean from Standard is protected;
myONFacesMap: IndexedDataMapOfShapeShape from TopTools is protected;
myONElemMap: IndexedMapOfOrientedShape from TopTools is protected;
friends
class HBuilder from TopOpeBRepBuild
end Builder from TopOpeBRepBuild;

View File

@@ -0,0 +1,731 @@
// File: TopOpeBRepBuild_Builder.cxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State.hxx>
#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
#include <TopOpeBRepBuild_GTool.hxx>
#include <TopOpeBRepDS_SurfaceIterator.hxx>
#include <TopOpeBRepDS_Surface.hxx>
#include <TopOpeBRepDS_Curve.hxx>
#include <TopOpeBRepDS_CurveExplorer.hxx>
#include <TopOpeBRepDS_Point.hxx>
#include <TopOpeBRepDS_Config.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
#include <TopOpeBRepTool_ShapeExplorer.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TopOpeBRepDS_Filter.hxx>
#include <TopOpeBRepDS_Reducer.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCU();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCUV();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPF();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPS();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextSF2();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSHEX();
Standard_EXPORT void debmarksplit(const Standard_Integer i) {cout<<"++ debmarksplit "<<i<<endl;}
Standard_EXPORT void debchangesplit(const Standard_Integer i) {cout<<"++ debchangesplit "<<i<<endl;}
#endif
static Standard_Integer STATIC_SOLIDINDEX = 0;
#include <TopOpeBRepBuild_SplitEdge.hxx>
#include <TopOpeBRepBuild_SplitFace.hxx>
#include <TopOpeBRepBuild_SplitSolid.hxx>
#include <TopOpeBRepBuild_SplitShapes.hxx>
#include <TopOpeBRepBuild_Fill.hxx>
Standard_EXPORT TopOpeBRepBuild_Builder* GLOBAL_PBUILDER;
//=======================================================================
//function : TopOpeBRepBuild_Builder
//purpose :
//=======================================================================
TopOpeBRepBuild_Builder::TopOpeBRepBuild_Builder(const TopOpeBRepDS_BuildTool& BT)
: myBuildTool(BT),
mySectionDone(Standard_False),
myIsKPart(0),
myClassifyDef(Standard_False),
myClassifyVal(Standard_True),
myProcessON(Standard_False)
{
GLOBAL_PBUILDER = this;
InitSection();
}
//modified by NIZHNY-MZV Sat May 6 10:04:49 2000
//=======================================================================
//function : Destroy
//purpose : virtual destructor
//=======================================================================
void TopOpeBRepBuild_Builder::Destroy()
{
}
//=======================================================================
//function : ChangeBuildTool
//purpose :
//=======================================================================
TopOpeBRepDS_BuildTool& TopOpeBRepBuild_Builder::ChangeBuildTool()
{
return myBuildTool;
}
//=======================================================================
//function : BuildTool
//purpose :
//=======================================================================
const TopOpeBRepDS_BuildTool& TopOpeBRepBuild_Builder::BuildTool() const
{
return myBuildTool;
}
//=======================================================================
//function : DataStructure
//purpose :
//=======================================================================
Handle(TopOpeBRepDS_HDataStructure) TopOpeBRepBuild_Builder::DataStructure() const
{
return myDataStructure;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
#ifdef DEB
GdumpSHASETreset();
#endif
Clear();
myDataStructure = HDS;
BuildVertices(HDS);
SplitEvisoONperiodicF();
BuildEdges(HDS);
BuildFaces(HDS);
myIsKPart = 0;
InitSection();
SplitSectionEdges();
TopOpeBRepDS_Filter F(HDS, &myShapeClassifier);
F.ProcessFaceInterferences(mySplitON);
TopOpeBRepDS_Reducer R(HDS);
R.ProcessFaceInterferences(mySplitON);
} // Perform
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const TopoDS_Shape& S1, const TopoDS_Shape& S2)
{
Perform(HDS);
myShape1 = S1; myShape2 = S2;
myIsKPart = FindIsKPart();
} // Perform
//=======================================================================
//function : AddIntersectionEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::AddIntersectionEdges
(TopoDS_Shape& aFace,const TopAbs_State ToBuild1,const Standard_Boolean RevOri1,TopOpeBRepBuild_ShapeSet& WES) const
{
TopoDS_Shape anEdge;
TopOpeBRepDS_CurveIterator FCurves = myDataStructure->FaceCurves(aFace);
for (; FCurves.More(); FCurves.Next()) {
Standard_Integer iC = FCurves.Current();
#ifdef DEB
Standard_Boolean tCU = TopOpeBRepBuild_GettraceCU();
Standard_Boolean NtCUV = !TopOpeBRepBuild_GettraceCUV();
if(tCU) {cout<<endl;myDataStructure->Curve(iC).Dump(cout,iC,NtCUV);}
#endif
const TopTools_ListOfShape& LnewE = NewEdges(iC);
for (TopTools_ListIteratorOfListOfShape Iti(LnewE); Iti.More(); Iti.Next()) {
anEdge = Iti.Value();
TopAbs_Orientation ori = FCurves.Orientation(ToBuild1);
TopAbs_Orientation newori = Orient(ori,RevOri1);
if(newori == TopAbs_EXTERNAL) continue;
myBuildTool.Orientation(anEdge,newori);
const Handle(Geom2d_Curve)& PC = FCurves.PCurve();
myBuildTool.PCurve(aFace,anEdge,PC);
WES.AddStartElement(anEdge);
}
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::Clear()
{
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it;
for (it.Initialize(mySplitOUT); it.More(); it.Next()) {
const TopoDS_Shape& e = it.Key();
if ( e.ShapeType() == TopAbs_EDGE ) {
Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
if (!isse) mySplitOUT.ChangeFind(e).Clear();
}
}
for (it.Initialize(mySplitIN); it.More(); it.Next()) {
const TopoDS_Shape& e = it.Key();
if ( e.ShapeType() == TopAbs_EDGE ) {
Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
if (!isse) mySplitIN.ChangeFind(e).Clear();
}
}
for (it.Initialize(mySplitON); it.More(); it.Next()) {
const TopoDS_Shape& e = it.Key();
if ( e.ShapeType() == TopAbs_EDGE ) {
Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
if (!isse) mySplitON.ChangeFind(e).Clear();
}
}
myMergedOUT.Clear();
myMergedIN.Clear();
myMergedON.Clear();
} // Clear
//=======================================================================
//function : NewFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_Builder::NewFaces(const Standard_Integer I) const
{
const TopTools_ListOfShape& L = myNewFaces->Array1().Value(I);
return L;
} // NewFaces
//=======================================================================
//function : ChangeNewFaces
//purpose : private
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_Builder::ChangeNewFaces(const Standard_Integer I)
{
TopTools_ListOfShape& L = myNewFaces->ChangeArray1().ChangeValue(I);
return L;
} // ChangeNewFaces
//=======================================================================
//function : NewEdges
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_Builder::NewEdges(const Standard_Integer I) const
{
if ( myNewEdges.IsBound(I) ) {
return myNewEdges.Find(I);
}
else {
return myEmptyShapeList;
}
} // NewEdges
//=======================================================================
//function : ChangeNewEdges
//purpose : private
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_Builder::ChangeNewEdges(const Standard_Integer I)
{
if ( ! myNewEdges.IsBound(I) ) {
TopTools_ListOfShape thelist;
myNewEdges.Bind(I, thelist);
}
TopTools_ListOfShape& L = myNewEdges.ChangeFind(I);
return L;
} // ChangeNewEdges
//=======================================================================
//function : NewVertex
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_Builder::NewVertex(const Standard_Integer I) const
{
const TopoDS_Shape& V = myNewVertices->Array1().Value(I);
return V;
} // NewVertex
//=======================================================================
//function : ChangeNewVertex
//purpose : private
//=======================================================================
TopoDS_Shape& TopOpeBRepBuild_Builder::ChangeNewVertex(const Standard_Integer I)
{
TopoDS_Shape& V = myNewVertices->ChangeArray1().ChangeValue(I);
return V;
} // ChangeNewVertex
//=======================================================================
//function : ToSplit
//purpose : private
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::ToSplit(const TopoDS_Shape& S,const TopAbs_State ToBuild) const
{
Standard_Boolean issplit = IsSplit(S,ToBuild);
Standard_Boolean hasgeom = myDataStructure->HasGeometry(S);
Standard_Boolean hassame = myDataStructure->HasSameDomain(S);
Standard_Boolean tosplit = (!issplit) && (hasgeom || hassame);
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
if (tSPS) {
cout<<"tosplit "<<tosplit<<" : "<<"!issplit "<<(!issplit);
cout<<" && (hasgeom || hassame) ("<<hasgeom<<" || "<<hassame<<")"<<endl;
}
#endif
return tosplit;
} // ToSplit
//=======================================================================
//function : MarkSplit
//purpose : private
//=======================================================================
void TopOpeBRepBuild_Builder::MarkSplit(const TopoDS_Shape& S,const TopAbs_State ToBuild,const Standard_Boolean Bval)
{
TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &mySplitOUT;
else if ( ToBuild == TopAbs_IN ) p = &mySplitIN;
else if ( ToBuild == TopAbs_ON ) p = &mySplitON;
if ( p == NULL ) return;
TopOpeBRepDS_ListOfShapeOn1State thelist;
if (!(*p).IsBound(S)) (*p).Bind(S, thelist);
TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).ChangeFind(S);
losos.Split(Bval);
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
if(tSPS){
GdumpSHA(S, (char *) "MarkSplit ");
cout<<" ";TopAbs::Print(ToBuild,cout);cout<<" "<<Bval<<endl;
debmarksplit(iS);
}
#endif
} // MarkSplit
//=======================================================================
//function : IsSplit
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::IsSplit(const TopoDS_Shape& S,const TopAbs_State ToBuild) const
{
Standard_Boolean res = Standard_False;
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &mySplitOUT;
else if ( ToBuild == TopAbs_IN ) p = &mySplitIN;
else if ( ToBuild == TopAbs_ON ) p = &mySplitON;
if ( p == NULL ) return res;
if ((*p).IsBound(S)) {
const TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).Find(S);
res = losos.IsSplit();
#ifdef DEB
// Standard_Integer n = losos.ListOnState().Extent();
#endif
}
return res;
} // IsSplit
//=======================================================================
//function : Splits
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_Builder::Splits(const TopoDS_Shape& S, const TopAbs_State ToBuild) const
{
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &mySplitOUT;
else if ( ToBuild == TopAbs_IN ) p = &mySplitIN;
else if ( ToBuild == TopAbs_ON ) p = &mySplitON;
if ( p == NULL ) return myEmptyShapeList;
if ((*p).IsBound(S)) {
const TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).Find(S);
const TopTools_ListOfShape& L = losos.ListOnState();
return L;
}
return myEmptyShapeList;
} // Splits
//=======================================================================
//function : ChangeSplit
//purpose : private
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_Builder::ChangeSplit(const TopoDS_Shape& S,const TopAbs_State ToBuild)
{
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
if(tSPS){
GdumpSHA(S, (char *) "ChangeSplit ");
cout<<" ";TopAbs::Print(ToBuild,cout);cout<<endl;
debchangesplit(iS);
}
#endif
TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &mySplitOUT;
else if ( ToBuild == TopAbs_IN ) p = &mySplitIN;
else if ( ToBuild == TopAbs_ON ) p = &mySplitON;
if ( p == NULL ) return myEmptyShapeList;
TopOpeBRepDS_ListOfShapeOn1State thelist1;
if (!(*p).IsBound(S)) (*p).Bind(S, thelist1);
TopOpeBRepDS_ListOfShapeOn1State& losos = (*p).ChangeFind(S);
TopTools_ListOfShape& L = losos.ChangeListOnState();
return L;
} // ChangeSplit
//=======================================================================
//function : ShapePosition
//purpose : compute position of shape S compared with the shapes of list LS
// if S is found IN any shape of LS, return IN
// else return OUT
//=======================================================================
TopAbs_State TopOpeBRepBuild_Builder::ShapePosition(const TopoDS_Shape& S, const TopTools_ListOfShape& LS)
{
TopAbs_State state = TopAbs_UNKNOWN;
// take the edges of myEdgeAvoid as shape to avoid
// during face classification
const TopTools_ListOfShape* PLOS = &myEmptyShapeList;
TopAbs_ShapeEnum tS = S.ShapeType();
if (tS == TopAbs_FACE) PLOS = &myEdgeAvoid;
// NYI : idem with myFaceAvoid if (tS == TopAbs_SOLID)
for (TopTools_ListIteratorOfListOfShape Iti(LS); Iti.More(); Iti.Next()) {
const TopoDS_Shape& SLS = Iti.Value();
#ifdef DEB
// TopAbs_ShapeEnum tSLS = SLS.ShapeType();
#endif
state = myShapeClassifier.StateShapeShape(S,(*PLOS),SLS);
if (state != TopAbs_OUT && state != TopAbs_UNKNOWN) return state;
}
if (state == TopAbs_UNKNOWN) return state;
return TopAbs_OUT;
}
//=======================================================================
//function : KeepShape
//purpose : compute <pos2> = position of shape <S1> / shapes of list <LS2>
// shape S1 is kept
// - if LS2 is empty
// - if (pos2 == ToBuild1)
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::KeepShape(const TopoDS_Shape& S1,const TopTools_ListOfShape& LS2,const TopAbs_State ToBuild1)
{
Standard_Boolean keep = Standard_True;
if ( ! LS2.IsEmpty() ) {
TopAbs_State pos2 = ShapePosition(S1,LS2);
if ( pos2 != ToBuild1 ) keep = Standard_False;
}
return keep;
}
//=======================================================================
//function : TopType
//purpose : return the type of upper subshape found in <S>
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepBuild_Builder::TopType(const TopoDS_Shape& S)
{
TopAbs_ShapeEnum t;
TopOpeBRepTool_ShapeExplorer e;
t = TopAbs_COMPOUND; e.Init(S,t); if (e.More()) return t;
t = TopAbs_COMPSOLID; e.Init(S,t); if (e.More()) return t;
t = TopAbs_SOLID; e.Init(S,t); if (e.More()) return t;
t = TopAbs_SHELL; e.Init(S,t); if (e.More()) return t;
t = TopAbs_FACE; e.Init(S,t); if (e.More()) return t;
t = TopAbs_WIRE; e.Init(S,t); if (e.More()) return t;
t = TopAbs_EDGE; e.Init(S,t); if (e.More()) return t;
t = TopAbs_VERTEX; e.Init(S,t); if (e.More()) return t;
return TopAbs_SHAPE;
}
//=======================================================================
//function : Reverse
//purpose : compute orientation reversibility according to build states
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Reverse(const TopAbs_State ToBuild1,const TopAbs_State ToBuild2)
{
Standard_Boolean rev;
if (ToBuild1 == TopAbs_IN && ToBuild2 == TopAbs_IN) rev = Standard_False;
else rev = (ToBuild1 == TopAbs_IN);
return rev;
}
//=======================================================================
//function : Orient
//purpose : reverse the orientation
//=======================================================================
TopAbs_Orientation TopOpeBRepBuild_Builder::Orient(const TopAbs_Orientation Ori,const Standard_Boolean Reverse)
{
#ifdef DEB
TopAbs_Orientation result;
#else
TopAbs_Orientation result=TopAbs_FORWARD;
#endif
switch (Reverse) {
case Standard_True : result = TopAbs::Complement(Ori); break;
case Standard_False : result = Ori; break;
}
return result;
}
//=======================================================================
//function : FindSameDomain
//purpose : complete the lists L1,L2 with the shapes of the DS
// having same domain :
// L1 = shapes sharing the same domain of L2 shapes
// L2 = shapes sharing the same domain of L1 shapes
// (L1 contains a face)
//=======================================================================
void TopOpeBRepBuild_Builder::FindSameDomain(TopTools_ListOfShape& L1,TopTools_ListOfShape& L2) const
{
Standard_Integer i;
Standard_Integer nl1 = L1.Extent(), nl2 = L2.Extent();
while ( nl1 > 0 || nl2 > 0 ) {
TopTools_ListIteratorOfListOfShape it1(L1);
for (i=1 ; i<=nl1; i++) {
const TopoDS_Shape& S1 = it1.Value();
#ifdef DEB
// Standard_Integer iS1 = myDataStructure->Shape(S1); // DEB
#endif
TopTools_ListIteratorOfListOfShape itsd(myDataStructure->SameDomain(S1));
for (; itsd.More(); itsd.Next() ) {
const TopoDS_Shape& S2 = itsd.Value();
#ifdef DEB
// Standard_Integer iS2 = myDataStructure->Shape(S2);// DEB
#endif
Standard_Boolean found = Contains(S2,L2);
if ( ! found ) {
L2.Prepend(S2);
nl2++;
}
}
it1.Next();
}
nl1 = 0;
TopTools_ListIteratorOfListOfShape it2(L2);
for (i=1 ; i<=nl2; i++) {
const TopoDS_Shape& S2 = it2.Value();
#ifdef DEB
// Standard_Integer iS2 = myDataStructure->Shape(S2);// DEB
#endif
TopTools_ListIteratorOfListOfShape itsd(myDataStructure->SameDomain(S2));
for (; itsd.More(); itsd.Next() ) {
const TopoDS_Shape& S1 = itsd.Value();
#ifdef DEB
// Standard_Integer iS1 = myDataStructure->Shape(S1);// DEB
#endif
Standard_Boolean found = Contains(S1,L1);
if ( ! found ) {
L1.Prepend(S1);
nl1++;
}
}
it2.Next();
}
nl2 = 0;
}
}
//=======================================================================
//function : FindSameDomainSameOrientation
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::FindSameDomainSameOrientation(TopTools_ListOfShape& L1, TopTools_ListOfShape& L2) const
{
FindSameDomain(L1,L2);
TopTools_ListIteratorOfListOfShape it(L1);
if ( !it.More() ) return;
const TopoDS_Shape& sref = it.Value();
#ifdef DEB
// Standard_Integer iref = myDataStructure->SameDomainReference(sref);
#endif
TopOpeBRepDS_Config oref = myDataStructure->SameDomainOrientation(sref);
TopTools_ListOfShape LL1,LL2;
for (it.Initialize(L1); it.More(); it.Next() ) {
const TopoDS_Shape& s = it.Value();
TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s);
if ( o == oref && !Contains(s,LL1) ) LL1.Append(s);
else if ( o != oref && !Contains(s,LL2) ) LL2.Append(s);
}
for (it.Initialize(L2); it.More(); it.Next() ) {
const TopoDS_Shape& s = it.Value();
TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s);
if ( o == oref && !Contains(s,LL1) ) LL1.Append(s);
else if ( o != oref && !Contains(s,LL2) ) LL2.Append(s);
}
L1 = LL1;
L2 = LL2;
}
//=======================================================================
//function : MapShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MapShapes(const TopoDS_Shape& S1,const TopoDS_Shape& S2)
{
Standard_Boolean S1null = S1.IsNull();
Standard_Boolean S2null = S2.IsNull();
ClearMaps();
if ( ! S1null ) TopExp::MapShapes(S1,myMAP1);
if ( ! S2null ) TopExp::MapShapes(S2,myMAP2);
}
//=======================================================================
//function : ClearMaps
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::ClearMaps()
{
myMAP1.Clear();
myMAP2.Clear();
}
//=======================================================================
//function : FindSameRank
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::FindSameRank(const TopTools_ListOfShape& L1,const Standard_Integer rank,TopTools_ListOfShape& L2) const
{
for ( TopTools_ListIteratorOfListOfShape it1(L1); it1.More(); it1.Next() ) {
const TopoDS_Shape& s = it1.Value();
Standard_Integer r = ShapeRank(s);
if ( r == rank && !Contains(s,L2) ) {
L2.Append(s);
}
}
}
//=======================================================================
//function : ShapeRank
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_Builder::ShapeRank(const TopoDS_Shape& s) const
{
Standard_Boolean isof1 = IsShapeOf(s,1);
Standard_Boolean isof2 = IsShapeOf(s,2);
Standard_Integer ancetre = (isof1 || isof2) ? ((isof1) ? 1 : 2) : 0;
return ancetre;
}
//=======================================================================
//function : IsShapeOf
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::IsShapeOf(const TopoDS_Shape& s,const Standard_Integer i) const
{
Standard_Boolean b = Standard_False;
if (i == 1) b = myMAP1.Contains(s);
else if (i == 2) b = myMAP2.Contains(s);
return b;
}
//=======================================================================
//function : Contains
//purpose : returns True if S is in the list L.
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Contains(const TopoDS_Shape& S,const TopTools_ListOfShape& L)
{
for (TopTools_ListIteratorOfListOfShape it(L); it.More(); it.Next() ) {
TopoDS_Shape& SL = it.Value();
Standard_Boolean issame = SL.IsSame(S);
if ( issame ) return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Opec12
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Opec12() const
{
Standard_Boolean b = (myState1 == TopAbs_OUT) && (myState2 == TopAbs_IN );
return b;
}
//=======================================================================
//function : Opec21
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Opec21() const
{
Standard_Boolean b = (myState1 == TopAbs_IN ) && (myState2 == TopAbs_OUT);
return b;
}
//=======================================================================
//function : Opecom
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Opecom() const
{
Standard_Boolean b = (myState1 == TopAbs_IN ) && (myState2 == TopAbs_IN );
return b;
}
//=======================================================================
//function : Opefus
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Opefus() const
{
Standard_Boolean b = (myState1 == TopAbs_OUT) && (myState2 == TopAbs_OUT);
return b;
}
//=======================================================================
//function : MSplit
//purpose :
//=======================================================================
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& TopOpeBRepBuild_Builder::MSplit(const TopAbs_State s) const
{
if (s == TopAbs_IN) return mySplitIN;
else if (s == TopAbs_OUT) return mySplitOUT;
else if (s == TopAbs_ON) return mySplitON;
return mySplitIN;
}
//=======================================================================
//function : ChangeMSplit
//purpose :
//=======================================================================
TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& TopOpeBRepBuild_Builder::ChangeMSplit(const TopAbs_State s)
{
if (s == TopAbs_IN) return mySplitIN;
else if (s == TopAbs_OUT) return mySplitOUT;
else if (s == TopAbs_ON) return mySplitON;
return mySplitIN;
}

View File

@@ -0,0 +1,220 @@
-- File: TopOpeBRepBuild_Builder1.cdl
-- Created: Wed Sep 29 09:33:29 1999
-- Author: Maxim ZVEREV
-- <mzv@irinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class Builder1 from TopOpeBRepBuild inherits Builder from TopOpeBRepBuild
---Purpose: extension of the class TopOpeBRepBuild_Builder dedicated
--- to avoid bugs in "Rebuilding Result" algorithm for the case of SOLID/SOLID Boolean Operations
uses
HBuilder from TopOpeBRepBuild ,
BuildTool from TopOpeBRepDS,
Shape from TopoDS,
Edge from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
SequenceOfShape from TopTools,
ShellFaceSet from TopOpeBRepBuild,
WireEdgeSet from TopOpeBRepBuild,
GTopo from TopOpeBRepBuild,
IndexedMapOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
DataMapOfOrientedShapeInteger from TopTools ,
HDataStructure from TopOpeBRepDS,
IndexedMapOfOrientedShape from TopTools,
IndexedDataMapOfShapeShape from TopTools ,
State from TopAbs,
IndexedDataMapOfShapeWithState from TopOpeBRepDS,
DataMapOfShapeState from TopOpeBRepDS,
PaveSet from TopOpeBRepBuild,
DataMapOfShapeListOfShape from TopTools
--raises
is
Create(BT: BuildTool from TopOpeBRepDS) returns
Builder1 from TopOpeBRepBuild ;
--------------------- BASE CLASS REDEFINITIONS
--modified by NIZHNY-MZV Sat May 6 10:07:00 2000
Destroy(me: out) is redefined virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_Builder1() { Destroy() ; }"
Clear(me:in out) is redefined;
---Purpose: Removes all splits and merges already performed.
-- Does NOT clear the handled DS (except ShapeWithStatesMaps).
Perform (me:in out;HDS:mutable HDataStructure from TopOpeBRepDS ) is redefined;
Perform(me: out; HDS : HDataStructure from TopOpeBRepDS;
S1 : Shape from TopoDS;
S2 : Shape from TopoDS) is redefined;
MergeKPart(me:in out) is redefined;
MergeKPart(me:in out;TB1,TB2:State) is redefined;
GFillSolidSFS(me:in out; SO1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
SFS:in out ShellFaceSet from TopOpeBRepBuild) is redefined;
GFillShellSFS(me:in out;SH1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
SFS: in out ShellFaceSet from TopOpeBRepBuild) is redefined;
GWESMakeFaces(me: out; FF: Shape from TopoDS;
WES : out WireEdgeSet from TopOpeBRepBuild;
LOF : out ListOfShape from TopTools) is redefined;
--------------------- END BASE CLASS REDEFINITIONS
--------------------- NEW METHODS
---Category: split edges and fill ShapeWithState Map
PerformShapeWithStates(me:out)is protected;
PerformShapeWithStates(me:out;
anObj:Shape from TopoDS;
aTool:Shape from TopoDS)
is protected;
StatusEdgesToSplit (me:out;
anObj:Shape from TopoDS;
anEdgesToSplitMap:IndexedMapOfShape from TopTools;
anEdgesToRestMap:IndexedMapOfShape from TopTools)
is protected;
SplitEdge (me:out;
anEdge:Shape from TopoDS;
aLNew: out ListOfShape from TopTools;
aDataMapOfShapeState:out DataMapOfShapeState from TopOpeBRepDS)
is protected;
GFillSplitsPVS (me: out;
anEdge: Shape from TopoDS;
G1 : GTopo from TopOpeBRepBuild;
PVS : out PaveSet from TopOpeBRepBuild);
PerformFacesWithStates(me:out;
anObj:Shape from TopoDS;
aFaces:IndexedMapOfShape from TopTools;
aSplF :out DataMapOfShapeState from TopOpeBRepDS)
is protected;
---Category: Fill Non-same domain faces
GFillFaceNotSameDomSFS(me:in out; F1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
SFS: in out ShellFaceSet from TopOpeBRepBuild);
GFillFaceNotSameDomWES(me:in out; F1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
GFillWireNotSameDomWES(me:in out; W1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
GFillEdgeNotSameDomWES(me:in out; E1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
---Category: Fill Same domain faces
GFillFaceSameDomSFS(me:in out; F1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
SFS: in out ShellFaceSet from TopOpeBRepBuild);
GFillFaceSameDomWES(me:in out; F1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
GFillWireSameDomWES(me:in out; W1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
GFillEdgeSameDomWES(me:in out; E1: Shape from TopoDS;
LSO2: ListOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
PerformONParts(me: in out; F: Shape from TopoDS;
SDfaces: IndexedMapOfShape from TopTools;
G: GTopo from TopOpeBRepBuild;
WES: in out WireEdgeSet from TopOpeBRepBuild);
PerformPieceIn2D(me: in out; aPieceToPerform : Edge from TopoDS;
aOriginalEdge : Edge from TopoDS;
edgeFace : Face from TopoDS;
toFace : Face from TopoDS;
G: GTopo from TopOpeBRepBuild;
keep : out Boolean from Standard);
PerformPieceOn2D(me: in out; aPieceObj : Shape from TopoDS;
aFaceObj : Shape from TopoDS;
aEdgeObj : Shape from TopoDS;
aListOfPieces : out ListOfShape from TopTools;
aListOfFaces : out ListOfShape from TopTools;
aListOfPiecesOut2d:out ListOfShape from TopTools )
returns Integer from Standard;
TwoPiecesON (me : in out; aSeq : SequenceOfShape from TopTools;
aListOfPieces : out ListOfShape from TopTools;
aListOfFaces : out ListOfShape from TopTools;
aListOfPiecesOut2d : out ListOfShape from TopTools)
returns Integer from Standard;
IsSame2d (me:out; aSeq:SequenceOfShape from TopTools;
aListOfPiecesOut2d:out ListOfShape from TopTools)
returns Integer from Standard is protected;
---Category: Tools, Correctors and auxiliary methods
CorrectResult2d (me:out; aResult:out Shape from TopoDS)
returns Integer from Standard;
--modified by NIZHNY-MZV Thu Feb 10 13:22:40 2000
OrientateEdgeOnFace(me; EdgeToPerform : out Edge from TopoDS;
baseFace : Face from TopoDS;
edgeFace : Face from TopoDS;
G1 : GTopo from TopOpeBRepBuild;
stateOfFaceOri : out Boolean from Standard) is protected;
fields
mySameDomMap : IndexedMapOfShape from TopTools;
mySDFaceToFill : Shape from TopoDS;
myBaseFaceToFill : Shape from TopoDS;
myMapOfEdgeFaces : IndexedDataMapOfShapeListOfShape from TopTools;
myMapOfEdgeWithFaceState : DataMapOfOrientedShapeInteger from TopTools;
myProcessedPartsOut2d : IndexedMapOfShape from TopTools;
myProcessedPartsON2d : IndexedMapOfShape from TopTools;
mySplitsONtoKeep : IndexedMapOfShape from TopTools;
mySourceShapes : IndexedMapOfOrientedShape from TopTools;
myMapOfCorrect2dEdges: IndexedDataMapOfShapeShape from TopTools;
-- new faces to split with their splits
myFSplits:DataMapOfShapeListOfShape is protected;
-- new edges to split with their splits
myESplits:DataMapOfShapeListOfShape is protected;
friends
class HBuilder from TopOpeBRepBuild
end Builder1;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,885 @@
// File: TopOpeBRepBuild_Builder_1.cxx
// Created: Thu Oct 7 09:38:29 1999
// Author: Peter KURNEV
// <pkv@irinox.nnov.matra-dtv.fr>
#include <TopOpeBRepBuild_Builder.ixx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopOpeBRepBuild_PaveSet.hxx>
#include <TopOpeBRepBuild_GTool.hxx>
#include <TopOpeBRepBuild_Pave.hxx>
#include <TopOpeBRepBuild_Loop.hxx>
#include <TopOpeBRepBuild_EdgeBuilder.hxx>
#include <TopOpeBRepBuild_ListOfListOfLoop.hxx>
#include <TopOpeBRepBuild_Tools.hxx>
#include <TopOpeBRepBuild_GTopo.hxx>
#include <TopOpeBRepDS_DataMapOfShapeState.hxx>
#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState.hxx>
#include <TopOpeBRepDS_Interference.hxx>
#include <TopOpeBRepDS_ListOfInterference.hxx>
#include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
#include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
#include <TopOpeBRepDS_ShapeWithState.hxx>
#include <TopOpeBRepDS_DataStructure.hxx>
#include <BRep_Tool.hxx>
#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
#include <Geom_Curve.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopTools_DataMapOfShapeListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
//define parameter division number as 10*e^(-PI) = 0.43213918
const Standard_Real PAR_T = 0.43213918;
static TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E,
TopOpeBRepTool_ShapeClassifier& SC);
//=======================================================================
// : Definition the States of Shape's Entities for an Object
// : and a Tool. Thu Oct 7 09:38:29 1999
//=======================================================================
static TopTools_IndexedMapOfShape processedEdges;
static TopTools_IndexedMapOfShape theUsedVertexMap;
static TopTools_MapOfShape theUnkStateVer;
Standard_IMPORT Standard_Boolean GLOBAL_faces2d;
//modified by NIZNHY-PKV Mon Dec 16 11:38:55 2002 f
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::Destroy()
{
processedEdges.Clear();
theUsedVertexMap.Clear();
theUnkStateVer.Clear();
}
//modified by NIZNHY-PKV Mon Dec 16 11:38:59 2002 t
//=======================================================================
//function : PerformShapeWithStates
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::PerformShapeWithStates()
{
theUsedVertexMap.Clear();
theUnkStateVer.Clear();
myDataStructure -> ChangeDS().ChangeMapOfShapeWithStateObj().Clear();
myDataStructure -> ChangeDS().ChangeMapOfShapeWithStateTool().Clear();
//modified by NIZHNY-MZV Mon Feb 21 13:30:05 2000
//process section curves
Standard_Integer i, nbC = myDataStructure -> DS().NbCurves();
for(i = 1; i <= nbC; i++) {
TopTools_ListOfShape& LSE = ChangeNewEdges(i);
TopTools_ListIteratorOfListOfShape it(LSE);
for(; it.More(); it.Next()) {
const TopoDS_Shape& E = it.Value();
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(E), Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
}
}
//process section edges
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
Standard_Integer n = BDS.NbSectionEdges();
for (i = 1; i <= n; i++) {
TopTools_ListIteratorOfListOfShape anIt;
const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i));
if(E.IsNull()) continue;
const TopTools_ListOfShape& SplitsON = Splits(E, TopAbs_ON);
anIt.Initialize (SplitsON);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(aNewEdge), Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
}
// IN
const TopTools_ListOfShape& SplitsIN = Splits(E, TopAbs_IN);
anIt.Initialize (SplitsIN);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(aNewEdge), Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
}
// OUT
const TopTools_ListOfShape& SplitsOUT = Splits(E, TopAbs_OUT);
anIt.Initialize (SplitsOUT);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(aNewEdge), Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
}
}
//modified by NIZHNY-MZV Tue Apr 11 17:32:05 2000
//1) Add both arguments to facilitate the search
TopOpeBRepDS_ShapeWithState aShapeWithState;
TopOpeBRepDS_DataStructure& aDataStructure=myDataStructure->ChangeDS();
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithStateObj=
aDataStructure.ChangeMapOfShapeWithStateObj();
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithStateTool=
aDataStructure.ChangeMapOfShapeWithStateTool();
aMapOfShapeWithStateObj.Add(myShape1, aShapeWithState);
aMapOfShapeWithStateTool.Add(myShape2, aShapeWithState);
//2) Add all rejected shapes as OUT
TopTools_IndexedMapOfShape& aMapOfRejectedShapesObj=
aDataStructure.ChangeMapOfRejectedShapesObj();
TopTools_IndexedMapOfShape& aMapOfRejectedShapesTool=
aDataStructure.ChangeMapOfRejectedShapesTool();
aShapeWithState.SetIsSplitted (Standard_False);
aShapeWithState.SetState (TopAbs_OUT);
Standard_Integer iW, j, nW, nE,
nRSObj = aMapOfRejectedShapesObj.Extent(),
nRSTool = aMapOfRejectedShapesTool.Extent();
for(i = 1; i <= nRSObj; i++) {
const TopoDS_Shape& aFace = aMapOfRejectedShapesObj(i);
if(aFace.ShapeType() != TopAbs_FACE)
continue;
TopTools_IndexedMapOfShape aWiresMap;
TopExp::MapShapes (aFace, TopAbs_WIRE, aWiresMap);
nW=aWiresMap.Extent ();
for (iW=1; iW<=nW; iW++) {
const TopoDS_Shape& aWire=aWiresMap(iW);
//
TopTools_IndexedMapOfShape anEdgesMap;
TopExp::MapShapes (aWire, TopAbs_EDGE, anEdgesMap);
nE=anEdgesMap.Extent ();
for (j=1; j<=nE; j++)
aMapOfShapeWithStateObj.Add(anEdgesMap(j), aShapeWithState); // add edge
aMapOfShapeWithStateObj.Add(aWire, aShapeWithState); // add wire
}
aMapOfShapeWithStateObj.Add(aFace, aShapeWithState); // add face
}
for(i = 1; i <= nRSTool; i++) {
const TopoDS_Shape& aFace = aMapOfRejectedShapesTool(i);
//modified by NIZHNY-MZV Wed Apr 5 10:27:18 2000
if(aFace.ShapeType() != TopAbs_FACE)
continue;
TopTools_IndexedMapOfShape aWiresMap;
TopExp::MapShapes (aFace, TopAbs_WIRE, aWiresMap);
nW=aWiresMap.Extent ();
for (iW=1; iW<=nW; iW++) {
const TopoDS_Shape& aWire=aWiresMap(iW);
//
TopTools_IndexedMapOfShape anEdgesMap;
TopExp::MapShapes (aWire, TopAbs_EDGE, anEdgesMap);
nE=anEdgesMap.Extent ();
for (j=1; j<=nE; j++)
aMapOfShapeWithStateTool.Add(anEdgesMap(j), aShapeWithState); // add edge
aMapOfShapeWithStateTool.Add(aWire, aShapeWithState); // add wire
}
aMapOfShapeWithStateTool.Add(aFace, aShapeWithState); // add face
}
PerformShapeWithStates (myShape1, myShape2);
processedEdges.Clear();
PerformShapeWithStates (myShape2, myShape1);
processedEdges.Clear();
// Print Block
// printf(" ..::PerformShapeWithStates() [Dump is off]\n");
/* printf(" ..::PerformShapeWithStates() [Dump is on]\n");
TopOpeBRepDS_DataStructure& aDS= myDataStructure-> ChangeDS();
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithStateObj=
aDS.ChangeMapOfShapeWithStateObj();
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithStateTool=
aDS.ChangeMapOfShapeWithStateTool();
TopOpeBRepBuild_Tools::DumpMapOfShapeWithState(0, aMapOfShapeWithStateObj);
TopOpeBRepBuild_Tools::DumpMapOfShapeWithState(1, aMapOfShapeWithStateTool);
*/
// Phase#2 Phase ON
// PerformOn2D ();
}
//=======================================================================
//function :PerformShapeWithStates
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::PerformShapeWithStates (const TopoDS_Shape& anObj,
const TopoDS_Shape& aReference)
{
myShapeClassifier.SetReference(aReference);
TopOpeBRepDS_DataStructure& aDS= myDataStructure-> ChangeDS();
// Get aMapOfShapeWithState for Obj
Standard_Boolean aFlag;
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState=
aDS.ChangeMapOfShapeWithState(anObj, aFlag);
if (!aFlag) return;
//
Standard_Integer i, j, k, nS, nF, nE;
TopTools_IndexedMapOfShape aFacesMap, aFacesWithInterferencesMap, aFacesToRestMap;
TopOpeBRepDS_DataMapOfShapeState aSplFacesState;
TopTools_IndexedMapOfShape aShellsMap;
TopExp::MapShapes(anObj, TopAbs_SHELL, aShellsMap);
nS=aShellsMap.Extent();
for (i=1; i<=nS; i++) {
const TopoDS_Shape& aShell = aShellsMap(i);
if (aMapOfShapeWithState.Contains (aShell)) continue;
else if (!myDataStructure -> HasShape(aShell)) {
// Shell has no interference.
// So, define its state and push into the Map as is.// A.1
TopOpeBRepBuild_Tools::FindStateThroughVertex (aShell, myShapeClassifier,
aMapOfShapeWithState, theUnkStateVer);
continue;
}
else {// A.2
// Shell has interference. Try to separate it into FacesToRest and InterferredFace
aFacesMap.Clear();
aFacesWithInterferencesMap.Clear();
aFacesToRestMap.Clear();
aSplFacesState.Clear();
TopExp::MapShapes (aShell, TopAbs_FACE, aFacesMap);
nF=aFacesMap.Extent();
for (j=1; j<=nF; j++) {
const TopoDS_Shape& aFace = aFacesMap(j);
if (aMapOfShapeWithState.Contains (aFace)) {
// if the face is known, its edges are also known.
// We just insert this info. into aSplFacesState in order to
// propagate the state for faces with unknown states.
TopTools_IndexedMapOfShape anEdgesMap;
TopExp::MapShapes (aFace, TopAbs_EDGE, anEdgesMap);
nE=anEdgesMap.Extent();
for (k=1; k<=nE; k++) {
const TopoDS_Shape& anEdge=anEdgesMap(k);
const TopOpeBRepDS_ShapeWithState& aSWS=
aMapOfShapeWithState.FindFromKey(anEdge);
TopAbs_State aState=aSWS.State();
aSplFacesState.Bind (anEdge, aState);
}
continue;
}
else if (myDataStructure -> HasShape(aFace))
aFacesWithInterferencesMap.Add (aFace);
else {
aFacesToRestMap.Add (aFace);
}
} // ... next Face
// work with aFacesWithInterferencesMap
PerformFacesWithStates (anObj, aFacesWithInterferencesMap, aSplFacesState);
// Propagate the States for all unknown faces from aFacesToRestMap
TopTools_MapOfShape anUnkStateEdge;
TopOpeBRepBuild_Tools::PropagateState (aSplFacesState,aFacesToRestMap,
TopAbs_EDGE, TopAbs_FACE, myShapeClassifier,
aMapOfShapeWithState, anUnkStateEdge);
///// Propagate on WIres from aFacesToRestMap
TopOpeBRepBuild_Tools::PropagateStateForWires (aFacesToRestMap, aMapOfShapeWithState);
} // end of else A.2
} // next Shell
}
//=======================================================================
//function :PerformFacesWithStates
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::PerformFacesWithStates (const TopoDS_Shape& anObj,
const TopTools_IndexedMapOfShape& aFacesWithInterferencesMap,
TopOpeBRepDS_DataMapOfShapeState& aSplFacesState)
{
TopOpeBRepDS_DataStructure& aDS= myDataStructure-> ChangeDS();
// Get aMapOfShapeWithState for Obj
Standard_Boolean aFlag;
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState=aDS.ChangeMapOfShapeWithState(anObj, aFlag);
if (!aFlag) return;
//
Standard_Integer i, j, k, nF, nW, nE;
nF=aFacesWithInterferencesMap.Extent();
for (i=1; i<=nF; i++) {
TopTools_IndexedMapOfShape anEdgesToSplitMap, anEdgesToRestMap;
const TopoDS_Shape& aFace = aFacesWithInterferencesMap(i);
TopTools_IndexedMapOfShape aWireMap;
TopExp::MapShapes (aFace, TopAbs_WIRE, aWireMap);
nW=aWireMap.Extent();
for (j=1; j<=nW; j++) {
const TopoDS_Shape& aWire=aWireMap(j);
if (!myDataStructure -> HasShape(aWire)) {
// Wire has no interference.
// So, define its state and push into the Map as is.
TopOpeBRepBuild_Tools::FindStateThroughVertex (aWire, myShapeClassifier,
aMapOfShapeWithState, theUnkStateVer);
continue;
}
else {
// Wire has an interferences
TopTools_IndexedMapOfShape anEdgeMap;
TopExp::MapShapes (aWire, TopAbs_EDGE, anEdgeMap);
nE=anEdgeMap.Extent ();
for (k=1; k<=nE; k++) {
const TopoDS_Shape& anEdge=anEdgeMap(k);
if (myDataStructure -> HasShape(anEdge)) {
anEdgesToSplitMap.Add(anEdge);
}
else {
anEdgesToRestMap.Add(anEdge);
}
}
// split edges and define the states for all edges and parts of edges
StatusEdgesToSplit (anObj, anEdgesToSplitMap, anEdgesToRestMap);
////// After StatusEdgesToSplit we can find the status of each Rest Edge
////// in aMapOfShapeWithState. So we can insert this info. into
////// aSplFacesState in order to propagate the state for faces.
nE=anEdgesToRestMap.Extent();
for (k=1; k<=nE; k++) {
const TopoDS_Shape anEdge=anEdgesToRestMap(k);
if (aMapOfShapeWithState.Contains (anEdge)) {
const TopOpeBRepDS_ShapeWithState& aSWS=aMapOfShapeWithState.FindFromKey(anEdge);
TopAbs_State aState=aSWS.State();
aSplFacesState.Bind (anEdge, aState);
}
}
} //end of else {// Wire has an interferences
} // next Wire
} // next interferred Face ... for (i=1; i<=nF; i++) ...
}
//=======================================================================
//function :StatusEdgesToSplit
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::StatusEdgesToSplit (const TopoDS_Shape& anObj,
const TopTools_IndexedMapOfShape& anEdgesToSplitMap,
const TopTools_IndexedMapOfShape& anEdgesToRestMap)
{
TopOpeBRepDS_DataStructure& aDS= myDataStructure-> ChangeDS();
// Get aMapOfShapeWithState for Obj
Standard_Boolean aFlag;
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState=aDS.ChangeMapOfShapeWithState(anObj, aFlag);
if (!aFlag) return;
//
Standard_Integer i, nE=anEdgesToSplitMap.Extent();
if (!nE) return;
TopOpeBRepDS_DataMapOfShapeState aSplEdgesState;
TopTools_ListIteratorOfListOfShape anIt;
TopAbs_State aState;
for (i=1; i<=nE; i++) {
const TopoDS_Shape& anEdge=anEdgesToSplitMap(i);
if(processedEdges.Contains(anEdge)) {
if (aMapOfShapeWithState.Contains(anEdge)) {
const TopOpeBRepDS_ShapeWithState& aSWS=
aMapOfShapeWithState.FindFromKey(anEdge);
if (aSWS.IsSplitted()) {
const TopTools_ListOfShape& SplitsON=aSWS.Part(TopAbs_ON);
anIt.Initialize (SplitsON);
for (; anIt.More(); anIt.Next())
aSplEdgesState.Bind(anIt.Value(), TopAbs_ON);
const TopTools_ListOfShape& SplitsOUT=aSWS.Part(TopAbs_OUT);
anIt.Initialize (SplitsOUT);
for (; anIt.More(); anIt.Next())
aSplEdgesState.Bind(anIt.Value(), TopAbs_OUT);
const TopTools_ListOfShape& SplitsIN=aSWS.Part(TopAbs_IN);
anIt.Initialize (SplitsIN);
for (; anIt.More(); anIt.Next())
aSplEdgesState.Bind(anIt.Value(), TopAbs_IN);
}
}
continue;
}
processedEdges.Add(anEdge);
TopOpeBRepDS_ShapeWithState aShapeWithState;
// if IsSplit - it is the case of edges from SameDomain faces
Standard_Boolean IsSplitON = IsSplit(anEdge, TopAbs_ON);
if(IsSplitON) {
// ON
const TopTools_ListOfShape& SplitsON = Splits(anEdge, TopAbs_ON);
anIt.Initialize (SplitsON);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
aNewEdge.Orientation (anEdge.Orientation());
aShapeWithState.AddPart (aNewEdge, TopAbs_ON);
aSplEdgesState.Bind(anIt.Value(), TopAbs_ON);
}
// IN
const TopTools_ListOfShape& SplitsIN = Splits(anEdge, TopAbs_IN);
anIt.Initialize (SplitsIN);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
aNewEdge.Orientation (anEdge.Orientation());
aShapeWithState.AddPart (aNewEdge, TopAbs_IN);
aSplEdgesState.Bind(anIt.Value(), TopAbs_IN);
}
// OUT
const TopTools_ListOfShape& SplitsOUT = Splits(anEdge, TopAbs_OUT);
anIt.Initialize (SplitsOUT);
for (; anIt.More(); anIt.Next()) {
TopoDS_Shape aNewEdge=anIt.Value();
aNewEdge.Orientation (anEdge.Orientation());
aShapeWithState.AddPart (aNewEdge, TopAbs_OUT);
aSplEdgesState.Bind(anIt.Value(), TopAbs_OUT);
}
aShapeWithState.SetIsSplitted(Standard_True);
aMapOfShapeWithState.Add(anEdge, aShapeWithState);
continue;
}
// Attempt to split the Edge (for all other edges (from non SameDomain Faces))
TopOpeBRepDS_DataMapOfShapeState aDataMapOfShapeState;
TopTools_ListOfShape aLNew;
Standard_Boolean oldState = GLOBAL_faces2d;
GLOBAL_faces2d = Standard_True;
SplitEdge (anEdge, aLNew, aDataMapOfShapeState);
GLOBAL_faces2d = oldState;
//
if (!aLNew.Extent()) {
// * It means that whole Edge is IN (see SplitEdge(...) at line
// G1=TopOpeBRepBuild_GTool::GFusSame(tf,tf); Operation Fuse
// loses all parts of the Edge with IN state, but we need
// to have all parts. So, we have to rest the Edge as is ...
// ** But the edge itself will have UNKNOWN state and one split Part with state =IN.
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(anEdge), Vf, Vl);
Standard_Boolean HasSDV1 = myDataStructure->HasSameDomain(Vf);
Standard_Boolean HasSDV2 = myDataStructure->HasSameDomain(Vl);
TopoDS_Edge aNewEdge = TopoDS::Edge(anEdge);
//if edge has SD edges , it is error because it must be processed in SplitSectionEdges
//but if we here we don't do anything with it
if(myDataStructure -> HasSameDomain(aNewEdge)) {
HasSDV1 = Standard_False;
HasSDV2 = Standard_False;
}
//if vertices has SD we must update edge, so we copy it
if(HasSDV1 || HasSDV2) {
TopoDS_Shape EOR = anEdge;
EOR.Orientation(TopAbs_FORWARD);
Standard_Real ParF = BRep_Tool::Parameter(Vf, TopoDS::Edge(EOR));
Standard_Real ParL = BRep_Tool::Parameter(Vl, TopoDS::Edge(EOR));
myBuildTool.CopyEdge (EOR, aNewEdge);
if (HasSDV1) { // on prend le vertex reference de V
Standard_Integer iref = myDataStructure->SameDomainReference(Vf);
Vf = TopoDS::Vertex(myDataStructure->Shape(iref));
Vf.Orientation(TopAbs_FORWARD);
}
if (HasSDV2) { // on prend le vertex reference de V
Standard_Integer iref = myDataStructure->SameDomainReference(Vl);
Vl = TopoDS::Vertex(myDataStructure->Shape(iref));
Vl.Orientation(TopAbs_REVERSED);
}
Standard_Boolean bitclosed = Vf.IsSame(Vl);
aNewEdge.Closed(bitclosed);
myBuildTool.AddEdgeVertex (aNewEdge, Vf);
myBuildTool.Parameter (aNewEdge, Vf, ParF);
myBuildTool.AddEdgeVertex (aNewEdge, Vl);
myBuildTool.Parameter (aNewEdge, Vl, ParL);
aNewEdge.Orientation (anEdge.Orientation());
}
aState= ClassifyEdgeToSolidByOnePoint(aNewEdge, myShapeClassifier);
aShapeWithState.SetIsSplitted (Standard_True);
aShapeWithState.AddPart (aNewEdge, aState);
aSplEdgesState.Bind(aNewEdge, aState);
TopExp::Vertices(aNewEdge, Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
if (!BRep_Tool::Degenerated(TopoDS::Edge(aNewEdge))) {
// MSV: it may be the case when an edge has one state but its vertex
// has another state. We should clarify this to avoid incorrect
// propagation of state.
myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vf));
if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON)
theUnkStateVer.Add(Vf);
if (!Vf.IsSame(Vl)) {
myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vl));
if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON)
theUnkStateVer.Add(Vl);
}
}
}
else {
// Usual case. The Edge was splitted onto several parts:
TopTools_ListIteratorOfListOfShape aLIt(aLNew);
for (; aLIt.More(); aLIt.Next()) {
const TopoDS_Shape& aS = aLIt.Value();
aState = aDataMapOfShapeState(aS);
////////////////////////////////////////////////////////////////////////////
// ** When aState==TopAbs_IN it is not evidence that it is realy so.
// There are some cases when JYL does not define ON parts completely.
// So, as we want to have right states, we have to do it ourselves.
// PKV Mon 25 Oct 1999
Standard_Boolean isdegen = BRep_Tool::Degenerated(TopoDS::Edge(aS));
//if edge is degenerated we trust that it have IN state without classify
if (aState==TopAbs_IN && !isdegen)
aState= ClassifyEdgeToSolidByOnePoint(TopoDS::Edge(aS), myShapeClassifier);
////////////////////////////////////////////////////////////////////////////
aShapeWithState.AddPart (aS, aState);
aShapeWithState.SetIsSplitted (Standard_True);
aSplEdgesState.Bind(aS, aState);
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(TopoDS::Edge(aS), Vf, Vl);
theUsedVertexMap.Add(Vf);
theUsedVertexMap.Add(Vl);
if (!isdegen) {
// MSV: clarify state of vertices (see my above comment)
myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vf));
if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON)
theUnkStateVer.Add(Vf);
if (!Vf.IsSame(Vl)) {
myShapeClassifier.StateP3DReference(BRep_Tool::Pnt(Vl));
if (myShapeClassifier.State() != aState && myShapeClassifier.State() != TopAbs_ON)
theUnkStateVer.Add(Vl);
}
}
}
}
const TopTools_ListOfShape& EspON = aShapeWithState.Part(TopAbs_ON);
Standard_Integer nON = EspON.Extent();
if(!IsSplitON && nON) {
TopOpeBRepDS_ListOfShapeOn1State ONspl;
TopTools_ListOfShape& lON = ONspl.ChangeListOnState();
lON.Assign(EspON);
ONspl.Split(Standard_True);
mySplitON.Bind(anEdge, ONspl);
myDataStructure -> ChangeDS().AddSectionEdge(TopoDS::Edge(anEdge));
}
aMapOfShapeWithState.Add(anEdge, aShapeWithState);
} // end for (i=1; i<=nE; i++)
nE=anEdgesToRestMap.Extent();
for (i=1; i<=nE; i++) {
const TopoDS_Shape& anEdge=anEdgesToRestMap.FindKey(i);
if (aMapOfShapeWithState.Contains (anEdge)) {
const TopOpeBRepDS_ShapeWithState& aSWS=
aMapOfShapeWithState.FindFromKey(anEdge);
if (!aSWS.IsSplitted()) {
// just in case
aState=aSWS.State();
aSplEdgesState.Bind (anEdge, aState);
continue;
}
}
}
if (nE)
// Propagate the status for anEdgesToRestMap edges
TopOpeBRepBuild_Tools::PropagateState (aSplEdgesState, anEdgesToRestMap,
TopAbs_VERTEX, TopAbs_EDGE, myShapeClassifier,
aMapOfShapeWithState, theUnkStateVer);
}
//=======================================================================
//function : SplitEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder1::SplitEdge (const TopoDS_Shape& anEdge,
TopTools_ListOfShape& aLNew,
TopOpeBRepDS_DataMapOfShapeState& aDataMapOfShapeState)
{
Standard_Real aPar1, aPar2;
TopAbs_Orientation anOr1, anOr2;
// Attention! If you didn't do the orientation of the Edge =FORWARD,
// the GFillPointTopologyPVS() method will give you a garbage!
TopoDS_Shape EdgeF=anEdge;
EdgeF.Orientation(TopAbs_FORWARD);
// Make a PaveSet PVS on edge EF
TopOpeBRepBuild_PaveSet PVS (EdgeF);
TopOpeBRepBuild_GTopo G1;
TopAbs_ShapeEnum tf = TopAbs_FACE;
G1=TopOpeBRepBuild_GTool::GFusSame(tf,tf);
myEdgeReference = TopoDS::Edge(EdgeF);
GFillPointTopologyPVS(EdgeF, G1, PVS);
PVS.InitLoop();
//firstly we detect paves with equal params
// MSV Oct 23, 2001:
// Add Paves to a standard list rather than to a PaveSet to avoid
// possible sequence disturbance in InitLoop.
// Check points for equality in both 3d and 1d spaces using maximum
// of tolerances of the edge and compared vertices, in 1d using resolution
// on edge from that value
TopOpeBRepBuild_ListOfPave aPVSlist;
TopTools_DataMapOfShapeListOfInteger aVerOriMap;
BRepAdaptor_Curve aCurveAdaptor(TopoDS::Edge(anEdge));
Standard_Real tolEdge = BRep_Tool::Tolerance(TopoDS::Edge(anEdge));
while (PVS.MoreLoop()) {
Handle(TopOpeBRepBuild_Pave) aPave1=Handle(TopOpeBRepBuild_Pave)::DownCast(PVS.Loop());
const TopoDS_Vertex& aV1= TopoDS::Vertex(aPave1->Vertex());
aPar1 = aPave1->Parameter();
PVS.NextLoop();
if (!PVS.MoreLoop()) {
aPVSlist.Append(aPave1);
break;
}
Handle(TopOpeBRepBuild_Pave) aPave2=Handle(TopOpeBRepBuild_Pave)::DownCast(PVS.Loop());
const TopoDS_Vertex& aV2= TopoDS::Vertex(aPave2->Vertex());
aPar2 = aPave2->Parameter();
Standard_Real tolV1 = BRep_Tool::Tolerance(aV1);
Standard_Real tolV2 = BRep_Tool::Tolerance(aV2);
Standard_Real tolMax = Max(tolEdge,Max(tolV1,tolV2));
Standard_Real resol = aCurveAdaptor.Resolution(tolMax);
Standard_Real delta = Abs(aPar1 - aPar2);
if(delta < resol) {
Standard_Real dist = BRep_Tool::Pnt(aV1).Distance(BRep_Tool::Pnt(aV2));
if (dist < tolMax || delta < Precision::PConfusion()) {
TopOpeBRepDS_Kind IntType1 = aPave1 -> InterferenceType();
Standard_Boolean Int3d1 = (IntType1 == TopOpeBRepDS_FACE);
Standard_Boolean HasSDV1 = myDataStructure->HasSameDomain(aV1);
Standard_Boolean HasSDV2 = myDataStructure->HasSameDomain(aV2);
Standard_Boolean UsedV1 = theUsedVertexMap.Contains(aV1);
Standard_Boolean UsedV2 = theUsedVertexMap.Contains(aV2);
Standard_Boolean takeFirst = Standard_True;
if(HasSDV1) ;
else if(HasSDV2) takeFirst = Standard_False;
else if(UsedV1) ;
else if(UsedV2) takeFirst = Standard_False;
else if(Int3d1) ;
else takeFirst = Standard_False;
TopoDS_Shape aVer;
Standard_Boolean HasSDV;
TopAbs_Orientation anOriOpp;
if (takeFirst) {
aPVSlist.Append(aPave1);
aVer = aV1; HasSDV = HasSDV1; anOriOpp = aV2.Orientation();
}
else {
aPVSlist.Append(aPave2);
aVer = aV2; HasSDV = HasSDV2; anOriOpp = aV1.Orientation();
}
if (aV1.Orientation() != aV2.Orientation()) {
// MSV: save orientation of removed vertex
TColStd_ListOfInteger thelist;
if (!aVerOriMap.IsBound(aVer)) aVerOriMap.Bind(aVer, thelist);
TColStd_ListOfInteger& anOriList = aVerOriMap(aVer);
anOriList.Append(takeFirst);
anOriList.Append(anOriOpp);
// mark this vertex as having unknown state
if (HasSDV) {
Standard_Integer iref = myDataStructure->SameDomainReference(aVer);
aVer = myDataStructure->Shape(iref);
}
theUnkStateVer.Add(aVer);
}
PVS.NextLoop();
continue;
}
}
aPVSlist.Append(aPave1);
}
TopOpeBRepBuild_ListIteratorOfListOfPave aPVSit(aPVSlist);
while (aPVSit.More()) {
Handle(TopOpeBRepBuild_Pave) aPave1 = aPVSit.Value();
TopoDS_Shape aV1= aPave1->Vertex();
aV1.Orientation(TopAbs_FORWARD);
aPar1 = aPave1->Parameter();
anOr1=(aPave1->Vertex()).Orientation();
if (aVerOriMap.IsBound(aV1)) {
// MSV: restore orientation of removed vertex
TColStd_ListOfInteger& anOriList = aVerOriMap(aV1);
if (!anOriList.IsEmpty()) {
if (anOriList.First()) {
TColStd_ListIteratorOfListOfInteger it(anOriList); it.Next();
anOr1 = (TopAbs_Orientation) it.Value();
}
anOriList.RemoveFirst(); anOriList.RemoveFirst();
}
}
aPVSit.Next();
if (!aPVSit.More()) break;
Handle(TopOpeBRepBuild_Pave) aPave2 = aPVSit.Value();
TopoDS_Shape aV2= aPave2->Vertex();
aV2.Orientation(TopAbs_REVERSED);
aPar2 = aPave2->Parameter();
anOr2=(aPave2->Vertex()).Orientation();
if (aVerOriMap.IsBound(aV2)) {
TColStd_ListOfInteger& anOriList = aVerOriMap(aV2);
if (!anOriList.IsEmpty()) {
if (!anOriList.First()) {
TColStd_ListIteratorOfListOfInteger it(anOriList); it.Next();
anOr2 = (TopAbs_Orientation) it.Value();
}
}
}
// MSV: avoid creation of an edge with invalid range
if (aPar1 > aPar2) continue;
Standard_Boolean HasSDV1 = myDataStructure->HasSameDomain(aV1);
Standard_Boolean HasSDV2 = myDataStructure->HasSameDomain(aV2);
if (HasSDV1) { // on prend le vertex reference de V
Standard_Integer iref = myDataStructure->SameDomainReference(aV1);
aV1 = myDataStructure->Shape(iref);
aV1.Orientation(TopAbs_FORWARD);
}
if (HasSDV2) { // on prend le vertex reference de V
Standard_Integer iref = myDataStructure->SameDomainReference(aV2);
aV2 = myDataStructure->Shape(iref);
aV2.Orientation(TopAbs_REVERSED);
}
// Make new edge from EdgeF
TopoDS_Edge aNewEdge;
myBuildTool.CopyEdge (EdgeF, aNewEdge);
Standard_Boolean bitclosed = aV1.IsSame(aV2);
aNewEdge.Closed(bitclosed);
myBuildTool.AddEdgeVertex (aNewEdge, aV1);
myBuildTool.Parameter (aNewEdge, aV1, aPar1);
myBuildTool.AddEdgeVertex (aNewEdge, aV2);
myBuildTool.Parameter (aNewEdge, aV2, aPar2);
// State of piece
TopAbs_State aState=TopAbs_IN;
if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_REVERSED) aState=TopAbs_OUT;
if (anOr1==TopAbs_FORWARD && anOr2==TopAbs_INTERNAL) aState=TopAbs_OUT;
if (anOr1==TopAbs_INTERNAL && anOr2==TopAbs_REVERSED) aState=TopAbs_OUT;
///* Added
if (anOr1==TopAbs_INTERNAL && anOr2==TopAbs_INTERNAL) aState=TopAbs_OUT;
//printf(" anOr1=%d, anOr2=%d\n", anOr1, anOr2);
// set old orientation to new edge;
aNewEdge.Orientation (anEdge.Orientation());
aLNew.Append(aNewEdge);
aDataMapOfShapeState.Bind(aNewEdge, aState);
}
//GEDBUMakeEdges(EdgeF,EDBU,aListOfShape);
}
static TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E,
TopOpeBRepTool_ShapeClassifier& SC)
{
Standard_Real f2 = 0., l2 = 0., par = 0.;
Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2);
gp_Pnt aP3d;
if(C3D.IsNull()) {
//it means that we are in degenerated edge
const TopoDS_Vertex& fv = TopExp::FirstVertex(E);
if(fv.IsNull())
return TopAbs_UNKNOWN;
aP3d = BRep_Tool::Pnt(fv);
}
else {//usual case
par = f2*PAR_T + (1 - PAR_T)*l2;
C3D -> D0(par, aP3d);
}
SC.StateP3DReference(aP3d);
return SC.State();
}

View File

@@ -0,0 +1,195 @@
// File: TopOpeBRepBuild_Builder_2.cxx
// Created: Tue Feb 1 15:25:07 2000
// Author: Peter KURNEV
// <pkv@irinox.nnov.matra-dtv.fr>
#include <TopOpeBRepBuild_Builder1.ixx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Builder.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopOpeBRepDS_CurveExplorer.hxx>
//=======================================================================
//function : TopOpeBRepBuild_Builder1::CorrectResult2d
//purpose : Change the Result (after CorrectFace2d)
//
//=======================================================================
Standard_Integer TopOpeBRepBuild_Builder1::CorrectResult2d(TopoDS_Shape& aResult)
{
Standard_Integer aNb=myMapOfCorrect2dEdges.Extent();
if(!aNb)
return 0;
if (aResult.ShapeType()!=TopAbs_SOLID)
return 0;
//
// 1. Map Of sources' subshapes .
// The map (aSourceShapeMap) is to prevent unnecessary coping
TopTools_IndexedMapOfShape aSourceShapeMap;
TopExp::MapShapes(myShape1, TopAbs_EDGE, aSourceShapeMap);
TopExp::MapShapes(myShape2, TopAbs_EDGE, aSourceShapeMap);
TopTools_IndexedDataMapOfShapeShape EdMap;
BRep_Builder BB;
TopoDS_Shape aLocalShape = aResult.EmptyCopied();
TopoDS_Solid aSolid=TopoDS::Solid(aLocalShape);
// TopoDS_Solid aSolid=TopoDS::Solid(aResult.EmptyCopied());
TopExp_Explorer anExpShells(aResult, TopAbs_SHELL);
for (; anExpShells.More(); anExpShells.Next()) {
const TopoDS_Shell& S=TopoDS::Shell(anExpShells.Current());
aLocalShape = S.EmptyCopied();
TopoDS_Shell aShell=TopoDS::Shell(aLocalShape);
// TopoDS_Shell aShell=TopoDS::Shell(S.EmptyCopied());
TopExp_Explorer anExpFaces(S, TopAbs_FACE);
for (; anExpFaces.More(); anExpFaces.Next()) {
TopoDS_Face F=TopoDS::Face(anExpFaces.Current());
//modified by NIZHNY-MZV Mon Mar 27 09:51:59 2000
TopAbs_Orientation Fori = F.Orientation();
//we should explore FORWARD face
// F.Orientation(TopAbs_FORWARD);
aLocalShape = F.EmptyCopied();
TopoDS_Face aFace=TopoDS::Face(aLocalShape);
// TopoDS_Face aFace=TopoDS::Face(F.EmptyCopied());
TopExp_Explorer anExpWires(F, TopAbs_WIRE);
for (; anExpWires.More(); anExpWires.Next()) {
TopoDS_Wire W=TopoDS::Wire(anExpWires.Current());
//modified by NIZHNY-MZV Mon Mar 27 09:51:59 2000
TopAbs_Orientation Wori = W.Orientation();
//we should explore FORWARD wire
// W.Orientation(TopAbs_FORWARD);
aLocalShape = W.EmptyCopied();
TopoDS_Wire aWire = TopoDS::Wire(aLocalShape);
// TopoDS_Wire aWire = TopoDS::Wire(W.EmptyCopied());
TopExp_Explorer anExpEdges(W, TopAbs_EDGE);
for (; anExpEdges.More(); anExpEdges.Next()) {
TopoDS_Edge E = TopoDS::Edge(anExpEdges.Current());
if (EdMap.Contains(E)) {
TopoDS_Shape anEdge = EdMap.ChangeFromKey(E);
anEdge.Orientation(E.Orientation());
BB.Add (aWire, anEdge);
continue;
}
if (myMapOfCorrect2dEdges.Contains(E)) {
TopoDS_Shape anEdge=myMapOfCorrect2dEdges.ChangeFromKey(E);
anEdge.Orientation(E.Orientation());
BB.Add (aWire, anEdge);
EdMap.Add(E, anEdge);
continue;
}
// add edges
TopoDS_Edge anEdge;
//we copy edge in order to not change it in source shapes
if(aSourceShapeMap.Contains(E)) {
TopoDS_Shape aLocalShape1 = E.EmptyCopied();
anEdge = TopoDS::Edge(aLocalShape1);
// anEdge = TopoDS::Edge(E.EmptyCopied());
EdMap.Add(E, anEdge);
TopExp_Explorer anExpVertices(E, TopAbs_VERTEX);
Standard_Boolean free = anEdge.Free();
anEdge.Free(Standard_True);
for(; anExpVertices.More(); anExpVertices.Next())
BB.Add(anEdge, anExpVertices.Current());
anEdge.Free(free);
}
else
anEdge = E;
anEdge.Orientation(E.Orientation());
BB.Add (aWire, anEdge);
}
// Add wires
aWire.Orientation(Wori);
BB.Add (aFace, aWire);
}
aFace.Orientation(Fori);
BB.Add (aShell, aFace);
}
aShell.Orientation(S.Orientation());
BB.Add (aSolid, aShell);
}
aResult=aSolid;
//update section curves
TopOpeBRepDS_CurveExplorer cex(myDataStructure->DS());
for (; cex.More(); cex.Next()) {
Standard_Integer ic = cex.Index();
TopTools_ListOfShape& LSE = ChangeNewEdges(ic);
TopTools_ListOfShape corrLSE;
TopTools_ListIteratorOfListOfShape it(LSE);
for(; it.More(); it.Next()) {
const TopoDS_Shape& E = it.Value();
if(EdMap.Contains(E)) {
const TopoDS_Shape& newE = EdMap.FindFromKey(E);
corrLSE.Append(newE);
}
else
corrLSE.Append(E);
}
LSE.Clear();
LSE.Append(corrLSE);
}
//update section edges
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
Standard_Integer i,nes = BDS.NbSectionEdges();
for(i = 1; i <= nes; i++) {
const TopoDS_Shape& es = BDS.SectionEdge(i);
if(es.IsNull())
continue;
for(Standard_Integer j = 0; j <= 2; j++) {
TopAbs_State staspl = TopAbs_State(j); // 0 - IN, 1 - OUT, 2 - ON
TopTools_ListOfShape& LSE = ChangeSplit(es,staspl);
TopTools_ListOfShape corrLSE;
TopTools_ListIteratorOfListOfShape it(LSE);
for(; it.More(); it.Next()) {
const TopoDS_Shape& E = it.Value();
if(EdMap.Contains(E)) {
const TopoDS_Shape& newE = EdMap.FindFromKey(E);
corrLSE.Append(newE);
}
else
corrLSE.Append(E);
}
LSE.Clear();
LSE.Append(corrLSE);
}
}
return 1;
}

View File

@@ -0,0 +1,50 @@
-- File: TopOpeBRepBuild_BuilderON.cdl
-- Created: Mon Jun 14 10:23:56 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class BuilderON from TopOpeBRepBuild
uses
PBuilder from TopOpeBRepBuild,
PGTopo from TopOpeBRepBuild,
PWireEdgeSet from TopOpeBRepBuild,
ListOfShape from TopTools,
Shape from TopoDS,
Interference from TopOpeBRepDS,
ListOfInterference from TopOpeBRepDS,
Plos from TopOpeBRepTool
is
-- BuilderON3d
--------------
Create returns BuilderON;
Create(PB:PBuilder;F:Shape;PG:PGTopo;PLSclass:Plos;PWES:PWireEdgeSet) returns BuilderON;
Perform(me:in out;PB:PBuilder;F:Shape;PG:PGTopo;PLSclass:Plos;PWES:PWireEdgeSet) is static;
-- private
GFillONCheckI(me;I:Interference) returns Boolean;
GFillONPartsWES1(me:in out;I:Interference);
GFillONPartsWES2(me:in out;I:Interference;EspON:Shape);
-- BuilderON2d
--------------
Perform2d(me:in out;PB:PBuilder;F:Shape;PG:PGTopo;PLSclass:Plos;PWES:PWireEdgeSet) is static;
-- private
GFillONParts2dWES2(me:in out;I:Interference;EspON:Shape);
fields
myPB : PBuilder from TopOpeBRepBuild;
myPG : PGTopo from TopOpeBRepBuild;
myPLSclass : Plos from TopOpeBRepTool;
myPWES : PWireEdgeSet from TopOpeBRepBuild;
myFace : Shape from TopoDS;
myFEI : ListOfInterference from TopOpeBRepDS; --BuilderON2d
end BuilderON from TopOpeBRepBuild;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,245 @@
// File: TopOpeBRepBuild_BuilderON2d.cxx
// Created: Thu May 7 10:36:33 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepBuild_BuilderON.jxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_SC.hxx>
#include <TopOpeBRepDS_InterferenceTool.hxx>
#include <TopOpeBRepDS_EXPORT.hxx>
#include <TopOpeBRepDS_connex.hxx>
#include <TopOpeBRepDS.hxx>
#include <TopOpeBRepBuild_define.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Precision.hxx>
#define M_OUT(st) (st == TopAbs_OUT)
#define M_IN( st) (st == TopAbs_IN)
#define M_FORWARD(st) (st == TopAbs_FORWARD)
#define M_REVERSED(st) (st == TopAbs_REVERSED)
#ifdef DEB
Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEINTERNAL();
Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEEXTERNAL();
Standard_EXPORT void debfillonf(const Standard_Integer iF);
Standard_EXPORT void debON2d(const Standard_Integer iF)
{cout<<"++ debON2d "<<iF<<" "<<endl;}
#endif
Standard_EXPORT TopAbs_State FUN_build_TB(const TopOpeBRepBuild_PBuilder& PB,const Standard_Integer rank); // xpu290698
Standard_EXPORT Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder& B,
const TopoDS_Shape& sEG,const TopoDS_Shape& sFOR,const TopoDS_Shape& sFS,
const Standard_Boolean EGBoundFOR,
const TopOpeBRepDS_Transition& TFE,const TopAbs_State TB1,const TopAbs_State TB2);
Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString& m);
Standard_EXPORTEXTERN TopOpeBRepDS_PDataStructure GLOBAL_DS2d;
//=======================================================================
//function : Perform2d
//purpose :
//=======================================================================
void TopOpeBRepBuild_BuilderON::Perform2d
(const TopOpeBRepBuild_PBuilder& PB,
const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
{
myPB = PB;
myFace = FOR;
myPG = PG;
myPLSclass = PLSclass;
myPWES = PWES;
const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
if (GLOBAL_DS2d == NULL) GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure)new TopOpeBRepDS_DataStructure();
const TopOpeBRepDS_ListOfInterference& lFEI = GLOBAL_DS2d->ShapeInterferences(FOR);
#ifdef DEB
Standard_Integer iFOR;Standard_Boolean tFOR=myPB->GtraceSPS(FOR,iFOR);
if (tFOR) debfillonf(iFOR);
if (tFOR) {cout<<endl<<"LI on F"<<iFOR<<":"<<endl;
for (TopOpeBRepDS_ListIteratorOfListOfInterference iit(lFEI); iit.More(); iit.Next())
{iit.Value()->Dump(cout);cout<<endl;}}
#endif
for (TopOpeBRepDS_ListIteratorOfListOfInterference itI(lFEI); itI.More(); itI.Next()){
const Handle(TopOpeBRepDS_Interference)& I = itI.Value();
TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(I,GT,GI,ST,SI);
const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
#ifdef DEB
// Standard_Integer iEG=BDS.Shape(EG);
#endif
const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
#ifdef DEB
// Standard_Integer nEspON=lEspON.Extent();
#endif
for(TopTools_ListIteratorOfListOfShape it(lEspON);it.More();it.Next()) {
const TopoDS_Shape& EspON=it.Value();
GFillONParts2dWES2(I,EspON);
}
}
}
//=======================================================================
//function : GFillONPartsWES2
//purpose :
//=======================================================================
void TopOpeBRepBuild_BuilderON::GFillONParts2dWES2(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& EspON)
{
const Handle(TopOpeBRepDS_HDataStructure)& HDS=myPB->DataStructure();
const TopOpeBRepDS_DataStructure& BDS= HDS->DS();
const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
TopAbs_State TB1,TB2;myPG->StatesON(TB1,TB2);
TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
// const TopOpeBRepDS_Transition& TFE=SSI->Transition();
Standard_Boolean EGBoundFOR=SSI->GBound();
const TopoDS_Face& FOR=TopoDS::Face(myFace); Standard_Integer iFOR=BDS.Shape(FOR);
const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
#ifdef DEB
// Standard_Integer iEG=BDS.Shape(EG);
#endif
const TopoDS_Face& FS=TopoDS::Face(BDS.Shape(SI));
#ifdef DEB
// Standard_Integer iFS=BDS.Shape(FS);
// Standard_Boolean isclosedFF=BRep_Tool::IsClosed(EG,FOR);
// Standard_Boolean isclosedFS=BRep_Tool::IsClosed(EG,FS);
// Standard_Boolean isclosed=(isclosedFF || isclosedFS);
// Standard_Boolean isrest=BDS.IsSectionEdge(EG);
// Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
// Standard_Integer rankFS=myPB->GShapeRank(FS);
#endif
Standard_Integer rankEG=myPB->GShapeRank(EG);
#ifdef DEB
// Standard_Integer rankFOR=myPB->GShapeRank(FOR);
#endif
// TopAbs_State TBEG = (rankEG == 1) ? TB1 : TB2;
TopAbs_State TBEG = FUN_build_TB(myPB,rankEG);
#ifdef DEB
// TopAbs_State TFEbef = TFE.Before();
// TopAbs_State TFEaft = TFE.After();
// Standard_Boolean EGboundFOR =
// Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I)->GBound();
#endif
Standard_Boolean eghassd = HDS->HasSameDomain(EG);
#ifdef DEB
Standard_Boolean tFOR=myPB->GtraceSPS(iFOR);
// Standard_Boolean tE=myPB->GtraceSPS(GI);
// Standard_Boolean tEFOR = (tE && tFOR);
if (tFOR) {debON2d(iFOR);}
if (tFOR) {I->Dump(cout);cout<<endl;}
#endif
Standard_Integer iFCX=SI;
Standard_Boolean FFinSDSO = Standard_True;
#ifdef DEB
// Standard_Boolean FFinSDDO = Standard_False;
#endif
Standard_Boolean FFinSD= Standard_True;
TopoDS_Face FCX = FS;
#ifdef DEB
// TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
// TopAbs_Orientation oFS = BDS.Shape(iFS).Orientation();
// TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
// Standard_Integer irefFOR = BDS.SameDomainRef(FOR);
// Standard_Integer irefFCX = BDS.SameDomainRef(FCX);
// Standard_Boolean FORisref = (irefFOR == iFOR);
// Standard_Boolean FCXisref = (irefFCX == iFCX);
#endif
TopAbs_Orientation oegFCXF;Standard_Boolean EGBoundFCX = FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF);
TopAbs_Orientation oegFCX ;
#ifdef DEB
// Standard_Boolean ok2 =
#endif
FUN_tool_orientEinF(EG,FCX,oegFCX);
Standard_Boolean opeFus = myPB->Opefus();
Standard_Boolean opeCut = myPB->Opec12() || myPB->Opec21();
Standard_Boolean opeCom = myPB->Opecom();
Standard_Boolean yap6 = Standard_True;
yap6 = yap6 && FFinSD;
// yap6 = yap6 && (!EGBoundFOR);
// yap6 = yap6 && EGBoundFCX;
yap6 = yap6 && (EGBoundFOR || EGBoundFCX);
yap6 = yap6 && eghassd;
//=========================================
if ( yap6) {
#ifdef DEB
if (tFOR) cout<<"* yap6 = 1"<<endl;
#endif
TopAbs_Orientation neworiE;
// FF est samedomain avec FCX
// on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
// au lieu de la transition par rapport a la matiere 3d de la face FS
// EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
Standard_Boolean b = Standard_False;
Standard_Boolean SO = FFinSDSO;//(FFinSDSO && (oFOR == oFCX)) || (FFinSDDO && (oFOR != oFCX));
#ifdef DEB
// Standard_Integer rkToFill = BDS.AncestorRank(myFace); //DEB
#endif
Standard_Boolean rk1 = (rankEG == 1);
if (!rk1) return;
TopAbs_Orientation oegFOR;
Standard_Boolean shareG;
Standard_Boolean ok = Standard_False;
if (EGBoundFCX)
ok = FUN_ds_shareG(myPB->DataStructure(),iFOR,iFCX,GI,TopoDS::Edge(EspON),shareG);
else if (EGBoundFOR)
ok = FUN_ds_shareG(myPB->DataStructure(),iFCX,iFOR,GI,TopoDS::Edge(EspON),shareG);
if (!ok) return; // nyiFUNRAISE
#ifdef DEB
if (tFOR) cout<<" shareG="<<shareG<<endl;
#endif
if (SO) {
// FOR and FCX share geometric domain.
if (opeFus) b = shareG;
else if (opeCut) b = (!shareG) && M_OUT(TBEG);
else if (opeCom) b = shareG;
}
if (!b) return;
if (!EGBoundFOR) {
TopAbs_Orientation oegFCXF1; FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF1);
neworiE = oegFCXF;
}
else if (EGBoundFOR) {
FUN_tool_orientEinFFORWARD(EG,TopoDS::Face(FOR),oegFOR);
neworiE = oegFOR;
}
// Standard_Real f,l; FUN_tool_bounds(EG,f,l); Standard_Real parON = (f+l)*.4352;
Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(EspON),f,l); Standard_Real parON = (f+l)*.4352; // xpu120698
Standard_Boolean ESO; ok = FUN_tool_curvesSO(TopoDS::Edge(EspON),parON,EG,ESO);
if (!ok) return; // xpu120698
if (!ESO) neworiE = TopAbs::Complement(neworiE);
TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
if (oFOR != oFCX) neworiE = TopAbs::Complement(neworiE);
TopoDS_Shape newE = EspON;
newE.Orientation(neworiE);
myPWES->AddStartElement(newE);
#ifdef DEB
if (tFOR) cout<<" add spON e"<<GI<<endl;
#endif
return;
} // yap6
} // GFillONPartsWES2

View File

@@ -0,0 +1,55 @@
-- File: TopOpeBRepBuild_CompositeClassifier.cdl
-- Created: Fri Jan 5 15:16:22 1996
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1996
deferred class CompositeClassifier from TopOpeBRepBuild
inherits LoopClassifier from TopOpeBRepBuild
---Purpose:
-- classify composite Loops, i.e, loops that can be either a Shape, or
-- a block of Elements.
uses
ShapeEnum from TopAbs,
Shape from TopoDS,
State from TopAbs,
Loop from TopOpeBRepBuild,
BlockBuilder from TopOpeBRepBuild
is
Initialize(BB : BlockBuilder);
Compare(me : in out; L1,L2 : Loop) returns State from TopAbs
is redefined;
CompareShapes(me : in out; B1,B2 : Shape from TopoDS)
---Purpose: classify shape <B1> with shape <B2>
returns State from TopAbs is deferred;
CompareElementToShape(me : in out; E,B : Shape from TopoDS)
---Purpose: classify element <E> with shape <B>
returns State from TopAbs is deferred;
ResetShape(me : in out; B : Shape from TopoDS) is deferred;
---Purpose: prepare classification involving shape <B>
-- calls ResetElement on first element of <B>
ResetElement(me : in out; E : Shape from TopoDS) is deferred;
---Purpose: prepare classification involving element <E>.
CompareElement(me : in out; E : Shape from TopoDS) is deferred;
---Purpose: Add element <E> in the set of elements used in classification.
State(me : in out) returns State from TopAbs is deferred;
---Purpose: Returns state of classification of 2D point, defined by
-- ResetElement, with the current set of elements, defined by Compare.
fields
myBlockBuilder : Address is protected; -- (TopOpeBRepBuild_BlockBuilder*)
end CompositeClassifier from TopOpeBRepBuild;

View File

@@ -0,0 +1,108 @@
// File: TopOpeBRepBuild_CompositeClassifier.cxx
// Created: Fri Jan 5 15:26:38 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_CompositeClassifier.ixx>
#include <BRepTools.hxx>
#include <TCollection_AsciiString.hxx>
#define MYBB ((TopOpeBRepBuild_BlockBuilder*)myBlockBuilder)
// sourvenir d'un raise sur FrozenShape lors du Add(myShell,aFace)
// avec un shell qui a ete deja ete place dans le solide interne du
// TopOpeBRepTool_SolidClassifier par LoadShell.
#ifdef DEB
//static Standard_Integer dddjyl = 0;
//static Standard_Integer dddebi = 0;
//static Standard_Integer dddebi2 = 0;
//static void SAVSS(const TopoDS_Shape& S1,const TopoDS_Shape& S2)
//{
// TCollection_AsciiString aname_1("cc_1"), aname_2("cc_2");
// Standard_CString name_1 = aname_1.ToCString(), name_2 = aname_2.ToCString();
// cout<<"compositeclassifier : "<<name_1<<","<<name_2<<endl;
// BRepTools::Write(S1,name_1); BRepTools::Write(S2,name_2);
//}
#endif
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
TopOpeBRepBuild_CompositeClassifier::TopOpeBRepBuild_CompositeClassifier
(const TopOpeBRepBuild_BlockBuilder& BB) :
myBlockBuilder((void*)&BB)
{
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_CompositeClassifier::Compare
(const Handle(TopOpeBRepBuild_Loop)& L1,
const Handle(TopOpeBRepBuild_Loop)& L2)
{
TopAbs_State state = TopAbs_UNKNOWN;
Standard_Boolean isshape1 = L1->IsShape();
Standard_Boolean isshape2 = L2->IsShape();
if ( isshape2 && isshape1 ) { // L1 is Shape , L2 is Shape
const TopoDS_Shape& s1 = L1->Shape();
const TopoDS_Shape& s2 = L2->Shape();
state = CompareShapes(s1,s2);
}
else if ( isshape2 && !isshape1 ) { // L1 is Block , L2 is Shape
TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
Bit1.Initialize();
Standard_Boolean yena1 = Bit1.More();
while (yena1) {
const TopoDS_Shape& s1 = MYBB->Element(Bit1);
const TopoDS_Shape& s2 = L2->Shape();
state = CompareElementToShape(s1,s2);
yena1 = Standard_False;
if (state == TopAbs_UNKNOWN) {
if (Bit1.More()) Bit1.Next();
yena1 = Bit1.More();
}
}
}
else if ( !isshape2 && isshape1 ) { // L1 is Shape , L2 is Block
const TopoDS_Shape& s1 = L1->Shape();
ResetShape(s1);
TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
const TopoDS_Shape& s2 = MYBB->Element(Bit2);
CompareElement(s2);
}
state = State();
}
else if ( !isshape2 && !isshape1 ) { // L1 is Block , L2 is Block
TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
Bit1.Initialize();
Standard_Boolean yena1 = Bit1.More();
while (yena1) {
const TopoDS_Shape& s1 = MYBB->Element(Bit1);
ResetElement(s1);
TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
const TopoDS_Shape& s2 = MYBB->Element(Bit2);
CompareElement(s2);
}
state = State();
yena1 = Standard_False;
if (state == TopAbs_UNKNOWN) {
if (Bit1.More()) Bit1.Next();
yena1 = Bit1.More();
}
}
}
return state;
}

View File

@@ -0,0 +1,158 @@
-- File: TopOpeBRepBuild_CorrectFace2d.cdl
-- Created: Tue Jan 25 17:43:26 2000
-- Author: Peter KURNEV
-- <pkv@irinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class CorrectFace2d from TopOpeBRepBuild
---Purpose:
uses
Box2d from Bnd,
Face from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Shape from TopoDS,
Vec2d from gp,
Pnt2d from gp,
Curve from Geom2d,
IndexedMapOfOrientedShape from TopTools,
ListOfShape from TopTools,
IndexedDataMapOfShapeShape from TopTools
--raises
is
Create returns CorrectFace2d from TopOpeBRepBuild;
Create (aFace: Face from TopoDS;
anAvoidMap: IndexedMapOfOrientedShape from TopTools;
aMap:out IndexedDataMapOfShapeShape from TopTools)
returns CorrectFace2d from TopOpeBRepBuild;
Face (me) returns Face from TopoDS;
---C++: return const &
Perform (me:out);
IsDone (me) returns Boolean from Standard;
ErrorStatus (me) returns Integer from Standard;
-- CorrectedFace returns copied face (not myFace)
CorrectedFace (me) returns Face from TopoDS;
---C++: return const &
SetMapOfTrans2dInfo (me:out; aMap:out IndexedDataMapOfShapeShape from TopTools);
MapOfTrans2dInfo (me:out) returns IndexedDataMapOfShapeShape from TopTools;
---C++: return &
-- private and static block
CheckFace (me:out)
is private;
MakeRightWire (me:out)
returns Integer from Standard
is private;
GetP2dFL (myclass;
aFace : Face from TopoDS;
anEdge: Edge from TopoDS;
P2dF : out Pnt2d from gp;
P2dL : out Pnt2d from gp);
MakeHeadList (me;
aFirstEdge: Shape from TopoDS;
aHeadList : out ListOfShape from TopTools)
is private;
CheckList (myclass;
--modified by NIZNHY-PKV Mon Apr 24 14:41:44 2000f
aFace : Face from TopoDS;
--modified by NIZNHY-PKV Mon Apr 24 14:41:55 2000 t
aHeadList : out ListOfShape from TopTools);
TranslateCurve2d (me:out;
anEdge : Edge from TopoDS;
aFace : Face from TopoDS;
aTranslateVec: Vec2d from gp;
aCurve2d :out Curve from Geom2d)
is private;
OuterWire (me; anOuterWire:out Wire from TopoDS)
returns Integer from Standard
is private;
BndBoxWire (me; aWire: Wire from TopoDS;
aB2d:out Box2d from Bnd)
is private;
MoveWire2d (me:out;
aWire:out Wire from TopoDS;
aTrV: Vec2d from gp)
is private;
MoveWires2d (me:out;
aWire:out Wire from TopoDS)
is private;
UpdateEdge (me:out;
E : Edge from TopoDS;
C : Curve from Geom2d;
F : Face from TopoDS;
Tol : Real)
is private;
UpdateEdge (me:out;
E : Edge from TopoDS;
C1,C2 : Curve from Geom2d;
F : Face from TopoDS;
Tol : Real)
is private;
BuildCopyData(me:out;
F: Face from TopoDS;
anAvoidMap: IndexedMapOfOrientedShape from TopTools;
aCopyFace:out Face from TopoDS;
aCopyAvoidMap:out IndexedMapOfOrientedShape from TopTools;
aNeedToUsePMap: Boolean from Standard)
is private;
ConnectWire (me:out;
aCopyFace:out Face from TopoDS;
aCopyAvoidMap: IndexedMapOfOrientedShape from TopTools;
aTryToConnectFlag: Boolean from Standard)
returns Integer from Standard
is private;
fields
myFace : Face from TopoDS;
myCorrectedFace: Face from TopoDS;
myIsDone : Boolean from Standard;
myErrorStatus : Integer from Standard;
myFaceTolerance: Real from Standard;
myCurrentWire : Wire from TopoDS;
myOrderedWireList: ListOfShape from TopTools;
myAvoidMap : IndexedMapOfOrientedShape from TopTools;
myMap : Address from Standard;
myCopyFace : Face from TopoDS;
myCopyAvoidMap : IndexedMapOfOrientedShape from TopTools;
myEdMapInversed: IndexedDataMapOfShapeShape from TopTools;
end CorrectFace2d;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
-- File: TopOpeBRepBuild_EdgeBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class EdgeBuilder from TopOpeBRepBuild
inherits Area1dBuilder from TopOpeBRepBuild
uses
Shape from TopoDS,
PaveSet from TopOpeBRepBuild,
PaveClassifier from TopOpeBRepBuild,
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild
is
Create returns EdgeBuilder;
Create(LS : in out PaveSet; LC : in out PaveClassifier;
ForceClass : Boolean = Standard_False) returns EdgeBuilder;
---Purpose: Creates a EdgeBuilder to find the areas of
-- the shapes described by <LS> using the classifier <LC>.
InitEdgeBuilder(me : in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) is static;
-- Output methods
InitEdge(me : in out) is static;
MoreEdge(me) returns Boolean from Standard is static;
NextEdge(me : in out) is static;
-- Exploration of the vertex of current edge
InitVertex(me : in out) is static;
MoreVertex(me) returns Boolean from Standard is static;
NextVertex(me : in out) is static;
Vertex(me) returns Shape from TopoDS is static;
---C++: return const &
Parameter(me) returns Real is static;
end EdgeBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,129 @@
// File: TopOpeBRepBuild_EdgeBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
// Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_EdgeBuilder.ixx>
#include <TopOpeBRepBuild_Pave.hxx>
//=======================================================================
//function : TopOpeBRepBuild_EdgeBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_EdgeBuilder::TopOpeBRepBuild_EdgeBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_EdgeBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_EdgeBuilder::TopOpeBRepBuild_EdgeBuilder
(TopOpeBRepBuild_PaveSet& LS, TopOpeBRepBuild_PaveClassifier& LC,
const Standard_Boolean ForceClass)
{
InitEdgeBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : InitEdgeBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_EdgeBuilder::InitEdgeBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : InitEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_EdgeBuilder::InitEdge()
{
InitArea();
}
//=======================================================================
//function : MoreEdge
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_EdgeBuilder::MoreEdge() const
{
Standard_Boolean b = MoreArea();
return b;
}
//=======================================================================
//function : NextEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_EdgeBuilder::NextEdge()
{
NextArea();
}
//=======================================================================
//function : InitVertex
//purpose :
//=======================================================================
void TopOpeBRepBuild_EdgeBuilder::InitVertex()
{
InitLoop();
}
//=======================================================================
//function : MoreVertex
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_EdgeBuilder::MoreVertex() const
{
Standard_Boolean b = MoreLoop();
return b;
}
//=======================================================================
//function : NextVertex
//purpose :
//=======================================================================
void TopOpeBRepBuild_EdgeBuilder::NextVertex()
{
NextLoop();
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_EdgeBuilder::Vertex() const
{
const Handle(TopOpeBRepBuild_Loop)& L = Loop();
const Handle(TopOpeBRepBuild_Pave)& PV = *((Handle(TopOpeBRepBuild_Pave)*)&L);
const TopoDS_Shape& V = PV->Vertex();
return V;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real TopOpeBRepBuild_EdgeBuilder::Parameter() const
{
const Handle(TopOpeBRepBuild_Loop)& L = Loop();
const Handle(TopOpeBRepBuild_Pave)& PV = *((Handle(TopOpeBRepBuild_Pave)*)&L);
Standard_Real parV = PV->Parameter();
return parV;
}

View File

@@ -0,0 +1,394 @@
// File: TopOpeBRepBuild_Builder.cxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_Builder.jxx>
#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS.hxx>
#include <BRep_Builder.hxx>
#include <TopExp.hxx>
#include <BRepAdaptor_Curve.hxx>
//#include <BRepAdaptor_Curve2d.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TopOpeBRepBuild_define.hxx>
#include <Bnd_Box.hxx>
#include <TopOpeBRepTool_FuseEdges.hxx>
#include <Standard_ProgramError.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOFE();
#endif
//=======================================================================
//function : End
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::End()
{
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
{
// recodage de la continuite (edge,(f1,f2)) != C0 perdue lors
// du changement de surface-support d'une arete non decoupee
// d'une face tangente.
for (Standard_Integer i=1;i<=2;i++) {
TopoDS_Shape S; TopAbs_State sta=TopAbs_UNKNOWN;
if ( i==1 ) { S = myShape1; sta = myState1; }
else if ( i==2 ) { S = myShape2; sta = myState2; }
TopExp_Explorer exs;
for (exs.Init(S,TopAbs_SHELL);exs.More();exs.Next()) {
// for (TopExp_Explorer exs(S,TopAbs_SHELL);exs.More();exs.Next()) {
const TopoDS_Shape& SH = exs.Current();
Standard_Boolean SHhassha = BDS.HasShape(SH);
if ( !SHhassha ) continue;
Standard_Boolean Fhassam = Standard_False;
TopExp_Explorer exf;
for (exf.Init(SH,TopAbs_FACE);exf.More(); exf.Next()) {
// for (TopExp_Explorer exf(SH,TopAbs_FACE);exf.More(); exf.Next()) {
Fhassam = myDataStructure->HasSameDomain(exf.Current());
if ( Fhassam ) break;
}
if ( !Fhassam ) continue;
TopTools_IndexedDataMapOfShapeListOfShape M;
TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,M);
Standard_Integer nE = M.Extent();
for (Standard_Integer iE = 1; iE <= nE; iE++) {
const TopoDS_Edge& E = TopoDS::Edge(M.FindKey(iE));
if ( IsSplit(E,sta) ) continue;
const TopTools_ListOfShape& LF = M.FindFromIndex(iE);
if ( LF.Extent() < 2 ) continue;
// NYI : > 2 faces connexes par E : iterer sur tous les couples
TopTools_ListIteratorOfListOfShape itLF(LF);
const TopoDS_Face& F1 = TopoDS::Face(itLF.Value()); itLF.Next();
const TopoDS_Face& F2 = TopoDS::Face(itLF.Value());
GeomAbs_Shape C = BRep_Tool::Continuity(E,F1,F2);
if ( C == GeomAbs_C0 ) continue;
Standard_Boolean F1hassam = myDataStructure->HasSameDomain(F1);
Standard_Boolean F2hassam = myDataStructure->HasSameDomain(F2);
if ( !F1hassam && !F2hassam ) continue;
Standard_Boolean F1issplit = IsSplit(F1,sta);
Standard_Boolean F2issplit = IsSplit(F2,sta);
F1issplit &= (Splits(F1,sta).Extent() != 0);
F2issplit &= (Splits(F2,sta).Extent() != 0);
if ( !F1issplit && !F2issplit ) continue;
TopoDS_Face FF1=F1,FF2=F2;
for (Standard_Integer ii=1; ii<=2; ii++) {
if ((ii==1 && !F1issplit) || (ii==2 && !F2issplit)) continue;
TopoDS_Face F;
if (ii==1) F = F1;
else F = F2;
Standard_Boolean f = Standard_False;
TopTools_ListIteratorOfListOfShape it;
for (it.Initialize(Splits(F,sta));it.More();it.Next()) {
const TopoDS_Shape& SF = it.Value();
if (SF.ShapeType() != TopAbs_FACE) continue;
TopExp_Explorer ex;
for (ex.Init(SF,TopAbs_EDGE);ex.More();ex.Next()) {
if (ex.Current().IsSame(E)) {
if (ii==1) FF1 = TopoDS::Face(it.Value());
else FF2 = TopoDS::Face(it.Value());
f = Standard_True; break;
}
}
if (f) break;
}
}
BRep_Builder B;
B.Continuity(E,FF1,FF2,C);
}
}
}
}
// M.A.J de la tolerance des vertex
{
// modified by NIZHNY-MKK Fri Oct 6 16:13:33 2000.BEGIN
TopTools_MapOfShape aMapOfNewEdges, aMapOfNewVertices;
TopTools_ListIteratorOfListOfShape anIt;
Standard_Integer iteratorofnewshape=0;
for(iteratorofnewshape=1; iteratorofnewshape <= myDataStructure->NbCurves(); iteratorofnewshape++) {
for(anIt.Initialize(NewEdges(iteratorofnewshape)); anIt.More(); anIt.Next()) {
aMapOfNewEdges.Add(anIt.Value());
}
}
for(iteratorofnewshape=1; iteratorofnewshape <= myDataStructure->NbPoints(); iteratorofnewshape++) {
aMapOfNewVertices.Add(NewVertex(iteratorofnewshape));
}
// modified by NIZHNY-MKK Fri Oct 6 16:13:36 2000.END
TopoDS_Compound R;BRep_Builder B;B.MakeCompound(R);
const TopTools_ListOfShape& lmergesha1 = Merged(myShape1,myState1);
TopTools_ListIteratorOfListOfShape it(lmergesha1); for(;it.More();it.Next()) B.Add(R,it.Value());
const TopTools_ListOfShape& LOES = Section();
#ifdef DEB
// Standard_Integer nLOES = LOES.Extent();
#endif
TopTools_IndexedDataMapOfShapeListOfShape idmoelof; TopExp::MapShapesAndAncestors(R,TopAbs_EDGE,TopAbs_FACE,idmoelof);
TopTools_IndexedDataMapOfShapeListOfShape idmovloe; TopExp::MapShapesAndAncestors(R,TopAbs_VERTEX,TopAbs_EDGE,idmovloe);
TopTools_IndexedDataMapOfShapeListOfShape idmovloes; for (TopTools_ListIteratorOfListOfShape I(LOES);I.More();I.Next())
TopExp::MapShapesAndAncestors(I.Value(),TopAbs_VERTEX,TopAbs_EDGE,idmovloes);
Standard_Integer iv,nv = idmovloe.Extent();
for (iv=1;iv<=nv;iv++) {
Standard_Integer nP1 = 0;
const TopoDS_Vertex& V = TopoDS::Vertex(idmovloe.FindKey(iv));
Standard_Boolean isbe = idmovloes.Contains(V);
if ( !isbe ) continue;
const TopTools_ListOfShape& loe1 = idmovloe.FindFromIndex(iv);
#ifdef DEB
// Standard_Integer nloe1 = loe1.Extent();
#endif
TopTools_MapOfShape mose; //une seule fois chaque arete
TopTools_ListOfShape loe;
TopTools_ListIteratorOfListOfShape iloe;
for (iloe.Initialize(loe1);iloe.More();iloe.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(iloe.Value());
Standard_Boolean isb = mose.Contains(E); if (isb) continue;
mose.Add(E);loe.Append(E);
}
#ifdef DEB
// Standard_Integer nloe = loe.Extent();
#endif
for (iloe.Initialize(loe);iloe.More();iloe.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(iloe.Value());
const TopTools_ListOfShape& lof = idmoelof.FindFromKey(E);
Standard_Integer nlof = lof.Extent();
nP1 += nlof+1;
}
TColgp_Array1OfPnt TP(1,nP1);
Standard_Integer nP2 = 0;
for (iloe.Initialize(loe);iloe.More();iloe.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(iloe.Value());
Standard_Real pv = BRep_Tool::Parameter(V,E);
gp_Pnt Pv;
Standard_Real f,l;Handle(Geom_Curve) C3D = BRep_Tool::Curve(E,f,l);
if (!C3D.IsNull()) {
Pv = C3D->Value(pv);
TP(++nP2) = Pv;
}
const TopTools_ListOfShape& lof = idmoelof.FindFromKey(E);
#ifdef DEB
// Standard_Integer nlof = lof.Extent();
#endif
for (TopTools_ListIteratorOfListOfShape ilof(lof);ilof.More();ilof.Next()) {
const TopoDS_Face& F = TopoDS::Face(ilof.Value());
Standard_Real tolpc;
Standard_Boolean pcf = FC2D_HasCurveOnSurface(E,F);
Handle(Geom2d_Curve) C2D;
if (!pcf) {
C2D = FC2D_CurveOnSurface(E,F,f,l,tolpc);
if (C2D.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::End 1");
Standard_Real tolE = BRep_Tool::Tolerance(E);
Standard_Real tol = Max(tolE,tolpc);
B.UpdateEdge(E,C2D,F,tol);
}
C2D = FC2D_CurveOnSurface(E,F,f,l,tolpc);
gp_Pnt2d P2 = C2D->Value(pv);
BRepAdaptor_Surface BAS(F,Standard_False);
Pv = BAS.Value(P2.X(),P2.Y());
TP(++nP2) = Pv;
// modified by NIZHNY-MKK Fri Sep 29 16:08:28 2000.BEGIN
if(aMapOfNewEdges.Contains(E)) {
Standard_Real anEdgeTol = BRep_Tool::Tolerance(E);
Standard_Real aFaceTol = BRep_Tool::Tolerance(F);
if(anEdgeTol < aFaceTol)
B.UpdateEdge(E, aFaceTol);
}
// modified by NIZHNY-MKK Fri Sep 29 16:08:32 2000.END
}
// modified by NIZHNY-MKK Fri Sep 29 16:54:08 2000.BEGIN
if(aMapOfNewVertices.Contains(V)) {
Standard_Real aVertexTol = BRep_Tool::Tolerance(V);
Standard_Real anEdgeTol = BRep_Tool::Tolerance(E);
if (aVertexTol < anEdgeTol)
B.UpdateVertex(V, anEdgeTol);
}
// modified by NIZHNY-MKK Fri Sep 29 16:54:12 2000.END
}
Standard_Real newtol = BRep_Tool::Tolerance(V);
Bnd_Box BOX;
gp_Pnt Pv = BRep_Tool::Pnt(V);
BOX.Set(Pv);
for (Standard_Integer i=1;i<=nP2;i++) {
const gp_Pnt& Pi = TP(i);
BOX.Update(Pi.X(),Pi.Y(),Pi.Z());
}
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
BOX.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
gp_Pnt P1(aXmin, aYmin, aZmin);
gp_Pnt P2(aXmax, aYmax, aZmax);
Standard_Real d = P1.Distance(P2);
if (d > newtol) {
#ifdef DEB
cout<<"\npoint P"<<iv<<" "<<Pv.X()<<" "<<Pv.Y()<<" "<<Pv.Z()<<endl;
cout<<"TopOpeBRepBuild_Builder::End BOX newtol "<<newtol<<" -> "<<d<<endl;
#endif
newtol = d;
B.UpdateVertex(V,newtol);
}
}
}
Standard_Boolean makeFE = Standard_True;
#ifdef DEB
makeFE = !TopOpeBRepBuild_GetcontextNOFE();
#endif
if (makeFE) {
// TopAbs_State state = myState1;
TopTools_ListOfShape& ls = ChangeMerged(myShape1,myState1);
for (TopTools_ListIteratorOfListOfShape itls(ls);itls.More();itls.Next()) {
TopoDS_Shape& SFE = itls.Value();
TopOpeBRepTool_FuseEdges FE(SFE);
// avoid fusing old edges
TopTools_IndexedMapOfShape mapOldEdges;
TopExp::MapShapes (myShape1, TopAbs_EDGE, mapOldEdges);
TopExp::MapShapes (myShape2, TopAbs_EDGE, mapOldEdges);
FE.AvoidEdges (mapOldEdges);
// Get List of edges that have been fused
TopTools_DataMapOfIntegerListOfShape mle;
FE.Edges(mle);
Standard_Integer nle = mle.Extent();
if ( nle != 0 ) {
FE.Perform();
SFE = FE.Shape();
TopTools_DataMapOfIntegerShape mre;
TopTools_DataMapOfShapeShape mlf;
FE.ResultEdges(mre);
FE.Faces(mlf);
// edit the split to remove to edges to be fused and put them into the Merged
//
UpdateSplitAndMerged(mle, mre, mlf, TopAbs_IN);
UpdateSplitAndMerged(mle, mre, mlf, TopAbs_OUT);
UpdateSplitAndMerged(mle, mre, mlf, TopAbs_ON);
}
} // makeFE
}
}
//=======================================================================
//function : UpdateSplitAndMerged
//purpose : edit the split to remove to edges to be fused and put them into the Merged
//=======================================================================
void TopOpeBRepBuild_Builder::UpdateSplitAndMerged(const TopTools_DataMapOfIntegerListOfShape& mle,
const TopTools_DataMapOfIntegerShape& mre,
const TopTools_DataMapOfShapeShape& mlf,
const TopAbs_State state)
{
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MapSplit = MSplit(state);
TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it;
for (it.Initialize(MapSplit); it.More(); it.Next()) {
const TopoDS_Shape& e = it.Key();
// For each edge of the MapSplit
if ( e.ShapeType() == TopAbs_EDGE ) {
// get the list of splitted edges.
TopTools_ListOfShape& LstSplit = ChangeSplit(e,state);
// for each edge of the list of splitted edges
TopTools_ListIteratorOfListOfShape itSplitEdg;
itSplitEdg.Initialize(LstSplit);
while ( itSplitEdg.More()) {
const TopoDS_Shape& edgecur = itSplitEdg.Value();
// for each "packet" of edges to be fused
TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape itLstEdg;
itLstEdg.Initialize(mle);
Standard_Boolean Found = Standard_False;
while ( itLstEdg.More() && !Found) {
const Standard_Integer& iLst = itLstEdg.Key();
const TopTools_ListOfShape& LmapEdg = mle.Find(iLst);
// look for each edge of the list if it is in the map Split
TopTools_ListIteratorOfListOfShape itEdg;
itEdg.Initialize(LmapEdg);
while ( itEdg.More() && !Found ) {
const TopoDS_Shape& edgefuse = itEdg.Value();
if (edgecur.IsSame(edgefuse)) {
Found = Standard_True;
LstSplit.Remove(itSplitEdg);
// edit the list of merged
TopAbs_State stateMerged;
if (ShapeRank(e) == 1)
stateMerged = myState1;
else
stateMerged = myState2;
TopTools_ListOfShape LstMerged;
LstMerged.Append(mre(iLst));
ChangeMerged(e,stateMerged) = LstMerged;
}
itEdg.Next();
}
itLstEdg.Next();
}
if (!Found) {
itSplitEdg.Next();
}
}
}
// For each face of the MapSplit
else if ( e.ShapeType() == TopAbs_FACE ) {
// get the list of splitted faces.
TopTools_ListOfShape& LstSplit = ChangeSplit(e,state);
// for each face of the list of splitted faces
TopTools_ListIteratorOfListOfShape itSplitFac;
itSplitFac.Initialize(LstSplit);
while ( itSplitFac.More()) {
const TopoDS_Shape& facecur = itSplitFac.Value();
if (mlf.IsBound(facecur)) {
LstSplit.InsertBefore(mlf(facecur),itSplitFac);
LstSplit.Remove(itSplitFac);
}
else {
itSplitFac.Next();
}
}
}
}
}

View File

@@ -0,0 +1,329 @@
// file: TopOpeBRepBuild_Grid.cxx
// Created: Thu Mar 7 10:49:33 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopOpeBRepBuild_WireToFace.hxx>
#include <TopOpeBRepTool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <Standard_ProgramError.hxx>
#include <TopOpeBRepDS_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOREGUFA();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextREGUXPU();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSAVFREGU();
void debregufa(const Standard_Integer /*iF*/) {}
#endif
#ifdef DRAW
#include <DBRep.hxx>
#endif
#define M_FORWARD(O) (O == TopAbs_FORWARD)
#define M_REVERSED(O) (O == TopAbs_REVERSED)
//=======================================================================
//function : RegularizeFaces
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::RegularizeFaces
(const TopoDS_Shape& FF,const TopTools_ListOfShape& lnewFace,TopTools_ListOfShape& LOF)
{
LOF.Clear();
myMemoSplit.Clear();
TopTools_ListIteratorOfListOfShape itl(lnewFace);
for (;itl.More();itl.Next()) {
const TopoDS_Shape& newFace = itl.Value();
TopTools_ListOfShape newFaceLOF;
RegularizeFace(FF,newFace,newFaceLOF);
#ifdef DEB
// Standard_Integer nnewFaceLOF = newFaceLOF.Extent(); // DEB
#endif
LOF.Append(newFaceLOF);
}
#ifdef DEB
// Standard_Integer nLOF = LOF.Extent(); // DEB
#endif
Standard_Integer nr = myMemoSplit.Extent();
if (nr == 0 ) return;
// lfsdFF = faces SameDomain de FF
TopTools_ListOfShape lfsdFF,lfsdFF1,lfsdFF2;
GFindSamDom(FF,lfsdFF1,lfsdFF2);
lfsdFF.Append(lfsdFF1);
lfsdFF.Append(lfsdFF2);
TopTools_ListIteratorOfListOfShape itlfsdFF(lfsdFF);
for (; itlfsdFF.More(); itlfsdFF.Next()) {
const TopoDS_Shape& fsdFF = itlfsdFF.Value();
// au moins une arete de FF dont le Split() est lui meme Split()
TopExp_Explorer x;
for (x.Init(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
// for (TopExp_Explorer x(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
const TopoDS_Shape& e = x.Current();
#ifdef DEB
// Standard_Integer ie = myDataStructure->Shape(e); //DEB
// Standard_Boolean issect = myDataStructure->DS().IsSectionEdge(TopoDS::Edge(e));
#endif
Standard_Integer ranke = GShapeRank(e);
TopAbs_State staeope = (ranke==1) ? myState1 : myState2;
for (Standard_Integer iiista = 1; iiista <= 2; iiista++ ) {
TopAbs_State stae = staeope;
if (iiista == 2) stae = TopAbs_ON;
Standard_Boolean issplite = IsSplit(e,stae);
if (!issplite) continue;
TopTools_ListOfShape& lspe = ChangeSplit(e,stae);
#ifdef DEB
// Standard_Integer nlspe = lspe.Extent(); // DEB
#endif
TopTools_ListOfShape newlspe;
for (TopTools_ListIteratorOfListOfShape itl1(lspe);itl1.More();itl1.Next()) {
const TopoDS_Shape& esp = itl1.Value();
Standard_Boolean espmemo = myMemoSplit.Contains(esp);
if (!espmemo) newlspe.Append(esp);
else {
const TopTools_ListOfShape& lspesp = Splits(esp,stae);
GCopyList(lspesp,newlspe);
}
}
lspe.Clear();
GCopyList(newlspe,lspe);
} // iiista
} // explorer (fsdFF,TopAbs_EDGE)
} // itlfsdFF.More()
} // RegularizeFaces
/*static void FUN_setInternal(TopoDS_Face& F)
{
TopExp_Explorer ex(F,TopAbs_EDGE);
TopTools_MapOfShape meF,meR,meI;
for (; ex.More(); ex.Next()){
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
TopAbs_Orientation oE = E.Orientation();
Standard_Boolean isclo = BRep_Tool::IsClosed(E,F); // E has 2d rep on F
if (isclo) continue;
Standard_Boolean isb = Standard_False; // the edge is FOR + REV in F
if (M_FORWARD(oE)) {meF.Add(E); isb = meR.Contains(E);}
else if (M_REVERSED(oE)) {meR.Add(E); isb = meF.Contains(E);}
if (isb) meI.Add(E.Oriented(TopAbs_INTERNAL));
}
BRep_Builder BB;
TopTools_MapIteratorOfMapOfShape it(meI);
for (; it.More(); it.Next()){
const TopoDS_Edge& E = TopoDS::Edge(it.Key());
BB.Remove(F,E.Oriented(TopAbs_FORWARD));
BB.Remove(F,E.Oriented(TopAbs_REVERSED));
BB.Add(F,E);
}
}*/
//=======================================================================
//function : RegularizeFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::RegularizeFace
(const TopoDS_Shape& FF,const TopoDS_Shape& anewFace,TopTools_ListOfShape& LOF)
{
LOF.Clear();
const TopoDS_Face& newFace = TopoDS::Face(anewFace);
Standard_Boolean toregu = Standard_True;
Standard_Boolean usewtof = Standard_True;
#ifdef DEB
Standard_Integer iF;Standard_Boolean tSPSFF=GtraceSPS(FF,iF);
// Standard_Boolean savfregu = TopOpeBRepBuild_GettraceSAVFREGU();
if (TopOpeBRepBuild_GetcontextNOREGUFA()) toregu = Standard_False;
if (TopOpeBRepBuild_GetcontextREGUXPU()) usewtof = Standard_False;
if (tSPSFF) debregufa(iF);
#endif
// If the same edge appears FOR+REV in the resulting face and
// whereas it's not a closing edge, set it as INTERNAL instead.
// FRA60275(iF=4) + PRO16297
// FUN_setInternal(newFace);
if (!toregu) {
LOF.Append(newFace);
return;
}
TopTools_DataMapOfShapeListOfShape ownw; // OldWires --> NewWires;
Standard_Boolean rw = Standard_False;
Standard_Boolean rf = Standard_False;
myESplits.Clear();
rw = TopOpeBRepTool::RegularizeWires(newFace,ownw,myESplits);
if ( !rw ) {
LOF.Append(newFace);
return;
}
TopTools_ListOfShape newfaces;
if (usewtof) {
TopOpeBRepBuild_WireToFace wtof;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itownw(ownw);
for (; itownw.More(); itownw.Next()) {
const TopTools_ListOfShape& lw = itownw.Value();
// xpu200798 : cto902D4 f14ou
// recall ownw = {(ow = old wire, lnw = {list of new wires descendant of old wire}}
// if lnw is empty, then ow is kept unchanged.
Standard_Boolean kept = lw.IsEmpty();
if (kept) {
const TopoDS_Wire& ow = TopoDS::Wire(itownw.Key());
wtof.AddWire(ow);
}
for(TopTools_ListIteratorOfListOfShape iw(lw);iw.More();iw.Next()) {
const TopoDS_Wire& w = TopoDS::Wire(iw.Value());
wtof.AddWire(w);
}
}
wtof.MakeFaces(newFace,newfaces);
#ifdef DEB
// Standard_Integer nnewfaces = newfaces.Extent(); // DEB
#endif
rf = (newfaces.Extent() != 0);
}
else {
rf = TopOpeBRepTool::RegularizeFace(newFace,ownw,newfaces);
}
if (!rf) {
LOF.Append(newFace);
return;
}
#ifdef DEB
if (tSPSFF) { cout<<"RegularizeFace "<<iF<<endl; debregufa(iF); }
#endif
// LOF = nouvelles faces regularisees de newFace
TopTools_ListIteratorOfListOfShape itlnf(newfaces);
for (; itlnf.More(); itlnf.Next())
LOF.Append(TopoDS::Face(itlnf.Value()));
// mise a jour des aretes decoupees
// Edge(FF) = {E}, E-->Split(E) = {E'}, E'-->myESplits(E') = {E''}
TopTools_MapOfShape menf; // menf = aretes de newFace
TopExp_Explorer x;
for (x.Init(newFace,TopAbs_EDGE);x.More();x.Next()) {
const TopoDS_Shape& E = x.Current();
menf.Add(E);
}
// lfsdFF = faces SameDomain de FF
TopTools_ListOfShape lfsdFF,lfsdFF1,lfsdFF2;
GFindSamDom(FF,lfsdFF1,lfsdFF2);
lfsdFF.Append(lfsdFF1);
lfsdFF.Append(lfsdFF2);
TopTools_ListIteratorOfListOfShape itlfsdFF(lfsdFF);
for (; itlfsdFF.More(); itlfsdFF.Next()) {
const TopoDS_Shape& fsdFF = itlfsdFF.Value();
#ifdef DEB
Standard_Integer ifsdFF=0;Standard_Boolean tSPSfsdFF=GtraceSPS(fsdFF,ifsdFF);
if (tSPSfsdFF) debregufa(ifsdFF);
#endif
Standard_Integer rankfsdFF = GShapeRank(fsdFF);
TopAbs_State stafsdFF = (rankfsdFF == 1) ? myState1 : myState2;
#ifdef DEB
// Standard_Boolean issplitfsdFF = IsSplit(fsdFF,stafsdFF);
#endif
/*#ifdef DEB
const TopTools_ListOfShape& lspfsdFF = Splits(fsdFF,stafsdFF);
Standard_Integer nlspfsdFF = lspfsdFF.Extent();
#endif*/
// iteration sur les aretes de fsdFF
for (x.Init(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
//fsdFFe : 1 edge de fsdFF = 1 face SameDomain de FF
const TopoDS_Shape& fsdFFe = x.Current();
#ifdef DEB
Standard_Integer ifsdFFe = 0;Standard_Boolean tSPSfsdFFe=GtraceSPS(fsdFFe,ifsdFFe);
if (tSPSfsdFFe) debregufa(ifsdFFe);
#endif
// a priori, on ne peut avoir plus de deux etats splites
// sur l'arete , soit (IN + ON) , soit (OUT + ON)
for (Standard_Integer iiista = 1; iiista <= 2; iiista++ ) {
TopAbs_State stafsdFFe = stafsdFF;
if (iiista == 2) stafsdFFe = TopAbs_ON;
TopTools_ListOfShape& lspfsdFFe = ChangeSplit(fsdFFe,stafsdFFe);
#ifdef DEB
// Standard_Boolean issplitfsdFFe = IsSplit(fsdFFe,stafsdFFe);
// Standard_Integer nlspfsdFFe = lspfsdFFe.Extent();
#endif
Standard_Integer nDEB2=0 ;
for (TopTools_ListIteratorOfListOfShape it(lspfsdFFe);it.More();it.Next()) {
// fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
const TopoDS_Shape& espfsdFFe = it.Value();
Standard_Boolean inmenf = menf.Contains(espfsdFFe);
if (!inmenf) continue;
// fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
// espfsdFFe est une arete de Split(fsdFFe) ET figure dans newFace (Cf supra E')
Standard_Boolean resplitloc = myESplits.IsBound(espfsdFFe);
if (resplitloc) {
// fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
// espfsdFFe est une arete de Split(fsdFFe) ET figure dans newFace (Cf supra E')
// espfsdFFe de newFace a ete redecoupee par RegularizeWires
// son decoupage lresplit est stocke dans la DS du Builder
const TopTools_ListOfShape& lresplit = myESplits.Find(espfsdFFe); //Cf supra E''
nDEB2 = lresplit.Extent();
// on memorise que espfsdFFe est redecoupee ...
myMemoSplit.Add(espfsdFFe);
// on stocke le nouveau decoupage de espfsdFFe dans la DS du builder ...
TopTools_ListOfShape& lsp = ChangeSplit(espfsdFFe,stafsdFFe);
GCopyList(lresplit,lsp);
nDEB2 = lsp.Extent();
}
} // it.More
} // iiista
} // explore(fsdFF,TopAbs_EDGE)
} // itlfsdFF.More()
#ifdef DRAW
if (tSPSFF) debregufa(iF);
if (tSPSFF && savfregu) {
TCollection_AsciiString str("fregu"); str = str + iF;
DBRep::Set(str.ToCString(),newFace);
cout<<"newFace "<<str<<" built on face "<<iF<<" saved"<<endl;
}
#endif
} // RegularizeFace

View File

@@ -0,0 +1,38 @@
-- File: TopOpeBRepBuild_FaceAreaBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class FaceAreaBuilder from TopOpeBRepBuild
inherits Area2dBuilder from TopOpeBRepBuild
---Purpose:
-- The FaceAreaBuilder algorithm is used to construct Faces from a LoopSet,
-- where the Loop is the composite topological object of the boundary,
-- here wire or block of edges.
-- The LoopSet gives an iteration on Loops.
-- For each Loop it indicates if it is on the boundary (wire) or if it
-- results from an interference (block of edges).
-- The result of the FaceAreaBuilder is an iteration on areas.
-- An area is described by a set of Loops.
uses
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild
is
Create returns FaceAreaBuilder;
Create(LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) returns FaceAreaBuilder;
---Purpose: Creates a FaceAreaBuilder to build faces on
-- the (wires,blocks of edge) of <LS>, using the classifier <LC>.
InitFaceAreaBuilder(me: in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) is static;
end FaceAreaBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,40 @@
// File: TopOpeBRepBuild_FaceAreaBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
//Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_FaceAreaBuilder.ixx>
//=======================================================================
//function : TopOpeBRepBuild_FaceAreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_FaceAreaBuilder::TopOpeBRepBuild_FaceAreaBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_FaceAreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_FaceAreaBuilder::TopOpeBRepBuild_FaceAreaBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitFaceAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : TopOpeBRepBuild_FaceAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceAreaBuilder::InitFaceAreaBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}

View File

@@ -0,0 +1,106 @@
-- File: TopOpeBRepBuild_FaceBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class FaceBuilder from TopOpeBRepBuild
uses
Shape from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
IndexedMapOfShape from TopTools,
IndexedDataMapOfShapeShape from TopTools,
ShapeSet from TopOpeBRepBuild,
LoopSet from TopOpeBRepBuild,
BlockIterator from TopOpeBRepBuild,
BlockBuilder from TopOpeBRepBuild,
WireEdgeSet from TopOpeBRepBuild,
FaceAreaBuilder from TopOpeBRepBuild,
DataMapOfShapeInteger from TopTools
is
Create returns FaceBuilder;
Create(ES : in out WireEdgeSet; F : Shape from TopoDS;
ForceClass : Boolean = Standard_False) returns FaceBuilder;
---Purpose: Create a FaceBuilder to build the faces on
-- the shapes (wires, blocks of edge) described by <LS>.
InitFaceBuilder(me : in out;
ES : in out WireEdgeSet; F : Shape from TopoDS;
ForceClass : Boolean);
DetectUnclosedWire(me : in out;
mapVVsameG : out IndexedDataMapOfShapeShape from TopTools;
mapVon1Edge : out IndexedDataMapOfShapeShape from TopTools);
---Purpose: Removes are non 3d-closed wires.
-- Fills up maps <mapVVsameG> and <mapVon1Edge>, in order to
-- correct 3d-closed but unclosed (topologic connexity) wires.
-- modifies myBlockBuilder
CorrectGclosedWire(me : in out;
mapVVref : IndexedDataMapOfShapeShape from TopTools;
mapVon1Edge : IndexedDataMapOfShapeShape from TopTools);
---Purpose: Using the given maps, change the topology of the 3d-closed
-- wires, in order to get closed wires.
DetectPseudoInternalEdge(me : in out;
mapE : out IndexedMapOfShape from TopTools);
---Purpose: Removes edges appearing twice (FORWARD,REVERSED) with a bounding
-- vertex not connected to any other edge.
-- mapE contains edges found.
-- modifies myBlockBuilder.
Face(me) returns Shape from TopoDS;
---C++: return const &
---Purpose: return myFace
-- Output methods
InitFace(me : in out) returns Integer from Standard;
MoreFace(me) returns Boolean from Standard;
NextFace(me : in out);
-- Exploration of the wires of the current face
InitWire(me : in out) returns Integer from Standard;
MoreWire(me) returns Boolean from Standard;
NextWire(me : in out);
IsOldWire(me) returns Boolean from Standard;
OldWire(me) returns Shape from TopoDS;
---Purpose: Returns current wire
-- This wire may be :
-- * an old wire OldWire(), which has not been reconstructed;
-- * a new wire made of edges described by ...NewEdge() methods.
---C++: return const &
-- Exploration of the edges of current wire when IsOldWire = False
FindNextValidElement(me : in out);
---Purpose: Iterates on myBlockIterator until finding a valid element
InitEdge(me : in out) returns Integer from Standard;
MoreEdge(me) returns Boolean from Standard;
NextEdge(me : in out);
Edge(me) returns Shape from TopoDS;
---Purpose: Returns current new edge of current new wire.
---C++: return const &
EdgeConnexity(me;E:Shape) returns Integer;
AddEdgeWire(me;E:Shape;W:in out Shape)
returns Integer;
--- private
MakeLoops(me : in out; SS : in out ShapeSet from TopOpeBRepBuild)
is private;
fields
myFace : Face from TopoDS;
myLoopSet : LoopSet from TopOpeBRepBuild;
myBlockIterator : BlockIterator from TopOpeBRepBuild;
myBlockBuilder : BlockBuilder from TopOpeBRepBuild;
myFaceAreaBuilder : FaceAreaBuilder from TopOpeBRepBuild;
myMOSI : DataMapOfShapeInteger from TopTools;
end FaceBuilder;

View File

@@ -0,0 +1,695 @@
// File: TopOpeBRepBuild_FaceBuilder.cxx
// Created: Fri Jan 5 18:10:57 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_FaceBuilder.ixx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
//#include <BRepAdaptor_Curve2d.hxx>
#include <TopExp.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedMapOfOrientedShape.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopOpeBRepBuild_WireEdgeClassifier.hxx>
#include <TopOpeBRepBuild_Loop.hxx>
#include <TopOpeBRepBuild_BlockBuilder.hxx>
#include <TopOpeBRepBuild_LoopSet.hxx>
#include <Standard_ProgramError.hxx>
#include <Precision.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopOpeBRepBuild_define.hxx>
#undef RM_HANGING
// MSV: RM_HANGING behaviour: when state of wire is UNCLOSEDW we do not
// remove the whole wire but remove the chains of hanging edges. This would
// produce a good result in some cases. But :-( it gives regressions on grid
// tests (1cto 021 W4,X4). Therefore I leaved this code not active.
#ifdef RM_HANGING
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#endif
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettracePURGE();
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
#include <TopOpeBRepDS_DSX.hxx>
void debifb() {}
#endif
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
//=======================================================================
//function : TopOpeBRepBuild_FaceBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_FaceBuilder::TopOpeBRepBuild_FaceBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_FaceBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_FaceBuilder::TopOpeBRepBuild_FaceBuilder(TopOpeBRepBuild_WireEdgeSet& WES,const TopoDS_Shape& F,const Standard_Boolean ForceClass)
{
InitFaceBuilder(WES,F,ForceClass);
}
//=======================================================================
//function : InitFaceBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::InitFaceBuilder(TopOpeBRepBuild_WireEdgeSet& WES,const TopoDS_Shape& F,const Standard_Boolean ForceClass)
{
myFace = TopoDS::Face(F);
#ifdef DEB
Standard_Boolean deb = TopOpeBRepDS_GettraceSPSX(myFace);
if (deb) debifb();
#endif
MakeLoops(WES);
TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
TopOpeBRepBuild_WireEdgeClassifier WEC(F,BB);
TopOpeBRepBuild_LoopSet& LS = myLoopSet;
myFaceAreaBuilder.InitFaceAreaBuilder(LS,WEC,ForceClass);
// Standard_Boolean hascnxsta = WES.HasConnexStartElement();
// if ( hascnxsta ) {
// myMOSI.Clear();
// InitFace();
// for (;MoreFace();NextFace()) {
// InitWire();
// for (;MoreWire();NextWire()) {
// Standard_Boolean isold = IsOldWire();if (isold) continue;
// InitEdge();
// for(;MoreEdge();NextEdge()) {
// const TopoDS_Shape& E = Edge();
// Standard_Boolean issta = WES.IsStartElement(E);
// Standard_Boolean nsta = WES.NStartElement(E);Standard_Boolean iscnx = (nsta == 2);
// if (!issta || !iscnx ) continue;
// Standard_Boolean isb = myMOSI.IsBound(E);
// if (!isb) myMOSI.Bind(E,0);
// Standard_Integer nmosi = myMOSI(E);
// nmosi++;
// myMOSI(E) = nmosi;
// }
// }
// }
// } // hascnxsta
}
//---------------------------------------------------------------
void FUN_DetectVerticesOn1Edge(const TopoDS_Shape& W,TopTools_IndexedDataMapOfShapeShape& mapVon1E)
{
// Fills the map <mapVon1edge>,with vertices of <W> of 3d connexity 1.
TopTools_IndexedDataMapOfShapeListOfShape mapVedges;
TopExp::MapShapesAndAncestors(W,TopAbs_VERTEX,TopAbs_EDGE,mapVedges);
Standard_Integer nV = mapVedges.Extent();
for (Standard_Integer i = 1;i <= nV;i++) {
const TopoDS_Shape& V = mapVedges.FindKey(i);
if (V.Orientation() == TopAbs_INTERNAL) continue;
const TopTools_ListOfShape& loE = mapVedges.FindFromIndex(i);
if (loE.Extent() < 2) {
// Keeping INTERNAL or EXTERNAL edges
const TopoDS_Shape& E = loE.First();
TopAbs_Orientation oriE = E.Orientation();
if ((oriE == TopAbs_INTERNAL) || (oriE == TopAbs_EXTERNAL)) continue;
mapVon1E.Add(V,E);
}
}
}
#define ISUNKNOWN -1
#define ISVERTEX 0
#define GCLOSEDW 1
#define UNCLOSEDW 2
#define CLOSEDW 10
Standard_Integer FUN_AnalyzemapVon1E(const TopTools_IndexedDataMapOfShapeShape& mapVon1E,
TopTools_IndexedDataMapOfShapeShape& mapVV)
{
#ifdef DRAW
Standard_Boolean trc = TopOpeBRepBuild_GettracePURGE();
if (trc) cout<<endl<<"* DetectUnclosedWire :"<<endl;
#endif
Standard_Integer res = ISUNKNOWN;
Standard_Integer nV = mapVon1E.Extent();
if (nV == 0) {
res = CLOSEDW;
}
else if (nV == 1) {
const TopoDS_Shape& E = mapVon1E.FindFromIndex(1);
Standard_Boolean Eclosed = E.Closed();
Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(E));
if (dgE) res = ISVERTEX;
else if (Eclosed) res = CLOSEDW;
else res = UNCLOSEDW;
}
else {
// Finding among all vertices,couple of vertices falling on same
// geometry.
// Filling up map <mapVV>,with (vi,vj),vi and vj are on same point.
Standard_Real tol = Precision::Confusion();
for (Standard_Integer i = 1;i <= nV;i++) {
const TopoDS_Vertex& vi = TopoDS::Vertex(mapVon1E.FindKey(i));
gp_Pnt pi = BRep_Tool::Pnt(vi);
for (Standard_Integer j = i+1;j <= nV;j++) {
const TopoDS_Vertex& vj = TopoDS::Vertex(mapVon1E.FindKey(j));
gp_Pnt pj = BRep_Tool::Pnt(vj);
Standard_Boolean same = pi.IsEqual(pj,tol);
if (same) {
mapVV.Add(vi,vj);
mapVV.Add(vj,vi);
break;
}
} // j
} // i
Standard_Integer nVV = mapVV.Extent();
#ifdef RM_HANGING
// MSV Oct 4, 2001: consider GCLOSEDW even if not all vertices from mapVon1E
// hit into mapVV; reason is the left vertices may start
// useless chains of hanging edges that can be removed to
// achieve a closed wire.
if (nVV > 0) res = GCLOSEDW;
#else
if (nVV == nV) res = GCLOSEDW;
#endif
else res = UNCLOSEDW;
}
return res;
} // FUN_AnalyzemapVon1E
#ifdef DRAW
void FUN_AnalyzemapVon1EDRAW(const Standard_Integer res,
const TopTools_IndexedDataMapOfShapeShape& mapVon1E,
const TopTools_IndexedDataMapOfShapeShape& mapVV,
const TopoDS_Shape& W,const Standard_Integer iiwi,
TopTools_IndexedDataMapOfShapeShape& mapVon1EdgeDRAW,
TopTools_IndexedDataMapOfShapeShape& mapVVsameGDRAW)
{
Standard_Boolean trc = TopOpeBRepBuild_GettracePURGE();
if (!trc) return;
cout<<"wire "<<iiwi;
if (res == ISVERTEX) {
cout<<" is vertex"<<endl;
}
else if (res == CLOSEDW) {
cout<<" is closed"<<endl;
}
else if (res == GCLOSEDW) {
cout<<" is Gclosed :"<<endl;
TCollection_AsciiString aa("w_");FUN_tool_draw(aa,W,iiwi);
Standard_Integer i ;
for ( i = 1;i <= mapVV.Extent();i++) {
Standard_Integer iV = mapVVsameGDRAW.Add(mapVV.FindKey(i),mapVV.FindFromIndex(i));
cout<<" on vve_"<<iV; aa = "vve_";
FUN_tool_draw(aa,mapVVsameGDRAW.FindKey(iV),iV);
}
for (i = 1;i <= mapVon1E.Extent();i++) {
Standard_Integer iE = mapVon1EdgeDRAW.Add(mapVon1E.FindKey(i),mapVon1E.FindFromIndex(i));
cout<<" on eed_"<<iE; aa = "eed_";
FUN_tool_draw(aa,mapVon1EdgeDRAW.FindFromIndex(iE),iE);
}
cout<<endl;
}
else if (res == UNCLOSEDW) {
cout<<" is unclosed "<<endl;
TCollection_AsciiString aa("w_");FUN_tool_draw(aa,W,iiwi);
}
cout<<endl;
} // FUN_AnalyzemapVon1EDRAW
#endif
//=======================================================================
//function : DetectUnclosedWire
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::DetectUnclosedWire(TopTools_IndexedDataMapOfShapeShape& mapVVsameG,
TopTools_IndexedDataMapOfShapeShape& mapVon1Edge)
{
// wire unclosed : has vertices of connexity == 1
// exception : a wire of one closed edge with only one vertex describing
// a face or a degenerated edge.
mapVVsameG.Clear();
mapVon1Edge.Clear();
// During the wire processing,
// * IF THE WIRE IS G-CLOSED,we fill up the maps :
// - <mapVVsameG> with vertices falling on same geometry
// - <mapVon1Edge> with (key = vertex,item = edge),
// the vertex is connected to only one unclosed,undegenerated edge.
// * Else,if it is unclosed,we delete it (or it`s hanging edges).
#ifdef DRAW
TopTools_IndexedDataMapOfShapeShape mapVon1EdgeDRAW,mapVVsameGDRAW;
Standard_Boolean trc = TopOpeBRepBuild_GettracePURGE();
if (trc) cout<<endl<<"* DetectUnclosedWire :"<<endl<<endl;
#endif
Standard_Integer iiwi = 0; // DEB
InitFace();
for (;MoreFace();NextFace()) {
InitWire();
for (;MoreWire();NextWire()) {
iiwi++;
Standard_Boolean isold = IsOldWire();
#ifdef DRAW
if ( trc && isold ) cout<<"wire "<<iiwi<<" is old wire => closed"<<endl;
#endif
if (isold) continue;
TopoDS_Compound cmp;BRep_Builder BB;BB.MakeCompound(cmp);
InitEdge();
for(;MoreEdge();NextEdge()) AddEdgeWire(Edge(),cmp);
TopoDS_Shape W = cmp;
// <mapVon1E> binds vertices of connexity 1 attached to one non-closed,non-degenerated edge.
TopTools_IndexedDataMapOfShapeShape mapVon1E;
FUN_DetectVerticesOn1Edge(W,mapVon1E);
TopTools_IndexedDataMapOfShapeShape mapVV;
Standard_Integer res = FUN_AnalyzemapVon1E(mapVon1E,mapVV);
#ifdef DRAW
FUN_AnalyzemapVon1EDRAW(res,mapVon1E,mapVV,W,iiwi,mapVon1EdgeDRAW,mapVVsameGDRAW);
#endif
if (res == ISVERTEX) {
continue;
}
else if (res == CLOSEDW) {
continue;
}
else if (res == GCLOSEDW) {
Standard_Integer i;
for (i = 1;i <= mapVV.Extent();i++) {
mapVVsameG.Add(mapVV.FindKey(i),mapVV.FindFromIndex(i));
}
for (i = 1;i <= mapVon1E.Extent();i++) {
mapVon1Edge.Add(mapVon1E.FindKey(i),mapVon1E.FindFromIndex(i));
}
}
else if (res == UNCLOSEDW) {
#ifdef RM_HANGING
// MSV Oct 4, 2001: remove hanging edges
TopTools_IndexedDataMapOfShapeListOfShape mapVE;
TopExp::MapShapesAndAncestors (W, TopAbs_VERTEX, TopAbs_EDGE, mapVE);
Standard_Integer nV = mapVon1E.Extent();
for (Standard_Integer i = 1; i <= nV; i++)
{
TopoDS_Vertex V = TopoDS::Vertex (mapVon1E.FindKey(i));
if (mapVV.Contains(V)) continue; // V is in same geometry pair
while (1)
{
const TopTools_ListOfShape &LE = mapVE.FindFromKey(V);
// get not yet processed edge, count the number of such edges
Standard_Integer nEdges = 0;
TopoDS_Edge Edge;
TColStd_ListOfInteger LOI;
TopTools_ListIteratorOfListOfShape itE (LE);
for (; itE.More() && nEdges <= 1; itE.Next())
{
const TopoDS_Edge &E = TopoDS::Edge (itE.Value());
Standard_Integer I = myBlockBuilder.Element(E);
if (!E.Closed() && myBlockBuilder.ElementIsValid(I))
{
TopoDS_Vertex Vf,Vl;
TopExp::Vertices (E, Vf, Vl);
LOI.Append(I);
// consider not small edges only
if (!Vf.IsSame(Vl))
{
Edge = E;
nEdges++;
}
}
}
if (nEdges != 1) break; // stop this chain
// remove edges from Block Builder
TColStd_ListIteratorOfListOfInteger itLOI (LOI);
for (; itLOI.More(); itLOI.Next())
myBlockBuilder.SetValid (itLOI.Value(), Standard_False);
// get other vertex
TopoDS_Vertex aV1, aV2, otherV;
TopExp::Vertices (Edge, aV1, aV2);
if (aV1.IsSame (V))
otherV = aV2;
else if (aV2.IsSame (V))
otherV = aV1;
if (otherV.IsNull()) break;
V = otherV;
}
}
#else
TopExp_Explorer ex;
for (ex.Init(W,TopAbs_EDGE);ex.More();ex.Next()) {
// for (TopExp_Explorer ex(W,TopAbs_EDGE);ex.More();ex.Next()) {
Standard_Integer I = myBlockBuilder.Element(ex.Current());
myBlockBuilder.SetValid(I,Standard_False);
}
#endif
}
} // MoreWire
} // MoreFace
} // DetectUnclosedWire
//=======================================================================
//function : CorrectGclosedWire
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::CorrectGclosedWire(const TopTools_IndexedDataMapOfShapeShape& mapVVref,
const TopTools_IndexedDataMapOfShapeShape& mapVon1Edge)
{
// prequesitory : edges described by <mapVon1Edge> are not closed,not degenerated
#ifdef DEB
Standard_Boolean trc = TopOpeBRepDS_GettraceSTRANGE();
if (TopOpeBRepBuild_GettracePURGE()) {
cout<<endl<<"* CorrectGclosedWire :"<<endl<<endl;
trc = Standard_True;
}
#endif
Standard_Integer nVV = mapVVref.Extent();
for (Standard_Integer i = 1;i <= nVV;i++) {
const TopoDS_Vertex& V = TopoDS::Vertex(mapVVref.FindKey(i));
const TopoDS_Vertex& Vref = TopoDS::Vertex(mapVVref.FindFromIndex(i));
if (V.IsSame(Vref)) continue;
TopoDS_Edge E = TopoDS::Edge(mapVon1Edge.FindFromKey(V));
Standard_Real paronE = BRep_Tool::Parameter(V,E);
BRep_Builder BB;E.Free(Standard_True);
BB.Remove(E,V);
TopoDS_Shape aLocalShape = Vref.Oriented(V.Orientation());
TopoDS_Vertex newVref = TopoDS::Vertex(aLocalShape);
// TopoDS_Vertex newVref = TopoDS::Vertex(Vref.Oriented(V.Orientation()));
BB.Add(E,newVref);
#ifdef DEB
Standard_Integer iV = i,iVref = mapVVref.FindIndex(Vref),iE = mapVon1Edge.FindIndex(V);
if (trc) cout << " replacing V "<<iV<<" with V "<<iVref<<" on edge "<<iE<<endl;
#endif
TopOpeBRepDS_BuildTool BT;
BT.Parameter(E,newVref,paronE);
}
}
//=======================================================================
//function : DetectPseudoInternalEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::DetectPseudoInternalEdge(TopTools_IndexedMapOfShape& MapE)
{
TopoDS_Compound cmp;BRep_Builder BB;BB.MakeCompound(cmp);
InitFace();
for (;MoreFace();NextFace()) {
InitWire();
for (;MoreWire();NextWire()) {
Standard_Boolean isold = IsOldWire(); if (isold) continue;
InitEdge();
for(;MoreEdge();NextEdge()) AddEdgeWire(Edge(),cmp);
} // MoreWire
} // MoreFace
TopTools_IndexedDataMapOfShapeListOfShape mapVOE;
TopExp::MapShapesAndAncestors(cmp,TopAbs_VERTEX,TopAbs_EDGE,mapVOE);
Standard_Integer nv = mapVOE.Extent();
MapE.Clear();
for (Standard_Integer i = 1; i <= nv; i++) {
const TopTools_ListOfShape& le = mapVOE.FindFromIndex(i);
Standard_Integer ne = le.Extent();
if (ne == 2) {
TopTools_ListIteratorOfListOfShape ile(le); const TopoDS_Shape& e1 = ile.Value();
ile.Next(); const TopoDS_Shape& e2 = ile.Value();
Standard_Boolean same = e1.IsSame(e2);
TopAbs_Orientation o1 = e1.Orientation();
TopAbs_Orientation o2 = e2.Orientation();
Standard_Boolean o1co2 = (o1 == TopAbs::Complement(o2));
if ( same && o1co2 ) {
MapE.Add(e1);
Standard_Integer ie1 = myBlockBuilder.Element(e1);
myBlockBuilder.SetValid(ie1,Standard_False);
Standard_Integer ie2 = myBlockBuilder.Element(e2);
myBlockBuilder.SetValid(ie2,Standard_False);
}
}
}
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_FaceBuilder::Face() const
{
return myFace;
}
//=======================================================================
//function : InitFace
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_FaceBuilder::InitFace()
{
Standard_Integer n = myFaceAreaBuilder.InitArea();
return n;
}
//=======================================================================
//function : MoreFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_FaceBuilder::MoreFace() const
{
Standard_Boolean b = myFaceAreaBuilder.MoreArea();
return b;
}
//=======================================================================
//function : NextFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::NextFace()
{
myFaceAreaBuilder.NextArea();
}
//=======================================================================
//function : InitWire
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_FaceBuilder::InitWire()
{
Standard_Integer n = myFaceAreaBuilder.InitLoop();
return n;
}
//=======================================================================
//function : MoreWire
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_FaceBuilder::MoreWire() const
{
Standard_Boolean b = myFaceAreaBuilder.MoreLoop();
return b;
}
//=======================================================================
//function : NextWire
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::NextWire()
{
myFaceAreaBuilder.NextLoop();
}
//=======================================================================
//function : IsOldWire
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_FaceBuilder::IsOldWire() const
{
const Handle(TopOpeBRepBuild_Loop)& L = myFaceAreaBuilder.Loop();
Standard_Boolean b = L->IsShape();
return b;
}
//=======================================================================
//function : OldWire
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_FaceBuilder::OldWire() const
{
const Handle(TopOpeBRepBuild_Loop)& L = myFaceAreaBuilder.Loop();
const TopoDS_Shape& B = L->Shape();
return B;
}
//=======================================================================
//function : FindNextValidElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::FindNextValidElement()
{
// prerequisites : myBlockIterator.Initialize
myFaceAreaBuilder.Loop();
Standard_Boolean found = Standard_False;
while ( myBlockIterator.More()) {
const Standard_Integer i = myBlockIterator.Value();
found = myBlockBuilder.ElementIsValid(i);
if (found) break;
else myBlockIterator.Next();
}
}
//=======================================================================
//function : InitEdge
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_FaceBuilder::InitEdge()
{
const Handle(TopOpeBRepBuild_Loop)& L = myFaceAreaBuilder.Loop();
if ( L->IsShape() )
Standard_DomainError::Raise("TopOpeBRepBuild_FaceBuilder:InitEdge");
else {
myBlockIterator = L->BlockIterator();
myBlockIterator.Initialize();
FindNextValidElement();
}
Standard_Integer n = myBlockIterator.Extent();
return n;
}
//=======================================================================
//function : MoreEdge
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_FaceBuilder::MoreEdge() const
{
Standard_Boolean b = myBlockIterator.More();
return b;
}
//=======================================================================
//function : NextEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::NextEdge()
{
myBlockIterator.Next();
FindNextValidElement();
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_FaceBuilder::Edge() const
{
if (!myBlockIterator.More()) Standard_Failure::Raise("OutOfRange");
const Standard_Integer i = myBlockIterator.Value();
Standard_Boolean isvalid = myBlockBuilder.ElementIsValid(i);
if (!isvalid) Standard_Failure::Raise("Edge not Valid");
const TopoDS_Shape& E = myBlockBuilder.Element(i);
return E;
}
//=======================================================================
//function : EdgeConnexity
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_FaceBuilder::EdgeConnexity(const TopoDS_Shape& /*E*/) const
{
#ifdef DEB
Standard_ProgramError::Raise("FaceBuilder::EdgeConnexity management disactivated");
#endif
return 0;
// Standard_Boolean inmosi = myMOSI.IsBound(E);
// Standard_Integer nmosi = (inmosi) ? myMOSI.Find(E) : 0;
// return nmosi;
}
//=======================================================================
//function : AddEdgeWire
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_FaceBuilder::AddEdgeWire(const TopoDS_Shape& E,TopoDS_Shape& W) const
{
Standard_Integer nadd = 0;
BRep_Builder BB;
BB.Add(W,E);nadd++;
// Standard_Integer nmosi = EdgeConnexity(E);
// Standard_Boolean addEC = (nmosi == 1);
// if (addEC) {
// TopAbs_Orientation oe = E.Orientation();
// TopAbs_Orientation oc = TopAbs::Complement(oe);
// TopoDS_Shape EC = E.Oriented(oc);
// BB.Add(W,EC);nadd++;
// }
return nadd;
}
//=======================================================================
//function : MakeLoops
//purpose :
//=======================================================================
void TopOpeBRepBuild_FaceBuilder::MakeLoops(TopOpeBRepBuild_ShapeSet& SS)
{
TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
TopOpeBRepBuild_ListOfLoop& LL = myLoopSet.ChangeListOfLoop();
// Build blocks on elements of SS
BB.MakeBlock(SS);
// make list of loop (LL) of the LoopSet
// - on shapes of the ShapeSet (SS)
// - on blocks of the BlockBuilder (BB)
// Add shapes of SS as shape loops
LL.Clear();
for(SS.InitShapes();SS.MoreShapes();SS.NextShape()) {
const TopoDS_Shape& S = SS.Shape();
Handle(TopOpeBRepBuild_Loop) ShapeLoop = new TopOpeBRepBuild_Loop(S);
LL.Append(ShapeLoop);
}
// Add blocks of BB as block loops
for (BB.InitBlock();BB.MoreBlock();BB.NextBlock()) {
TopOpeBRepBuild_BlockIterator BI = BB.BlockIterator();
Handle(TopOpeBRepBuild_Loop) BlockLoop = new TopOpeBRepBuild_Loop(BI);
LL.Append(BlockLoop);
}
}

View File

@@ -0,0 +1,179 @@
// File: TopOpeBRepBuild_Builder.cxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#ifndef _TopOpeBRepBuild_Fill_HeaderFile
#define _TopOpeBRepBuild_Fill_HeaderFile
//=======================================================================
//function : FillShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::FillShape(const TopoDS_Shape& S1,
const TopAbs_State ToBuild1,
const TopTools_ListOfShape& LS2,
const TopAbs_State ToBuild2,
TopOpeBRepBuild_ShapeSet& aSet,
const Standard_Boolean In_RevOri)
{
Standard_Boolean RevOri = In_RevOri;
TopAbs_ShapeEnum t = S1.ShapeType();
#ifdef DEB
TopAbs_ShapeEnum t1,t11;
#else
TopAbs_ShapeEnum t1=TopAbs_COMPOUND,t11=TopAbs_COMPOUND;
#endif
if (t == TopAbs_FACE ) {
t1 = TopAbs_WIRE;
t11 = TopAbs_EDGE;
}
else if (t == TopAbs_SOLID || t == TopAbs_SHELL) {
t1 = TopAbs_SHELL;
t11 = TopAbs_FACE;
}
// if the shape S1 is a SameDomain one, get its orientation compared
// with the shape taken as reference for all of the SameDomain shape of S1.
Standard_Boolean hsd = myDataStructure->HasSameDomain(S1);
if (hsd) {
TopOpeBRepDS_Config ssc = myDataStructure->SameDomainOrientation(S1);
if ( ssc == TopOpeBRepDS_DIFFORIENTED ) {
RevOri = ! RevOri;
#ifdef DEB
// Standard_Integer iFace = myDataStructure->Shape(S1);
// cout<<endl<<"********** ";
// cout<<"retournement d'orientation de ";TopAbs::Print(t,cout);
// cout<<" "<<iFace<<endl;
#endif
}
}
// work on a FORWARD shape <aShape>
TopoDS_Shape aShape = S1;
myBuildTool.Orientation(aShape,TopAbs_FORWARD);
TopoDS_Shape aSubShape;
TopAbs_Orientation newori;
// Explore the SubShapes of type <t1>
for (TopOpeBRepTool_ShapeExplorer ex1(aShape,t1); ex1.More(); ex1.Next()) {
aSubShape = ex1.Current();
if ( ! myDataStructure->HasShape(aSubShape) ) {
// SubShape is not in DS : classify it with shapes of LS2
Standard_Boolean keep = KeepShape(aSubShape,LS2,ToBuild1);
if (keep) {
newori = Orient(myBuildTool.Orientation(aSubShape),RevOri);
myBuildTool.Orientation(aSubShape,newori);
aSet.AddShape(aSubShape);
}
}
else {
// SubShape has geometry : split the <t11> SubShapes of the SubShape
TopOpeBRepTool_ShapeExplorer ex11(aSubShape,t11);
SplitShapes(ex11,ToBuild1,ToBuild2,aSet,RevOri);
}
} // exploration ot SubShapes of type <t1> of shape <S1>
} // FillShape
//=======================================================================
//function : FillFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::FillFace(const TopoDS_Shape& F1,
const TopAbs_State ToBuild1,
const TopTools_ListOfShape& LF2,
const TopAbs_State ToBuild2,
TopOpeBRepBuild_WireEdgeSet& WES,
const Standard_Boolean RevOri)
{
#ifdef DEB
Standard_Boolean tSPF = TopOpeBRepBuild_GettraceSPF();
// Standard_Integer iFace = myDataStructure->Shape(F1);
if(tSPF){cout<<endl;}
if(tSPF){GdumpSHASTA(F1,ToBuild1,"=-= FillFace ");}
#endif
myListOfFace = LF2;
FillShape(F1,ToBuild1,LF2,ToBuild2,WES,RevOri);
myListOfFace.Clear();
} // FillFace
//=======================================================================
//function : FillSolid
//purpose : load shells and faces from the solid in the ShellFaceSet <aSet>
//=======================================================================
void TopOpeBRepBuild_Builder::FillSolid(const TopoDS_Shape& S1,
const TopAbs_State ToBuild1,
const TopTools_ListOfShape& LS2,
const TopAbs_State ToBuild2,
TopOpeBRepBuild_ShapeSet& aSet,
const Standard_Boolean RevOri)
{
FillShape(S1,ToBuild1,LS2,ToBuild2,aSet,RevOri);
} // FillSolid
//=======================================================================
//function : FillVertexSet
//purpose : private
//=======================================================================
void TopOpeBRepBuild_Builder::FillVertexSet(TopOpeBRepDS_PointIterator& IT,
const TopAbs_State ToBuild,
TopOpeBRepBuild_PaveSet& PVS) const
{
for (; IT.More(); IT.Next()) {
FillVertexSetOnValue(IT,ToBuild,PVS);
}
}
//=======================================================================
//function : FillVertexSetOnValue
//purpose : private
//=======================================================================
void TopOpeBRepBuild_Builder::FillVertexSetOnValue
(const TopOpeBRepDS_PointIterator& IT,
const TopAbs_State ToBuild,
TopOpeBRepBuild_PaveSet& PVS) const
{
TopoDS_Shape V;
// ind = index of new point or existing vertex
Standard_Integer ind = IT.Current();
Standard_Boolean ispoint = IT.IsPoint();
//**!
//if (ispoint) V = NewVertex(ind);
if (ispoint && ind <= myDataStructure->NbPoints()) V = NewVertex(ind);
//**!
else V = myDataStructure->Shape(ind);
Standard_Real par = IT.Parameter();
TopAbs_Orientation ori = IT.Orientation(ToBuild);
Standard_Boolean keep = Standard_True;
// if (ori==TopAbs_EXTERNAL || ori==TopAbs_INTERNAL) keep = Standard_False;
if ( keep ) {
myBuildTool.Orientation(V,ori);
Handle(TopOpeBRepBuild_Pave) PV = new TopOpeBRepBuild_Pave(V,par,Standard_False);
PVS.Append(PV);
}
#ifdef DEB
const TopoDS_Edge& EDEB = PVS.Edge();
Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EDEB,iE);
if (tSPS) {
if (keep) cout<<"+"; else cout<<"-";
if (ispoint) cout<<" PDS "; else cout<<" VDS ";
cout<<ind<<" : "; GdumpORIPARPNT(ori,par,BRep_Tool::Pnt(TopoDS::Vertex(V)));
cout<<endl;
}
#endif
}
//#ifndef _TopOpeBRepBuild_Fill_HeaderFile
#endif

View File

@@ -0,0 +1,133 @@
-- File: TopOpeBRepBuild_FuseFace.cdl
-- Created: Tue Jul 28 16:36:19 1998
-- Author: LECLERE Florence
-- <flo@partox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class FuseFace from TopOpeBRepBuild
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
DataMapOfShapeListOfShape from TopTools,
ListOfShape from TopTools
is
Create
returns FuseFace from TopOpeBRepBuild;
---C++: inline
--
Create(LIF : ListOfShape from TopTools;
LRF : ListOfShape from TopTools;
CXM : Integer from Standard)
---C++: inline
--
returns FuseFace from TopOpeBRepBuild;
Init(me: in out; LIF : ListOfShape from TopTools;
LRF : ListOfShape from TopTools;
CXM : Integer from Standard)
is static;
PerformFace(me: in out)
is static;
PerformEdge(me: in out)
is static;
ClearEdge(me: in out)
is static;
ClearVertex(me: in out)
is static;
IsDone(me)
returns Boolean from Standard
---C++: inline
is static;
IsModified(me)
returns Boolean from Standard
---C++: inline
is static;
LFuseFace(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LInternEdge(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LExternEdge(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LModifEdge(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LInternVertex(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LExternVertex(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
LModifVertex(me)
returns ListOfShape from TopTools
---C++: return const&
is static;
fields
myLIF : ListOfShape from TopTools;
myLRF : ListOfShape from TopTools;
myLFF : ListOfShape from TopTools;
myLIE : ListOfShape from TopTools is protected;
myLEE : ListOfShape from TopTools is protected;
myLME : ListOfShape from TopTools is protected;
myLIV : ListOfShape from TopTools is protected;
myLEV : ListOfShape from TopTools is protected;
myLMV : ListOfShape from TopTools is protected;
myInternal : Boolean from Standard;
myModified : Boolean from Standard;
myDone : Boolean from Standard;
end FuseFace;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
// File: TopOpeBRepBuild_FuseFace.lxx
// Created: Thu Jul 30 14:06:57 1998
// Author: LECLERE Florence
// <flo@partox.paris1.matra-dtv.fr>
#include <StdFail_NotDone.hxx>
//=======================================================================
//function : TopOpeBRepBuild_FuseFace
//purpose :
//=======================================================================
inline TopOpeBRepBuild_FuseFace::TopOpeBRepBuild_FuseFace ():myDone(Standard_False)
{}
//=======================================================================
//function : TopOpeBRepBuild_FuseFace
//purpose :
//=======================================================================
inline TopOpeBRepBuild_FuseFace::TopOpeBRepBuild_FuseFace (
const TopTools_ListOfShape& LIF,
const TopTools_ListOfShape& LRF,
const Standard_Integer CXM)
{
Init(LIF,LRF,CXM);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean TopOpeBRepBuild_FuseFace::IsDone() const
{
return myDone;
}
//=======================================================================
//function : IsModified
//purpose :
//=======================================================================
inline Standard_Boolean TopOpeBRepBuild_FuseFace::IsModified() const
{
return myModified;
}
//=======================================================================
//function : ListOfFusionnedFaces
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LFuseFace() const
{
return myLFF;
}
//=======================================================================
//function : ListOfInternalEdges
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LInternEdge() const
{
return myLIE;
}
//=======================================================================
//function : ListOfExternalEdges
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LExternEdge() const
{
return myLEE;
}
//=======================================================================
//function : ListOfModifiedEdges
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LModifEdge() const
{
return myLME;
}
//=======================================================================
//function : ListOfInternalVertex
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LInternVertex() const
{
return myLIV;
}
//=======================================================================
//function : ListOfExternalVertex
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LExternVertex() const
{
return myLEV;
}
//=======================================================================
//function : ListOfModifiedVertex
//purpose :
//=======================================================================
inline const TopTools_ListOfShape& TopOpeBRepBuild_FuseFace::LModifVertex() const
{
return myLMV;
}

View File

@@ -0,0 +1,33 @@
-- File: TopOpeBRepBuild_GIter.cdl
-- Created: Tue Feb 13 17:47:51 1996
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1996
class GIter from TopOpeBRepBuild
uses
State from TopAbs,
GTopo from TopOpeBRepBuild
is
Create returns GIter;
Create(G : GTopo) returns GIter;
Find(me : in out) is static private;
Init(me : in out) is static;
Init(me : in out; G : GTopo) is static;
More(me) returns Boolean is static;
Next(me : in out) is static;
Current(me; s1,s2 : in out State from TopAbs) is static;
Dump(me; OS : in out OStream) is static;
fields
myII : Integer;
mypG : Address; -- (GTopo*)
end GIter;

View File

@@ -0,0 +1,72 @@
// File: TopOpeBRepBuild_TopOpeBRepBuild_GIter.cxx
// Created: Tue Feb 13 17:50:18 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_GIter.ixx>
#include <TopOpeBRepBuild_GTopo.hxx>
#define MYGTOPO (*((TopOpeBRepBuild_GTopo*)mypG))
TopOpeBRepBuild_GIter::TopOpeBRepBuild_GIter() : myII(0),mypG(NULL)
{
}
TopOpeBRepBuild_GIter::TopOpeBRepBuild_GIter(const TopOpeBRepBuild_GTopo& G) :
myII(0),mypG(NULL)
{
Init(G);
}
void TopOpeBRepBuild_GIter::Find()
{
while ( myII <= 8 ) {
Standard_Boolean b = MYGTOPO.Value(myII);
if (b) break;
myII++;
}
}
void TopOpeBRepBuild_GIter::Init()
{
myII = 0;
Find();
}
void TopOpeBRepBuild_GIter::Init(const TopOpeBRepBuild_GTopo& G)
{
mypG = (Standard_Address)&G;
Init();
}
Standard_Boolean TopOpeBRepBuild_GIter::More() const
{
if (myII <= 8) {
Standard_Boolean b = MYGTOPO.Value(myII);
return b;
}
else
return Standard_False;
}
void TopOpeBRepBuild_GIter::Next()
{
myII++;
Find();
}
void TopOpeBRepBuild_GIter::Current(TopAbs_State& s1, TopAbs_State& s2) const
{
if ( !More() ) return;
Standard_Integer i1,i2;
MYGTOPO.Index(myII,i1,i2);
s1 = MYGTOPO.GState(i1);
s2 = MYGTOPO.GState(i2);
}
void TopOpeBRepBuild_GIter::Dump(Standard_OStream& OS) const
{
if ( !More()) return;
TopAbs_State s1,s2; Current(s1,s2);
Standard_Boolean b = MYGTOPO.Value(s1,s2);
TopOpeBRepBuild_GTopo::DumpSSB(OS,s1,s2,b); OS<<endl;
}

View File

@@ -0,0 +1,31 @@
-- File: TopOpeBRepBuild_GTool.cdl
-- Created: Tue Feb 13 17:36:03 1996
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1996
class GTool from TopOpeBRepBuild
uses
GTopo from TopOpeBRepBuild,
ShapeEnum from TopAbs,
OStream from Standard
is
GFusUnsh(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GFusSame(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GFusDiff(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GCutUnsh(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GCutSame(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GCutDiff(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GComUnsh(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GComSame(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
GComDiff(myclass; s1,s2 : ShapeEnum from TopAbs) returns GTopo;
Dump(myclass; OS : in out OStream from Standard);
end GTool;

View File

@@ -0,0 +1,170 @@
// File: TopOpeBRepBuild_GTool.cxx
// Created: Tue Feb 13 17:40:02 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_GTool.ixx>
#include <TopOpeBRepBuild_GIter.hxx>
//=======================================================================
//function : GFusUnsh
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GFusUnsh
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,0,0,
0,0,1,
0,1,0,
t1,t2,
TopOpeBRepDS_UNSHGEOMETRY,TopOpeBRepDS_UNSHGEOMETRY);
}
//=======================================================================
//function : GFusSame
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GFusSame
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,0,0,
0,1,1,
0,1,0,
t1,t2,
TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : GFusDiff
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GFusDiff
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,0,0,
0,0,1,
0,1,0,
t1,t2,
TopOpeBRepDS_DIFFORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : GCutUnsh
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GCutUnsh
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
0,0,1,
0,0,0,
t1,t2,
TopOpeBRepDS_UNSHGEOMETRY,TopOpeBRepDS_UNSHGEOMETRY);
}
//=======================================================================
//function : GCutSame
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GCutSame
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
0,0,1,
0,0,0,
t1,t2,
TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : GCutDiff
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GCutDiff
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
0,1,1,
0,0,0,
t1,t2,
TopOpeBRepDS_DIFFORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : GComUnsh
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GComUnsh
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
1,0,0,
0,0,0,
t1,t2,
TopOpeBRepDS_UNSHGEOMETRY,TopOpeBRepDS_UNSHGEOMETRY);
}
//=======================================================================
//function : GComSame
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GComSame
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
1,1,0,
0,0,0,
t1,t2,
TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : GComDiff
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTool::GComDiff
(const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2)
{
return TopOpeBRepBuild_GTopo(0,1,0,
1,0,0,
0,0,0,
t1,t2,
TopOpeBRepDS_DIFFORIENTED,TopOpeBRepDS_SAMEORIENTED);
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTool::Dump(Standard_OStream& OS)
{
TopOpeBRepBuild_GIter gi;
TopOpeBRepBuild_GTopo g;
g = TopOpeBRepBuild_GTool::GFusUnsh(TopAbs_FACE,TopAbs_FACE);
g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) gi.Dump(OS); OS<<endl;
g = TopOpeBRepBuild_GTool::GFusSame(TopAbs_FACE,TopAbs_FACE);
g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) gi.Dump(OS); OS<<endl;
g = TopOpeBRepBuild_GTool::GFusDiff(TopAbs_FACE,TopAbs_FACE);
g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) gi.Dump(OS); OS<<endl;
g = TopOpeBRepBuild_GTool::GCutDiff(TopAbs_FACE,TopAbs_EDGE);
g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) gi.Dump(OS); OS<<endl;
g = g.CopyPermuted();
g.Dump(OS); for (gi.Init(g); gi.More(); gi.Next()) gi.Dump(OS); OS<<endl;
}

View File

@@ -0,0 +1,69 @@
-- File: TopOpeBRepBuild_GTopo.cdl
-- Created: Tue Feb 13 16:13:56 1996
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1996
class GTopo from TopOpeBRepBuild
uses
ShapeEnum from TopAbs,
State from TopAbs,
Config from TopOpeBRepDS
is
Create returns GTopo;
Create(II,IN,IO,NI,NN,NO,OI,ON,OO : Integer;
t1,t2 : ShapeEnum from TopAbs;
C1,C2 : Config from TopOpeBRepDS) returns GTopo;
Reset(me : in out) is static;
Set(me : in out; II,IN,IO,NI,NN,NO,OI,ON,OO : Boolean) is static;
Type(me; t1,t2 : out ShapeEnum from TopAbs) is static;
ChangeType(me : in out; t1,t2 : ShapeEnum from TopAbs) is static;
Config1(me) returns Config from TopOpeBRepDS is static;
Config2(me) returns Config from TopOpeBRepDS is static;
ChangeConfig(me : in out; C1,C2 : Config from TopOpeBRepDS) is static;
Value(me; s1,s2 : State from TopAbs) returns Boolean is static;
Value(me; I1,I2 : Integer) returns Boolean is static;
Value(me; II : Integer) returns Boolean is static;
ChangeValue(me : in out; i1,i2 : Integer; b : Boolean) is static;
ChangeValue(me : in out; s1,s2 : State from TopAbs; b : Boolean) is static;
GIndex(me; S : State from TopAbs) returns Integer is static;
GState(me; I : Integer) returns State from TopAbs is static;
Index(me; II : Integer; i1,i2 : in out Integer) is static;
DumpVal(me; OS : in out OStream; s1,s2 : State from TopAbs) is static;
DumpType(me; OS : in out OStream) is static;
DumpSSB(myclass; OS : in out OStream; s1,s2:State from TopAbs; b : Boolean);
Dump(me; OS : in out OStream; s : Address = NULL) is virtual;
StatesON(me; s1,s2 : out State from TopAbs) is static;
IsToReverse1(me) returns Boolean is static;
IsToReverse2(me) returns Boolean is static;
SetReverse(me : in out; rev : Boolean) is static;
Reverse(me) returns Boolean is static;
CopyPermuted(me) returns GTopo is static;
fields
mycases : Boolean from Standard[3,3];
-- IN ON OUT
-- IN ii in io
-- ON ni nn no
-- OUT oi on oo
myt1,myt2 : ShapeEnum from TopAbs;
myConfig1,myConfig2 : Config from TopOpeBRepDS;
myReverseForce : Boolean;
myReverseValue : Boolean;
end GTopo;

View File

@@ -0,0 +1,420 @@
// File: TopOpeBRepBuild_GTopo.cxx
// Created: Tue Feb 13 16:35:16 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TCollection_AsciiString.hxx>
#include <TopOpeBRepBuild_GTopo.ixx>
#include <Standard_ProgramError.hxx>
#include <TopOpeBRepDS.hxx>
#include <TopAbs.hxx>
//=======================================================================
//function : TopOpeBRepBuild_GTopo
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo::TopOpeBRepBuild_GTopo()
{
Reset();
}
//=======================================================================
//function : TopOpeBRepBuild_GTopo
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo::TopOpeBRepBuild_GTopo
(const Standard_Integer ii,const Standard_Integer in,const Standard_Integer io,
const Standard_Integer ni,const Standard_Integer nn,const Standard_Integer no,
const Standard_Integer oi,const Standard_Integer on,const Standard_Integer oo,
const TopAbs_ShapeEnum t1, const TopAbs_ShapeEnum t2,
const TopOpeBRepDS_Config C1, const TopOpeBRepDS_Config C2)
{
Reset();
Set((Standard_Boolean)ii,(Standard_Boolean)in,(Standard_Boolean)io,
(Standard_Boolean)ni,(Standard_Boolean)nn,(Standard_Boolean)no,
(Standard_Boolean)oi,(Standard_Boolean)on,(Standard_Boolean)oo);
myt1 = t1;
myt2 = t2;
myConfig1 = C1;
myConfig2 = C2;
}
//=======================================================================
//function : Reset
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::Reset()
{
myt1 = myt2 = TopAbs_SHAPE;
mycases[0][0] = mycases[0][1] = mycases[0][2] =
mycases[1][0] = mycases[1][1] = mycases[1][2] =
mycases[2][0] = mycases[2][1] = mycases[2][2] = Standard_False;
myConfig1 = myConfig2 = TopOpeBRepDS_UNSHGEOMETRY;
myReverseForce = myReverseValue = Standard_False;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::Set
(const Standard_Boolean ii,const Standard_Boolean in,const Standard_Boolean io,
const Standard_Boolean ni,const Standard_Boolean nn,const Standard_Boolean no,
const Standard_Boolean oi,const Standard_Boolean on,const Standard_Boolean oo)
{
mycases[0][0] = ii; mycases[0][1] = in; mycases[0][2] = io;
mycases[1][0] = ni; mycases[1][1] = nn; mycases[1][2] = no;
mycases[2][0] = oi; mycases[2][1] = on; mycases[2][2] = oo;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::Type(TopAbs_ShapeEnum& t1,
TopAbs_ShapeEnum& t2) const
{
t1 = myt1;
t2 = myt2;
}
//=======================================================================
//function : ChangeType
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::ChangeType(const TopAbs_ShapeEnum t1,
const TopAbs_ShapeEnum t2)
{
myt1 = t1;
myt2 = t2;
}
//=======================================================================
//function : Config1
//purpose :
//=======================================================================
TopOpeBRepDS_Config TopOpeBRepBuild_GTopo::Config1() const
{
return myConfig1;
}
//=======================================================================
//function : Config2
//purpose :
//=======================================================================
TopOpeBRepDS_Config TopOpeBRepBuild_GTopo::Config2() const
{
return myConfig2;
}
//=======================================================================
//function : ChangeConfig
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::ChangeConfig(const TopOpeBRepDS_Config C1,
const TopOpeBRepDS_Config C2)
{
myConfig1 = C1;
myConfig2 = C2;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::Value(const Standard_Integer i1,
const Standard_Integer i2) const
{
Standard_Boolean b = mycases[i1][i2];
return b;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::Value(const TopAbs_State s1,
const TopAbs_State s2) const
{
Standard_Integer i1 = GIndex(s1);
Standard_Integer i2 = GIndex(s2);
Standard_Boolean b = mycases[i1][i2];
return b;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::Value(const Standard_Integer II) const
{
Standard_Integer i1,i2; Index(II,i1,i2);
Standard_Boolean b = Value(i1,i2);
return b;
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::ChangeValue(const Standard_Integer i1,
const Standard_Integer i2,
const Standard_Boolean b)
{
mycases[i1][i2] = b;
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::ChangeValue(const TopAbs_State s1,
const TopAbs_State s2,
const Standard_Boolean b)
{
Standard_Integer i1 = GIndex(s1);
Standard_Integer i2 = GIndex(s2);
mycases[i1][i2] = b;
}
//=======================================================================
//function : GIndex
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_GTopo::GIndex(const TopAbs_State s) const
{
if (s == TopAbs_IN ) return 0;
else if (s == TopAbs_ON ) return 1;
else if (s == TopAbs_OUT) return 2;
else Standard_ProgramError::Raise("GIndex : bad input");
return 0;
}
//=======================================================================
//function : GState
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_GTopo::GState(const Standard_Integer i) const
{
if (i == 0) return TopAbs_IN;
else if (i == 1) return TopAbs_ON;
else if (i == 2) return TopAbs_OUT;
else Standard_ProgramError::Raise("GState : bad input");
return TopAbs_UNKNOWN;
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::Index(const Standard_Integer II,
Standard_Integer& i1,
Standard_Integer& i2) const
{
switch (II) {
case 0 : i1 = 0; i2 = 0; break;
case 1 : i1 = 0; i2 = 1; break;
case 2 : i1 = 0; i2 = 2; break;
case 3 : i1 = 1; i2 = 0; break;
case 4 : i1 = 1; i2 = 1; break;
case 5 : i1 = 1; i2 = 2; break;
case 6 : i1 = 2; i2 = 0; break;
case 7 : i1 = 2; i2 = 1; break;
case 8 : i1 = 2; i2 = 2; break;
}
}
//=======================================================================
//function : DumpVal
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::DumpVal(Standard_OStream& OS,
const TopAbs_State s1,
const TopAbs_State s2) const
{
OS<<Value(s1,s2);
}
//=======================================================================
//function : DumpType
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::DumpType(Standard_OStream& OS) const
{
TopAbs::Print(myt1,OS); OS<<"/"; TopAbs::Print(myt2,OS);
}
//=======================================================================
//function : DumpSSB
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::DumpSSB(Standard_OStream& OS,
const TopAbs_State s1,
const TopAbs_State s2,
const Standard_Boolean b)
{
TopAbs::Print(s1,OS); OS<<" "; TopAbs::Print(s2,OS); OS<<" : "<<b;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::Dump(Standard_OStream& OS,
const Standard_Address a) const
{
char* s = (char*)a;
DumpType(OS);
OS<<" "; TopOpeBRepDS::Print(myConfig1,OS);
OS<<" "; TopOpeBRepDS::Print(myConfig2,OS);
OS<<endl;
if (myReverseForce) OS<<"reverse value : "<<myReverseValue<<endl;
if(s) OS<<s; OS<<"\\ I N O";
OS<<endl;
if(s) OS<<s; OS<<"I ";
DumpVal(OS,TopAbs_IN,TopAbs_IN); OS<<" ";
DumpVal(OS,TopAbs_IN,TopAbs_ON); OS<<" ";
DumpVal(OS,TopAbs_IN,TopAbs_OUT); OS<<endl;
if(s) OS<<s; OS<<"N ";
DumpVal(OS,TopAbs_ON,TopAbs_IN); OS<<" ";
DumpVal(OS,TopAbs_ON,TopAbs_ON); OS<<" ";
DumpVal(OS,TopAbs_ON,TopAbs_OUT); OS<<endl;
if(s) OS<<s; OS<<"O ";
DumpVal(OS,TopAbs_OUT,TopAbs_IN); OS<<" ";
DumpVal(OS,TopAbs_OUT,TopAbs_ON); OS<<" ";
DumpVal(OS,TopAbs_OUT,TopAbs_OUT); OS<<endl;
}
//=======================================================================
//function : States
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::StatesON(TopAbs_State& s1,
TopAbs_State& s2) const
{
s1 = TopAbs_UNKNOWN;
if ( Value(TopAbs_ON,TopAbs_IN) ) s1 = TopAbs_IN;
else if ( Value(TopAbs_ON,TopAbs_OUT)) s1 = TopAbs_OUT;
s2 = TopAbs_UNKNOWN;
if ( Value(TopAbs_IN,TopAbs_ON) ) s2 = TopAbs_IN;
else if ( Value(TopAbs_OUT,TopAbs_ON)) s2 = TopAbs_OUT;
if ( s1 == TopAbs_UNKNOWN || s2 == TopAbs_UNKNOWN ) {
Standard_ProgramError::Raise("Gtopo : StatesON incorrect");
}
}
//=======================================================================
//function : IsToReverse1
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::IsToReverse1() const
{
if (myReverseForce) {
return myReverseValue;
}
else {
TopAbs_State s1,s2;StatesON(s1,s2);
Standard_Boolean IsToRev;
if (s1 == TopAbs_IN && s2 == TopAbs_IN) IsToRev = Standard_False;
else IsToRev = (s1 == TopAbs_IN);
return IsToRev;
}
Standard_ProgramError::Raise("GTopo::IsToReverse1");
return Standard_False; // dummy
}
//=======================================================================
//function : IsToReverse2
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::IsToReverse2() const
{
if (myReverseForce) {
return myReverseValue;
}
else {
TopAbs_State s1,s2;
StatesON(s1,s2);
Standard_Boolean IsToRev;
if (s1 == TopAbs_IN && s2 == TopAbs_IN) IsToRev = Standard_False;
else IsToRev = (s2 == TopAbs_IN);
return IsToRev;
}
Standard_ProgramError::Raise("GTopo::IsToReverse2");
return Standard_False; // dummy
}
//=======================================================================
//function : SetReverse
//purpose :
//=======================================================================
void TopOpeBRepBuild_GTopo::SetReverse(const Standard_Boolean rev)
{
myReverseForce = Standard_True;
myReverseValue = rev;
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_GTopo::Reverse() const
{
if (myReverseForce) return myReverseValue;
Standard_ProgramError::Raise("GTopo::ReverseValue undefined");
return Standard_False; // dummy
}
//=======================================================================
//function : CopyPermuted
//purpose :
//=======================================================================
TopOpeBRepBuild_GTopo TopOpeBRepBuild_GTopo::CopyPermuted() const
{
TopOpeBRepBuild_GTopo g;
g.ChangeType(myt2,myt1);
g.ChangeConfig(myConfig2,myConfig1);
Standard_Integer i,j;
for (i=0; i<3; i++) for (j=0; j<3; j++) g.ChangeValue(j,i,Value(i,j));
if (myReverseForce) g.SetReverse(myReverseValue);
return g;
}

View File

@@ -0,0 +1,375 @@
// file: TopOpeBRepBuild_Grid.cxx
// Created: Thu Mar 7 10:49:33 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextSPEON();
#endif
//=======================================================================
//function : GToSplit
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GToSplit(const TopoDS_Shape& S,const TopAbs_State TB) const
{
Standard_Boolean issplit = IsSplit(S,TB);
Standard_Boolean facshap = myDataStructure->HasShape(S) && (S.ShapeType() == TopAbs_FACE);
Standard_Boolean hasgeom = myDataStructure->HasGeometry(S);
Standard_Boolean hassame = myDataStructure->HasSameDomain(S);
Standard_Boolean tosplit = (!issplit) && (facshap || hasgeom || hassame);
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
if (tSPS) {
cout<<"GToSplit ";GdumpSHA(S);cout<<" ";TopAbs::Print(TB,cout);
cout<<" "<<tosplit<<" : "<<"!issplit "<<(!issplit);
cout<<" && (facshap || hasgeom || hassame) ";
cout<<"("<<facshap<<" || "<<hasgeom<<" || "<<hassame<<")"<<endl;
cout.flush();
}
#endif
#ifdef DEB
if (TopOpeBRepBuild_GetcontextSPEON()) { //CONTEXT
tSPS = Standard_True; //CONTEXT
Standard_Boolean hasON = Standard_False; //CONTEXT
Standard_Boolean isE = (S.ShapeType() == TopAbs_EDGE); //CONTEXT
if (isE) { //CONTEXT
const TopoDS_Edge& E = TopoDS::Edge(S); //CONTEXT
Standard_Boolean issE = myDataStructure->DS().IsSectionEdge(E); //CONTEXT
if (issE) { //CONTEXT
Standard_Boolean issplitON = IsSplit(E,TopAbs_ON); //CONTEXT
if (issplitON) { //CONTEXT
Standard_Integer n = Splits(E,TopAbs_ON).Extent(); //CONTEXT
hasON = (n>0); //CONTEXT
} //CONTEXT
} //CONTEXT
} //CONTEXT
Standard_Boolean tosplitH = tosplit || hasON; //CONTEXT
if(tSPS){cout<<"GToSplit context SPEON";} //CONTEXT
if(tSPS){cout<<" "<<tosplitH<<" : "<<"tosplit "<<tosplit;} //CONTEXT
if(tSPS){cout<<" || hasON "<<hasON<<endl;} //CONTEXT
} //CONTEXT
#endif
return tosplit;
} // GToSplit
//=======================================================================
//function : GToMerge
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GToMerge(const TopoDS_Shape& S) const
{
TopAbs_State TB = TopAbs_IN;
Standard_Boolean ismerged = IsMerged(S,TB);
Standard_Boolean hassame = myDataStructure->HasSameDomain(S);
Standard_Boolean tomerge = (!ismerged && hassame);
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(S,iS);
if(tSPS){cout<<"GToMerge ";GdumpSHA(S);cout<<" ";TopAbs::Print(TB,cout);}
if(tSPS){cout<<" "<<tomerge<<" : !ismerged "<<(!ismerged)<<" && hassame "<<hassame<<endl;}
#endif
return tomerge;
} // GToMerge
//=======================================================================
//function : GTakeCommonOfSame
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GTakeCommonOfSame(const TopOpeBRepBuild_GTopo& G)
{
TopAbs_State t1,t2; G.StatesON(t1,t2);
Standard_Boolean sam = Standard_False;
if (t1 == TopAbs_OUT && t2 == TopAbs_OUT) sam = Standard_True;
else if (t1 == TopAbs_OUT && t2 == TopAbs_IN ) sam = Standard_False;
else if (t1 == TopAbs_IN && t2 == TopAbs_OUT) sam = Standard_False;
else if (t1 == TopAbs_IN && t2 == TopAbs_IN ) sam = Standard_True;
return sam;
}
//=======================================================================
//function : GTakeCommonOfDiff
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GTakeCommonOfDiff(const TopOpeBRepBuild_GTopo& G)
{
TopAbs_State t1,t2; G.StatesON(t1,t2);
Standard_Boolean dif = Standard_False;
if (t1 == TopAbs_OUT && t2 == TopAbs_OUT) dif = Standard_False;
else if (t1 == TopAbs_OUT && t2 == TopAbs_IN ) dif = Standard_True;
else if (t1 == TopAbs_IN && t2 == TopAbs_OUT) dif = Standard_True;
else if (t1 == TopAbs_IN && t2 == TopAbs_IN ) dif = Standard_False;
return dif;
}
//=======================================================================
//function : GFindSamDom
//purpose : complete the lists L1,L2 with the shapes of the DS
// having same domain
//=======================================================================
void TopOpeBRepBuild_Builder::GFindSamDom(const TopoDS_Shape& S,TopTools_ListOfShape& L1,TopTools_ListOfShape& L2) const
{
L1.Clear(); L2.Clear();
L1.Append(S);
GFindSamDom(L1,L2);
}
//=======================================================================
//function : GFindSamDom
//purpose : complete the lists L1,L2 with the shapes of the DS
// having same domain
//=======================================================================
void TopOpeBRepBuild_Builder::GFindSamDom(TopTools_ListOfShape& L1,TopTools_ListOfShape& L2) const
{
Standard_Integer i;
Standard_Integer nl1 = L1.Extent(), nl2 = L2.Extent();
while ( nl1 > 0 || nl2 > 0 ) {
TopTools_ListIteratorOfListOfShape it1(L1);
for (i=1 ; i<=nl1; i++) {
const TopoDS_Shape& S1 = it1.Value();
#ifdef DEB
// Standard_Integer iS1 = myDataStructure->Shape(S1);
#endif
TopTools_ListIteratorOfListOfShape itsd(myDataStructure->SameDomain(S1));
for (; itsd.More(); itsd.Next() ) {
const TopoDS_Shape& S2 = itsd.Value();
#ifdef DEB
// Standard_Integer iS2 = myDataStructure->Shape(S2);
#endif
Standard_Boolean found = GContains(S2,L2);
if ( ! found ) {
L2.Prepend(S2);
nl2++;
}
}
it1.Next();
}
nl1 = 0;
TopTools_ListIteratorOfListOfShape it2(L2);
for (i=1 ; i<=nl2; i++) {
const TopoDS_Shape& S2 = it2.Value();
#ifdef DEB
// Standard_Integer iS2 = myDataStructure->Shape(S2);
#endif
TopTools_ListIteratorOfListOfShape itsd(myDataStructure->SameDomain(S2));
for (; itsd.More(); itsd.Next() ) {
const TopoDS_Shape& S1 = itsd.Value();
#ifdef DEB
// Standard_Integer iS1 = myDataStructure->Shape(S1);
#endif
Standard_Boolean found = GContains(S1,L1);
if ( ! found ) {
L1.Prepend(S1);
nl1++;
}
}
it2.Next();
}
nl2 = 0;
}
}
//=======================================================================
//function : GFindSamDomSODO
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFindSamDomSODO(const TopoDS_Shape& S,TopTools_ListOfShape& LSO,TopTools_ListOfShape& LDO) const
{
LSO.Clear();
LDO.Clear();
LSO.Append(S);
GFindSamDomSODO(LSO,LDO);
}
//=======================================================================
//function : GFindSamDomSODO
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFindSamDomSODO(TopTools_ListOfShape& LSO,TopTools_ListOfShape& LDO) const
{
TopTools_ListIteratorOfListOfShape it;
it.Initialize(LSO);
if ( ! it.More() ) return;
const TopoDS_Shape& sref = it.Value();
#ifdef DEB
// Standard_Integer iref = myDataStructure->SameDomainReference(sref);
#endif
TopOpeBRepDS_Config oref = myDataStructure->SameDomainOrientation(sref);
GFindSamDom(LSO,LDO);
#ifdef DEB
Standard_Integer iS; Standard_Boolean tSPS = GtraceSPS(sref,iS);
if(tSPS) {
TCollection_AsciiString ss("GFindSamDom result on ");
GdumpSHA(sref,(Standard_Address)ss.ToCString());cout<<endl;
GdumpSAMDOM(LSO, (char *) "L1 : ");
GdumpSAMDOM(LDO, (char *) "L2 : ");
}
#endif
TopTools_ListOfShape LLSO,LLDO;
for (it.Initialize(LSO); it.More(); it.Next() ) {
const TopoDS_Shape& s = it.Value();
TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s);
#ifdef DEB
// Standard_Integer iS = myDataStructure->Shape(s);
#endif
if ( o == oref && !GContains(s,LLSO) ) LLSO.Append(s);
else if ( o != oref && !GContains(s,LLDO) ) LLDO.Append(s);
}
for (it.Initialize(LDO); it.More(); it.Next() ) {
const TopoDS_Shape& s = it.Value();
TopOpeBRepDS_Config o = myDataStructure->SameDomainOrientation(s);
#ifdef DEB
// Standard_Integer iS = myDataStructure->Shape(s);
#endif
if ( o == oref && !GContains(s,LLSO) ) LLSO.Append(s);
else if ( o != oref && !GContains(s,LLDO) ) LLDO.Append(s);
}
Standard_Integer nso,ndo;
nso = LLSO.Extent();
ndo = LLDO.Extent();
LSO = LLSO;
LDO = LLDO;
nso = LSO.Extent();
ndo = LDO.Extent();
}
//=======================================================================
//function : GMapShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GMapShapes(const TopoDS_Shape& S1,const TopoDS_Shape& S2)
{
Standard_Boolean S1null = S1.IsNull();
Standard_Boolean S2null = S2.IsNull();
GClearMaps();
if ( ! S1null ) TopExp::MapShapes(S1,myMAP1);
if ( ! S2null ) TopExp::MapShapes(S2,myMAP2);
}
//=======================================================================
//function : GClearMaps
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GClearMaps()
{
myMAP1.Clear();
myMAP2.Clear();
}
//=======================================================================
//function : GFindSameRank
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFindSameRank
(const TopTools_ListOfShape& L1,const Standard_Integer Rank,TopTools_ListOfShape& L2) const
{
for ( TopTools_ListIteratorOfListOfShape it1(L1); it1.More(); it1.Next() ) {
const TopoDS_Shape& s = it1.Value();
#ifdef DEB
// Standard_Integer iS = myDataStructure->Shape(s);
#endif
Standard_Integer r = GShapeRank(s);
if ( r == Rank && !GContains(s,L2) ) {
L2.Append(s);
}
}
}
//=======================================================================
//function : GShapeRank
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_Builder::GShapeRank(const TopoDS_Shape& S) const
{
Standard_Boolean isof1 = GIsShapeOf(S,1);
Standard_Boolean isof2 = GIsShapeOf(S,2);
Standard_Integer ancetre = (isof1 || isof2) ? ((isof1) ? 1 : 2) : 0;
return ancetre;
}
//=======================================================================
//function : GIsShapeOf
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GIsShapeOf(const TopoDS_Shape& S,const Standard_Integer I) const
{
if (S.IsNull()) return Standard_False;
Standard_Boolean b = Standard_False;
if (I == 1) b = myMAP1.Contains(S);
else if (I == 2) b = myMAP2.Contains(S);
return b;
}
//=======================================================================
//function : GContains
//purpose : returns True if S is in the list L.
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GContains(const TopoDS_Shape& S,const TopTools_ListOfShape& L)
{
for (TopTools_ListIteratorOfListOfShape it(L); it.More(); it.Next() ) {
const TopoDS_Shape& SL = it.Value();
Standard_Boolean issame = SL.IsSame(S);
if ( issame ) return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GCopyList
//purpose :
// copy des elements [i1..i2] de Lin dans Lou. 1er element de Lin = index 1
//=======================================================================
void TopOpeBRepBuild_Builder::GCopyList(const TopTools_ListOfShape& Lin,const Standard_Integer I1,const Standard_Integer I2,TopTools_ListOfShape& Lou)
{
TopTools_ListIteratorOfListOfShape it(Lin);
Standard_Integer nadd = 0;
for ( Standard_Integer i = 1; it.More(); it.Next(),i++ ) {
const TopoDS_Shape& EL = it.Value();
if ( i >= I1 && i <= I2 ) {
Lou.Append(EL);
nadd++;
}
}
}
//=======================================================================
//function : GCopyList
//purpose :
// copy de Lin dans Lou
//=======================================================================
void TopOpeBRepBuild_Builder::GCopyList(const TopTools_ListOfShape& Lin,TopTools_ListOfShape& Lou)
{
const Standard_Integer I1 = 1;
const Standard_Integer I2 = Lin.Extent();
GCopyList(Lin,I1,I2,Lou);
}

View File

@@ -0,0 +1,811 @@
// file: TopOpeBRepBuild_GridEE.cxx
// Created: Thu Mar 7 10:49:33 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopOpeBRepBuild_define.hxx>
#include <TopOpeBRepDS_EXPORT.hxx>
#ifdef DRAW
#include <TopOpeBRepDS_DRAW.hxx>
#endif
#include <TopOpeBRepDS_EXPORT.hxx>
#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepDS_TKI.hxx>
#include <TopOpeBRepDS.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <TopOpeBRepDS_Dumper.hxx>
#include <Standard_ProgramError.hxx>
#ifdef DEB
Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOSG();
#endif
#define M_FORWARD(st) (st == TopAbs_FORWARD)
#define M_REVERSED(st) (st == TopAbs_REVERSED)
#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
Standard_EXPORT Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
//=======================================================================
//function : GMergeEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GMergeEdges(const TopTools_ListOfShape& LE1,const TopTools_ListOfShape& LE2,const TopOpeBRepBuild_GTopo& G1)
{
if ( LE1.IsEmpty() ) return;
TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
const TopoDS_Shape& E1 = LE1.First();
#ifdef DEB
Standard_Integer iE; Standard_Boolean tSPS1 = GtraceSPS(E1,iE);
if(tSPS1){
cout<<endl;cout<<"--- GMergeEdges "<<endl;
GdumpEDG(E1);
GdumpSAMDOM(LE1, (char *) "1 : ");
GdumpSAMDOM(LE2, (char *) "2 : ");
}
#endif
myEdgeReference = TopoDS::Edge(E1);
TopOpeBRepBuild_PaveSet PVS(E1);
GFillEdgesPVS(LE1,LE2,G1,PVS);
// Create a edge builder EBU
TopoDS_Shape E1F = LE1.First(); E1F.Orientation(TopAbs_FORWARD);
TopOpeBRepBuild_PaveClassifier VCL(E1F);
Standard_Boolean equalpar = PVS.HasEqualParameters();
if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
TopOpeBRepBuild_EdgeBuilder EDBU(PVS,VCL);
// Build the new edges LEM
TopTools_ListOfShape LEM;
GEDBUMakeEdges(E1F,EDBU,LEM);
// connect new edges as edges built TB1 on LE1 edges
TopTools_ListIteratorOfListOfShape it1;
for (it1.Initialize(LE1); it1.More(); it1.Next()) {
const TopoDS_Shape& E11 = it1.Value();
ChangeMerged(E11,TB1) = LEM;
}
// connect new edges as edges built TB2 on LE2 edges
TopTools_ListIteratorOfListOfShape it2;
for (it2.Initialize(LE2); it2.More(); it2.Next()) {
const TopoDS_Shape& E2 = it2.Value();
ChangeMerged(E2,TB2) = LEM;
}
} // GMergeEdges
//=======================================================================
//function : GFillEdgesPVS
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFillEdgesPVS(const TopTools_ListOfShape& LE1,const TopTools_ListOfShape& LE2,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_PaveSet& PVS)
{
if ( LE1.IsEmpty() ) return;
TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
const TopoDS_Shape& E1 = LE1.First();
myEdgeReference = TopoDS::Edge(E1);
TopTools_ListIteratorOfListOfShape it1;
for (it1.Initialize(LE1); it1.More(); it1.Next()) {
const TopoDS_Shape& E11 = it1.Value();
Standard_Boolean ismerged = IsMerged(E11,TB1);
#ifdef DEB
Standard_Integer i1; Standard_Boolean tSPS1 = GtraceSPS(E11,i1);
if(tSPS1){
cout<<endl;cout<<"--- GFillEdgesPVS ";GdumpSHA(E11);
cout<<" ismerged : "<<ismerged<<" ";TopAbs::Print(TB1,cout);cout<<endl;
}
#endif
if (!ismerged) GFillEdgePVS(E11,LE2,G1,PVS);
}
TopOpeBRepBuild_GTopo G2 = G1.CopyPermuted();
TopTools_ListIteratorOfListOfShape it2;
for (it2.Initialize(LE2); it2.More(); it2.Next() ) {
const TopoDS_Shape& E2 = it2.Value();
Standard_Boolean ismerged = IsMerged(E2,TB2);
#ifdef DEB
Standard_Integer i2; Standard_Boolean tSPS2 = GtraceSPS(E2,i2);
if(tSPS2){
cout<<endl;
cout<<"--- GFillEdgesPVS ";GdumpSHA(E2);
cout<<" ismerged : "<<ismerged<<" ";TopAbs::Print(TB2,cout);cout<<endl;
}
#endif
if (!ismerged) GFillEdgePVS(E2,LE1,G2,PVS);
}
} // GFillEdgesPVS
//=======================================================================
//function : GFillEdgePVS
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFillEdgePVS(const TopoDS_Shape& E,
const TopTools_ListOfShape& /*LE2*/,
const TopOpeBRepBuild_GTopo& G,
TopOpeBRepBuild_PaveSet& PVS)
{
TopAbs_ShapeEnum t1,t2,ShapeInterf;
G.Type(t1,t2);
ShapeInterf = t1;
TopAbs_State TB1,TB2;
G.StatesON(TB1,TB2);
// work on a FORWARD edge EF
TopoDS_Shape EF = E;
EF.Orientation(TopAbs_FORWARD);
// Add the point/vertex topology build/found on edge EF in PVS
GFillPointTopologyPVS(EF,G,PVS);
} // GFillEdgePVS
// --- iterer sur EPit jusqu'a la prochaine interference dont la
// --- transition est definie sur un shape de type SHA Before et After
static Standard_Boolean FUN_MoreSHAINT(TopOpeBRepDS_PointIterator& EPit,
const TopAbs_ShapeEnum SHA)
{
Standard_Boolean more = Standard_False;
while (EPit.More()) {
const Handle(TopOpeBRepDS_Interference)& I = EPit.Value();
const TopOpeBRepDS_Transition& T = I->Transition();
TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
TopAbs_ShapeEnum SB,SA; Standard_Integer IB,IA; FDS_Tdata(I,SB,IB,SA,IA);
TopAbs_ShapeEnum b = T.ShapeBefore(), a = T.ShapeAfter();
Standard_Boolean rejet = ( (b != SHA) || (a != SHA) );
if ( rejet ) EPit.Next();
else {
more = Standard_True;
break;
}
}
return more;
}
// Unused :
/*#ifdef DEB
static Standard_Integer FUN_getTRASHA(const Standard_Integer geti,
const TopOpeBRepDS_ListOfInterference& lFOR, const Standard_Integer FOR,
const TopOpeBRepDS_ListOfInterference& lREV, const Standard_Integer REV,
const TopOpeBRepDS_ListOfInterference& lINT, const Standard_Integer INT)
{
Standard_Integer trasha = 0;
if (geti == 1) { // get i before
if (REV) trasha = lREV.First()->Transition().Before();
if (INT) trasha = lINT.First()->Transition().Before();
}
if (geti == 2) { // get i after
if (FOR) trasha = lFOR.Last()->Transition().After();
if (INT) trasha = lINT.Last()->Transition().After();
}
return trasha;
}
#endif*/
#ifdef DEB
void debfillp(const Standard_Integer i) {cout <<"+ + debfillp "<<i<<endl;}
void debfillpon(const Standard_Integer i) {cout <<"+ + debfillpon "<<i<<endl;}
void debfillpin(const Standard_Integer i) {cout <<"+ + debfillpin "<<i<<endl;}
void debfillpou(const Standard_Integer i) {cout <<"+ + debfillpou "<<i<<endl;}
void debfillp2(const Standard_Integer i) {cout <<"+ + debfillp2 "<<i<<endl;}
#endif
//Standard_IMPORT extern Standard_Boolean GLOBAL_faces2d;
Standard_IMPORT Standard_Boolean GLOBAL_faces2d;
Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I);
//Standard_IMPORT extern Standard_Boolean GLOBAL_IEtoMERGE; // xpu240498
Standard_IMPORT Standard_Boolean GLOBAL_IEtoMERGE; // xpu240498
//Standard_IMPORT extern Standard_Integer GLOBAL_issp;
Standard_IMPORT Standard_Integer GLOBAL_issp;
//Standard_IMPORT extern Standard_Integer GLOBAL_hassd;
Standard_IMPORT Standard_Integer GLOBAL_hassd;
static Standard_Boolean FUN_isonbound(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
const Handle(TopOpeBRepDS_Interference)& I)
{
Standard_Integer G = I->Geometry();
TopOpeBRepDS_Kind KG = I->GeometryType();
Standard_Boolean Gb1 = (KG == TopOpeBRepDS_VERTEX);
if (Gb1) {
Handle(TopOpeBRepDS_EdgeVertexInterference) EVI= Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
Standard_Boolean vhassd = HDS->HasSameDomain(HDS->DS().Shape(G));
Gb1 = (EVI.IsNull()) ? Standard_False : EVI->GBound();
Gb1 = Gb1 && !vhassd;
}
return Gb1;
}
#define TheIN (1)
#define TheON (2)
#define TheOUT (3)
#define HASSD2d (2)
#define HASSD3d (3)
#define FIRST (1)
#define LAST (2)
//=======================================================================
//function : GFillPointTopologyPVS
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& E,
const TopOpeBRepBuild_GTopo& G,
TopOpeBRepBuild_PaveSet& PVS)
{
#ifdef DEB
// TopAbs_State TB1,TB2;
// G.StatesON(TB1,TB2);
// TopOpeBRepDS_Config GConf1 = G.Config1();
// TopOpeBRepDS_Config GConf2 = G.Config2();
#endif
TopAbs_ShapeEnum t1,t2,ShapeInterf;
G.Type(t1,t2);
ShapeInterf = t1;
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
const Standard_Integer iEDS = BDS.Shape(E);
#ifdef DEB
// Standard_Integer rkE = BDS.AncestorRank(E);
#endif
Standard_Boolean isSE = BDS.IsSectionEdge(TopoDS::Edge(E));
Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(E));
Standard_Boolean isEd;
isEd = BRep_Tool::Degenerated(TopoDS::Edge(E));
#ifdef DEB
// Standard_Boolean hsd = myDataStructure->HasSameDomain(E); //xpu170498
#endif
Standard_Boolean isfafa = BDS.Isfafa(); //xpu120598
#ifdef DEB
Standard_Boolean tSPSE=GtraceSPS(iEDS);
TCollection_AsciiString striE=TopOpeBRepDS::SPrint(TopAbs_EDGE,iEDS);
const TopoDS_Shape& EPVS=PVS.Edge();Standard_Integer iEPVS;Standard_Boolean tSPSEPVS=GtraceSPS(EPVS,iEPVS);
Standard_Boolean tSPS = tSPSE || tSPSEPVS;
if(tSPS){
cout<<endl;
cout<<"--- GFillPointTopologyPVS : ShapeInterf ";TopAbs::Print(ShapeInterf,cout);
cout<<",efil ";GdumpSHA(E);cout<<",eref ";GdumpSHA(myEdgeReference);
cout<<",ffil ";GdumpSHA(myFaceToFill);cout<<",fref ";GdumpSHA(myFaceReference);
cout<<endl;
debfillp(iEDS);
}
#endif
Standard_Boolean isspin=(GLOBAL_issp==TheIN), isspou=(GLOBAL_issp==TheOUT), isspon=(GLOBAL_issp==TheON);
if (isSE && (GLOBAL_issp == 0)) return; // splits done in process ProcessSectionEdges
#ifdef DEB
// Standard_Integer iefil = BDS.Shape(E);
// Standard_Integer iffil = BDS.Shape(myFaceToFill);
// Standard_Integer ieref = BDS.Shape(myEdgeReference);
// Standard_Integer ifref = BDS.Shape(myFaceReference);
if(tSPS) {
if (isspon) debfillpon(iEDS);
if (isspin) debfillpin(iEDS);
if (isspou) debfillpou(iEDS);
}
#endif
// 0.
//---
const TopOpeBRepDS_ListOfInterference& lIE = BDS.ShapeInterferences(E);
Standard_Boolean scanall = (isspin || isspou || isspon); // xpu161198: BUC60382 //xpu011098: CTS21180(e8on); cto900I7(e12on)
// loiSHAINT = interferences avec les 2 proprietes
// - fournies par un PointIterator
// - dont la transition est definie / shape = ShapeInterf
TopOpeBRepDS_ListOfInterference loiSHAINT;
if (scanall) FDS_assign(lIE,loiSHAINT);
else {
TopOpeBRepDS_PointIterator EPit(lIE);
EPit.Init(BDS.ShapeInterferences(E));
Standard_Boolean addi = FUN_MoreSHAINT(EPit,ShapeInterf);
while (addi) {
const Handle(TopOpeBRepDS_Interference)& II = EPit.Value();
loiSHAINT.Append(II);
EPit.Next();
addi = FUN_MoreSHAINT(EPit,ShapeInterf);
}
}
TopOpeBRepDS_TKI tki;
tki.FillOnGeometry(loiSHAINT); // groupage par geometrie d'interference
// - kp1 -
// BUC60093 : only 2 G : 1 point && 1 vertex
// deleting interfs on G = vertex sdm && closingE
TopoDS_Vertex vclo; Standard_Boolean closedE = TopOpeBRepTool_TOOL::ClosedE(TopoDS::Edge(E),vclo);
Standard_Integer kp1 = 0; Standard_Integer ikp1 = 0;
if (closedE) {
tki.Init();
Standard_Integer nG = 0;
while (tki.More()) {
nG++;
TopOpeBRepDS_Kind Kcur;Standard_Integer Gcur;
tki.Value(Kcur,Gcur);
if (Kcur == TopOpeBRepDS_POINT) {tki.Next();continue;}
const TopoDS_Shape& v = BDS.Shape(Gcur);
TopoDS_Shape oov;
FUN_ds_getoov(v,myDataStructure,oov);
Standard_Boolean samev = v.IsSame(vclo), sameoov = oov.IsSame(vclo);
if (samev || sameoov) {ikp1 = Gcur; kp1 = Gcur;}
tki.Next();
}
if (nG == 1) kp1 = 0; // we have only one interf on vGclo -> keep the interf
} //kp1
// - kp6 - nyiReducing
// xpu250998 : cto900M5 (e5,p1)
// prequesitory : if we have I3d on Gb0 FORWARD or REVERSED, we do NOT need
// interference on Gb1 to determinate split IN/OUT of edge.
Standard_Boolean kp6 = (!isSE);
if (kp6) {
kp6 = Standard_False;
TopOpeBRepDS_ListIteratorOfListOfInterference it(loiSHAINT);
for (; it.More(); it.Next()){
const Handle(TopOpeBRepDS_Interference)& I = it.Value();
TopOpeBRepDS_Kind ST = I->SupportType();
if (ST != TopOpeBRepDS_FACE) continue;
TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN);
Standard_Boolean FORREV = (O == TopAbs_FORWARD) || (O == TopAbs_REVERSED);
if (!FORREV) continue;
Standard_Boolean Gb1 = ::FUN_isonbound(myDataStructure,I);
if (!Gb1) {kp6 = Standard_True; break;}
} // it(l3dFOR+l3dREV)
}
// 1.
//---
tki.Init();
while (tki.More()) {
// lieu courant : Kcur,Gcur; Interferences : LICur
TopOpeBRepDS_Kind Kcur;
Standard_Integer Gcur;
const TopOpeBRepDS_ListOfInterference& LICur = tki.Value(Kcur,Gcur);
Standard_Boolean point = (Kcur == TopOpeBRepDS_POINT); //xpu170498
Standard_Boolean vertex = (Kcur == TopOpeBRepDS_VERTEX);//xpu170498
#ifdef DEB
// Standard_Integer nLICur = LICur.Extent();
Standard_Boolean trcI = Standard_False;
if(trcI) {TopOpeBRepDS_Dumper DSD(myDataStructure); TCollection_AsciiString aa("lI");
aa += TCollection_AsciiString(Gcur); DSD.DumpLOI(LICur,cout,aa);}
#endif
Standard_Boolean Ghsd = Standard_False; TopoDS_Shape vGsd;
if (vertex) Ghsd = FUN_ds_getoov(BDS.Shape(Gcur), myDataStructure, vGsd); //xpu221098
// recall : I3d=(I3dF,I3dFE) : I3dF=(T(F),G,F), I3dFE=(T(F),G,E)
// I2d=I2dFE
// I1d=(T(E),V,E)
if ((Kcur == TopOpeBRepDS_VERTEX) && (kp1 == Gcur)) {tki.Next();continue;}
const Handle(TopOpeBRepDS_Interference)& I = LICur.First();
Standard_Real parSE = FDS_Parameter(I);
TopOpeBRepDS_ListOfInterference LICurcopy;
TopOpeBRepDS_ListOfInterference l3dFcur; FDS_assign(LICur,LICurcopy); Standard_Integer n3d=FUN_selectSKinterference(LICurcopy,TopOpeBRepDS_FACE,l3dFcur);
TopOpeBRepDS_ListOfInterference l2dFEcur; FDS_assign(LICur,LICurcopy); Standard_Integer n2d=FUN_ds_hasI2d(iEDS,LICurcopy,l2dFEcur);
TopOpeBRepDS_ListOfInterference l1dEcur; FDS_assign(LICur,LICurcopy);
FUN_selectTRASHAinterference(LICurcopy,TopAbs_EDGE,l1dEcur);
TopAbs_State stb; Standard_Integer isb; Standard_Integer bdim;
TopAbs_State sta; Standard_Integer isa; Standard_Integer adim;
FUN_ds_GetTr(BDS,iEDS,Gcur,LICur,
stb,isb,bdim,
sta,isa,adim);
if (isSE) {
// before
Standard_Boolean bIN1d = (stb==TopAbs_IN)&&(bdim==1);
Standard_Boolean bIN2d = (stb==TopAbs_IN)&&(bdim==2);
Standard_Boolean bIN3d = (stb==TopAbs_IN)&&(bdim==3);
Standard_Boolean bOUT2d = (stb==TopAbs_OUT)&&(bdim==2);
Standard_Boolean bOUT3d = (stb==TopAbs_OUT)&&(bdim==3);
// after
Standard_Boolean aIN1d = (sta==TopAbs_IN)&&(adim==1);
Standard_Boolean aIN2d = (sta==TopAbs_IN)&&(adim==2);
Standard_Boolean aIN3d = (sta==TopAbs_IN)&&(adim==3);
Standard_Boolean aOUT2d = (sta==TopAbs_OUT)&&(adim==2);
Standard_Boolean aOUT3d = (sta==TopAbs_OUT)&&(adim==3);
TopOpeBRepDS_Transition newT; Standard_Boolean INb=Standard_False,INa=Standard_False;
if (isfafa) {
if (isspon) {
if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
INb = bIN1d;
INa = aIN1d;
newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE);
} else if (isspin) {
INb = bIN2d;
INa = aIN2d;
newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
} else if (isspou) {
INb = !bOUT2d;
INa = !aOUT2d;
newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
}
}
else {
if (isspon) {
if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
INb = bIN1d || bIN2d;
INa = aIN1d || aIN2d;
newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE);
} else if (isspin) {
if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
INb = bIN3d;
INa = aIN3d;
if (INb) newT.Index(isb);
else newT.Index(isa);
newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
} else if (isspou) {
if ((stb == TopAbs_IN)&&(sta == TopAbs_IN)) {tki.Next(); continue;}
INb = !bOUT3d;
INa = !aOUT3d;
if (bOUT3d) newT.Index(isb);
else newT.Index(isa);
newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
}
}
TopAbs_State sb = INb ? TopAbs_IN : TopAbs_OUT;
TopAbs_State sa = INa ? TopAbs_IN : TopAbs_OUT;
newT.StateBefore(sb);newT.StateAfter(sa);
Standard_Integer S=0; // dummy
Standard_Boolean B = (Kcur == TopOpeBRepDS_POINT) ? Standard_False : (Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound());
Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,Gcur,parSE,Kcur,B);
TopOpeBRepDS_ListOfInterference li; li.Append(newI); TopOpeBRepDS_PointIterator itCur(li);
GFillPointTopologyPVS(E,itCur,G,PVS);
#ifdef DEB
if(tSPS) {newI->Dump(cout,"\nnewinterf ","\n\n"); debfillp2(iEDS);}
#endif
{tki.Next(); continue;}
} // isSE
// - kp3 -
// xpu200598 interference 2d at GPOINT
Standard_Boolean kp3 = (n2d > 0) && point;
TopAbs_Orientation Okp3 = TopAbs_EXTERNAL;
if (kp3) Okp3=l2dFEcur.First()->Transition().Orientation(TopAbs_IN);
TopOpeBRepDS_PointIterator itCur(LICur); Standard_Integer iICur=0;
while ( itCur.More() ) {
iICur++;
const Handle(TopOpeBRepDS_Interference)& I1=itCur.Value();
const TopOpeBRepDS_Transition& T1=I1->Transition();
T1.Orientation(TopAbs_IN);
TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
#ifdef DEB
if(tSPS) {I1->Dump(cout,"\n? keepinterf ","\n\n"); debfillp2(iEDS);}
#endif
Standard_Boolean keepinterf1 = Standard_False;
if (isEd) {
keepinterf1 = Standard_True;
}
else {
if (GLOBAL_faces2d) { // split 2d
Standard_Boolean has2d3d = (n2d >0 && n3d >0); // JYL300998
// JYL300998 : traitement correct de cto 100 K1 e27 (chanceux auparavant, schema d'I faux)
// e27 n'est PAS arete de section mais doit etre traitee comme telle.
// e27 possede des I de nature 2d et 3d en V8
// on privilegie l'info 3d
if (has2d3d && !isSE) {
#ifdef DEB
const Handle(TopOpeBRepDS_Interference)& i2d =
#endif
l2dFEcur.First();
const Handle(TopOpeBRepDS_Interference)& i3d = l3dFcur.First();
Standard_Boolean id3d = (I1 == i3d);
#ifdef DEB
Standard_Boolean id2d = (I1 == i2d);
#endif
keepinterf1 = id3d;
#ifdef DEB
if (tSPS) {
cout<<"DEB : GFillPointTopologyPVS E"<<iEDS<<" has2d3d"<<endl;
i2d->Dump(cout,"2d : ","\n");
i3d->Dump(cout,"3d : ","\n");
I1->Dump (cout,"I1 : ","\n");
if (id3d) cout<<"--> Interference 3d ";
if (id2d) cout<<"--> Interference 2d ";
if (keepinterf1) cout<<" traitee"<<endl;
else cout<<" non traitee"<<endl;
cout<<endl;
}
#endif
}
else {
keepinterf1 = Standard_True; // PRO13075 tspIN(e17)
}
} // split 2d
else { // split 3d
keepinterf1 = (ST1 == TopOpeBRepDS_FACE); // (iICur == 1);
}
}
if ( keepinterf1 ) {
if (kp6) {
Standard_Boolean Gb1 = ::FUN_isonbound(myDataStructure,I1);
if (!Gb1) GFillPointTopologyPVS(E,itCur,G,PVS);
}
else {
GFillPointTopologyPVS(E,itCur,G,PVS);
}
if (!dgE) break; // xpu140498
} // keepinterf1
itCur.Next();
} // itCur.More
tki.Next();
} // tki.More()
}
//=======================================================================
//function : GFillPointTopologyPVS
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& E,
const TopOpeBRepDS_PointIterator& EPit,
const TopOpeBRepBuild_GTopo& G1,
TopOpeBRepBuild_PaveSet& PVS) const
{
const TopoDS_Shape& EPVS = PVS.Edge();
//modified by NIZHNY-MZV Mon Feb 21 14:47:34 2000
const Handle(TopOpeBRepDS_Interference)& I1=EPit.Value();
TopOpeBRepDS_Kind ST1 = I1->SupportType();
#ifdef DEB
Standard_Integer iE; Standard_Boolean tSPSE = GtraceSPS(E,iE);
Standard_Integer iEPVS; Standard_Boolean tSPSEPVS = GtraceSPS(EPVS,iEPVS);
Standard_Boolean tSPS = tSPSE || tSPSEPVS;
if ( tSPS ) debfillp(iE);
#endif
TopAbs_State TB1,TB2;
G1.StatesON(TB1,TB2);
TopOpeBRepDS_Config Conf = G1.Config1();
TopAbs_State TB = TB1;
// iG = index of new point or existing vertex
Standard_Integer iG = EPit.Current();
Standard_Boolean ispoint = EPit.IsPoint();
TopoDS_Vertex VIG; // NYI pointer
if (ispoint) VIG = TopoDS::Vertex(NewVertex(iG));
else VIG = TopoDS::Vertex(myDataStructure->Shape(iG));
if (VIG.IsNull()) return; //PMN 17/02/99 Nothing to add.
Standard_Boolean hasVSD = Standard_False;
Standard_Integer iVRE = 0; TopoDS_Shape VRE; // NYI pointer
if (!ispoint) {
hasVSD = myDataStructure->HasSameDomain(VIG);
if (hasVSD) { // on prend VRE = vertex reference de VIG
iVRE = myDataStructure->SameDomainReference(VIG);
VRE = TopoDS::Vertex(myDataStructure->Shape(iVRE));
}
}
TopoDS_Vertex VPV; // NYI pointer on VRE or VIG
if (hasVSD) VPV = TopoDS::Vertex(VRE);
else VPV = VIG;
// else VPV = TopoDS::Vertex(VIG);
Standard_Real par = EPit.Parameter();
TopAbs_Orientation ori = EPit.Orientation(TB);
#ifdef DEB
if ( tSPS ) debfillp(iE);
#endif
Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(E,EPVS);
if (Conf == TopOpeBRepDS_DIFFORIENTED) ori = TopAbs::Complement(ori);
#ifdef DEB
if (!TopOpeBRepBuild_GetcontextNOSG()) {
#endif
if (!samegeom) ori = TopAbs::Complement(ori);
#ifdef DEB
}
#endif
Standard_Boolean lesmemes = E.IsEqual(myEdgeReference);
if ( !lesmemes ) {
Standard_Real parref = par;
const TopoDS_Edge& EE = TopoDS::Edge(E);
GParamOnReference(VPV,EE,parref);
#ifdef DEB
if(tSPS){
cout<<"par "<<par<<" / ";GdumpSHA(E);cout<<" --> parref "<<parref<<" / ";GdumpSHA(EPVS);
cout<<endl;
}
#endif
par = parref;
}
Standard_Boolean kpbound = Standard_False;
{
TopoDS_Vertex vclo; Standard_Boolean Eclosed = TopOpeBRepTool_TOOL::ClosedE(myEdgeReference,vclo);
#ifdef DEB
// Standard_Integer ivclo = myDataStructure->Shape(vclo);
#endif
TopAbs_Orientation oriI = EPit.Orientation(TopAbs_IN);
// kpbound = lesmemes && Eclosed && hasVSD && (ori == TopAbs_INTERNAL) && (TB == TopAbs_OUT); -xpu140898
// xpu110398 cto 009 L2 : e6ou en v11
// xpu140898 USA60111 : e9ou (!=0) + e7ou(=0)
Standard_Boolean INTEXT = (oriI == TopAbs_INTERNAL) && (TB == TopAbs_IN);
INTEXT = INTEXT || (oriI == TopAbs_EXTERNAL) && (TB == TopAbs_OUT);
kpbound = lesmemes && Eclosed && INTEXT;
if ( kpbound ) {
kpbound = vclo.IsSame(VIG);
if (!kpbound) {
TopoDS_Shape VSD; Standard_Boolean ok = FUN_ds_getoov(VIG,myDataStructure->DS(),VSD);
if (ok) kpbound = vclo.IsSame(VSD);
}
}
}
if (!kpbound) {
VPV.Orientation(ori);
Standard_Boolean vofe = Standard_False;
Handle(TopOpeBRepBuild_Pave) PV = new TopOpeBRepBuild_Pave(VPV,par,vofe);
if (hasVSD) {
PV->HasSameDomain(Standard_True);
const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
Standard_Integer iVSD = myDataStructure->Shape(VSD);
if (iVSD == iVRE) PV->SameDomain(VIG);
else PV->SameDomain(VSD);
}
//modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
PV -> InterferenceType() = ST1;
PVS.Append(PV);
#ifdef DEB
gp_Pnt P = BRep_Tool::Pnt(VPV);
if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ori,par,P);cout<<endl;}
if(tSPS) {
// Standard_Boolean trc = Standard_False;
#ifdef DRAW
if (trc) {
FUN_draw2d(par,TopoDS::Edge(E),myEdgeReference,myFaceReference);
FUN_draw(VPV); FUN_draw(E); FUN_draw(myFaceReference);
}
#endif
}
#endif
}
else {
Standard_Real parf,parl; FUN_tool_bounds(myEdgeReference,parf,parl);
TopAbs_Orientation ovpv;
ovpv = TopAbs_FORWARD;
VPV.Orientation(ovpv);
Standard_Boolean vfofe = Standard_False;
Handle(TopOpeBRepBuild_Pave) PVF = new TopOpeBRepBuild_Pave(VPV,parf,vfofe);
if (hasVSD) {
PVF->HasSameDomain(Standard_True);
const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
Standard_Integer iVSD = myDataStructure->Shape(VSD);
if (iVSD == iVRE) PVF->SameDomain(VIG);
else PVF->SameDomain(VSD);
}
//modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
PVF -> InterferenceType() = ST1;
PVS.Append(PVF);
#ifdef DEB
gp_Pnt PF = BRep_Tool::Pnt(VPV);
if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ovpv,parf,PF);cout<<endl;}
#endif
ovpv = TopAbs_REVERSED;
VPV.Orientation(ovpv);
Standard_Boolean vrofe = Standard_False;
Handle(TopOpeBRepBuild_Pave) PVR = new TopOpeBRepBuild_Pave(VPV,parl,vrofe);
if (hasVSD) {
PVR->HasSameDomain(Standard_True);
const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
Standard_Integer iVSD = myDataStructure->Shape(VSD);
if (iVSD == iVRE) PVR->SameDomain(VIG);
else PVR->SameDomain(VSD);
}
//modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
PVR -> InterferenceType() = ST1;
PVS.Append(PVR);
#ifdef DEB
gp_Pnt PR = BRep_Tool::Pnt(VPV);
if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ovpv,parl,PR);cout<<endl;}
#endif
PVS.RemovePV(Standard_False); // jyl + 980217
}
}
//=======================================================================
//function : GParamOnReference
//purpose : calcul du parametre de V sur myEdgeReference de myFaceReference
// V est sur la surface de myFaceReference,
// V est un vertex de E
// E est une arete samedomain de myEdgeReference
// retourne true si ok
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::GParamOnReference(const TopoDS_Vertex& V,
const TopoDS_Edge& /*E*/,
Standard_Real& P) const
{
Handle(Geom_Surface) su = BRep_Tool::Surface(myFaceReference);
Handle(Geom_Plane) suplan = Handle(Geom_Plane)::DownCast(su);
if ( suplan.IsNull() ) {
#ifdef DEB
cout<<"NYI : GParamOnReference : not planar"<<endl;
#endif
return Standard_False;
}
gp_Pln pln = suplan->Pln(); gp_Pnt p3 = BRep_Tool::Pnt(V);
Standard_Real u,v; ElSLib::Parameters(pln,p3,u,v); gp_Pnt2d p2(u,v);
Standard_Real f,l,tolpc; Handle(Geom2d_Curve) C2D;
C2D = FC2D_CurveOnSurface(myEdgeReference,myFaceReference,f,l,tolpc);
if (C2D.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::GParamOnReference");
// Standard_Real U;
Geom2dAdaptor_Curve AC(C2D);
switch ( AC.GetType() ) {
case GeomAbs_Line:
P = ElCLib::Parameter(AC.Line(),p2); break;
case GeomAbs_Circle:
P = ElCLib::Parameter(AC.Circle(),p2); break;
case GeomAbs_Ellipse:
P = ElCLib::Parameter(AC.Ellipse(),p2); break;
case GeomAbs_Hyperbola:
P = ElCLib::Parameter(AC.Hyperbola(),p2); break;
case GeomAbs_Parabola:
P = ElCLib::Parameter(AC.Parabola(),p2); break;
default :
#ifdef DEB
cout<<"NYI : GParamOnReference : OtherCurve on planar surface"<<endl;
#endif
return Standard_False;
}
return Standard_True;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,694 @@
// file: TopOpeBRepBuild_Griddump.cxx
// Created: Thu Mar 7 10:49:33 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopOpeBRepBuild_define.hxx>
#include <stdio.h>
#ifdef DRAW
#include <DBRep.hxx>
#endif
#include <TopOpeBRepBuild_GIter.hxx>
#include <TopOpeBRepBuild_GTool.hxx>
#include <TopOpeBRepDS_Surface.hxx>
#include <TopOpeBRepDS_Curve.hxx>
#include <TopOpeBRepDS_Point.hxx>
#include <TopOpeBRepDS_Interference.hxx>
#include <TopOpeBRepDS_Config.hxx>
#include <TopOpeBRepDS_Dumper.hxx>
#include <TopOpeBRepDS.hxx>
#include <TopOpeBRepTool_ShapeExplorer.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopOpeBRepBuild_WireEdgeSet.hxx>
#ifdef DEB
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSPSXX(const Standard_Integer,const Standard_Integer);
static TCollection_AsciiString PRODINS("dins ");
#endif
//=======================================================================
//function : GdumpLS
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpLS(const TopTools_ListOfShape& L) const
{
TopTools_ListIteratorOfListOfShape it(L);
for (; it.More(); it.Next() ) {
const TopoDS_Shape& SL = it.Value();
GdumpSHA(SL);
}
}
#else
void TopOpeBRepBuild_Builder::GdumpLS(const TopTools_ListOfShape&) const
{
}
#endif
//=======================================================================
//function : PrintGeo
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::PrintGeo(const TopoDS_Shape& S)
{
if (S.ShapeType() == TopAbs_VERTEX) PrintPnt(TopoDS::Vertex(S));
else if (S.ShapeType() == TopAbs_EDGE) PrintCur(TopoDS::Edge(S));
else if (S.ShapeType() == TopAbs_FACE) PrintSur(TopoDS::Face(S));
}
#else
void TopOpeBRepBuild_Builder::PrintGeo(const TopoDS_Shape&)
{
}
#endif
//=======================================================================
//function : PrintSur
//purpose : print the name of a surface
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::PrintSur(const TopoDS_Face& F)
{
BRepAdaptor_Surface STA_Surface(F);
GeomAbs_SurfaceType t = STA_Surface.GetType();
switch(t) {
case GeomAbs_Plane : cout<<"PLANE"; break;
case GeomAbs_Cylinder : cout<<"CYLINDER"; break;
case GeomAbs_Cone : cout<<"CONE"; break;
case GeomAbs_Sphere : cout<<"SPHERE"; break;
case GeomAbs_Torus : cout<<"TORUS"; break;
case GeomAbs_BezierSurface : cout<<"BEZIERSURFACE"; break;
case GeomAbs_BSplineSurface : cout<<"BSPLINESURFACE"; break;
case GeomAbs_SurfaceOfRevolution : cout<<"SURFACEOFREVOLUTION"; break;
case GeomAbs_SurfaceOfExtrusion : cout<<"SURFACEOFEXTRUSION"; break;
case GeomAbs_OtherSurface : default : cout<<"OTHERSURFACE"; break;
}
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::PrintSur(const TopoDS_Face& )
{
}
#endif
//=======================================================================
//function : PrintCur
//purpose : print the name of a curve
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::PrintCur(const TopoDS_Edge& E)
{
TopLoc_Location L; Standard_Real f,l;
Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,f,l);
if ( C.IsNull() ) return;
GeomAdaptor_Curve GC(C);
GeomAbs_CurveType t = GC.GetType();
switch(t) {
case GeomAbs_Line : cout<<"LINE"; break;
case GeomAbs_Circle : cout<<"CIRCLE"; break;
case GeomAbs_Ellipse : cout<<"ELLIPSE"; break;
case GeomAbs_Hyperbola : cout<<"HYPERBOLA"; break;
case GeomAbs_Parabola : cout<<"PARABOLA"; break;
case GeomAbs_BezierCurve : cout<<"BEZIERCURVE"; break;
case GeomAbs_BSplineCurve : cout<<"BSPLINECURVE "<<GC.BSpline()->Degree(); break;
case GeomAbs_OtherCurve : cout<<"OTHERCURVE"; break;
}
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::PrintCur(const TopoDS_Edge&)
{
}
#endif
//=======================================================================
//function : PrintPnt
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::PrintPnt(const TopoDS_Vertex& V)
{
GdumpPNT(BRep_Tool::Pnt(V));
}
#else
void TopOpeBRepBuild_Builder::PrintPnt(const TopoDS_Vertex&)
{
}
#endif
//=======================================================================
//function : PrintOri
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::PrintOri(const TopoDS_Shape& S)
{
TopAbs::Print(S.Orientation(),cout);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::PrintOri(const TopoDS_Shape& /*S*/)
{
}
#endif
//=======================================================================
//function : StringState
//purpose :
//=======================================================================
#ifdef DEB
TCollection_AsciiString TopOpeBRepBuild_Builder::StringState(const TopAbs_State st)
#else
TCollection_AsciiString TopOpeBRepBuild_Builder::StringState(const TopAbs_State)
#endif
{
TCollection_AsciiString s;
#ifdef DEB
switch(st) {
case TopAbs_ON : s.AssignCat("ON"); break;
case TopAbs_IN : s.AssignCat("IN"); break;
case TopAbs_OUT : s.AssignCat("OUT"); break;
case TopAbs_UNKNOWN : s.AssignCat("UNKNOWN"); break;
}
#endif
return s;
}
//=======================================================================
//function : GdumpPNT
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpPNT(const gp_Pnt& P)
{
cout<<P.X()<<" "<<P.Y()<<" "<<P.Z(); cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpPNT(const gp_Pnt&)
{
}
#endif
//=======================================================================
//function : GdumpORIPARPNT
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpORIPARPNT(const TopAbs_Orientation o,
const Standard_Real p,
const gp_Pnt& Pnt)
{
TopAbs::Print(o,cout); cout<<" "<<p<<" pnt "; GdumpPNT(Pnt); cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpORIPARPNT(const TopAbs_Orientation,
const Standard_Real,const gp_Pnt&)
{
}
#endif
//=======================================================================
//function : GdumpEDGVER
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpEDGVER(const TopoDS_Shape& E,
const TopoDS_Shape& V,
const Standard_Address s) const
{
char* c = (char*)s; if (c) cout<<c;
const TopoDS_Edge& EE = TopoDS::Edge(E);
const TopoDS_Vertex& VV = TopoDS::Vertex(V);
Standard_Real par = BRep_Tool::Parameter(VV,EE);
gp_Pnt P = BRep_Tool::Pnt(VV);
GdumpORIPARPNT(VV.Orientation(),par,P);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpEDGVER(const TopoDS_Shape&,
const TopoDS_Shape&,
const Standard_Address) const
{
}
#endif
//=======================================================================
//function : GdumpEDG
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpEDG(const TopoDS_Shape& E,
const Standard_Address s) const
{
char* c = (char*)s; if (c) cout<<c;
const TopoDS_Edge& EE = TopoDS::Edge(E);
Standard_Integer n = 0;
GdumpSHAORI(E, (char *) "vertices of ");cout<<endl;
TopOpeBRepTool_ShapeExplorer ex(E,TopAbs_VERTEX);
char strpar[256]; sprintf(strpar," #");
for (; ex.More(); ex.Next()) {
const TopoDS_Vertex& VV = TopoDS::Vertex(ex.Current());
TopAbs_Orientation o = VV.Orientation();
cout<<"vertex v";
if (o == TopAbs_FORWARD) cout<<"F";
else if (o == TopAbs_REVERSED) cout<<"R";
else if (o == TopAbs_INTERNAL) cout<<"I";
else if (o == TopAbs_EXTERNAL) cout<<"E";
cout<<++n<<" "; TopOpeBRepBuild_Builder::PrintPnt(VV); cout<<";";
Standard_Real par = BRep_Tool::Parameter(VV,EE);
char spar[255];sprintf(spar," par%d %f",n,par); strcat(strpar,spar);
}
if(n) cout<<strpar<<endl;
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpEDG(const TopoDS_Shape&,
const Standard_Address) const
{
}
#endif
//=======================================================================
//function : GdumpSAMDOM
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GdumpSAMDOM(const TopTools_ListOfShape& L,
const Standard_Address astr) const
{
TopOpeBRepDS_Dumper Dumper(myDataStructure);
cout<<Dumper.SPrintShapeRefOri(L,(char*)astr)<<endl;
cout.flush();
}
//=======================================================================
//function : GdumpSHA
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHA(const TopoDS_Shape& S,
const Standard_Address str) const
{
char* c = (char*)str; if (c) cout<<c;
if (S.IsNull()) return;
TopAbs_ShapeEnum tS = S.ShapeType(); Standard_Integer iS = 0;
if ( ! myDataStructure.IsNull() ) iS = myDataStructure->Shape(S);
TopOpeBRepDS::Print(tS,iS,cout);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHA(const TopoDS_Shape&,
const Standard_Address) const
{
}
#endif
//=======================================================================
//function : GdumpSHAORI
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHAORI(const TopoDS_Shape& S,
const Standard_Address str) const
{
char* c = (char*)str; if (c) cout<<c;
GdumpSHA(S,NULL); cout<<","; PrintOri(S);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHAORI(const TopoDS_Shape& ,
const Standard_Address ) const
{
}
#endif
//=======================================================================
//function : GdumpSHAORIGEO
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHAORIGEO(const TopoDS_Shape& S,
const Standard_Address str) const
{
char* c = (char*)str; if (c) cout<<c;
GdumpSHAORI(S,NULL); cout<<","; PrintGeo(S);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHAORIGEO(const TopoDS_Shape& ,
const Standard_Address ) const
{
}
#endif
//=======================================================================
//function : GdumpSHASTA
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHASTA(const TopoDS_Shape& S,
const TopAbs_State T,
const TCollection_AsciiString& a,
const TCollection_AsciiString& b) const
{
cout<<a;
GdumpSHAORIGEO(S,NULL); cout<<","<<StringState(T).ToCString();
cout<<b;
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHASTA(const TopoDS_Shape& ,
const TopAbs_State ,
const TCollection_AsciiString& ,
const TCollection_AsciiString& ) const
{
}
#endif
//=======================================================================
//function : GdumpSHASTA
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHASTA(const Standard_Integer iS,
const TopAbs_State T,
const TCollection_AsciiString& a,
const TCollection_AsciiString& b) const
{
const TopoDS_Shape& S = myDataStructure->Shape(iS);
GdumpSHASTA(S,T,a,b);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHASTA(const Standard_Integer ,
const TopAbs_State ,
const TCollection_AsciiString& ,
const TCollection_AsciiString& ) const
{
}
#endif
//=======================================================================
//function : GdumpSHASTA
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpSHASTA(const Standard_Integer iS,
const TopAbs_State T,
const TopOpeBRepBuild_ShapeSet& SS,
const TCollection_AsciiString& a,
const TCollection_AsciiString& b,
const TCollection_AsciiString& c)const
{
const TopoDS_Shape& S = myDataStructure->Shape(iS);
TCollection_AsciiString aib = a + " " + SS.DEBNumber() + " " + b;
GdumpSHASTA(S,T,aib,c);
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpSHASTA(const Standard_Integer ,
const TopAbs_State ,
const TopOpeBRepBuild_ShapeSet& ,
const TCollection_AsciiString& ,
const TCollection_AsciiString& ,
const TCollection_AsciiString& )const
{
}
#endif
//=======================================================================
//function : GdumpSHASETreset
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GdumpSHASETreset()
{
#ifdef DEB
mySHASETindex = 0;
#endif
}
//=======================================================================
//function : GdumpSHASETindex
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_Builder::GdumpSHASETindex()
{
Standard_Integer n = 0;
#ifdef DEB
n = ++mySHASETindex;
#endif
return n;
}
//=======================================================================
//function : GdumpEXP
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpEXP(const TopOpeBRepTool_ShapeExplorer& Ex) const
{
if ( ! Ex.More() ) return;
TopAbs_ShapeEnum t = Ex.Current().ShapeType();
if (t == TopAbs_SOLID) cout<<"";
else if (t == TopAbs_FACE) cout<<" ";
else if (t == TopAbs_EDGE) cout<<" ";
else cout<<"??";
Ex.DumpCurrent(cout);
Standard_Integer I = myDataStructure->Shape(Ex.Current());
if ( I != 0 ) cout<<" : shape "<<I;
cout<<endl;
cout.flush();
}
#else
void TopOpeBRepBuild_Builder::GdumpEXP(const TopOpeBRepTool_ShapeExplorer& ) const
{
}
#endif
//=======================================================================
//function : GdumpSOBU
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GdumpSOBU(TopOpeBRepBuild_SolidBuilder& /*ME*/) const
{
#ifdef DEB
#endif
} // GdumpSOBU
#ifdef DEB
void* GFABUMAKEFACEPWES_DEB = NULL;
#endif
//=======================================================================
//function : GdumpFABU
//purpose :
//=======================================================================
#ifdef DEB
void TopOpeBRepBuild_Builder::GdumpFABU(TopOpeBRepBuild_FaceBuilder& ME) const
{
const TopoDS_Shape& face = ME.Face();
Standard_Integer iF;
// Standard_Boolean tSPS =
GtraceSPS(face,iF);
TopOpeBRepBuild_WireEdgeSet* PWES = (TopOpeBRepBuild_WireEdgeSet*)GFABUMAKEFACEPWES_DEB;
Standard_Integer nf,nw,ne;
ME.InitFace();
if ( ME.MoreFace() ) cout<<"clear;"<<endl;
for (nf=0;ME.MoreFace();ME.NextFace()) {
nf++;
cout<<"# face "<<nf<<endl;
for (nw=0,ME.InitWire();ME.MoreWire();ME.NextWire()) {
nw++;
Standard_Boolean ow = ME.IsOldWire();
cout<<"# wire "<<nw;if(ow)cout<<" (old)";else cout<<" (new)";cout<<endl;
if (!ow) {
TCollection_AsciiString whatis("whatis");
for(ne=0,ME.InitEdge();ME.MoreEdge();ME.NextEdge()) {
ne++;
const TopoDS_Edge& EE = TopoDS::Edge(ME.Edge());
TCollection_AsciiString Enam("E");
TCollection_AsciiString VFnam("VF");
TCollection_AsciiString VRnam("VR");
Enam = Enam + ne + "NF" + nf + "F" + iF;
if (PWES) Enam = Enam + PWES->DEBName() + PWES->DEBNumber();
VFnam = VFnam + ne + "NF" + nf + "F" + iF;
VRnam = VRnam + ne + "NF" + nf + "F" + iF;
// cout<<" puts \"edge "<<ne<<" : "<<Enam<<"\"";cout<<"; ";
TopoDS_Vertex VF,VR; TopExp::Vertices(EE,VF,VR);
if ( ! VF.IsNull() && !VR.IsNull() && !EE.IsNull()) {
#ifdef DRAW
DBRep::Set(Enam.ToCString(),EE);
DBRep::Set(VFnam.ToCString(),VF);
DBRep::Set(VRnam.ToCString(),VR);
#endif
cout<<PRODINS<<"-O -p 0.5 "<<Enam; cout<<"; ";
// cout<<PRODINS<<VFnam; cout<<"; ";
// cout<<PRODINS<<VRnam; cout<<"; ";
// gp_Pnt PF = BRep_Tool::Pnt(VF);
// gp_Pnt PR = BRep_Tool::Pnt(VR);
// cout<<endl;
// cout<<"# ";
// cout<<"dinp "<<VFnam<<" ";TopOpeBRepBuild_Builder::PrintPnt(VF);cout<<"; ";
// cout<<"dinp "<<VRnam<<" ";TopOpeBRepBuild_Builder::PrintPnt(VR);cout<<"; ";
cout<<endl;
whatis += " "; whatis += Enam;
}
}
if (ne) cout<<" "<<whatis<<endl<<endl;
}
}
}
cout.flush();
} // GdumpFABU
#else
void TopOpeBRepBuild_Builder::GdumpFABU(TopOpeBRepBuild_FaceBuilder& ) const
{
}
#endif
//=======================================================================
//function : GdumpEDBU
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::GdumpEDBU(TopOpeBRepBuild_EdgeBuilder& /*ME*/) const
{
#ifdef DEB
#endif
} // GdumpEDBU
//=======================================================================
//function : GtraceSPS
//purpose :
//=======================================================================
#ifdef DEB
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const Standard_Integer iS) const
#else
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const Standard_Integer ) const
#endif
{
Standard_Boolean b = Standard_False;
#ifdef DEB
Standard_Integer ibid;
b = GtraceSPS(myDataStructure->Shape(iS),ibid);
#endif
return b;
}
//=======================================================================
//function : GtraceSPS
//purpose :
//=======================================================================
#ifdef DEB
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const Standard_Integer i,
const Standard_Integer j) const
#else
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const Standard_Integer ,
const Standard_Integer ) const
#endif
{
Standard_Boolean b = Standard_False;
#ifdef DEB
b = TopOpeBRepDS_GettraceSPSXX(i,j);
#endif
return b;
}
//=======================================================================
//function : GtraceSPS
//purpose :
//=======================================================================
#ifdef DEB
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const TopoDS_Shape& S) const
#else
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const TopoDS_Shape& ) const
#endif
{
Standard_Boolean b = Standard_False;
#ifdef DEB
Standard_Integer iS;
b = GtraceSPS(S,iS);
#endif
return b;
}
//=======================================================================
//function : GtraceSPS
//purpose :
//=======================================================================
#ifdef DEB
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const TopoDS_Shape& S,
Standard_Integer& IS) const
#else
Standard_Boolean TopOpeBRepBuild_Builder::GtraceSPS(const TopoDS_Shape&,
Standard_Integer& IS) const
#endif
{
IS = 0; Standard_Boolean b = Standard_False;
#ifdef DEB
if ( ! myDataStructure.IsNull() ) {
if ( ! S.IsNull() ) {
IS = myDataStructure->Shape(S);
b = TopOpeBRepDS_GettraceSPSX(IS);
}
}
#endif
return b;
}
//=======================================================================
//function : GcheckNBOUNDS
//purpose :
//=======================================================================
#ifdef DEB
Standard_Boolean TopOpeBRepBuild_Builder::GcheckNBOUNDS(const TopoDS_Shape& E)
#else
Standard_Boolean TopOpeBRepBuild_Builder::GcheckNBOUNDS(const TopoDS_Shape& )
#endif
{
Standard_Boolean res = Standard_False;
#ifdef DEB
Standard_Integer nf = 0, nr = 0;
TopOpeBRepTool_ShapeExplorer ex(E,TopAbs_VERTEX);
for(; ex.More(); ex.Next()) {
TopAbs_Orientation o = ex.Current().Orientation();
if (o == TopAbs_FORWARD) nf++;
if (o == TopAbs_REVERSED) nr++;
}
if ( nf == 1 && nr == 1 ) res = Standard_True;
#endif
return res;
}

View File

@@ -0,0 +1,229 @@
-- File: TopOpeBRepBuild_HBuilder.cdl
-- Created: Mon Jun 14 10:23:56 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class HBuilder from TopOpeBRepBuild inherits TShared from MMgt
---Purpose: The HBuilder algorithm constructs topological
-- objects from an existing topology and new
-- geometries attached to the topology. It is used to
-- construct the result of a topological operation;
-- the existing topologies are the parts involved in
-- the topological operation and the new geometries
-- are the intersection lines and points.
uses
State from TopAbs,
Shape from TopoDS,
ListOfShape from TopTools,
BuildTool from TopOpeBRepDS,
HDataStructure from TopOpeBRepDS,
Builder from TopOpeBRepBuild,
DataMapOfShapeInteger from TopTools,
DataMapOfIntegerInteger from TColStd,
DataMapOfIntegerListOfInteger from TColStd,
ListOfInteger from TColStd,
--modified by NIZHNY-MZV Thu Apr 20 10:12:48 2000
Builder1 from TopOpeBRepBuild
raises
NoSuchObject from Standard
is
Create (BT : BuildTool from TopOpeBRepDS) returns mutable HBuilder;
BuildTool(me) returns BuildTool from TopOpeBRepDS;
---C++: return const &
Perform (me : mutable; HDS : mutable HDataStructure from TopOpeBRepDS)
is static;
---Purpose:
-- Stores the data structure <HDS>,
-- Create shapes from the new geometries described in <HDS>.
Perform (me : mutable; HDS : mutable HDataStructure from TopOpeBRepDS;
S1,S2 : Shape from TopoDS)
is static;
---Purpose:
-- Same as previous + evaluates if an operation performed on shapes S1,S2
-- is a particular case.
Clear(me : mutable)
is static;
---Purpose: Removes all split and merge already performed.
-- Does NOT clear the handled DS.
DataStructure(me) returns HDataStructure from TopOpeBRepDS
is static;
---Purpose: returns the DS handled by this builder
ChangeBuildTool(me : mutable) returns BuildTool from TopOpeBRepDS
is static;
---C++: return &
MergeShapes(me : mutable;
S1 : Shape from TopoDS; TB1 : State from TopAbs;
S2 : Shape from TopoDS; TB2 : State from TopAbs)
is static;
---Purpose: Merges the two shapes <S1> and <S2> keeping the
-- parts of states <TB1>,<TB2> in <S1>,<S2>.
MergeSolids(me : mutable;
S1 : Shape from TopoDS; TB1 : State from TopAbs;
S2 : Shape from TopoDS; TB2 : State from TopAbs)
is static;
---Purpose: Merges the two solids <S1> and <S2> keeping the
-- parts in each solid of states <TB1> and <TB2>.
MergeSolid(me : mutable; S : Shape from TopoDS; TB : State from TopAbs)
is static;
---Purpose: Merges the solid <S> keeping the
-- parts of state <TB>.
IsSplit(me; S : Shape from TopoDS; ToBuild : State from TopAbs)
returns Boolean
is static;
---Purpose:
-- Returns True if the shape <S> has been split.
Splits(me; S : Shape from TopoDS; ToBuild : State from TopAbs)
returns ListOfShape from TopTools
raises NoSuchObject from Standard -- if S is not IsSplit()
is static;
---Purpose:
-- Returns the split parts <ToBuild> of shape <S>.
---C++: return const &
IsMerged(me; S : Shape from TopoDS; ToBuild : State from TopAbs)
returns Boolean from Standard
is static;
---Purpose:
-- Returns True if the shape <S> has been merged.
Merged(me; S : Shape from TopoDS; ToBuild : State from TopAbs)
returns ListOfShape from TopTools
raises NoSuchObject from Standard -- if <S> is not IsMerged()
is static;
---Purpose:
-- Returns the merged parts <ToBuild> of shape <S>.
---C++: return const &
NewVertex(me; I : Integer ) returns Shape from TopoDS
is static;
---Purpose:
-- Returns the vertex created on point <I>.
---C++: return const &
NewEdges(me; I : Integer ) returns ListOfShape from TopTools
is static;
---Purpose:
-- Returns the edges created on curve <I>.
---C++: return const &
ChangeNewEdges(me : mutable; I : Integer )
returns ListOfShape from TopTools
is static;
---Purpose:
-- Returns the edges created on curve <I>.
---C++: return &
NewFaces(me; I : Integer ) returns ListOfShape from TopTools
is static;
---Purpose:
-- Returns the faces created on surface <I>.
---C++: return const &
Section(me : mutable) returns ListOfShape from TopTools;
---C++: return const &
InitExtendedSectionDS(me : mutable; k : Integer = 3);
-- k = 1 : section edges built on intersection curves
-- k = 2 : section edges built on edges
-- k = 3 : all section edges
InitSection(me : mutable; k : Integer = 3);
-- k = 1 : section edges built on intersection curves
-- k = 2 : section edges built on edges
-- k = 3 : all section edges
MoreSection(me) returns Boolean;
NextSection(me:mutable);
CurrentSection(me) returns Shape from TopoDS;
---C++: return const &
MakeEdgeAncestorMap(me : mutable) is private;
GetDSEdgeFromSectEdge(me : mutable; E : Shape from TopoDS; rank : Integer)
returns Integer;
GetDSFaceFromDSEdge(me : mutable; indexEdg, rank : Integer)
---C++: return &
returns ListOfInteger from TColStd;
MakeCurveAncestorMap(me : mutable) is private;
GetDSCurveFromSectEdge(me : mutable; SectEdge : Shape from TopoDS)
returns Integer;
GetDSFaceFromDSCurve(me : mutable; indexCur, rank : Integer)
returns Integer;
GetDSPointFromNewVertex(me : mutable; NewVert : Shape from TopoDS)
returns Integer;
EdgeCurveAncestors(me : mutable;E : Shape from TopoDS;
F1,F2 : out Shape from TopoDS;
IC : out Integer) returns Boolean;
---Purpose: search for the couple of face F1,F2
-- (from arguments of supra Perform(S1,S2,HDS)) method which
-- intersection gives section edge E built on an intersection curve.
-- returns True if F1,F2 have been valued.
-- returns False if E is not a section edge built
-- on intersection curve IC.
EdgeSectionAncestors(me : mutable; E : Shape from TopoDS;
LF1,LF2 : out ListOfShape from TopTools;
LE1,LE2 : out ListOfShape from TopTools) returns Boolean;
---Purpose: search for the couple of face F1,F2
-- (from arguments of supra Perform(S1,S2,HDS)) method which
-- intersection gives section edge E built on at least one edge .
-- returns True if F1,F2 have been valued.
-- returns False if E is not a section edge built
-- on at least one edge of S1 and/or S2.
-- LE1,LE2 are edges of S1,S2 which common part is edge E.
-- LE1 or LE2 may be empty() but not both.
IsKPart(me : mutable) returns Integer from Standard is static;
---Purpose: Returns 0 is standard operation, != 0 if particular case
MergeKPart(me : mutable; TB1,TB2 : State from TopAbs) is static;
ChangeBuilder(me : mutable)
---C++: return &
returns Builder from TopOpeBRepBuild;
fields
myBuilder : Builder1 from TopOpeBRepBuild is protected;
-- Edge of mySection / index Edge Splitted ON of 1 or of 2
mySectEdgeDSEdges1 : DataMapOfShapeInteger from TopTools;
mySectEdgeDSEdges2 : DataMapOfShapeInteger from TopTools;
-- Index of Edge of the DS splitted ON / List of Faces of 1 or of 2
myDSEdgesDSFaces1 : DataMapOfIntegerListOfInteger from TColStd;
myDSEdgesDSFaces2 : DataMapOfIntegerListOfInteger from TColStd;
myMakeEdgeAncestorIsDone : Boolean from Standard;
-- Edge of mySection / index of Curve of the DS
mySectEdgeDSCurve : DataMapOfShapeInteger from TopTools;
myMakeCurveAncestorIsDone : Boolean from Standard;
-- new Vertex / index of point of the DS
myNewVertexDSPoint : DataMapOfShapeInteger from TopTools;
myMakePointAncestorIsDone : Boolean from Standard;
myEmptyShape : Shape from TopoDS;
myEmptyIntegerList : ListOfInteger from TColStd;
end HBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,686 @@
// File: TopOpeBRepBuild_HBuilder.cxx
// Created: Mon Jun 14 11:48:36 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_HBuilder.ixx>
#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State.hxx>
#include <TopOpeBRepDS_CurveIterator.hxx>
#include <TopOpeBRepDS_CurveExplorer.hxx>
#include <TopOpeBRepDS_Interference.hxx>
#include <TopOpeBRepDS_ShapeShapeInterference.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
#include <Standard_ProgramError.hxx>
#include <TopOpeBRepBuild_define.hxx>
//=======================================================================
//function : TopOpeBRepBuild_HBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_HBuilder::TopOpeBRepBuild_HBuilder
(const TopOpeBRepDS_BuildTool& BT)
: myBuilder(BT),
myMakeEdgeAncestorIsDone(Standard_False),
myMakeCurveAncestorIsDone(Standard_False),
myMakePointAncestorIsDone(Standard_False)
{
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::Perform
(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
myBuilder.Perform(HDS);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const TopoDS_Shape& S1, const TopoDS_Shape& S2)
{
myBuilder.Perform(HDS,S1,S2);
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::Clear()
{
myBuilder.Clear();
InitExtendedSectionDS();
}
//=======================================================================
//function : DataStructure
//purpose :
//=======================================================================
Handle(TopOpeBRepDS_HDataStructure) TopOpeBRepBuild_HBuilder::DataStructure() const
{
return myBuilder.DataStructure();
}
//=======================================================================
//function : ChangeBuildTool
//purpose :
//=======================================================================
TopOpeBRepDS_BuildTool& TopOpeBRepBuild_HBuilder::ChangeBuildTool()
{
TopOpeBRepDS_BuildTool& BT = myBuilder.ChangeBuildTool();
return BT;
}
//=======================================================================
//function : BuildTool
//purpose :
//=======================================================================
const TopOpeBRepDS_BuildTool& TopOpeBRepBuild_HBuilder::BuildTool() const
{
return myBuilder.BuildTool();
}
//=======================================================================
//function : MergeShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::MergeShapes
(const TopoDS_Shape& S1, const TopAbs_State ToBuild1,const TopoDS_Shape& S2, const TopAbs_State ToBuild2)
{
myBuilder.MergeShapes(S1,ToBuild1,S2,ToBuild2);
}
//=======================================================================
//function : MergeSolids
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::MergeSolids
(const TopoDS_Shape& S1, const TopAbs_State ToBuild1,const TopoDS_Shape& S2, const TopAbs_State ToBuild2)
{
myBuilder.MergeSolids(S1,ToBuild1,S2,ToBuild2);
}
//=======================================================================
//function : MergeSolid
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::MergeSolid(const TopoDS_Shape& S, const TopAbs_State ToBuild)
{
myBuilder.MergeSolid(S,ToBuild);
}
//=======================================================================
//function : IsSplit
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_HBuilder::IsSplit(const TopoDS_Shape& S, const TopAbs_State ToBuild) const
{
Standard_Boolean res = myBuilder.IsSplit(S,ToBuild);
return res;
}
//=======================================================================
//function : Splits
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Splits(const TopoDS_Shape& S, const TopAbs_State ToBuild) const
{
const TopTools_ListOfShape& L = myBuilder.Splits(S,ToBuild);
return L;
}
//=======================================================================
//function : IsMerged
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_HBuilder::IsMerged(const TopoDS_Shape& S, const TopAbs_State ToBuild) const
{
Standard_Boolean res = myBuilder.IsMerged(S,ToBuild);
return res;
}
//=======================================================================
//function : Merged
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Merged(const TopoDS_Shape& S, const TopAbs_State ToBuild) const
{
const TopTools_ListOfShape& L = myBuilder.Merged(S,ToBuild);
return L;
}
//=======================================================================
//function : NewVertex
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_HBuilder::NewVertex(const Standard_Integer I) const
{
const TopoDS_Shape& V = myBuilder.NewVertex(I);
return V;
}
//=======================================================================
//function : NewEdges
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::NewEdges(const Standard_Integer I) const
{
const TopTools_ListOfShape& L = myBuilder.NewEdges(I);
return L;
}
//=======================================================================
//function : ChangeNewEdges
//purpose :
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::ChangeNewEdges(const Standard_Integer I)
{
TopTools_ListOfShape& L = myBuilder.ChangeNewEdges(I);
return L;
}
//=======================================================================
//function : NewFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::NewFaces(const Standard_Integer I) const
{
const TopTools_ListOfShape& L = myBuilder.NewFaces(I);
return L;
}
//=======================================================================
//function : Section
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_HBuilder::Section()
{
const TopTools_ListOfShape& L = myBuilder.Section();
return L;
}
static TopTools_ListOfShape* PLE = NULL;
static TopTools_ListIteratorOfListOfShape* PITLE = NULL;
//=======================================================================
//function : InitExtendedSectionDS
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::InitExtendedSectionDS(const Standard_Integer k)
{
if (k == 1) {
myMakeCurveAncestorIsDone = Standard_False;
}
else if (k == 2) {
myMakeEdgeAncestorIsDone = Standard_False;
}
else if (k == 3) {
myMakeEdgeAncestorIsDone = Standard_False;
myMakeCurveAncestorIsDone = Standard_False;
}
else return;
}
//=======================================================================
//function : InitSection
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::InitSection(const Standard_Integer k)
{
if (PLE == NULL) PLE = new TopTools_ListOfShape();
if (PITLE == NULL) PITLE = new TopTools_ListIteratorOfListOfShape();
PLE->Clear(); PITLE->Initialize(*PLE);
InitExtendedSectionDS(k);
if (k == 1) myBuilder.SectionCurves(*PLE);
else if (k == 2) myBuilder.SectionEdges(*PLE);
else if (k == 3) myBuilder.Section(*PLE);
else return;
PITLE->Initialize(*PLE);
}
//=======================================================================
//function : MoreSection
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_HBuilder::MoreSection() const
{
if (PITLE == NULL) return Standard_False;
Standard_Boolean b = PITLE->More();
return b;
}
//=======================================================================
//function : NextSection
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::NextSection()
{
if (PITLE == NULL) return;
if (PITLE->More()) PITLE->Next();
}
//=======================================================================
//function : CurrentSection
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_HBuilder::CurrentSection() const
{
if (PITLE == NULL) Standard_ProgramError::Raise("no more CurrentSection");
if (!PITLE->More()) Standard_ProgramError::Raise("no more CurrentSection");
return PITLE->Value();
}
//=======================================================================
//function : MakeEdgeAncestorMap
//purpose : private
//=======================================================================
void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap()
{
if(myMakeEdgeAncestorIsDone)
return;
mySectEdgeDSEdges1.Clear();
mySectEdgeDSEdges2.Clear();
myDSEdgesDSFaces1.Clear();
myDSEdgesDSFaces2.Clear();
myMakeEdgeAncestorIsDone = Standard_True;
TopTools_MapOfShape MF, ME;
const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
// Standard_Integer ns = DS.NbShapes(),is;
Standard_Integer ns = DS.NbShapes();
// Standard_Integer ei, fi, re, rf ,gi, ise;
Standard_Integer ei, fi, re, rf ,gi;
TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State
it(myBuilder.mySplitON);
TopTools_ListIteratorOfListOfShape its;
for(;it.More(); it.Next()) {
const TopoDS_Shape& ShaSpl = it.Key();
ei = DS.Shape(ShaSpl);
re = DS.AncestorRank(ShaSpl);
if(!re) continue;
TopOpeBRepDS_ListOfShapeOn1State& losos1s =
(*(TopOpeBRepDS_ListOfShapeOn1State*)&it.Value());
TopTools_ListOfShape& los = losos1s.ChangeListOnState();
its.Initialize(los);
if(re == 1)
for(; its.More(); its.Next()) {
TopoDS_Shape& SecEdg = its.Value();
if(!mySectEdgeDSEdges1.IsBound(SecEdg))
mySectEdgeDSEdges1.Bind(SecEdg, ei);
}
else if(re == 2)
for(; its.More(); its.Next()) {
TopoDS_Shape& SecEdg = its.Value();
if(!mySectEdgeDSEdges2.IsBound(SecEdg))
mySectEdgeDSEdges2.Bind(SecEdg,ei);
}
}
// Standard_Boolean gb;
TopOpeBRepDS_Kind gk;
for (fi=1;fi<=ns;fi++) {
const TopoDS_Shape& fds = DS.Shape(fi);
if(fds.IsNull())
continue;
if (fds.ShapeType() != TopAbs_FACE) continue;
TopOpeBRepDS_ListIteratorOfListOfInterference
it1(DS.ShapeInterferences(fds));
for (;it1.More();it1.Next()) {
Handle(TopOpeBRepDS_ShapeShapeInterference) SSI =
Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(it1.Value());
if (SSI.IsNull()) continue;
gk = SSI->GeometryType();
gi = SSI->Geometry();
if (gk != TopOpeBRepDS_EDGE) continue;
rf = DS.AncestorRank(fds);
if(!rf) continue;
// if (!MF.Contains(fds) ) {
// MF.Add(fds);
if(rf == 1) {
if(!myDSEdgesDSFaces1.IsBound(gi)) {
TColStd_ListOfInteger thelist;
myDSEdgesDSFaces1.Bind(gi,thelist );
}
myDSEdgesDSFaces1.ChangeFind(gi).Append(fi);
}
else if(rf == 2) {
if(!myDSEdgesDSFaces2.IsBound(gi)){
TColStd_ListOfInteger thelist1;
myDSEdgesDSFaces2.Bind(gi, thelist1);
}
myDSEdgesDSFaces2.ChangeFind(gi).Append(fi);
}
// }
}
}
}
//=======================================================================
//function : GetDSEdgeFromSectEdge
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_HBuilder::GetDSEdgeFromSectEdge(const TopoDS_Shape& E,const Standard_Integer rank)
{
if(!myMakeEdgeAncestorIsDone)
MakeEdgeAncestorMap();
Standard_Integer i = 0;
if(rank == 1) {
if(mySectEdgeDSEdges1.IsBound(E))
i = mySectEdgeDSEdges1.Find(E);
}
if(rank == 2) {
if(mySectEdgeDSEdges2.IsBound(E))
i = mySectEdgeDSEdges2.Find(E);
}
return i;
}
//=======================================================================
//function : GetDSFaceFromDSEdge
//purpose :
//=======================================================================
TColStd_ListOfInteger& TopOpeBRepBuild_HBuilder::GetDSFaceFromDSEdge
(const Standard_Integer indexEdg, const Standard_Integer rank)
{
if(!myMakeEdgeAncestorIsDone)
MakeEdgeAncestorMap();
if(rank == 1) {
if(myDSEdgesDSFaces1.IsBound(indexEdg)) {
TColStd_ListOfInteger& loi =
myDSEdgesDSFaces1.ChangeFind(indexEdg);
return loi;
}
}
if(rank == 2) {
if(myDSEdgesDSFaces2.IsBound(indexEdg)) {
TColStd_ListOfInteger& loi =
myDSEdgesDSFaces2.ChangeFind(indexEdg);
return loi;
}
}
return myEmptyIntegerList;
}
//=======================================================================
//function : MakeCurveAncestorMap
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::MakeCurveAncestorMap()
{
if(myMakeCurveAncestorIsDone)
return;
mySectEdgeDSCurve.Clear();
myMakeCurveAncestorIsDone = Standard_True;
#ifndef DEB
// static const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS(); // How to do static <--> const
#else
const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
#endif
TopTools_ListIteratorOfListOfShape itloe;
TopOpeBRepDS_CurveExplorer cex(DS,Standard_True);
// Standard_Integer ic, icm;
Standard_Integer ic;
for (; cex.More(); cex.Next()) {
ic = cex.Index();
const TopTools_ListOfShape& LOS = myBuilder.myNewEdges.Find(ic);
itloe.Initialize(LOS);
for(;itloe.More();itloe.Next()) {
TopoDS_Shape& E = *((TopoDS_Shape*)(&itloe.Value()));
if(mySectEdgeDSCurve.IsBound(E)) {
#ifdef DEB
cout<<"BRepAlgo_DSAccess::MakeEdgeAncestorFromCurve : program error"<<endl;
#endif
}
mySectEdgeDSCurve.Bind(E, ic);
}
}
}
//=======================================================================
//function : GetDSCurveFromSectEdge
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_HBuilder::GetDSCurveFromSectEdge(const TopoDS_Shape& SectEdge)
{
Standard_Integer i = 0;
if(!myMakeCurveAncestorIsDone)
MakeCurveAncestorMap();
if(mySectEdgeDSCurve.IsBound(SectEdge)) {
i = mySectEdgeDSCurve.Find(SectEdge);
}
return i;
}
//=======================================================================
//function : GetDSFaceFromDSCurve
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_HBuilder::GetDSFaceFromDSCurve(const Standard_Integer indexCur,const Standard_Integer rank)
{
Standard_Integer i = 0;
if(!myMakeCurveAncestorIsDone)
MakeCurveAncestorMap();
const TopOpeBRepDS_DataStructure& DS = DataStructure()->DS();
if(rank == 1) {
const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur);
const TopoDS_Shape& F1 = DSC.Shape1();
i = DS.Shape(F1);
}
if(rank == 2) {
const TopOpeBRepDS_Curve& DSC = DS.Curve(indexCur);
const TopoDS_Shape& F2 = DSC.Shape2();
i = DS.Shape(F2);
}
return i;
}
//=======================================================================
//function : GetDSPointFromNewVertex
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_HBuilder::GetDSPointFromNewVertex(const TopoDS_Shape& NewVert)
{
if(!myMakePointAncestorIsDone) {
myMakePointAncestorIsDone = Standard_True;
TopOpeBRepDS_DataStructure& DS = DataStructure()->ChangeDS();
Standard_Integer i, NbPoint = DS.NbPoints();
for(i = 1; i <= NbPoint; i++) {
const TopoDS_Shape& Vertex = NewVertex(i);
if(!Vertex.IsNull())
myNewVertexDSPoint.Bind(Vertex, i);
}
}
Standard_Integer iPnt = 0;
if(myNewVertexDSPoint.IsBound(NewVert))
iPnt = myNewVertexDSPoint.Find(NewVert);
return iPnt;
}
//=======================================================================
//function : EdgeCurveAncestors
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeCurveAncestors(const TopoDS_Shape& E,TopoDS_Shape& F1,TopoDS_Shape& F2,Standard_Integer& IC)
{
F1.Nullify(); F2.Nullify(); IC = 0;
const Handle(TopOpeBRepDS_HDataStructure)& HDS = myBuilder.DataStructure();
const TopOpeBRepDS_DataStructure& DS = HDS->DS();
// TopTools_ListIteratorOfListOfShape itloe;
IC = GetDSCurveFromSectEdge(E);
if(!IC)
return Standard_False;
Standard_Integer iF1, iF2;
iF1 = GetDSFaceFromDSCurve(IC, 1);
iF2 = GetDSFaceFromDSCurve(IC, 2);
F1 = DS.Shape(iF1);
F2 = DS.Shape(iF2);
return Standard_True;
}
//=======================================================================
//function : EdgeSectionAncestors
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_HBuilder::EdgeSectionAncestors
(const TopoDS_Shape& E, TopTools_ListOfShape& LF1, TopTools_ListOfShape& LF2, TopTools_ListOfShape& LE1, TopTools_ListOfShape& LE2)
{
if (E.ShapeType() != TopAbs_EDGE) return Standard_False;
LF1.Clear(); LF2.Clear(); LE1.Clear(); LE2.Clear();
TColStd_ListOfInteger f1, f2;
f1.Clear(); f2.Clear();
Standard_Integer ie1, ie2, curr;
ie1 = GetDSEdgeFromSectEdge(E,1);
ie2 = GetDSEdgeFromSectEdge(E,2);
TColStd_ListIteratorOfListOfInteger it;
if(ie1 && ie2) {
TColStd_MapOfInteger moi;
f1 = GetDSFaceFromDSEdge(ie1,1);
it.Initialize(f1);
moi.Clear();
for(; it.More(); it.Next()) {
moi.Add(it.Value());
}
it.Initialize(GetDSFaceFromDSEdge(ie2,1));
for(; it.More(); it.Next()) {
curr = it.Value();
if(!moi.Contains(curr)) {
moi.Add(curr);
f1.Append(curr);
}
}
f2 = GetDSFaceFromDSEdge(ie1,2);
it.Initialize(f2);
moi.Clear();
for(; it.More(); it.Next()) {
moi.Add(it.Value());
}
it.Initialize(GetDSFaceFromDSEdge(ie2,2));
for(; it.More(); it.Next()) {
curr = it.Value();
if(!moi.Contains(curr)) {
moi.Add(curr);
f2.Append(curr);
}
}
}
else {
if(ie1) {
f1 = GetDSFaceFromDSEdge(ie1,1);
f2 = GetDSFaceFromDSEdge(ie1,2);
}
else if(ie2) {
f1 = GetDSFaceFromDSEdge(ie2,1);
f2 = GetDSFaceFromDSEdge(ie2,2);
}
}
const TopOpeBRepDS_DataStructure& DS = myBuilder.DataStructure()->DS();
if(ie1)
LE1.Append(DS.Shape(ie1));
if(ie2)
LE2.Append(DS.Shape(ie2));
for(it.Initialize(f1); it.More(); it.Next()) {
curr = it.Value();
LF1.Append(DS.Shape(curr));
}
for(it.Initialize(f2); it.More(); it.Next()) {
curr = it.Value();
LF2.Append(DS.Shape(curr));
}
Standard_Boolean r = (!LF1.IsEmpty() && !LF2.IsEmpty());
r = r && (!LE1.IsEmpty() || !LE2.IsEmpty());
return r;
}
//=======================================================================
//function : IsKPart
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_HBuilder::IsKPart()
{
Standard_Integer kp = myBuilder.IsKPart();
return kp;
}
//=======================================================================
//function : MergeKPart
//purpose :
//=======================================================================
void TopOpeBRepBuild_HBuilder::MergeKPart(const TopAbs_State TB1,const TopAbs_State TB2)
{
Standard_Integer kp = IsKPart();
if ( kp ) myBuilder.MergeKPart(TB1,TB2);
}
//=======================================================================
//function : ChangeBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_Builder& TopOpeBRepBuild_HBuilder::ChangeBuilder()
{
return myBuilder;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
-- File: TopOpeBRepBuild_Loop.cdl
-- Created: Tue Dec 19 19:44:23 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class Loop from TopOpeBRepBuild inherits TShared from MMgt
---Purpose:
-- a Loop is an existing shape (Shell,Wire) or a set
-- of shapes (Faces,Edges) which are connex.
-- a set of connex shape is represented by a BlockIterator
uses
Shape from TopoDS,
BlockIterator from TopOpeBRepBuild,
ShapeEnum from TopAbs
is
Create(S : Shape from TopoDS) returns mutable Loop;
Create(BI : BlockIterator) returns mutable Loop;
IsShape(me) returns Boolean from Standard is virtual;
Shape(me) returns Shape from TopoDS is virtual;
---C++: return const &
-- only when IsShape() is true
BlockIterator(me) returns BlockIterator is static;
---C++: return const &
-- only when IsShape() is false
Dump(me) is virtual;
fields
myIsShape : Boolean from Standard is protected;
myShape : Shape from TopoDS is protected;
myBlockIterator : BlockIterator is protected;
end Loop from TopOpeBRepBuild;

View File

@@ -0,0 +1,67 @@
// File: TopOpeBRepBuild_Loop.cxx
// Created: Tue Dec 19 19:52:32 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_Loop.ixx>
//=======================================================================
//function : TopOpeBRepBuild_Loop
//purpose :
//=======================================================================
TopOpeBRepBuild_Loop::TopOpeBRepBuild_Loop
(const TopoDS_Shape& S) :
myIsShape(Standard_True),myShape(S),myBlockIterator(0,0)
{
}
//=======================================================================
//function : TopOpeBRepBuild_Loop
//purpose :
//=======================================================================
TopOpeBRepBuild_Loop::TopOpeBRepBuild_Loop
(const TopOpeBRepBuild_BlockIterator& BI) :
myIsShape(Standard_False),myBlockIterator(BI)
{
}
//=======================================================================
//function : IsShape
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Loop::IsShape() const
{
return myIsShape;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_Loop::Shape() const
{
return myShape;
}
//=======================================================================
//function : BlockIterator
//purpose :
//=======================================================================
const TopOpeBRepBuild_BlockIterator& TopOpeBRepBuild_Loop::BlockIterator() const
{
return myBlockIterator;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void TopOpeBRepBuild_Loop::Dump() const
{
}

View File

@@ -0,0 +1,26 @@
-- File: TopOpeBRepBuild_LoopClassifier.cdl
-- Created: Wed Mar 3 17:29:13 1993
-- Author: Jean Yves LEBEY
-- <jyl@sdsun2>
---Copyright: Matra Datavision 1993
deferred class LoopClassifier from TopOpeBRepBuild
---Purpose: classify loops in order to build Areas
uses
ShapeEnum from TopAbs,
State from TopAbs,
Loop from TopOpeBRepBuild
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_LoopClassifier(){Delete() ; }"
Compare(me : in out; L1,L2 : Loop from TopOpeBRepBuild)
returns State from TopAbs is deferred;
---Purpose: Returns the state of loop <L1> compared with loop <L2>.
end LoopClassifier from TopOpeBRepBuild;

View File

@@ -0,0 +1,10 @@
// File: TopOpeBRepBuild_LoopClassifier.cxx
// Created: Thu Mar 11 14:30:55 1993
// Author: Jean Yves LEBEY
// <jyl@sdsun2>
// Copyright: Matra Datavision
#include <TopOpeBRepBuild_LoopClassifier.ixx>
void TopOpeBRepBuild_LoopClassifier::Delete()
{}

View File

@@ -0,0 +1,40 @@
-- File: TopOpeBRepBuild_LoopSet.cdl
-- Created: Tue Mar 23 14:55:16 1993
-- Author: Jean Yves LEBEY
-- <jyl@phobox>
---Copyright: Matra Datavision 1993
class LoopSet from TopOpeBRepBuild
uses
Loop from TopOpeBRepBuild,
ListOfLoop from TopOpeBRepBuild,
ListIteratorOfListOfLoop from TopOpeBRepBuild
is
Create returns LoopSet;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_LoopSet(){Delete() ; }"
-- filling : append loops (shapes,blocks) in list
ChangeListOfLoop(me : in out) returns ListOfLoop is static;
---C++: return &
-- exploration of the loops
InitLoop(me : in out) is virtual;
MoreLoop(me) returns Boolean is virtual;
NextLoop(me : in out) is virtual;
Loop(me) returns Loop from TopOpeBRepBuild is virtual;
---C++: return const &
fields
myListOfLoop : ListOfLoop;
myLoopIterator : ListIteratorOfListOfLoop;
myLoopIndex : Integer from Standard;
myNbLoop : Integer from Standard;
end LoopSet from TopOpeBRepBuild;

View File

@@ -0,0 +1,74 @@
// File: TopOpeBRepBuild_LoopSet.cxx
// Created: Tue Mar 23 15:01:08 1993
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepBuild_LoopSet.ixx>
//=======================================================================
//function : TopOpeBRepBuild_LoopSet
//purpose :
//=======================================================================
TopOpeBRepBuild_LoopSet::TopOpeBRepBuild_LoopSet() :
myLoopIndex(1), myNbLoop(0)
{
}
void TopOpeBRepBuild_LoopSet::Delete()
{}
//=======================================================================
//function : InitLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_LoopSet::InitLoop()
{
myLoopIterator.Initialize(myListOfLoop);
myLoopIndex = 1; myNbLoop = myListOfLoop.Extent();
}
//=======================================================================
//function : MoreLoop
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_LoopSet::MoreLoop() const
{
Standard_Boolean b = myLoopIterator.More();
return b;
}
//=======================================================================
//function : NextLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_LoopSet::NextLoop()
{
myLoopIndex++;
myLoopIterator.Next();
}
//=======================================================================
//function : Loop
//purpose :
//=======================================================================
const Handle(TopOpeBRepBuild_Loop)& TopOpeBRepBuild_LoopSet::Loop() const
{
const Handle(TopOpeBRepBuild_Loop)& L = myLoopIterator.Value();
return L;
}
//=======================================================================
//function : ChangeListOfLoop
//purpose :
//=======================================================================
TopOpeBRepBuild_ListOfLoop& TopOpeBRepBuild_LoopSet::ChangeListOfLoop()
{
return myListOfLoop;
}

View File

@@ -0,0 +1,625 @@
// File: TopOpeBRepBuild_Merge.cxx
// Created: Tue Aug 30 11:13:16 1994
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_Builder.jxx>
#include <TopOpeBRepBuild_ShellFaceSet.hxx>
#include <TopOpeBRepBuild_SolidBuilder.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
#include <BRep_Tool.hxx>
#include <TopOpeBRepBuild_define.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRep_Builder.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRepCheck.hxx>
#include <TopoDS_Iterator.hxx>
//#include <DBRep.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck.hxx>
#include <BRepCheck_Result.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPS();
#endif
//------------
//static Standard_Integer ifvNbFace = 0;
//static char *name = " ";
//-------------
static void CorrectEdgeOrientation(TopoDS_Shape& aWire)
{
TopTools_ListOfShape anEdgeList, anAuxList, aTrueEdgeList;
BRep_Builder BB;
TopoDS_Vertex vf, vl, v1f, v1l;
Standard_Boolean append = Standard_True;
TopoDS_Iterator tdi(aWire, Standard_False, Standard_False);
for(; tdi.More(); tdi.Next()) anEdgeList.Append(tdi.Value());
Standard_Integer n = anEdgeList.Extent();
if(n <= 1) return;
TopTools_ListIteratorOfListOfShape anIt(anEdgeList);
TopoDS_Shape anCurEdge = anIt.Value();
TopExp::Vertices(TopoDS::Edge(anCurEdge), vf, vl, Standard_True);
aTrueEdgeList.Append(anCurEdge);
anIt.Next();
while(n > 0 && append) {
for(; anIt.More(); anIt.Next()) {
append = Standard_False;
anCurEdge = anIt.Value();
TopExp::Vertices(TopoDS::Edge(anCurEdge), v1f, v1l, Standard_True);
if(v1f.IsSame(vl)) {
aTrueEdgeList.Append(anCurEdge);
vl = v1l;
append = Standard_True;
continue;
}
if(v1l.IsSame(vf)) {
aTrueEdgeList.Append(anCurEdge);
vf = v1f;
append = Standard_True;
continue;
}
if(v1l.IsSame(vl)) {
TopoDS_Shape anRevEdge = anCurEdge.Reversed();
aTrueEdgeList.Append(anRevEdge);
vl = v1f;
append = Standard_True;
continue;
}
if(v1f.IsSame(vf)) {
TopoDS_Shape anRevEdge = anCurEdge.Reversed();
aTrueEdgeList.Append(anRevEdge);
vf = v1l;
append = Standard_True;
continue;
}
anAuxList.Append(anCurEdge);
}
anEdgeList.Assign(anAuxList);
anAuxList.Clear(); //something wrong in Assign when list contains 1 element.
n = anEdgeList.Extent();
anIt.Initialize(anEdgeList);
}
if(n > 0) aTrueEdgeList.Append(anEdgeList);
aWire.Nullify();
BB.MakeWire(TopoDS::Wire(aWire));
anIt.Initialize(aTrueEdgeList);
for(; anIt.More(); anIt.Next()) BB.Add(aWire, anIt.Value());
}
static void CorrectUnclosedWire(TopoDS_Shape& aWire)
{
// cout << "-------CorrectUnclosedWire" << endl;
BRep_Builder BB;
TopoDS_Iterator tdi(aWire, Standard_False, Standard_False);
Standard_Integer nbe = 0;
for(; tdi.More(); tdi.Next()) {
nbe++;
const TopoDS_Shape& ed = tdi.Value();
Standard_Integer nbv = 0;
TopoDS_Iterator tdie(ed, Standard_False, Standard_False);
for(; tdie.More(); tdie.Next()) {
nbv++;
}
// cout << "Edge " << nbe << " : " << nbv << endl;
if(nbv <= 1) {
// cout << "Remove bad edge" << endl;
BB.Remove(aWire, ed);
}
}
TopTools_IndexedDataMapOfShapeListOfShape VElists;
VElists.Clear();
TopExp::MapShapesAndAncestors(aWire, TopAbs_VERTEX, TopAbs_EDGE, VElists);
Standard_Integer nbVer = VElists.Extent(), i;
for(i = 1; i <= nbVer; i++) {
const TopTools_ListOfShape& Elist = VElists.FindFromIndex(i);
if(Elist.Extent() == 1) {
TopoDS_Shape anEdge = Elist.First();
// cout << "Remove redundant edge" << endl;
BB.Remove(aWire, anEdge);
}
}
}
//=======================================================================
//function : MergeShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MergeShapes(const TopoDS_Shape& S1,const TopAbs_State ToBuild1,const TopoDS_Shape& S2,const TopAbs_State ToBuild2)
{
Standard_Boolean lesmemes = S1.IsEqual(S2);
if (lesmemes) {
#ifdef DEB
cout<<"TopOpeBRepBuild : S1 == S2"<<endl;
#endif
return;
}
#ifdef DEB
GdumpSHASETreset();
#endif
myState1 = ToBuild1;
myState2 = ToBuild2;
myShape1 = S1;
myShape2 = S2;
Standard_Boolean S1null = S1.IsNull();
Standard_Boolean S2null = S2.IsNull();
MapShapes(S1,S2);
SplitSectionEdges();
//======================== debut KPart
if (IsKPart()) {
MergeKPart();
ClearMaps();
return;
}
//======================== fin KPart
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
// Create a face set <SFS> connected by edges
// -----------------------------------------
TopOpeBRepBuild_ShellFaceSet SFS;
#ifdef DEB
SFS.DEBNumber(GdumpSHASETindex());
#endif
// NYI : SplitCompound appele par SplitShape
TopOpeBRepTool_ShapeExplorer ex1;
#ifdef DEB
TopAbs_ShapeEnum t1,tex1;
#else
TopAbs_ShapeEnum t1=TopAbs_COMPOUND,tex1=TopAbs_COMPOUND;
#endif
if ( ! S1null ) {
t1 = tex1 = TopType(S1);
if ( t1 == TopAbs_COMPOUND ) {
tex1 = TopAbs_SOLID; ex1.Init(S1,tex1);
if ( ! ex1.More() ) {
tex1 = TopAbs_SHELL; ex1.Init(S1,tex1);
if ( ! ex1.More() ) {
tex1 = TopAbs_FACE; ex1.Init(S1,tex1);
if( ! ex1.More() ) {
tex1 = TopAbs_EDGE; ex1.Init(S1,tex1);
}
}
}
}
else if (t1 == TopAbs_WIRE) {
tex1 = TopAbs_EDGE; ex1.Init(S1,tex1);
}
else ex1.Init(S1,tex1);
SplitShapes(ex1,ToBuild1,ToBuild2,SFS,RevOri1);
}
TopOpeBRepTool_ShapeExplorer ex2;
#ifdef DEB
TopAbs_ShapeEnum t2,tex2;
#else
TopAbs_ShapeEnum t2=TopAbs_COMPOUND,tex2=TopAbs_COMPOUND;
#endif
if ( ! S2null ) {
t2 = tex2 = TopType(S2);
if ( t2 == TopAbs_COMPOUND ) {
tex2 = TopAbs_SOLID; ex2.Init(S2,tex2);
if ( ! ex2.More() ) {
tex2 = TopAbs_SHELL; ex2.Init(S2,tex2);
if ( ! ex2.More() ) {
tex2 = TopAbs_FACE; ex2.Init(S2,tex2);
if( ! ex2.More() ) {
tex2 = TopAbs_EDGE; ex2.Init(S2,tex2);
}
}
}
}
else if (t2 == TopAbs_WIRE) {
tex2 = TopAbs_EDGE; ex2.Init(S2,tex2);
}
else ex2.Init(S2,tex2);
SplitShapes(ex2,ToBuild2,ToBuild1,SFS,RevOri2);
}
// S1 or S2 = COMPOUND : connect them the list of merged shapes build
// on the first subshape.
if ( ! S1null ) {
if ( t1 == TopAbs_COMPOUND ) {
TopTools_ListOfShape& L1 = ChangeMerged(S1,ToBuild1);
ex1.Init(S1,tex1);
if ( ex1.More() ) {
const TopoDS_Shape& SS1 = ex1.Current();
TopTools_ListOfShape& LSS1 = ChangeMerged(SS1,ToBuild1);
L1 = LSS1;
}
}
}
if ( ! S2null ) {
if ( t2 == TopAbs_COMPOUND ) {
TopTools_ListOfShape& L2 = ChangeMerged(S2,ToBuild2);
ex2.Init(S2,tex2);
if ( ex2.More() ) {
const TopoDS_Shape& SS2 = ex2.Current();
TopTools_ListOfShape& LSS2 = ChangeMerged(SS2,ToBuild2);
L2 = LSS2;
}
}
}
ClearMaps();
} // MergeShapes
//=======================================================================
//function : Classify
//purpose : LocOpe use
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::Classify() const
{
return myClassifyVal;
}
//=======================================================================
//function : ChangeClassify
//purpose : LocOpe use
//=======================================================================
void TopOpeBRepBuild_Builder::ChangeClassify(const Standard_Boolean classify)
{
myClassifyDef = Standard_True;
myClassifyVal = classify;
}
//=======================================================================
//function : MergeSolids
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MergeSolids(const TopoDS_Shape& S1,const TopAbs_State ToBuild1,const TopoDS_Shape& S2,const TopAbs_State ToBuild2)
{
MergeShapes(S1,ToBuild1,S2,ToBuild2);
} // MergeSolids
//=======================================================================
//function : MergeSolid
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MergeSolid(const TopoDS_Shape& S,const TopAbs_State ToBuild)
{
TopoDS_Shape Snull;
MergeShapes(S,ToBuild,Snull,ToBuild);
} // MergeSolid
//=======================================================================
//function : MakeSolids
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MakeSolids(TopOpeBRepBuild_SolidBuilder& SOBU,TopTools_ListOfShape& L)
{
TopoDS_Shape newSolid;
TopoDS_Shape newShell;
for (SOBU.InitSolid(); SOBU.MoreSolid(); SOBU.NextSolid()) {
myBuildTool.MakeSolid(newSolid);
for (SOBU.InitShell(); SOBU.MoreShell(); SOBU.NextShell()) {
Standard_Boolean isold = SOBU.IsOldShell();
if (isold) newShell = SOBU.OldShell();
else {
myBuildTool.MakeShell(newShell);
for (SOBU.InitFace(); SOBU.MoreFace(); SOBU.NextFace()) {
TopoDS_Shape F = SOBU.Face();
myBuildTool.AddShellFace(newShell,F);
}
}
myBuildTool.Closed(newShell,Standard_True); // NYI : check exact du caractere closed du shell
myBuildTool.AddSolidShell(newSolid,newShell);
}
L.Append(newSolid);
}
}
//=======================================================================
//function : MakeShells
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MakeShells(TopOpeBRepBuild_SolidBuilder& SOBU,TopTools_ListOfShape& L)
{
TopoDS_Shape newShell;
for (SOBU.InitShell(); SOBU.MoreShell(); SOBU.NextShell()) {
Standard_Boolean isold = SOBU.IsOldShell();
if (isold) newShell = SOBU.OldShell();
else {
myBuildTool.MakeShell(newShell);
for (SOBU.InitFace(); SOBU.MoreFace(); SOBU.NextFace()) {
TopoDS_Shape F = SOBU.Face();
myBuildTool.AddShellFace(newShell,F);
}
}
L.Append(newShell);
}
}
//=======================================================================
//function : MakeFaces
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MakeFaces(const TopoDS_Shape& aFace,TopOpeBRepBuild_FaceBuilder& FABU,TopTools_ListOfShape& L)
{
#ifdef DEB
Standard_Integer iF = 0; Standard_Boolean tSPS = GtraceSPS(aFace,iF);
if(tSPS){GdumpFABU(FABU);}
#endif
Standard_Boolean hashds = (!myDataStructure.IsNull());
TopoDS_Shape newFace;
TopoDS_Shape newWire;
for (FABU.InitFace(); FABU.MoreFace(); FABU.NextFace()) {
myBuildTool.CopyFace(aFace,newFace);
Standard_Boolean hns = Standard_False;
if (hashds) {
const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
hns = BDS.HasNewSurface(aFace);
if (hns) {
const Handle(Geom_Surface)& SU = BDS.NewSurface(aFace);
myBuildTool.UpdateSurface(newFace,SU);
}
}
for (FABU.InitWire(); FABU.MoreWire(); FABU.NextWire()) {
Standard_Boolean isold = FABU.IsOldWire();
if (isold) newWire = FABU.OldWire();
else {
myBuildTool.MakeWire(newWire);
for(FABU.InitEdge(); FABU.MoreEdge(); FABU.NextEdge()) {
TopoDS_Shape E = FABU.Edge();
if (hns) myBuildTool.UpdateSurface(E,aFace,newFace);
myBuildTool.AddWireEdge(newWire,E);
}
}
//----------- IFV
if(!isold) {
BRepCheck_Analyzer bca(newWire, Standard_False);
if (!bca.IsValid()) {
newWire.Free(Standard_True);
CorrectUnclosedWire(newWire);
const Handle(BRepCheck_Result)& bcr = bca.Result(newWire);
BRepCheck_ListIteratorOfListOfStatus itl(bcr->Status());
for(; itl.More(); itl.Next() ) {
if(itl.Value() == BRepCheck_BadOrientationOfSubshape) {
CorrectEdgeOrientation(newWire);
break;
}
}
}
}
myBuildTool.Closed(newWire,Standard_True); // NYI : check exact du caractere closed du wire
myBuildTool.AddFaceWire(newFace,newWire);
}
L.Append(newFace);
}
}
//=======================================================================
//function : MakeEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MakeEdges(const TopoDS_Shape& anEdge,TopOpeBRepBuild_EdgeBuilder& EDBU,TopTools_ListOfShape& L)
{
#ifdef DEB
Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(anEdge,iE);
Standard_Integer ne = 0;
#endif
Standard_Integer nvertex = 0;
for (TopOpeBRepTool_ShapeExplorer ex(anEdge,TopAbs_VERTEX); ex.More(); ex.Next()) nvertex++;
TopoDS_Shape newEdge;
for (EDBU.InitEdge(); EDBU.MoreEdge(); EDBU.NextEdge()) {
// 1 vertex sur edge courante => suppression edge
Standard_Integer nloop = 0;
for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) nloop++;
if ( nloop <= 1 ) continue;
myBuildTool.CopyEdge(anEdge,newEdge);
Standard_Boolean hasvertex = Standard_False;
for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) {
TopoDS_Shape V = EDBU.Vertex();
TopAbs_Orientation Vori = V.Orientation();
Standard_Boolean hassd = myDataStructure->HasSameDomain(V);
if (hassd) {
// on prend le vertex reference de V
Standard_Integer iref = myDataStructure->SameDomainReference(V);
V = myDataStructure->Shape(iref);
V.Orientation(Vori);
}
TopAbs_Orientation oriV = V.Orientation();
if ( oriV != TopAbs_EXTERNAL ) {
// betonnage
Standard_Boolean equafound = Standard_False;
TopExp_Explorer exE(newEdge,TopAbs_VERTEX);
for (; exE.More(); exE.Next() ) {
const TopoDS_Shape& VE = exE.Current();
TopAbs_Orientation oriVE = VE.Orientation();
if ( V.IsEqual(VE) ) {
equafound = Standard_True;
break;
}
else if (oriVE == TopAbs_FORWARD || oriVE == TopAbs_REVERSED) {
if (oriV == oriVE) {
equafound = Standard_True;
break;
}
}
else if (oriVE == TopAbs_INTERNAL || oriVE == TopAbs_EXTERNAL) {
Standard_Real parV = EDBU.Parameter();
Standard_Real parVE = BRep_Tool::Parameter(TopoDS::Vertex(VE),
TopoDS::Edge(newEdge));
if ( parV == parVE ) {
equafound = Standard_True;
break;
}
}
}
if ( !equafound ) {
hasvertex = Standard_True;
Standard_Real parV = EDBU.Parameter();
myBuildTool.AddEdgeVertex(newEdge,V);
myBuildTool.Parameter(newEdge,V,parV);
}
}
} // loop on vertices of new edge newEdge
#ifdef DEB
if(tSPS){cout<<endl;}
if(tSPS){cout<<"V of new edge "<<++ne<<endl;}
if(tSPS){GdumpEDG(newEdge);}
#endif
if (hasvertex) L.Append(newEdge);
} // loop on EDBU edges
} // MakeEdges
//=======================================================================
//function : IsMerged
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Builder::IsMerged(const TopoDS_Shape& S,const TopAbs_State ToBuild) const
{
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &myMergedOUT;
else if ( ToBuild == TopAbs_IN ) p = &myMergedIN;
else if ( ToBuild == TopAbs_ON ) p = &myMergedON;
if ( p == NULL ) return Standard_False;
Standard_Boolean notbound = ! (*p).IsBound(S);
if ( notbound ) {
return Standard_False;
}
else {
const TopTools_ListOfShape& L = Merged(S,ToBuild);
Standard_Boolean isempty = L.IsEmpty();
return (!isempty);
}
} // IsMerged
//=======================================================================
//function : Merged
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_Builder::Merged(const TopoDS_Shape& S,const TopAbs_State ToBuild) const
{
const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &myMergedOUT;
else if ( ToBuild == TopAbs_IN ) p = &myMergedIN;
else if ( ToBuild == TopAbs_ON ) p = &myMergedON;
if ( p == NULL ) return myEmptyShapeList;
if ( ! (*p).IsBound(S) ) {
return myEmptyShapeList;
}
else {
const TopTools_ListOfShape& L = (*p)(S).ListOnState();
return L;
}
} // Merged
//=======================================================================
//function : ChangeMerged
//purpose :
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_Builder::ChangeMerged(const TopoDS_Shape& S, const TopAbs_State ToBuild)
{
TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State* p = NULL;
if ( ToBuild == TopAbs_OUT ) p = &myMergedOUT;
else if ( ToBuild == TopAbs_IN ) p = &myMergedIN;
else if ( ToBuild == TopAbs_ON ) p = &myMergedON;
if ( p == NULL ) return myEmptyShapeList;
if ( ! (*p).IsBound(S) ) {
TopOpeBRepDS_ListOfShapeOn1State thelist;
(*p).Bind(S, thelist);
}
TopTools_ListOfShape& L = (*p)(S).ChangeListOnState();
return L;
} // ChangeMerged
//=======================================================================
//function : MergeEdges
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MergeEdges(const TopTools_ListOfShape& ,//L1,
const TopAbs_State ,//ToBuild1,
const TopTools_ListOfShape& ,//L2,
const TopAbs_State ,//ToBuild2,
const Standard_Boolean ,//Keepon1,
const Standard_Boolean ,//Keepon2,
const Standard_Boolean )//Keepon12)
{
} // MergeEdges
//=======================================================================
//function : MergeFaces
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::MergeFaces(const TopTools_ListOfShape& , //S1,
const TopAbs_State , //ToBuild1,
const TopTools_ListOfShape& , //S2,
const TopAbs_State , //ToBuild2
const Standard_Boolean ,//onA,
const Standard_Boolean ,//onB,
const Standard_Boolean )//onAB)
{
}

View File

@@ -0,0 +1,61 @@
-- File: TopOpeBRepBuild_Pave.cdl
-- Created: Mon Nov 14 09:49:36 1994
-- Author: Jean Yves LEBEY
-- <jyl@bravox>
---Copyright: Matra Datavision 1994
class Pave from TopOpeBRepBuild
inherits Loop from TopOpeBRepBuild
uses
ShapeEnum from TopAbs,
Shape from TopoDS,
--modified by NIZHNY-MZV Mon Feb 21 14:29:26 2000
Kind from TopOpeBRepDS
is
Create(V : Shape from TopoDS; P : Real; bound : Boolean) returns mutable Pave;
---Purpose: V = vertex, P = parameter of vertex <V>
-- bound = True if <V> is an old vertex
-- bound = False if <V> is a new vertex
HasSameDomain(me : mutable; b : Boolean);
SameDomain(me : mutable; VSD : Shape from TopoDS);
HasSameDomain(me) returns Boolean from Standard;
SameDomain(me) returns Shape from TopoDS;
---C++: return const &
Vertex(me) returns Shape from TopoDS is static;
---C++: return const &
ChangeVertex(me : mutable) returns Shape from TopoDS is static;
---C++: return &
-- used only by PaveSet
Parameter(me) returns Real from Standard is static;
--modified by NIZHNY-MZV Mon Feb 21 14:09:47 2000
Parameter(me: mutable; Par: Real from Standard) is static;
--modified by NIZHNY-MZV Mon Feb 21 14:25:58 2000
InterferenceType(me: mutable) returns Kind from TopOpeBRepDS;
---C++: return &
IsShape(me) returns Boolean from Standard is redefined;
Shape(me) returns Shape from TopoDS is redefined;
---C++: return const &
Dump(me) is redefined;
fields
myVertex : Shape from TopoDS;
myParam : Real from Standard;
myIsShape : Boolean from Standard;
myHasSameDomain : Boolean from Standard;
mySameDomain : Shape from TopoDS;
--modified by NIZHNY-MZV Mon Feb 21 14:26:58 2000
myIntType : Kind from TopOpeBRepDS;
end Pave from TopOpeBRepBuild;

View File

@@ -0,0 +1,142 @@
// File: TopOpeBRepBuild_Pave.cxx
// Created: Mon Nov 14 10:00:39 1994
// Author: Jean Yves LEBEY
// <jyl@bravox>
#include <TopOpeBRepBuild_Pave.ixx>
#include <TopAbs.hxx>
//=======================================================================
//function : TopOpeBRepBuild_Pave
//purpose :
//=======================================================================
TopOpeBRepBuild_Pave::TopOpeBRepBuild_Pave
(const TopoDS_Shape& V, const Standard_Real P, const Standard_Boolean B) :
TopOpeBRepBuild_Loop(V),
myVertex(V),myParam(P),myIsShape(B),myHasSameDomain(Standard_False),myIntType(TopOpeBRepDS_FACE)
{
}
//=======================================================================
//function : HasSameDomain
//purpose :
//=======================================================================
void TopOpeBRepBuild_Pave::HasSameDomain(const Standard_Boolean B)
{
myHasSameDomain = B;
}
//=======================================================================
//function : SameDomain
//purpose :
//=======================================================================
void TopOpeBRepBuild_Pave::SameDomain(const TopoDS_Shape& VSD)
{
mySameDomain = VSD;
}
//=======================================================================
//function : HasSameDomain
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Pave::HasSameDomain() const
{
return myHasSameDomain;
}
//=======================================================================
//function : SameDomain
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_Pave::SameDomain() const
{
return mySameDomain;
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_Pave::Vertex() const
{
return myVertex;
}
//=======================================================================
//function : ChangeVertex
//purpose :
//=======================================================================
TopoDS_Shape& TopOpeBRepBuild_Pave::ChangeVertex()
{
return myVertex;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real TopOpeBRepBuild_Pave::Parameter() const
{
return myParam;
}
//modified by NIZHNY-MZV Mon Feb 21 14:11:40 2000
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
void TopOpeBRepBuild_Pave::Parameter(const Standard_Real Par)
{
myParam = Par;
}
//=======================================================================
//function : IsShape
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Pave::IsShape() const
{
return myIsShape;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_Pave::Shape() const
{
return myVertex;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void TopOpeBRepBuild_Pave::Dump() const
{
#ifdef DEB
cout<<Parameter()<<" ";TopAbs::Print(Vertex().Orientation(),cout);
#endif
}
//modified by NIZHNY-MZV Mon Feb 21 14:27:48 2000
//=======================================================================
//function : ChangeVertex
//purpose :
//=======================================================================
TopOpeBRepDS_Kind& TopOpeBRepBuild_Pave::InterferenceType()
{
return myIntType;
}

View File

@@ -0,0 +1,74 @@
-- File: TopOpeBRepBuild_PaveClassifier.cdl
-- Created: Thu Jun 17 10:13:19 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class PaveClassifier from TopOpeBRepBuild
inherits LoopClassifier from TopOpeBRepBuild
---Purpose:
-- This class compares vertices on an edge.
--
-- A vertex V1 is inside a vertex V2 if V1 is on the
-- part of the curve defined by V2.
--
-- If V2 is FORWARD V1 must be after V2 on the curve.
-- If V2 is REVERSED V1 must be before V2 on the curve.
-- If V2 is INTERNAL V1 is always inside.
-- If V2 is EXTERNAL V1 is never inside.
uses
ShapeEnum from TopAbs,
State from TopAbs,
Shape from TopoDS,
Edge from TopoDS,
Orientation from TopAbs,
Loop from TopOpeBRepBuild
is
Create(E : Shape from TopoDS) returns PaveClassifier;
---Purpose: Create a Pave classifier to compare vertices on edge <E>.
Compare(me : in out; L1,L2 : Loop from TopOpeBRepBuild)
returns State from TopAbs;
---Purpose: Returns state of vertex <L1> compared with <L2>.
SetFirstParameter(me : in out; P : Real from Standard)
is static;
ClosedVertices(me : in out; B : Boolean from Standard)
is static;
AdjustCase(myclass;p1:Real;o:Orientation;
first,period:Real;tol:Real;
cas:out Integer) returns Real;
CompareOnNonPeriodic(me : in out) returns State from TopAbs
is static private;
CompareOnPeriodic(me : in out) returns State from TopAbs
is static private;
AdjustOnPeriodic(me : in out)
is static private;
ToAdjustOnPeriodic(me) returns Boolean from Standard
is static private;
fields
myEdge : Edge from TopoDS;
myEdgePeriodic : Boolean from Standard;
myFirst : Real from Standard;
myPeriod : Real from Standard;
mySameParameters : Boolean from Standard;
myClosedVertices : Boolean from Standard;
myP1 : Real from Standard;
myP2 : Real from Standard;
myO1 : Orientation from TopAbs;
myO2 : Orientation from TopAbs;
myCas1 : Integer from Standard; -- debug
myCas2 : Integer from Standard; -- debug
end PaveClassifier from TopOpeBRepBuild;

View File

@@ -0,0 +1,328 @@
// File: TopOpeBRepBuild_PaveClassifier.cxx
// Created: Thu Jun 17 18:44:17 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_PaveClassifier.ixx>
#include <TopOpeBRepBuild_Pave.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Tool.hxx>
#include <ElCLib.hxx>
#include <Geom_Curve.hxx>
#include <Precision.hxx>
#include <TopExp.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceVC();
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceCLOV();
#endif
//=======================================================================
//function : TopOpeBRepBuild_PaveClassifier
//purpose :
//=======================================================================
TopOpeBRepBuild_PaveClassifier::TopOpeBRepBuild_PaveClassifier
(const TopoDS_Shape& E) :
myEdgePeriodic(Standard_False),
mySameParameters(Standard_False),
myClosedVertices(Standard_False)
{
myEdge = TopoDS::Edge(E);
if ( ! BRep_Tool::Degenerated(myEdge) ) {
TopLoc_Location loc;
Standard_Real f,l;
Handle(Geom_Curve) C = BRep_Tool::Curve(myEdge,loc,f,l);
if ( !C.IsNull() ) {
if (C->IsPeriodic()) {
TopoDS_Vertex v1,v2;
TopExp::Vertices(myEdge,v1,v2); // v1 FORWARD, v2 REVERSED
if ( !v1.IsNull() && !v2.IsNull() ) {
// --- the edge has vertices
myFirst = f;
Standard_Real fC = C->FirstParameter();
Standard_Real lC = C->LastParameter();
myPeriod = lC - fC;
myEdgePeriodic = mySameParameters = v1.IsSame(v2);
if ( mySameParameters ) {
myFirst = BRep_Tool::Parameter(v1,myEdge);
}
}
else {
// --- the edge has no vertices
myFirst = f;
myPeriod = l - f;
myEdgePeriodic = Standard_True;
mySameParameters = Standard_False;
}
}
}
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<endl;
if (myEdgePeriodic) {
cout<<"VC : periodic edge : myFirst "<<myFirst<<" myPeriod "<<myPeriod<<endl;
if (mySameParameters)cout<<"VC same parameters "<<endl;
else cout<<"VC no same parameters"<<endl;
}
else {
cout<<"VC : non periodic edge : f "<<f<<" l "<<l<<endl;
}
}
#endif
} // ! degenerated
}
//=======================================================================
//function : CompareOnNonPeriodic
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_PaveClassifier::CompareOnNonPeriodic()
{
TopAbs_State state = TopAbs_UNKNOWN;
Standard_Boolean lower=Standard_False;
switch (myO2) {
case TopAbs_FORWARD : lower = Standard_False; break;
case TopAbs_REVERSED : lower = Standard_True; break;
case TopAbs_INTERNAL : state = TopAbs_IN; break;
case TopAbs_EXTERNAL : state = TopAbs_OUT; break;
}
if (state == TopAbs_UNKNOWN) {
if (myP1 == myP2) {
if ( myO1 == myO2 ) state = TopAbs_IN;
else state = TopAbs_OUT;
}
else if (myP1 < myP2) {
if (lower) state = TopAbs_IN;
else state = TopAbs_OUT;
}
else {
if (lower) state = TopAbs_OUT;
else state = TopAbs_IN;
}
}
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"VC_NP : ";
if (myP1 == myP2) cout<<" p1 = p2";
else if (myP1 < myP2) cout<<" p1 < p2";
else if (myP1 > myP2) cout<<" p1 > p2";
cout<<" --> state "; TopAbs::Print(state,cout); cout<<endl;
}
#endif
return state;
}
//=======================================================================
//function : AdjustCase
//purpose :
//=======================================================================
Standard_Real TopOpeBRepBuild_PaveClassifier::AdjustCase(const Standard_Real p1,
const TopAbs_Orientation o,
const Standard_Real first,
const Standard_Real period,
const Standard_Real tol,
Standard_Integer& cas)
{
Standard_Real p2;
if ( Abs(p1-first) < tol ) { // p1 is first
if (o == TopAbs_REVERSED) {
p2 = p1 + period;
cas = 1;
}
else {
p2 = p1;
cas = 2;
}
}
else { // p1 is not on first
Standard_Real last = first+period;
if ( Abs(p1-last) < tol ) { // p1 is on last
p2 = p1;
cas = 3;
}
else { // p1 is not on last
p2 = ElCLib::InPeriod(p1,first,last);
cas = 4;
}
}
return p2;
}
//=======================================================================
//function : AdjustOnPeriodic
//purpose : (private)
//=======================================================================
void TopOpeBRepBuild_PaveClassifier::AdjustOnPeriodic()
{
if ( ! ToAdjustOnPeriodic() ) return;
#ifdef DEB
Standard_Real p1 = myP1, p2 = myP2;
#endif
Standard_Real tol = Precision::PConfusion();
if (mySameParameters) {
myP1 = AdjustCase(myP1,myO1,myFirst,myPeriod,tol,myCas1);
myP2 = AdjustCase(myP2,myO2,myFirst,myPeriod,tol,myCas2);
}
else if (myO1 != myO2 ) {
if (myO1 == TopAbs_FORWARD) myP2 = AdjustCase(myP2,myO2,myP1,myPeriod,tol,myCas2);
if (myO2 == TopAbs_FORWARD) myP1 = AdjustCase(myP1,myO1,myP2,myPeriod,tol,myCas1);
}
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"p1 "<<p1<<" ";TopAbs::Print(myO1,cout);cout<<" --> "<<myP1<<endl;
cout<<"p2 "<<p2<<" ";TopAbs::Print(myO2,cout);cout<<" --> "<<myP2<<endl;
}
#endif
}
//=======================================================================
//function : ToAdjustOnPeriodic
//purpose : (private)
//=======================================================================
Standard_Boolean TopOpeBRepBuild_PaveClassifier::ToAdjustOnPeriodic() const
{
Standard_Boolean toadjust = ( (mySameParameters) || (myO1 != myO2 ) );
return toadjust;
}
//=======================================================================
//function : CompareOnPeriodic
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_PaveClassifier::CompareOnPeriodic()
{
TopAbs_State state;
if ( ToAdjustOnPeriodic() ) {
state = CompareOnNonPeriodic();
}
else if (myO1 == TopAbs_FORWARD) {
state = TopAbs_OUT;
myCas1 = myCas2 = 5;
}
else if (myO1 == TopAbs_REVERSED) {
state = TopAbs_OUT;
myCas1 = myCas2 = 6;
}
else {
state = TopAbs_OUT;
myCas1 = myCas2 = 7;
}
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"VC_P : cas "<<myCas1<<"__"<<myCas2;
cout<<" --> state "; TopAbs::Print(state,cout); cout<<endl;
}
#endif
return state;
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_PaveClassifier::Compare
(const Handle(TopOpeBRepBuild_Loop)& L1,
const Handle(TopOpeBRepBuild_Loop)& L2)
{
const Handle(TopOpeBRepBuild_Pave)& PV1 =
*((Handle(TopOpeBRepBuild_Pave)*)&(L1));
const Handle(TopOpeBRepBuild_Pave)& PV2 =
*((Handle(TopOpeBRepBuild_Pave)*)&(L2));
myCas1 = myCas2 = 0; // debug
myO1 = PV1->Vertex().Orientation();
myO2 = PV2->Vertex().Orientation();
myP1 = PV1->Parameter();
myP2 = PV2->Parameter();
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<endl<<"VC : "<<myP1<<" "<<myP2<<" ";
TopAbs::Print(myO1,cout); cout<<" "; TopAbs::Print(myO2,cout);
cout<<" (p "<<myEdgePeriodic;
cout<<" s "<<mySameParameters<<" c "<<myClosedVertices<<")"<<endl;
}
#endif
if ( myEdgePeriodic && ToAdjustOnPeriodic() ) {
AdjustOnPeriodic();
}
TopAbs_State state;
if (myEdgePeriodic)
state = CompareOnPeriodic();
else
state = CompareOnNonPeriodic();
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"VC : --> final state "; TopAbs::Print(state,cout); cout<<endl;
}
#endif
return state;
}
//=======================================================================
//function : SetFirstParameter
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveClassifier::SetFirstParameter
(const Standard_Real P)
{
myFirst = P;
mySameParameters = Standard_True;
#ifdef DEB
if (TopOpeBRepTool_GettraceVC())
cout<<endl<<"VC : set first parameter "<<myFirst<<endl;
#endif
}
//=======================================================================
//function : ClosedVertices
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveClassifier::ClosedVertices
(const Standard_Boolean Closed)
{
myClosedVertices = Closed;
#ifdef DEB
if (TopOpeBRepTool_GettraceCLOV()) {
myEdgePeriodic = Closed;
cout<<"::::::::::::::::::::::::"<<endl;
cout<<"VC : myClosedVertices"<<myClosedVertices<<endl;
cout<<"VC : myEdgePeriodic "<<myEdgePeriodic<<endl;
cout<<"::::::::::::::::::::::::"<<endl;
}
#endif
}

View File

@@ -0,0 +1,66 @@
-- File: TopOpeBRepBuild_PaveSet.cdl
-- Created: Tue Jun 15 20:02:14 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class PaveSet from TopOpeBRepBuild
inherits LoopSet from TopOpeBRepBuild
---Purpose:
-- class providing an exploration of a set of vertices to build edges.
-- It is similar to LoopSet from TopOpeBRepBuild where Loop is Pave.
uses
Shape from TopoDS,
Edge from TopoDS,
Loop from TopOpeBRepBuild,
Pave from TopOpeBRepBuild,
ListOfPave from TopOpeBRepBuild,
ListIteratorOfListOfPave from TopOpeBRepBuild
is
Create(E : Shape from TopoDS) returns PaveSet from TopOpeBRepBuild;
---Purpose: Create a Pave set on edge <E>. It contains <E> vertices.
RemovePV(me:in out; B : Boolean); -- particular case B = T/F : try/don't try
-- to remove Pave in Prepare() (T by default)
Append(me : in out; PV : Pave from TopOpeBRepBuild) is static;
---Purpose: Add <PV> in the Pave set.
-- === start signature LoopSet
InitLoop(me : in out) is redefined;
MoreLoop(me) returns Boolean is redefined;
NextLoop(me : in out) is redefined;
Loop(me) returns Loop from TopOpeBRepBuild is redefined;
---C++: return const &
-- === end signature LoopSet
Edge(me) returns Edge from TopoDS is static;
---C++: return const &
HasEqualParameters(me : in out) returns Boolean is static;
EqualParameters(me) returns Real is static;
ClosedVertices(me : in out) returns Boolean is static;
Prepare(me : in out) is static private;
SortPave(myclass; Lin:ListOfPave; Lout:out ListOfPave);
fields
myEdge : Edge from TopoDS;
myVertices : ListOfPave from TopOpeBRepBuild;
myVerticesIt : ListIteratorOfListOfPave from TopOpeBRepBuild;
myEdgeVertexIndex : Integer from Standard;
myEdgeVertexCount : Integer from Standard;
myHasEqualParameters : Boolean from Standard;
myEqualParameters : Real from Standard;
myClosed : Boolean from Standard;
myPrepareDone : Boolean from Standard;
myRemovePV : Boolean;
end PaveSet from TopOpeBRepBuild;

View File

@@ -0,0 +1,454 @@
// File: TopOpeBRepBuild_PaveSet.cxx
// Created: Thu Jun 17 17:08:35 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_PaveSet.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp_Explorer.hxx>
#include <Precision.hxx>
#include <Geom_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopExp.hxx>
#include <gp_Pnt.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceVC();
#include <TopOpeBRepBuild_Builder.hxx>
#include <gp_Pnt.hxx>
#endif
//=======================================================================
//function : TopOpeBRepBuild_PaveSet
//purpose :
//=======================================================================
TopOpeBRepBuild_PaveSet::TopOpeBRepBuild_PaveSet(const TopoDS_Shape& E) :
myEdge(TopoDS::Edge(E)),
myHasEqualParameters(Standard_False),
myClosed(Standard_False),
myPrepareDone(Standard_False),
myRemovePV(Standard_True)
{
}
//=======================================================================
//function : RemovePV
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::RemovePV(const Standard_Boolean B)
{
myRemovePV = B;
}
//=======================================================================
//function : Append
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::Append
(const Handle(TopOpeBRepBuild_Pave)& PV)
{
myVertices.Append(PV);
myPrepareDone = Standard_False;
}
#include <TColStd_HArray1OfBoolean.hxx>
#include <TColStd_Array1OfBoolean.hxx>
//=======================================================================
//function : SortPave
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::SortPave(const TopOpeBRepBuild_ListOfPave& List,
TopOpeBRepBuild_ListOfPave& SortedList)
{
// NYI : sort a list o Items, giving a sorting function is impossible
// NYI : --> foobar method complexity n2.
Standard_Integer iPV=0,nPV = List.Extent();
Handle(TColStd_HArray1OfBoolean) HT =
new TColStd_HArray1OfBoolean(0,nPV,Standard_False);
TColStd_Array1OfBoolean& T = HT->ChangeArray1();
Handle(TopOpeBRepBuild_Pave) PV1;
for (Standard_Integer i = 1; i <= nPV; i++) {
Standard_Real parmin = RealLast();
TopOpeBRepBuild_ListIteratorOfListOfPave it(List);
for (Standard_Integer itest = 1; it.More(); it.Next(),itest++) {
if ( ! T(itest) ) {
const Handle(TopOpeBRepBuild_Pave)& PV2 = it.Value();
Standard_Real par = PV2->Parameter();
if (par < parmin) {
parmin = par;
PV1 = PV2;
iPV = itest;
}
}
}
SortedList.Append(PV1);
T(iPV) = Standard_True;
}
// tete = FORWARD
// modifier TopOpeBRepBuild_DataStructure::SortOnParameter
Standard_Boolean found = Standard_False;
TopOpeBRepBuild_ListIteratorOfListOfPave it(SortedList);
TopOpeBRepBuild_ListOfPave L1,L2;
for (; it.More(); it.Next() ) {
const Handle(TopOpeBRepBuild_Pave)& PV = it.Value();
if ( ! found) {
TopAbs_Orientation o = PV->Vertex().Orientation();
if (o == TopAbs_FORWARD) {
found = Standard_True;
L1.Append(PV);
}
else L2.Append(PV);
}
else L1.Append(PV);
}
SortedList.Clear();
SortedList.Append(L1);
SortedList.Append(L2);
}
static Standard_Boolean FUN_islook(const TopoDS_Edge& e)
{
TopoDS_Vertex v1,v2;
TopExp::Vertices(e,v1,v2);
gp_Pnt p1 = BRep_Tool::Pnt(v1);
gp_Pnt p2 = BRep_Tool::Pnt(v2);
Standard_Real dp1p2 = p1.Distance(p2);
Standard_Boolean islook = (Abs(dp1p2) > 1.e-8) ? Standard_True : Standard_False;
return islook;
}
//=======================================================================
//function : Prepare
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::Prepare()
{
// add the edge vertices to the list of interference
// if an edge vertex VE is already in the list as interference VI :
// - do not add VE in the list,
// - if VI is INTERNAL, set VI orientation to VE orientation.
// - remove VI from the list if :
// VI is EXTERNAL or VE and VI have opposite orientations.
//
if (myPrepareDone) {
return;
}
#ifdef DEB
Standard_Boolean trc = Standard_False;
trc = trc || TopOpeBRepTool_GettraceVC();
Standard_Integer iv=0;//,nv=myVertices.Extent();
if (trc) {
TopOpeBRepBuild_ListIteratorOfListOfPave itd(myVertices);
cout<<endl;
for(;itd.More();itd.Next() ) {
const Handle(TopOpeBRepBuild_Pave)& PV = itd.Value();
TopoDS_Vertex& VI = TopoDS::Vertex(PV->ChangeVertex());
Standard_Boolean hasVSD = PV->HasSameDomain();
TopoDS_Vertex VSD; if (hasVSD) VSD = TopoDS::Vertex(PV->SameDomain());
TopAbs_Orientation VIori = VI.Orientation();
Standard_Real p = PV->Parameter();
cout<<"pvs : v "<<++iv<<" par "<<p<<" ";TopAbs::Print(VIori,cout);cout<<endl;
}
}
#endif
Standard_Boolean isEd = BRep_Tool::Degenerated(myEdge);
Standard_Integer EdgeVertexCount = 0;
if (myRemovePV) { // jyl + 980217
TopExp_Explorer EVexp(myEdge,TopAbs_VERTEX);
for (; EVexp.More(); EVexp.Next() ) {
// VE = edge vertex
const TopoDS_Vertex& VE = TopoDS::Vertex(EVexp.Current());
TopAbs_Orientation VEori = VE.Orientation();
Standard_Boolean VEbound=(VEori==TopAbs_FORWARD)||(VEori==TopAbs_REVERSED);
Standard_Integer EdgeVertexIndex = 0;
Standard_Boolean addVE = Standard_True;
Standard_Boolean add = Standard_False;//ofv
TopOpeBRepBuild_ListIteratorOfListOfPave it(myVertices);
for(;it.More();it.Next() ) {
EdgeVertexIndex++; // skip edge vertices inserted at the head of the list
if (EdgeVertexIndex <= EdgeVertexCount) continue;
// PV = Parametrized vertex, VI = interference vertex
const Handle(TopOpeBRepBuild_Pave)& PV = it.Value();
TopoDS_Vertex& VI = TopoDS::Vertex(PV->ChangeVertex());
Standard_Boolean hasVSD = PV->HasSameDomain();
TopoDS_Vertex VSD; if (hasVSD) VSD = TopoDS::Vertex(PV->SameDomain());
TopAbs_Orientation VIori = VI.Orientation();
Standard_Boolean visameve = (VI.IsSame(VE));
Standard_Boolean vsdsameve = Standard_False;
if (hasVSD) vsdsameve = (VSD.IsSame(VE));
Standard_Boolean samevertexprocessing = (visameve || vsdsameve) && !isEd;
if (samevertexprocessing) {
// if (VEbound) { // xpu: 29-05-97
if (VEbound || vsdsameve) {
switch (VIori ) {
case TopAbs_EXTERNAL :
myVertices.Remove(it);
break;
case TopAbs_INTERNAL :
VI.Orientation(VEori);
break;
case TopAbs_FORWARD : case TopAbs_REVERSED :
//ofv:
//if (VIori != VEori) myVertices.Remove(it);
if (VIori != VEori)//ofv
{ myVertices.Remove(it);//ofv
Standard_Boolean islook = FUN_islook(myEdge);
if((VEbound && (vsdsameve ||visameve)) && islook) add = Standard_True;//ofv
}
break;
}
}
//ofv:
//addVE = Standard_False;
addVE = (!add) ? Standard_False : Standard_True;
break;
}
}
// if VE not found in the list, add it
if ( addVE ) {
Standard_Real parVE = BRep_Tool::Parameter(VE,myEdge);
Handle(TopOpeBRepBuild_Pave) newPV =
new TopOpeBRepBuild_Pave(VE,parVE,Standard_True);
myVertices.Prepend(newPV);
EdgeVertexCount++;
}
}
} // myRemovePV
Standard_Integer ll = myVertices.Extent();
// if no more interferences vertices, clear the list
if (ll == EdgeVertexCount) {
myVertices.Clear();
}
else if ( ll >= 2 ) {
// sort the parametrized vertices on Parameter() value.
TopOpeBRepBuild_ListOfPave List;
List = myVertices;
myVertices.Clear();
SortPave(List,myVertices);
}
#ifdef DEB
if ( TopOpeBRepTool_GettraceVC() ) {
myVerticesIt.Initialize(myVertices);
if ( MoreLoop() ) cout<<"--- PaveSet : Prepare"<<endl;
for (; MoreLoop(); NextLoop() ) {
const Handle(TopOpeBRepBuild_Pave)& PV =
*((Handle(TopOpeBRepBuild_Pave)*)&(Loop()));
const TopoDS_Vertex& v = TopoDS::Vertex(PV->Vertex());
Standard_Real p = PV->Parameter();
Standard_Boolean b = PV->IsShape();
TopOpeBRepBuild_Builder::GdumpORIPARPNT(v.Orientation(),p,BRep_Tool::Pnt(v));
if (b) cout<<" is bound"; else cout<<" is not bound";
cout<<endl;
}
}
#endif
myPrepareDone = Standard_True;
return;
}
//=======================================================================
//function : InitLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::InitLoop()
{
if ( ! myPrepareDone ) Prepare();
myVerticesIt.Initialize(myVertices);
}
//=======================================================================
//function : MoreLoop
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_PaveSet::MoreLoop()const
{
Standard_Boolean b = myVerticesIt.More();
return b;
}
//=======================================================================
//function : NextLoop
//purpose :
//=======================================================================
void TopOpeBRepBuild_PaveSet::NextLoop()
{
myVerticesIt.Next();
}
//=======================================================================
//function : Loop
//purpose :
//=======================================================================
const Handle(TopOpeBRepBuild_Loop)& TopOpeBRepBuild_PaveSet::Loop()const
{
const Handle(TopOpeBRepBuild_Loop)& L = myVerticesIt.Value();
return L;
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TopoDS_Edge& TopOpeBRepBuild_PaveSet::Edge()const
{
return myEdge;
}
//=======================================================================
//function : HasEqualParameters
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_PaveSet::HasEqualParameters()
{
myHasEqualParameters = Standard_False;
TopOpeBRepBuild_ListIteratorOfListOfPave it1,it2;
Standard_Real p1,p2;
for (it1.Initialize(myVertices);
(! myHasEqualParameters ) && it1.More();
it1.Next()) {
const TopoDS_Shape& v1 = it1.Value()->Vertex();
p1 = it1.Value()->Parameter();
for (it2.Initialize(myVertices);
(! myHasEqualParameters ) && it2.More();
it2.Next()) {
const TopoDS_Shape& v2 = it2.Value()->Vertex();
if ( v2.IsEqual(v1) ) continue;
p2 = it2.Value()->Parameter();
Standard_Real d = Abs(p1-p2);
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"VertexSet : p1,p2 d "<<p1<<","<<p2<<" "<<d<<endl;
}
#endif
if (d < Precision::PConfusion()) {
myHasEqualParameters = Standard_True;
myEqualParameters = p1;
}
}
}
if ( !myHasEqualParameters ) {
Standard_Boolean rd; Standard_Real f=0,l;
{
TopLoc_Location loc; Standard_Real ff,ll;
Handle(Geom_Curve) CmyEdge = BRep_Tool::Curve(myEdge,loc,ff,ll);
if ( CmyEdge.IsNull() ) rd = Standard_False;
else { f = ff; l = ll; rd = Standard_True; }
}
if (rd) {
for (it1.Initialize(myVertices);
(! myHasEqualParameters ) && it1.More();
it1.Next()) {
#ifdef DEB
// const TopoDS_Shape& v1 = it1.Value()->Vertex();
#endif
p1 = it1.Value()->Parameter();
Standard_Real d = Abs(p1-f);
if (d < Precision::PConfusion()) {
myHasEqualParameters = Standard_True;
myEqualParameters = f;
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"=*=*=*=*=*=*=*=*=*=*=*=*=*=*"<<endl;
cout<<"PaveSet : p1,f d "<<p1<<","<<f<<" "<<d<<endl;
cout<<"=*=*=*=*=*=*=*=*=*=*=*=*=*=*"<<endl;
}
#endif
}
}
}
}
return myHasEqualParameters;
}
//=======================================================================
//function : EqualParameters
//purpose :
//=======================================================================
Standard_Real TopOpeBRepBuild_PaveSet::EqualParameters() const
{
if (myHasEqualParameters) {
return myEqualParameters;
}
else {
// raise NYI
}
return 0.; // windowsNT
}
//=======================================================================
//function : ClosedVertices
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_PaveSet::ClosedVertices()
{
if (myVertices.IsEmpty()) return Standard_False;
TopoDS_Shape Vmin,Vmax;
Standard_Real parmin = RealLast(), parmax = RealFirst();
for (TopOpeBRepBuild_ListIteratorOfListOfPave it(myVertices);
it.More();
it.Next()) {
const TopoDS_Shape& V = it.Value()->Vertex();
Standard_Real par = it.Value()->Parameter();
if (par > parmax) { Vmax = V; parmax = par; }
if (par < parmin) { Vmin = V; parmin = par; }
}
myClosed = Vmin.IsSame(Vmax);
return myClosed;
}

View File

@@ -0,0 +1,294 @@
// File: TopOpeBRepBuild_SREGU.cxx
// Created: Tue Oct 21 15:05:25 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#include <TopOpeBRepBuild_Builder.ixx>
#include <TopOpeBRepBuild_ShellToSolid.hxx>
#include <TopOpeBRepTool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <Standard_ProgramError.hxx>
#include <TopOpeBRepDS_define.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOREGUSO();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GetcontextREGUXPU();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSAVSREGU();
Standard_EXPORT void debreguso(const Standard_Integer iS) {cout<<"++ debreguso "<<iS<<endl;}
#endif
#ifdef DRAW
#include <DBRep.hxx>
#endif
//=======================================================================
//function : RegularizeSolids
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::RegularizeSolids
(const TopoDS_Shape& SO,const TopTools_ListOfShape& lnewSolid,TopTools_ListOfShape& LOSO)
{
LOSO.Clear();
myMemoSplit.Clear();
TopTools_ListIteratorOfListOfShape itl(lnewSolid);
for (;itl.More();itl.Next()) {
const TopoDS_Shape& newSolid = itl.Value();
TopTools_ListOfShape newSolidLOSO;
RegularizeSolid(SO,newSolid,newSolidLOSO);
#ifdef DEB
// Standard_Integer nnewSolidLOSO = newSolidLOSO.Extent(); // DEB
#endif
LOSO.Append(newSolidLOSO);
}
#ifdef DEB
// Standard_Integer nLOSO = LOSO.Extent(); // DEB
#endif
Standard_Integer nr = myMemoSplit.Extent();
if (nr == 0 ) return;
// lsosdSO = solids SameDomain de SO
TopTools_ListOfShape lsosdSO,lsosdSO1,lsosdSO2;
GFindSamDom(SO,lsosdSO1,lsosdSO2);
lsosdSO.Append(lsosdSO1);
lsosdSO.Append(lsosdSO2);
TopTools_ListIteratorOfListOfShape itlsosdSO(lsosdSO);
for (; itlsosdSO.More(); itlsosdSO.Next()) {
const TopoDS_Shape& sosdSO = itlsosdSO.Value();
// au moins une arete de SO dont le Split() est lui meme Split()
TopExp_Explorer x;
for (x.Init(sosdSO,TopAbs_FACE);x.More();x.Next()) {
// for (TopExp_Explorer x(sosdSO,TopAbs_FACE);x.More();x.Next()) {
const TopoDS_Shape& f = x.Current();
Standard_Integer rankf=GShapeRank(f);TopAbs_State staf=(rankf==1)?myState1:myState2;
Standard_Boolean issplitf = IsSplit(f,staf);
if (!issplitf) continue;
TopTools_ListOfShape newlspf;
TopTools_ListOfShape& lspf = ChangeSplit(f,staf);
#ifdef DEB
// Standard_Integer nlspf = lspf.Extent(); // DEB
#endif
for (TopTools_ListIteratorOfListOfShape itl1(lspf);itl1.More();itl1.Next()) {
const TopoDS_Shape& fsp = itl1.Value();
Standard_Boolean fspmemo = myMemoSplit.Contains(fsp);
if (!fspmemo) newlspf.Append(fsp);
else {
TopTools_ListOfShape& lspfsp = ChangeSplit(fsp,staf);
GCopyList(lspfsp,newlspf);
}
}
lspf.Clear();
GCopyList(newlspf,lspf);
// if (staf == TopAbs_IN) {
// // IN Solide <=> ON ??? : M.A.J de Split(TopAbs_ON);
// Standard_Boolean issplitON = IsSplit(f,TopAbs_ON);
// TopTools_ListOfShape& lONf = ChangeSplit(f,TopAbs_ON);
// Standard_Integer nONf = lONf.Extent(); // DEB
// lONf.Clear();
// GCopyList(newlspf,lONf);
// } // TopAbs_IN
} // (sosdSO,TopAbs_FACE)
}
}
//=======================================================================
//function : RegularizeSolid
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::RegularizeSolid
(const TopoDS_Shape& SS,const TopoDS_Shape& anewSolid,TopTools_ListOfShape& LOSO)
{
LOSO.Clear();
const TopoDS_Solid& newSolid = TopoDS::Solid(anewSolid);
Standard_Boolean toregu = Standard_True;
Standard_Boolean usestos = Standard_True;
#ifdef DEB
Standard_Integer iS;Standard_Boolean tSPS=GtraceSPS(SS,iS);
// Standard_Boolean savsregu = TopOpeBRepBuild_GettraceSAVSREGU();
if (TopOpeBRepBuild_GetcontextNOREGUSO()) toregu = Standard_False;
if (TopOpeBRepBuild_GetcontextREGUXPU()) usestos = Standard_False;
if (tSPS) debreguso(iS);
#endif
if (!toregu) {
LOSO.Append(newSolid);
return;
}
TopTools_DataMapOfShapeListOfShape osns; // OldShells --> NewShells;
Standard_Boolean rw = Standard_False;
Standard_Boolean rf = Standard_False;
myFSplits.Clear();
rw = TopOpeBRepTool::RegularizeShells(newSolid,osns,myFSplits);
if ( !rw ) {
LOSO.Append(newSolid);
return;
}
TopTools_ListOfShape newSolids;
if (usestos) {
TopOpeBRepBuild_ShellToSolid stos;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itosns(osns);
for (; itosns.More(); itosns.Next()) {
/* JYL 120499 : a mettre dans l'areabuilder du solidbuilder du shelltosolid
// solution 1 : alerter le SolidClassifier utilise dans le SolidBuilder
// de ShellToSolid qu'il y a de des aretes mutilconnexes (2 faces)
// dans oldshe QU'IL NE FAUT PAS UTILISER pour tirer un point
// representatif du shell.
// map des edges -> list of face de oldshe
TopTools_IndexedDataMapOfShapeListOfShape maef;
TopExp::MapShapesAndAncestors(oldshe,TopAbs_EDGE,TopAbs_FACE,maef);
Standard_Integer ima=1,nma=maef.Extent();
for(;ima<=nma;ima++) {
const TopoDS_Edge& eevit = TopoDS::Edge(maef.FindKey(ima));
const TopTools_ListOfShape& lfa = maef(ima);
Standard_Integer nlfa = lfa.Extent();
if (nlfa > 2) {
}
}
// fin solution1
*/
const TopTools_ListOfShape& lns = itosns.Value();
for(TopTools_ListIteratorOfListOfShape iw(lns);iw.More();iw.Next()) {
stos.AddShell(TopoDS::Shell(iw.Value()));
}
}
stos.MakeSolids(newSolid,newSolids);
rf = (newSolids.Extent() != 0);
}
else {
rf = Standard_False;
// rf = TopOpeBRepTool::RegularizeSolid(newSolid,osns,newSolids);
}
if (!rf) {
LOSO.Append(newSolid);
return;
}
#ifdef DEB
if (tSPS) {
cout<<"RegularizeSolid "<<iS<<endl;
debreguso(iS);
}
#endif
// LOSO = nouvelles Solids regularisees de newSolid
TopTools_ListIteratorOfListOfShape itlnf(newSolids);
for (; itlnf.More(); itlnf.Next())
LOSO.Append(TopoDS::Solid(itlnf.Value()));
// mise a jour des faces decoupees
// Face(SS) = {E}, E-->Split(E) = {E'}, E'-->myFSplits(E') = {E''}
// manc : E'-->E pour pouvoir relier
// Split(manc(E')) = {myFSplits(E')}
TopTools_MapOfShape mfns; // mfns = faces de newSolid
TopExp_Explorer x;
for (x.Init(newSolid,TopAbs_FACE);x.More();x.Next()) {
const TopoDS_Shape& F = x.Current();
mfns.Add(F);
}
// lssdSS = Solids SameDomain de SS
TopTools_ListOfShape lssdSS,lssdSS1,lssdSS2;
GFindSamDom(SS,lssdSS1,lssdSS2);
lssdSS.Append(lssdSS1);
lssdSS.Append(lssdSS2);
TopTools_DataMapOfShapeShape manc;
TopTools_ListIteratorOfListOfShape itlssdSS(lssdSS);
for (; itlssdSS.More(); itlssdSS.Next()) {
const TopoDS_Shape& ssdSS = itlssdSS.Value();
#ifdef DEB
// Standard_Integer issdSS = myDataStructure->Shape(ssdSS); // DEB
#endif
Standard_Integer rankssdSS = GShapeRank(ssdSS);
TopAbs_State stassdSS = (rankssdSS == 1) ? myState1 : myState2;
#ifdef DEB
// Standard_Boolean issplitssdSS = IsSplit(ssdSS,stassdSS);
// const TopTools_ListOfShape& lspssdSS = Splits(ssdSS,stassdSS);
// Standard_Integer nlspssdSS = lspssdSS.Extent();
#endif
// iteration sur les faces de ssdSS
for (x.Init(ssdSS,TopAbs_FACE);x.More();x.Next()) {
//ssdSSf : 1 face de ssdSS = 1 solid SameDomain de Ss
const TopoDS_Shape& ssdSSf = x.Current();
#ifdef DEB
Standard_Integer issdSSf = 0;Standard_Boolean tSPSssdSSf=GtraceSPS(ssdSSf,issdSSf);
if (tSPSssdSSf) debreguso(issdSSf);
#endif
TopAbs_State stassdSSf = stassdSS;
TopTools_ListOfShape& lspssdSSf = ChangeSplit(ssdSSf,stassdSSf);
#ifdef DEB
// Standard_Boolean issplitssdSSf = IsSplit(ssdSSf,stassdSSf);
// Standard_Integer nlspssdSSf = lspssdSSf.Extent();
#endif
Standard_Integer nDEB2=0;
TopTools_ListOfShape newlspssdSSf; // nouvel ensemble de faces splittees de ssdSSf
for (TopTools_ListIteratorOfListOfShape it(lspssdSSf);it.More();it.Next()) {
const TopoDS_Shape& fspssdSSf = it.Value();
Standard_Boolean inmfns = mfns.Contains(fspssdSSf);
if (!inmfns) continue;
// ssdSSf est une face de ssdSS (Cf supra E)
// fspssdSSf de Split(ssdSSf) figure dans newSolid (Cf supra E')
Standard_Boolean rfsplitloc = myFSplits.IsBound(fspssdSSf);
if (rfsplitloc) {
// ssdSSf (Cf supra E) a ete splittee, fspssdSSf = arete splittee de ssdSSf
// fspssdSSf est une arete de Split(ssdSSf) ET figure dans newFace (Cf supra E')
// fspssdSSf de newFace a ete redecoupee par RegularizeWires
// son decoupage lrfsplit est stocke dans la DS du Builder
const TopTools_ListOfShape& lrfsplit = myFSplits.Find(fspssdSSf);//Cf supra E''
nDEB2 = lrfsplit.Extent();
// on memorise que fspssdSSf est redecoupee ...
myMemoSplit.Add(fspssdSSf);
// on stocke le nouveau decoupage de fspssdSSf dans la DS du builder ...
TopTools_ListOfShape& lsp = ChangeSplit(fspssdSSf,stassdSSf);
GCopyList(lrfsplit,lsp);
nDEB2 = lsp.Extent();
}
} // lspssdSSf.More()
} // explore(ssdSS,TopAbs_FACE)
} // itlssdSS.More()
#ifdef DRAW
if (tSPS) debreguso(iS);
if (tSPS && savsregu) {
TCollection_AsciiString str("sregu"); str = str + iS;
DBRep::Set(str.ToCString(),newSolid);
cout<<"newSolid "<<str<<" built on Solid "<<iS<<" saved"<<endl;
}
#endif
} // RegularizeSolid

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
-- File: TopOpeBRepBuild_ShapeListOfShape.cdl
-- Created: Mon Jun 12 10:23:56 1995
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1995
class ShapeListOfShape from TopOpeBRepBuild
---Purpose: represent shape + a list of shape
uses
ListOfShape from TopTools,
Shape from TopoDS
is
Create returns ShapeListOfShape from TopOpeBRepBuild;
Create(S : Shape from TopoDS)
returns ShapeListOfShape from TopOpeBRepBuild;
Create(S : Shape from TopoDS;
L : ListOfShape from TopTools)
returns ShapeListOfShape from TopOpeBRepBuild;
List(me)
returns ListOfShape from TopTools is static;
---C++: return const &
ChangeList(me : in out)
returns ListOfShape from TopTools is static;
---C++: return &
Shape(me)
returns Shape from TopoDS is static;
---C++: return const &
ChangeShape(me : in out)
returns Shape from TopoDS is static;
---C++: return &
fields
myList : ListOfShape from TopTools;
myShape : Shape from TopoDS;
end ShapeListOfShape from TopOpeBRepBuild;

View File

@@ -0,0 +1,111 @@
// File: TopOpeBRepBuild_ShapeListOfShape.cxx
// Created: Thu Jun 26 17:22:23 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#include <TopOpeBRepBuild_ShapeListOfShape.ixx>
#define MTTdmiomoslos TopTools_DataMapIteratorOfDataMapOfShapeListOfShape
#define MTTdmoslos TopTools_DataMapOfShapeListOfShape
#define MTTmiomos TopTools_MapIteratorOfMapOfShape
#define MTTmos TopTools_MapOfShape
#define MTTliolos TopTools_ListIteratorOfListOfShape
#define MTTlos TopTools_ListOfShape
#define MTs TopoDS_Shape
#define MTf TopoDS_Face
#define MTe TopoDS_Edge
#define MTv TopoDS_Vertex
#define MDSlioloi TopOpeBRepDS_ListIteratorOfListOfInterference
#define MDSloi TopOpeBRepDS_ListOfInterference
#define MDShi Handle(TopOpeBRepDS_Interference)
#define MDSi TopOpeBRepDS_Interference
#define MDShssi Handle(TopOpeBRepDS_ShapeShapeInterference)
#define MDSssi TopOpeBRepDS_ShapeShapeInterference
#define MDSii TopOpeBRepDS_InterferenceIterator
#define MDShds Handle(TopOpeBRepDS_HDataStructure)
#define MDSds TopOpeBRepDS_DataStructure
#define MDSk TopOpeBRepDS_Kind
#define MDSsd TopOpeBRepDS_ShapeData
#define MDSmosd TopOpeBRepDS_MapOfShapeData
#define Msr Standard_Real
#define Msi Standard_Integer
#define Msb Standard_Boolean
#define Mso Standard_Ostream
#define Mtcas TCollection_AsciiString
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceSPS();
#endif
//=======================================================================
//function : TopOpeBRepBuild_ShapeListOfShape
//purpose :
//=======================================================================
TopOpeBRepBuild_ShapeListOfShape::TopOpeBRepBuild_ShapeListOfShape()
{
}
//=======================================================================
//function : TopOpeBRepBuild_ShapeListOfShape
//purpose :
//=======================================================================
TopOpeBRepBuild_ShapeListOfShape::TopOpeBRepBuild_ShapeListOfShape
(const TopoDS_Shape& S)
{
myShape = S;
}
//=======================================================================
//function : TopOpeBRepBuild_ShapeListOfShape
//purpose :
//=======================================================================
TopOpeBRepBuild_ShapeListOfShape::TopOpeBRepBuild_ShapeListOfShape
(const TopoDS_Shape& S, const TopTools_ListOfShape& L)
{
myShape = S;
myList = L;
}
//=======================================================================
//function : List
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_ShapeListOfShape::List() const
{
return myList;
}
//=======================================================================
//function : ChangeList
//purpose :
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_ShapeListOfShape::ChangeList()
{
return myList;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_ShapeListOfShape::Shape() const
{
return myShape;
}
//=======================================================================
//function : ChangeShape
//purpose :
//=======================================================================
TopoDS_Shape& TopOpeBRepBuild_ShapeListOfShape::ChangeShape()
{
return myShape;
}

View File

@@ -0,0 +1,202 @@
-- File: TopOpeBRepBuild_ShapeSet.cdl
-- Created: Wed Jun 16 11:52:45 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class ShapeSet from TopOpeBRepBuild
---Purpose:
-- Auxiliary class providing an exploration of a set
-- of shapes to build faces or solids.
-- To build faces : shapes are wires, elements are edges.
-- To build solids : shapes are shells, elements are faces.
-- The ShapeSet stores a list of shapes, a list of elements
-- to start reconstructions, and a map to search neighbours.
-- The map stores the connection between elements through
-- subshapes of type <SubShapeType> given in constructor.
-- <SubShapeType> is :
-- - TopAbs_VERTEX to connect edges
-- - TopAbs_EDGE to connect faces
--
-- Signature needed by the BlockBuilder :
-- InitStartElements(me : in out)
-- MoreStartElements(me) returns Boolean;
-- NextStartElement(me : in out);
-- StartElement(me) returns Shape; ---C++: return const &
-- InitNeighbours(me : in out; S : Shape);
-- MoreNeighbours(me) returns Boolean;
-- NextNeighbour(me : in out);
-- Neighbour(me) returns Shape; ---C++: return const &
uses
ShapeEnum from TopAbs,
Orientation from TopAbs,
Shape from TopoDS,
ListOfShape from TopTools,
ListIteratorOfListOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
IndexedMapOfOrientedShape from TopTools,
ShapeExplorer from TopOpeBRepTool,
AsciiString from TCollection
is
-- Filling methods
Create (SubShapeType:ShapeEnum from TopAbs;
checkshape:Boolean = Standard_True) returns ShapeSet;
---Purpose: Creates a ShapeSet in order to build shapes connected
-- by <SubShapeType> shapes.
-- <checkshape>:check (or not) the shapes, startelements, elements added.
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~TopOpeBRepBuild_ShapeSet(){Delete() ; }"
AddShape(me:in out;S:Shape) is virtual;
---Purpose: Adds <S> to the list of shapes. (wires or shells).
AddStartElement(me:in out;S:Shape) is virtual;
---Purpose: (S is a face or edge)
-- Add S to the list of starting shapes used for reconstructions.
-- apply AddElement(S).
AddElement(me:in out;S:Shape) is virtual;
---Purpose: for each subshape SE of S of type mySubShapeType
-- - Add subshapes of S to the map of subshapes (mySubShapeMap)
-- - Add S to the list of shape incident to subshapes of S.
ProcessAddShape(me:in out;S:Shape) is static protected;
ProcessAddStartElement(me:in out;S:Shape) is static protected;
ProcessAddElement(me:in out;S:Shape) is static protected;
StartElements(me) returns ListOfShape from TopTools;
---Purpose: return a reference on myStartShapes
---C++: return const &
-- Iteration on the shapes of AddShape()
InitShapes(me:in out);
MoreShapes(me) returns Boolean;
NextShape(me:in out);
Shape(me) returns Shape;
---C++: return const &
-- Iteration on the start elements of AddStartElement()
InitStartElements(me:in out);
MoreStartElements(me) returns Boolean;
NextStartElement(me:in out);
StartElement(me) returns Shape;
---C++: return const &
-- Iteration on the neighbours of a shape of type myShapeType
-- through its subshapes of type mySubShapeType.
InitNeighbours(me:in out;S:Shape) is virtual;
MoreNeighbours(me:in out) returns Boolean;
NextNeighbour(me:in out);
Neighbour(me) returns Shape;
---C++: return const &
ChangeStartShapes(me:in out) returns ListOfShape from TopTools;
---C++: return &
IsStartElement(me;S:Shape) returns Boolean;
IsElement(me;S:Shape) returns Boolean;
IsShape(me;S:Shape) returns Boolean;
NStartElement(me;S:Shape) returns Integer;
NElement(me;S:Shape) returns Integer;
NShape(me;S:Shape) returns Integer;
FindNeighbours(me:in out) is virtual;
---Purpose: Build the list of neighbour shapes of myCurrentShape
-- (neighbour shapes and myCurrentShapes are of type t)
-- Initialize myIncidentShapesIter on neighbour shapes.
MakeNeighboursList(me:in out;E,V:Shape) returns ListOfShape from TopTools is virtual;
---C++: return const &
MaxNumberSubShape(me:in out;Shape:Shape) returns Integer;
-- check
CheckShape(me:in out;checkshape:Boolean); -- field myCheckShape
CheckShape(me) returns Boolean; -- field myCheckShape
CheckShape(me:in out;S:Shape;checkgeom:Boolean = Standard_False) returns Boolean;
-- debug
DumpName(me;OS:in out OStream;str:AsciiString);
DumpCheck(me;OS:in out OStream;str:AsciiString;S:Shape;chk:Boolean);
DumpSS(me:in out) is virtual;
DumpBB(me:in out) is virtual;
DEBName(me:in out;N:AsciiString);
DEBName(me) returns AsciiString;
---C++: return const &
DEBNumber(me:in out;I:Integer);
DEBNumber(me) returns Integer;
SName(me;S:Shape;sb:AsciiString="";sa:AsciiString="")
returns AsciiString is virtual;
SNameori(me;S:Shape;sb:AsciiString="";sa:AsciiString="")
returns AsciiString is virtual;
SName(me;S:ListOfShape from TopTools;sb:AsciiString="";sa:AsciiString="")
returns AsciiString is virtual;
SNameori(me;S:ListOfShape from TopTools;sb:AsciiString="";sa:AsciiString="")
returns AsciiString is virtual;
fields
myShapeType : ShapeEnum from TopAbs is protected;
-- shape type : edge
-- shape type : face
mySubShapeType : ShapeEnum from TopAbs is protected;
-- subshape type : vertex
-- subshape type : edge
mySubShapeExplorer : ShapeExplorer from TopOpeBRepTool is protected;
-- explorer of edge vertices
-- explorer of face edges
myStartShapes : ListOfShape from TopTools is protected;
-- list of starting edges
-- list of starting faces
myStartShapesIter : ListIteratorOfListOfShape from TopTools is protected;
-- myStartShapes iterator
mySubShapeMap : IndexedDataMapOfShapeListOfShape from TopTools is protected;
-- map of vertices
-- mySubShapeMap(vertex) = list of incident edges to a vertex
-- mySubShapeMap(edge) = list of incident faces to a edge
myIncidentShapesIter : ListIteratorOfListOfShape from TopTools is protected;
-- iter on list L of edges incident to a vertex, L = mySubShapeMap(vertex)
-- iter on list L of faces incident to a edge, L = mySubShapeMap(edge)
myShapes : ListOfShape from TopTools is protected;
-- list of wires which are not to be reconstructed
-- list of shells which are not to be reconstructed
myShapesIter : ListIteratorOfListOfShape from TopTools is protected;
-- myShapes iterator
myCurrentShape : Shape from TopoDS is protected;
-- current edge which neighbours are searched, using FindNeighbours()
-- current face which neighbours are searched, using FindNeighbours()
myCurrentShapeNeighbours : ListOfShape from TopTools is protected;
-- list of edges neighbour of the edge myCurrentShape
-- list of faces neighbour of the face myCurrentShape
-- debug
myDEBNumber : Integer from Standard is protected;
myDEBName : AsciiString is protected;
-- index of subshape is given by mySubShape
myOMSS : IndexedMapOfOrientedShape from TopTools is protected; -- AddStartElement
myOMES : IndexedMapOfOrientedShape from TopTools is protected; -- AddElement (+AddStartElement)
myOMSH : IndexedMapOfOrientedShape from TopTools is protected; -- AddShape
myCheckShape : Boolean from Standard is protected;
end ShapeSet from TopOpeBRepBuild;

View File

@@ -0,0 +1,757 @@
// File: TopOpeBRepBuild_ShapeSet.cxx
// Created: Thu Jun 17 17:21:05 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_ShapeSet.ixx>
#include <TopOpeBRepBuild_define.hxx>
#include <Standard_ProgramError.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <TopAbs.hxx>
#ifdef DRAW
#include <DBRep.hxx>
#include <DBRep_DrawableShape.hxx>
#include <TestTopOpeDraw_DrawableSHA.hxx>
#include <TestTopOpeDraw_TTOT.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
static TCollection_AsciiString PRODINS("dins ");
#endif
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCHK();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCHKOK();
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCHKNOK();
Standard_EXPORT void debaddss(){}
Standard_IMPORT TopOpeBRepBuild_Builder* LOCAL_PBUILDER_DEB;
#endif
//=======================================================================
//function : TopOpeBRepBuild_ShapeSet
//purpose :
//=======================================================================
TopOpeBRepBuild_ShapeSet::TopOpeBRepBuild_ShapeSet(const TopAbs_ShapeEnum SubShapeType,const Standard_Boolean checkshape) :
mySubShapeType(SubShapeType), myCheckShape(checkshape)
{
if (SubShapeType == TopAbs_EDGE) myShapeType = TopAbs_FACE;
else if (SubShapeType == TopAbs_VERTEX) myShapeType = TopAbs_EDGE;
else Standard_ProgramError::Raise("ShapeSet : bad ShapeType");
myDEBNumber = 0;
myCheckShape = Standard_False; // temporary NYI
}
void TopOpeBRepBuild_ShapeSet::Delete()
{}
//=======================================================================
//function : AddShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::AddShape(const TopoDS_Shape& S)
{
Standard_Boolean chk = CheckShape(S);
#ifdef DEB
DumpCheck(cout," AddShape",S,chk);
#endif
if (!chk) return;
ProcessAddShape(S);
}
//=======================================================================
//function : AddStartElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::AddStartElement(const TopoDS_Shape& S)
{
Standard_Boolean chk = CheckShape(S);
#ifdef DEB
DumpCheck(cout," AddStartElement",S,chk);
#endif
if (!chk) return;
ProcessAddStartElement(S);
}
//=======================================================================
//function : AddElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::AddElement(const TopoDS_Shape& S)
{
Standard_Boolean chk = CheckShape(S);
#ifdef DEB
DumpCheck(cout," AddElement",S,chk);
#endif
if (!chk) return;
ProcessAddElement(S);
}
//=======================================================================
//function : ProcessAddShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::ProcessAddShape(const TopoDS_Shape& S)
{
if ( !myOMSH.Contains(S) ) {
myOMSH.Add(S);
myShapes.Append(S);
}
}
//=======================================================================
//function : ProcessStartElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::ProcessAddStartElement(const TopoDS_Shape& S)
{
if ( !myOMSS.Contains(S) ) {
myOMSS.Add(S);
myStartShapes.Append(S);
ProcessAddElement(S);
}
}
//=======================================================================
//function : ProcessAddElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::ProcessAddElement(const TopoDS_Shape& S)
{
if ( !myOMES.Contains(S) ) {
myOMES.Add(S);
TopTools_ListOfShape Lemp;
TopOpeBRepTool_ShapeExplorer Ex(S,mySubShapeType);
for (; Ex.More(); Ex.Next()) {
const TopoDS_Shape& subshape = Ex.Current();
Standard_Boolean b = ( ! mySubShapeMap.Contains(subshape) );
if ( b ) mySubShapeMap.Add(subshape,Lemp);
mySubShapeMap.ChangeFromKey(subshape).Append(S);
}
}
}
//=======================================================================
//function : StartElements
//purpose :
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_ShapeSet::StartElements()const
{
return myStartShapes;
}
//=======================================================================
//function : InitShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::InitShapes()
{
myShapesIter.Initialize(myShapes);
}
//=======================================================================
//function : MoreShapes
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreShapes()const
{
Standard_Boolean b = myShapesIter.More();
return b;
}
//=======================================================================
//function : NextShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::NextShape()
{
myShapesIter.Next();
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::Shape()const
{
const TopoDS_Shape& S = myShapesIter.Value();
return S;
}
//=======================================================================
//function : InitStartElements
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::InitStartElements()
{
myStartShapesIter.Initialize(myStartShapes);
}
//=======================================================================
//function : MoreStartElements
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreStartElements()const
{
Standard_Boolean b = myStartShapesIter.More();
return b;
}
//=======================================================================
//function : NextStartElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::NextStartElement()
{
myStartShapesIter.Next();
}
//=======================================================================
//function : StartElement
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::StartElement()const
{
const TopoDS_Shape& S = myStartShapesIter.Value();
return S;
}
//=======================================================================
//function : InitNeighbours
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::InitNeighbours(const TopoDS_Shape& S)
{
mySubShapeExplorer.Init(S,mySubShapeType);
myCurrentShape = S;
FindNeighbours();
}
//=======================================================================
//function : MoreNeighbours
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::MoreNeighbours()
{
Standard_Boolean b = myIncidentShapesIter.More();
return b;
}
//=======================================================================
//function : NextNeighbour
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::NextNeighbour()
{
myIncidentShapesIter.Next();
Standard_Boolean noisimore = ! myIncidentShapesIter.More();
if ( noisimore ) {
Standard_Boolean ssemore = mySubShapeExplorer.More();
if ( ssemore ) {
mySubShapeExplorer.Next();
FindNeighbours();
}
}
}
//=======================================================================
//function : Neighbour
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_ShapeSet::Neighbour()const
{
const TopoDS_Shape& S = myIncidentShapesIter.Value();
return S;
}
//=======================================================================
//function : ChangeStartShapes
//purpose :
//=======================================================================
TopTools_ListOfShape& TopOpeBRepBuild_ShapeSet::ChangeStartShapes()
{
return myStartShapes;
}
//=======================================================================
//function : IsStartElement
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::IsStartElement(const TopoDS_Shape& S) const
{
Standard_Boolean b = Standard_False;
#ifdef DEB
b = myOMSS.Contains(S);
#endif
return b;
}
//=======================================================================
//function : IsElement
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::IsElement(const TopoDS_Shape& S) const
{
Standard_Boolean b = Standard_False;
#ifdef DEB
b = myOMES.Contains(S);
#endif
return b;
}
//=======================================================================
//function : IsShape
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::IsShape(const TopoDS_Shape& S) const
{
Standard_Boolean b = Standard_False;
#ifdef DEB
b = myOMSH.Contains(S);
#endif
return b;
}
//=======================================================================
//function : NStartElement
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_ShapeSet::NStartElement(const TopoDS_Shape& S) const
{
Standard_Integer n = 0;
#ifdef DEB
Standard_Boolean b = Standard_False;
b = IsStartElement(S);
if (b) n++;
b = IsStartElement(S.Oriented(TopAbs::Complement(S.Orientation())));
if (b) n++;
#endif
return n;
}
//=======================================================================
//function : NElement
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_ShapeSet::NElement(const TopoDS_Shape& S) const
{
Standard_Integer n = 0;
#ifdef DEB
Standard_Boolean b = Standard_False;
b = IsElement(S); if (b) n++;
b = IsElement(S.Oriented(TopAbs::Complement(S.Orientation())));
if (b) n++;
#endif
return n;
}
//=======================================================================
//function : IsShape
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_ShapeSet::NShape(const TopoDS_Shape& S) const
{
Standard_Integer n = 0;
#ifdef DEB
Standard_Boolean b = Standard_False;
b = IsShape(S);
if (b) n++;
b = IsShape(S.Oriented(TopAbs::Complement(S.Orientation())));
if (b) n++;
#endif
return n;
}
//=======================================================================
//function : FindNeighbours
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::FindNeighbours()
{
while (mySubShapeExplorer.More()) {
// l = list of edges neighbour of edge myCurrentShape trough
// the vertex mySubShapeExplorer.Current(), which is a vertex of the
// edge myCurrentShape.
const TopoDS_Shape& V = mySubShapeExplorer.Current();
const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V);
// myIncidentShapesIter iterates on the neighbour edges of the edge
// given as InitNeighbours() argument (this edge has been stored
// in the field myCurrentShape).
myIncidentShapesIter.Initialize(l);
if (myIncidentShapesIter.More()) break;
else mySubShapeExplorer.Next();
}
}
//=======================================================================
//function : MakeNeighboursList
//purpose : // (Earg = Edge, Varg = Vertex) to find connected to Earg by Varg
//=======================================================================
const TopTools_ListOfShape & TopOpeBRepBuild_ShapeSet::MakeNeighboursList(const TopoDS_Shape& Earg, const TopoDS_Shape& Varg)
{
const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg);
return l;
}
//=======================================================================
//function : MaxNumberSubShape
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_ShapeSet::MaxNumberSubShape(const TopoDS_Shape& Shape)
{
Standard_Integer i, m = 0;
TopOpeBRepTool_ShapeExplorer SE(Shape, mySubShapeType);
TopTools_ListIteratorOfListOfShape LI;
while(SE.More()) {
const TopoDS_Shape& SubShape = SE.Current();
if(!mySubShapeMap.Contains(SubShape)) {
SE.Next();
continue;
}
const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(SubShape);
LI.Initialize(l);
for(i = 0;LI.More();LI.Next(), i++) {}
m = Max(m, i);
SE.Next();
}
return m;
}
//=======================================================================
//function : CheckShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::CheckShape(const Standard_Boolean checkshape)
{
myCheckShape = checkshape;
#ifdef DEB
if (TopOpeBRepBuild_GettraceCHK() && !myCheckShape) {
DumpName(cout,"no checkshape set on ");cout<<endl;
}
#endif
}
//=======================================================================
//function : CheckShape
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::CheckShape() const
{
return myCheckShape;
}
//=======================================================================
//function : CheckShape
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_ShapeSet::CheckShape(const TopoDS_Shape& S,const Standard_Boolean checkgeom)
{
if (!myCheckShape) return Standard_True;
BRepCheck_Analyzer ana(S,checkgeom);
Standard_Boolean val = ana.IsValid();
if ( val ) {
return Standard_True;
}
else {
return Standard_False;
}
}
//=======================================================================
//function : DumpName
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DumpName(Standard_OStream& OS,const TCollection_AsciiString& str) const
{
OS<<str<<"("<<myDEBName<<","<<myDEBNumber<<")";
}
//=======================================================================
//function : DumpCheck
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DumpCheck(Standard_OStream& OS,const TCollection_AsciiString& str,const TopoDS_Shape& S,const Standard_Boolean chk) const
{
if (!myCheckShape) return;
#ifdef DEB
TopAbs_ShapeEnum t = S.ShapeType();
if (!chk) {
if (TopOpeBRepBuild_GettraceCHK() ||
TopOpeBRepBuild_GettraceCHKNOK() ) {
DumpName(OS,"*********************** ");
OS<<str<<" ";TopAbs::Print(t,OS);OS<<" : incorrect"<<endl;
}
}
else {
if (TopOpeBRepBuild_GettraceCHK() ||
TopOpeBRepBuild_GettraceCHKOK() ) {
DumpName(OS,"");
OS<<str<<" ";TopAbs::Print(t,OS);OS<<" : correct"<<endl;
}
}
if (!chk) debaddss();
#endif
}
//=======================================================================
//function : DumpSS
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DumpSS()
{
#ifdef DRAW
DumpName(cout,"\nDumpSS start ");
TopTools_ListIteratorOfListOfShape it;
Standard_Integer i,j,ne;
TCollection_AsciiString s1(" ");
InitShapes();
cout<<endl<<"#Shapes : ";if (!MoreShapes()) cout<<0;cout<<endl;
for (i=1;MoreShapes();NextShape(),i++) {
TCollection_AsciiString ns = SNameori(Shape());
cout<<PRODINS<<ns<<"; # "<<i<<" draw"<<endl;
DBRep::Set(ns.ToCString(),Shape());
}
InitStartElements();
cout<<"#StartElements : ";if (!MoreStartElements()) cout<<0;cout<<endl;
for (i=1;MoreStartElements();NextStartElement(),i++) {
cout<<PRODINS<<SNameori(StartElement())<<"; # "<<i<<" draw"<<endl;
}
InitStartElements();
cout<<"#Neighbours of StartElements : ";if (!MoreStartElements()) cout<<0;cout<<endl;
for (i=1;MoreStartElements();NextStartElement(),i++) {
const TopoDS_Shape& e = StartElement();
TCollection_AsciiString enam = SNameori(e);
InitNeighbours(e);
if (MoreNeighbours()) {
TCollection_AsciiString sne("clear; ");sne=sne+PRODINS+enam;
for (ne=1; MoreNeighbours(); NextNeighbour(),ne++) {
const TopoDS_Shape& N = Neighbour();
sne=sne+" "+SNameori(N);
}
sne=sne+"; wclick; #draw";
cout<<sne<<endl;
}
}
Standard_Integer ism,nsm=mySubShapeMap.Extent();
cout<<"#Incident shapes : ";if (!nsm) cout<<0;cout<<endl;
for (i=1,ism=1;ism<=nsm;ism++,i++) {
const TopoDS_Shape& v = mySubShapeMap.FindKey(ism);
const TopTools_ListOfShape& lsv = mySubShapeMap.FindFromIndex(ism);
TopTools_ListIteratorOfListOfShape itle(lsv);
if (itle.More()) {
TCollection_AsciiString vnam = SName(v);
TCollection_AsciiString sle("clear; ");sle=sle+PRODINS+vnam;
for (j=1;itle.More();itle.Next(),j++) {
const TopoDS_Shape& e = itle.Value();
sle=sle+" "+SNameori(e);
}
sle=sle+"; wclick; #draw";
cout<<sle<<endl;
}
}
DumpName(cout,"DumpSS end ");
#endif
}
//=======================================================================
//function : DumpBB
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DumpBB()
{
#ifdef DRAW
DumpName(cout,"\nDumpBB ");
TopTools_ListIteratorOfListOfShape it;
Standard_Integer i,j,ne = 0, nb = 1, curr, currloc;
TCollection_AsciiString s1(" "),stt,enam,nnam,vnam;
InitShapes();
cout<<endl<<"#Shapes : (block old) ";if (!MoreShapes()) cout<<0;cout<<endl;
for (i=1;MoreShapes();NextShape(),i++, nb++) {
cout<<"Block number"<<nb<<" (old)."<<endl;
const TopoDS_Shape& e = Shape();
TopoDS_Iterator ShapIter(e);
for(ne = 1;ShapIter.More();ShapIter.Next(), ne++) {
const TopoDS_Shape& subsha = ShapIter.Value();
TestTopOpeDraw_TTOT::ShapeEnumToString(subsha.ShapeType(),stt);
enam = stt+ne+"ShaB"+nb;
DBRep::Set(enam.ToCString(),subsha);
cout<<"clear; "<<PRODINS<<enam<<"; #draw"<<endl;
}
}
InitStartElements();
TopTools_IndexedMapOfShape mos;
cout<<"#Elements : (block new) : ";if (!MoreStartElements()) cout<<0;cout<<endl;
mos.Clear();
for (;MoreStartElements();NextStartElement()) {
const TopoDS_Shape& e = StartElement();
curr = mos.Extent();
if(mos.Add(e) > curr) {
cout<<"#Block number"<<nb<<" (new)."<<endl;
nb++;ne++;
enam = "";
enam = enam+"ste"+ne+"newB"+nb;
DBRep::Set(enam.ToCString(),e);
// char* name = enam.ToCString();
// Handle(TestTopOpeDraw_DrawableSHA) D = new TestTopOpeDraw_DrawableSHA
// (e, Draw_blanc, Draw_blanc, Draw_blanc, Draw_blanc, 100., 2, 30, name, Draw_blanc);
// Draw::Set(name,D);
// cout<<"wclick; clear; "<<PRODINS<<enam<<"; #draw"<<endl;
while(curr < mos.Extent()) {
curr = mos.Extent();
currloc = curr;
InitNeighbours(mos.FindKey(curr));
for (; MoreNeighbours(); NextNeighbour()) {
const TopoDS_Shape& N = Neighbour();
if(mos.Add(N) > currloc) {
currloc++;ne++;
// to know if ste or ele is displayed; start
const TopTools_ListOfShape& LSE = StartElements();
it.Initialize(LSE);
while(it.More())
if(it.Value() == N)
break;
else
it.Next();
enam = "";
if(it.More()) {
enam = enam+"ste"+ne+"newB"+nb;
// name = enam.ToCString();
// Handle(TestTopOpeDraw_DrawableSHA) Dloc =
// new TestTopOpeDraw_DrawableSHA
// (N, Draw_blanc, Draw_blanc, Draw_blanc, Draw_blanc,
// 100., 2, 30, name, Draw_blanc);
// Draw::Set(name,Dloc);
DBRep::Set(enam.ToCString(),N);
// cout<<PRODINS<<enam<<"; #draw"<<endl;
} else {
enam = enam+"ele"+ne+"newB"+nb;
DBRep::Set(enam.ToCString(),N);
cout<<PRODINS<<enam<<"; #draw"<<endl;
}
}
}
}
}
}
#endif
}
//=======================================================================
//function : DEBName
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DEBName(const TCollection_AsciiString& N)
{
myDEBName = N;
}
//=======================================================================
//function : DEBName
//purpose :
//=======================================================================
const TCollection_AsciiString& TopOpeBRepBuild_ShapeSet::DEBName() const
{
return myDEBName;
}
//=======================================================================
//function : DEBNumber
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShapeSet::DEBNumber(const Standard_Integer I)
{
myDEBNumber = I;
}
//=======================================================================
//function : DEBNumber
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_ShapeSet::DEBNumber() const
{
return myDEBNumber;
}
//=======================================================================
//function : SName
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShapeSet::SName(const TopoDS_Shape& S,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
str=sb;
TCollection_AsciiString WESi=myDEBName.SubString(1,1)+myDEBNumber;
str=str+WESi;
TopAbs_ShapeEnum t = S.ShapeType();
TCollection_AsciiString sts;TestTopOpeDraw_TTOT::ShapeEnumToString(t,sts);
sts.UpperCase();str=str+sts.SubString(1,1);
Standard_Integer isub = mySubShapeMap.FindIndex(S);
Standard_Integer ista = myOMSS.FindIndex(S);
Standard_Integer iele = myOMES.FindIndex(S);
Standard_Integer isha = myOMSH.FindIndex(S);
if (isub) str=str+"sub"+isub;
if (ista) str=str+"sta"+ista;
else if (iele) str=str+"ele"+iele;
if (isha) str=str+"sha"+isha;
str=str+sa;
#endif
return str;
}
//=======================================================================
//function : SNameori
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShapeSet::SNameori(const TopoDS_Shape& S,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
str=sb+SName(S);
TopAbs_Orientation o = S.Orientation();
TCollection_AsciiString sto;TestTopOpeDraw_TTOT::OrientationToString(o,sto);
str=str+sto.SubString(1,1);
str=str+sa;
#endif
return str;
}
//=======================================================================
//function : SName
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShapeSet::SName(const TopTools_ListOfShape& L,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SName(it.Value())+sa+" ";
#endif
return str;
}
//=======================================================================
//function : SNameori
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShapeSet::SNameori(const TopTools_ListOfShape& L,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SNameori(it.Value())+sa+" ";
#endif
return str;
}

View File

@@ -0,0 +1,72 @@
-- File: TopOpeBRepBuild_ShellFaceClassifier.cdl
-- Created: Thu Jun 17 10:15:32 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class ShellFaceClassifier from TopOpeBRepBuild
inherits CompositeClassifier from TopOpeBRepBuild
---Purpose:
-- Classify faces and shells.
-- shapes are Shells, Elements are Faces.
uses
ShapeEnum from TopAbs,
State from TopAbs,
Shape from TopoDS,
Shell from TopoDS,
Pnt from gp,
DataMapOfShapeShape from TopTools,
Builder from BRep,
SolidClassifier from TopOpeBRepTool,
BlockBuilder from TopOpeBRepBuild,
Loop from TopOpeBRepBuild
is
Create(BB : BlockBuilder) returns ShellFaceClassifier;
---Purpose: Creates a classifier in 3D space, to compare :
-- a face with a set of faces
-- a shell with a set of faces
-- a shell with a shell
Clear(me : in out) is static;
CompareShapes(me : in out; B1,B2 : Shape from TopoDS)
---Purpose: classify shell <B1> with shell <B2>
returns State from TopAbs;
CompareElementToShape(me : in out; F : Shape; S : Shape)
---Purpose: classify face <F> with shell <S>
returns State from TopAbs;
ResetShape(me : in out; S : Shape);
---Purpose: prepare classification involving shell <S>
-- calls ResetElement on first face of <S>
ResetElement(me : in out; F : Shape);
---Purpose: prepare classification involving face <F>
-- define 3D point (later used in Compare()) on first vertex of face <F>.
CompareElement(me : in out; F : Shape);
---Purpose: Add the face <F> in the set of faces used in 3D point
-- classification.
State(me : in out) returns State from TopAbs;
---Purpose: Returns state of classification of 3D point, defined by
-- ResetElement, with the current set of faces, defined by Compare.
fields
myFirstCompare : Boolean from Standard;
myPoint3d : Pnt from gp;
myShell : Shell from TopoDS;
myBuilder : Builder from BRep;
mySolidClassifier : SolidClassifier from TopOpeBRepTool;
myFaceShellMap : DataMapOfShapeShape from TopTools;
myShape : Shape from TopoDS;
end ShellFaceClassifier from TopOpeBRepBuild;

View File

@@ -0,0 +1,210 @@
// File: TopOpeBRepBuild_ShellFaceClassifier.cxx
// Created: Thu Jun 17 18:52:50 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_ShellFaceClassifier.ixx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shell.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <Standard_ProgramError.hxx>
#include <BRepAdaptor_Surface.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCHK();
#endif
//=======================================================================
//function : TopOpeBRepBuild_ShellFaceClassifier
//purpose :
//=======================================================================
TopOpeBRepBuild_ShellFaceClassifier::TopOpeBRepBuild_ShellFaceClassifier
(const TopOpeBRepBuild_BlockBuilder& BB) :
TopOpeBRepBuild_CompositeClassifier(BB)
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceClassifier::Clear()
{
mySolidClassifier.Clear();
myFaceShellMap.Clear();
}
//=======================================================================
//function : CompareShapes
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_ShellFaceClassifier::CompareShapes
(const TopoDS_Shape& B1, const TopoDS_Shape& B2)
{
#ifdef DEB
// const TopAbs_ShapeEnum t1 = B1.ShapeType();
// const TopAbs_ShapeEnum t2 = B2.ShapeType();
#endif
ResetShape(B1);
myShell = TopoDS::Shell(B2);
mySolidClassifier.LoadShell(myShell);
// myShell.Free(Standard_True);
TopAbs_State state = State();
return state;
}
//=======================================================================
//function : CompareElementToShape
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_ShellFaceClassifier::CompareElementToShape
(const TopoDS_Shape& F, const TopoDS_Shape& SHE)
{
#ifdef DEB
// const TopAbs_ShapeEnum t1 = F.ShapeType();
// const TopAbs_ShapeEnum t2 = SHE.ShapeType();
#endif
ResetElement(F);
myShell = TopoDS::Shell(SHE);
mySolidClassifier.LoadShell(myShell);
// myShell.Free(Standard_True);
TopAbs_State state = State();
return state;
}
//=======================================================================
//function : ResetShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceClassifier::ResetShape(const TopoDS_Shape& SHE)
{
#ifdef DEB
// const TopAbs_ShapeEnum t1 = SHE.ShapeType();
#endif
TopExp_Explorer ex(SHE,TopAbs_FACE);
const TopoDS_Face& F = TopoDS::Face(ex.Current());
ResetElement(F);
}
//=======================================================================
//function : ResetElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceClassifier::ResetElement(const TopoDS_Shape& F)
{
const TopAbs_ShapeEnum t = F.ShapeType();
// initialize myPoint3d with first vertex of face <E>
myFirstCompare = Standard_True;
TopExp_Explorer ex(F,TopAbs_VERTEX);
if ( ex.More() ) {
const TopoDS_Vertex& V = TopoDS::Vertex(ex.Current());
myPoint3d = BRep_Tool::Pnt(V);
}
else {
if(t == TopAbs_FACE) {
BRepAdaptor_Surface BAS(TopoDS::Face(F));
myPoint3d = BAS.Value(.5*(BAS.FirstUParameter()+BAS.LastUParameter()),
.5*(BAS.FirstVParameter()+BAS.LastVParameter()));
}
else {
myPoint3d.SetCoord(0.,0.,0.);
}
}
}
//=======================================================================
//function : CompareElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceClassifier::CompareElement(const TopoDS_Shape& F)
{
#ifdef DEB
// const TopAbs_ShapeEnum t = F.ShapeType();
#endif
if (myFirstCompare) {
Standard_Boolean found = myFaceShellMap.IsBound(F);
if ( !found ) {
// la face F est la premiere d'un bloc de faces
// la face F d'un bloc de faces (F est supposee n'appartenir qu'a
// un seul shell) n'a pas encore ete rencontree <=> le bloc de faces
// dont F fait partie n'a pas encore ete shellise
// on cree un shell et on l'attache a F
myBuilder.MakeShell(myShell);
myBuilder.Add(myShell,F);
myFaceShellMap.Bind(F,myShell);
}
else {
// la face F est la premiere d'un bloc de faces
// on recupere le shell correspondant au bloc de faces (shellise)
// dont F fait partie.
TopoDS_Shape sbid = myFaceShellMap.Find(F);
myShell = TopoDS::Shell(sbid);
}
myFirstCompare = Standard_False;
}
else {
// F n'est pas la premiere face d'un bloc.
// myShell est necessairement defini et represente le bloc de faces
// dont F fait partie
myBuilder.Add(myShell,F);
}
}
#ifdef DEB
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <TCollection_AsciiString.hxx>
static Standard_Integer STATIC_ishell = 0;
#endif
//=======================================================================
//function : State
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_ShellFaceClassifier::State()
{
TopAbs_State state;
Standard_Real tol3d = Precision::Confusion();
#ifdef DEB
if (TopOpeBRepBuild_GettraceCHK()) {
STATIC_ishell++;
TCollection_AsciiString home("/home/wb/mdl/gti/prod/TTOPOPE/src/test/data/");
TCollection_AsciiString sname("shell_"); sname = home + sname + STATIC_ishell;
TCollection_AsciiString vname("vertex_"); vname = home + vname + STATIC_ishell;
BRep_Builder B;TopoDS_Vertex V;B.MakeVertex(V,myPoint3d,tol3d);
cout<<"TopOpeBRepBuild_ShellFaceClassifier : write shell "<<sname;
cout<<" vertex "<<vname<<endl;
BRepTools::Write(myShell,sname.ToCString());
BRepTools::Write(V,vname.ToCString());
}
#endif
mySolidClassifier.Classify(myShell,myPoint3d,tol3d);
state = mySolidClassifier.State();
return state;
}

View File

@@ -0,0 +1,55 @@
-- File: TopOpeBRepBuild_ShellFaceSet.cdl
-- Created: Wed Jun 16 11:52:45 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class ShellFaceSet from TopOpeBRepBuild
inherits ShapeSet from TopOpeBRepBuild
---Purpose: a bound is a shell, a boundelement is a face.
-- The ShapeSet stores :
-- - a list of shell (bounds),
-- - a list of face (boundelements) to start reconstructions,
-- - a map of edge giving the list of face incident to an edge.
uses
Shape from TopoDS,
Solid from TopoDS,
AsciiString from TCollection,
ListOfShape from TopTools
is
Create returns ShellFaceSet from TopOpeBRepBuild;
---Purpose: Creates a ShellFaceSet to build blocks of faces
-- connected by edges.
Create(S : Shape from TopoDS; Addr : Address from Standard = NULL)
returns ShellFaceSet from TopOpeBRepBuild;
---Purpose: Creates a ShellFaceSet to build blocks of faces
-- connected by edges.
Solid(me) returns Solid from TopoDS is static;
---C++: return const &
AddShape(me:in out;S:Shape) is redefined;
AddStartElement(me:in out;S:Shape) is redefined;
AddElement(me:in out;S:Shape) is redefined;
DumpSS(me:in out) is redefined;
SName(me;S:Shape from TopoDS;sb:AsciiString = "";sa:AsciiString = "")
returns AsciiString from TCollection is redefined;
SName(me;S:ListOfShape from TopTools;sb:AsciiString = "";sa:AsciiString = "")
returns AsciiString from TCollection is redefined;
SNameori(me;S:Shape;sb:AsciiString = "";sa:AsciiString = "")
returns AsciiString from TCollection is redefined;
SNameori(me;S:ListOfShape from TopTools;sb:AsciiString = "";sa:AsciiString = "")
returns AsciiString from TCollection is redefined;
fields
mySolid : Solid from TopoDS;
end ShellFaceSet from TopOpeBRepBuild;

View File

@@ -0,0 +1,166 @@
// File: TopOpeBRepBuild_ShellFaceSet.cxx
// Created: Thu Jun 17 17:21:05 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#ifdef DRAW
#include <DBRep.hxx>
#include <TestTopOpeDraw_TTOT.hxx>
static TCollection_AsciiString PRODINS("dins ");
#endif
#include <TopOpeBRepBuild_ShellFaceSet.ixx>
#include <TopOpeBRepBuild_Builder.hxx>
#include <TopOpeBRepBuild_define.hxx>
#include <TopoDS.hxx>
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceCHK();
#endif
//=======================================================================
//function : TopOpeBRepBuild_ShellFaceSet
//purpose :
//=======================================================================
TopOpeBRepBuild_ShellFaceSet::TopOpeBRepBuild_ShellFaceSet() :
TopOpeBRepBuild_ShapeSet(TopAbs_EDGE)
{
#ifdef DEB
myDEBName = "SFS";
#endif
}
//=======================================================================
//function : TopOpeBRepBuild_ShellFaceSet
//purpose :
//=======================================================================
TopOpeBRepBuild_ShellFaceSet::TopOpeBRepBuild_ShellFaceSet
(const TopoDS_Shape& S,const Standard_Address A) : // DEB
TopOpeBRepBuild_ShapeSet(TopAbs_EDGE)
{
mySolid = TopoDS::Solid(S);
#ifdef DEB
myDEBName = "SFS";
if (A != NULL) {
TopOpeBRepBuild_Builder* pB = ((TopOpeBRepBuild_Builder*)((void*)A));
myDEBNumber = pB->GdumpSHASETindex();
Standard_Integer iS; Standard_Boolean tSPS = pB->GtraceSPS(S,iS);
if(tSPS){cout<<"creation SFS "<<myDEBNumber<<" on ";}
if(tSPS){pB->GdumpSHA(S,NULL);cout<<endl;}
}
if (TopOpeBRepBuild_GettraceCHK() && !myCheckShape) {
DumpName(cout,"no checkshape in creation of ");cout<<endl;
}
#endif
}
//=======================================================================
//function : AddShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceSet::AddShape(const TopoDS_Shape& S)
{
TopOpeBRepBuild_ShapeSet::AddShape(S);
}
//=======================================================================
//function : AddStartElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceSet::AddStartElement(const TopoDS_Shape& S)
{
TopOpeBRepBuild_ShapeSet::ProcessAddStartElement(S);
}
//=======================================================================
//function : AddElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceSet::AddElement(const TopoDS_Shape& S)
{
TopOpeBRepBuild_ShapeSet::AddElement(S);
}
//=======================================================================
//function : Solid
//purpose :
//=======================================================================
const TopoDS_Solid& TopOpeBRepBuild_ShellFaceSet::Solid() const
{
return mySolid;
}
//=======================================================================
//function : DumpSS
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellFaceSet::DumpSS()
{
#ifdef DEB
TopOpeBRepBuild_ShapeSet::DumpSS();
#endif
}
//=======================================================================
//function : SName
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShellFaceSet::SName(const TopoDS_Shape& S,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str=sb;
#ifdef DRAW
str=str+TopOpeBRepBuild_ShapeSet::SName(S);
str=str+sa;
DBRep::Set(str.ToCString(),S);
#endif
return str;
}
//=======================================================================
//function : SNameori
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShellFaceSet::SNameori(const TopoDS_Shape& S,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str=sb;
#ifdef DRAW
str=str+TopOpeBRepBuild_ShapeSet::SNameori(S);
if ( S.ShapeType() == TopAbs_FACE ) {
const TopoDS_Shape& F = TopoDS::Face(S);
DBRep::Set(str.ToCString(),S);
}
#endif
return str;
}
//=======================================================================
//function : SName
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShellFaceSet::SName(const TopTools_ListOfShape& L,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SName(it.Value())+sa+" ";
#endif
return str;
}
//=======================================================================
//function : SNameori
//purpose :
//=======================================================================
TCollection_AsciiString TopOpeBRepBuild_ShellFaceSet::SNameori(const TopTools_ListOfShape& L,const TCollection_AsciiString& sb,const TCollection_AsciiString& sa) const
{
TCollection_AsciiString str;
#ifdef DRAW
for (TopTools_ListIteratorOfListOfShape it(L);it.More();it.Next()) str=str+sb+SNameori(it.Value())+sa+" ";
#endif
return str;
}

View File

@@ -0,0 +1,38 @@
-- File: TopOpeBRepBuild_ShellToSolid.cdl
-- Created: Thu Oct 2 15:17:26 1997
-- Author: Xuan Trang PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ShellToSolid from TopOpeBRepBuild
---Purpose:
-- This class builds solids from a set of shells SSh and a solid F.
uses
Shell from TopoDS,
Solid from TopoDS,
ListOfShape from TopTools
is
Create returns ShellToSolid;
Init(me : in out)
is static;
AddShell(me : in out; Sh : Shell from TopoDS)
is static;
MakeSolids(me : in out;
So : Solid from TopoDS;
LSo : in out ListOfShape from TopTools)
is static;
fields
myLSh : ListOfShape from TopTools;
end ShellToSolid;

View File

@@ -0,0 +1,68 @@
// File: TopOpeBRepBuild_ShellToSolid.cxx
// Created: Thu Oct 2 15:21:18 1997
// Author: Xuan Trang PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepBuild_ShellToSolid.ixx>
#include <TopOpeBRepBuild_ShellFaceSet.hxx>
#include <TopOpeBRepBuild_SolidBuilder.hxx>
#include <TopOpeBRepBuild_Builder.hxx>
#include <TopOpeBRepDS_BuildTool.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
//=======================================================================
//function : TopOpeBRepBuild_ShellToSolid
//purpose :
//=======================================================================
TopOpeBRepBuild_ShellToSolid::TopOpeBRepBuild_ShellToSolid()
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellToSolid::Init()
{
myLSh.Clear();
}
//=======================================================================
//function : AddShell
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellToSolid::AddShell(const TopoDS_Shell& Sh)
{
myLSh.Append(Sh);
}
//=======================================================================
//function : MakeSolids
//purpose :
//=======================================================================
void TopOpeBRepBuild_ShellToSolid::MakeSolids(const TopoDS_Solid& So,
TopTools_ListOfShape& LSo)
{
LSo.Clear();
TopOpeBRepBuild_ShellFaceSet sfs(So);
for (TopTools_ListIteratorOfListOfShape it(myLSh);it.More();it.Next())
sfs.AddShape(it.Value());
Standard_Boolean ForceClass = Standard_True;
TopOpeBRepBuild_SolidBuilder SB;
SB.InitSolidBuilder(sfs,ForceClass);
TopOpeBRepDS_BuildTool BT;
TopOpeBRepBuild_Builder B(BT);
B.MakeSolids(SB,LSo);
}

View File

@@ -0,0 +1,38 @@
-- File: TopOpeBRepBuild_SolidAreaBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class SolidAreaBuilder from TopOpeBRepBuild
inherits Area3dBuilder from TopOpeBRepBuild
---Purpose:
-- The SolidAreaBuilder algorithm is used to construct Solids from a LoopSet,
-- where the Loop is the composite topological object of the boundary,
-- here wire or block of edges.
-- The LoopSet gives an iteration on Loops.
-- For each Loop it indicates if it is on the boundary (wire) or if it
-- results from an interference (block of edges).
-- The result of the SolidAreaBuilder is an iteration on areas.
-- An area is described by a set of Loops.
uses
LoopSet from TopOpeBRepBuild,
LoopClassifier from TopOpeBRepBuild
is
Create returns SolidAreaBuilder;
Create(LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) returns SolidAreaBuilder;
---Purpose: Creates a SolidAreaBuilder to build Solids on
-- the (shells,blocks of face) of <LS>, using the classifier <LC>.
InitSolidAreaBuilder(me: in out;
LS : in out LoopSet; LC : in out LoopClassifier;
ForceClass : Boolean = Standard_False) is static;
end SolidAreaBuilder from TopOpeBRepBuild;

View File

@@ -0,0 +1,40 @@
// File: TopOpeBRepBuild_SolidAreaBuilder.cxx
// Created: Thu Dec 21 17:07:40 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
//Copyright: Matra Datavision 1995
#include <TopOpeBRepBuild_SolidAreaBuilder.ixx>
//=======================================================================
//function : TopOpeBRepBuild_SolidAreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_SolidAreaBuilder::TopOpeBRepBuild_SolidAreaBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_SolidAreaBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_SolidAreaBuilder::TopOpeBRepBuild_SolidAreaBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitSolidAreaBuilder(LS,LC,ForceClass);
}
//=======================================================================
//function : TopOpeBRepBuild_SolidAreaBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidAreaBuilder::InitSolidAreaBuilder
(TopOpeBRepBuild_LoopSet& LS, TopOpeBRepBuild_LoopClassifier& LC,
const Standard_Boolean ForceClass)
{
InitAreaBuilder(LS,LC,ForceClass);
}

View File

@@ -0,0 +1,71 @@
-- File: TopOpeBRepBuild_SolidBuilder.cdl
-- Created: Thu Dec 21 17:07:40 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class SolidBuilder from TopOpeBRepBuild
uses
Shape from TopoDS,
ShapeSet from TopOpeBRepBuild,
LoopSet from TopOpeBRepBuild,
BlockIterator from TopOpeBRepBuild,
BlockBuilder from TopOpeBRepBuild,
ShellFaceSet from TopOpeBRepBuild,
SolidAreaBuilder from TopOpeBRepBuild
is
Create returns SolidBuilder;
Create(FS : in out ShellFaceSet; ForceClass : Boolean = Standard_False)
returns SolidBuilder;
---Purpose: Create a SolidBuilder to build the areas on
-- the shapes (shells, blocks of faces) described by <LS>.
InitSolidBuilder(me : in out;
FS : in out ShellFaceSet;
ForceClass : Boolean) is static;
-- Output methods
InitSolid(me : in out) returns Integer from Standard;
MoreSolid(me) returns Boolean from Standard is static;
NextSolid(me : in out) is static;
-- Exploration of the wires of the current Solid
InitShell(me : in out) returns Integer from Standard;
MoreShell(me) returns Boolean from Standard is static;
NextShell(me : in out) is static;
IsOldShell(me) returns Boolean from Standard is static;
OldShell(me) returns Shape from TopoDS is static;
---Purpose: Returns current shell
-- This shell may be :
-- * an old shell OldShell(), which has not been reconstructed;
-- * a new shell made of faces described by ...NewFace() methods.
---C++: return const &
-- Exploration of the faces of current shell when IsOldShell = False
InitFace(me : in out) returns Integer from Standard;
MoreFace(me) returns Boolean from Standard is static;
NextFace(me : in out) is static;
Face(me) returns Shape from TopoDS is static;
---Purpose: Returns current new face of current new shell.
---C++: return const &
--- private
MakeLoops(me : in out; SS : in out ShapeSet from TopOpeBRepBuild)
is static private;
fields
myLoopSet : LoopSet from TopOpeBRepBuild;
myBlockIterator : BlockIterator from TopOpeBRepBuild;
myBlockBuilder : BlockBuilder from TopOpeBRepBuild;
mySolidAreaBuilder : SolidAreaBuilder from TopOpeBRepBuild;
end SolidBuilder;

View File

@@ -0,0 +1,222 @@
// File: TopOpeBRepBuild_SolidBuilder.cxx
// Created: Fri Jan 5 18:11:10 1996
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepBuild_SolidBuilder.ixx>
#include <TopOpeBRepBuild_ShellFaceClassifier.hxx>
#include <TopOpeBRepBuild_Loop.hxx>
#include <TopOpeBRepBuild_BlockBuilder.hxx>
#include <TopOpeBRepBuild_LoopSet.hxx>
//=======================================================================
//function : TopOpeBRepBuild_SolidBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder()
{
}
//=======================================================================
//function : TopOpeBRepBuild_SolidBuilder
//purpose :
//=======================================================================
TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder
(TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
{
InitSolidBuilder(SFS,ForceClass);
}
//=======================================================================
//function : InitSolidBuilder
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidBuilder::InitSolidBuilder
(TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
{
MakeLoops(SFS);
TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
TopOpeBRepBuild_LoopSet& LS = myLoopSet;
TopOpeBRepBuild_ShellFaceClassifier SFC(BB);
mySolidAreaBuilder.InitSolidAreaBuilder(LS,SFC,ForceClass);
}
//=======================================================================
//function : InitSolid
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_SolidBuilder::InitSolid()
{
Standard_Integer n = mySolidAreaBuilder.InitArea();
return n;
}
//=======================================================================
//function : MoreSolid
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreSolid() const
{
Standard_Boolean b = mySolidAreaBuilder.MoreArea();
return b;
}
//=======================================================================
//function : NextSolid
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidBuilder::NextSolid()
{
mySolidAreaBuilder.NextArea();
}
//=======================================================================
//function : InitShell
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_SolidBuilder::InitShell()
{
Standard_Integer n = mySolidAreaBuilder.InitLoop();
return n;
}
//=======================================================================
//function : MoreShell
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreShell() const
{
Standard_Boolean b = mySolidAreaBuilder.MoreLoop();
return b;
}
//=======================================================================
//function : NextShell
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidBuilder::NextShell()
{
mySolidAreaBuilder.NextLoop();
}
//=======================================================================
//function : IsOldShell
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_SolidBuilder::IsOldShell() const
{
const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
Standard_Boolean b = L->IsShape();
return b;
}
//=======================================================================
//function : OldShell
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::OldShell() const
{
const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
const TopoDS_Shape& B = L->Shape();
return B;
}
//=======================================================================
//function : InitFace
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepBuild_SolidBuilder::InitFace()
{
const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
if ( L->IsShape() )
Standard_DomainError::Raise("TopOpeBRepBuild_SolidBuilder:InitFace");
else {
myBlockIterator = L->BlockIterator();
myBlockIterator.Initialize();
}
Standard_Integer n = myBlockIterator.Extent();
return n;
}
//=======================================================================
//function : MoreFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreFace() const
{
Standard_Boolean b = myBlockIterator.More();
return b;
}
//=======================================================================
//function : NextFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidBuilder::NextFace()
{
myBlockIterator.Next();
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::Face() const
{
#ifdef DEB
// const Standard_Integer i = myBlockIterator.Value(); // DEB
#endif
const TopoDS_Shape& F = myBlockBuilder.Element(myBlockIterator);
return F;
}
//=======================================================================
//function : MakeLoops
//purpose :
//=======================================================================
void TopOpeBRepBuild_SolidBuilder::MakeLoops(TopOpeBRepBuild_ShapeSet& SS)
{
TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
TopOpeBRepBuild_ListOfLoop& LL = myLoopSet.ChangeListOfLoop();
// Build blocks on elements of SS
BB.MakeBlock(SS);
// make list of loop (LL) of the LoopSet
// - on shapes of the ShapeSet (SS)
// - on blocks of the BlockBuilder (BB)
LL.Clear();
// Add shapes of SS as shape loops
for(SS.InitShapes(); SS.MoreShapes(); SS.NextShape()) {
const TopoDS_Shape& S = SS.Shape();
Handle(TopOpeBRepBuild_Loop) ShapeLoop = new TopOpeBRepBuild_Loop(S);
LL.Append(ShapeLoop);
}
// Add blocks of BB as block loops
for (BB.InitBlock(); BB.MoreBlock(); BB.NextBlock()) {
TopOpeBRepBuild_BlockIterator BI = BB.BlockIterator();
Handle(TopOpeBRepBuild_Loop) BlockLoop = new TopOpeBRepBuild_Loop(BI);
LL.Append(BlockLoop);
}
}

View File

@@ -0,0 +1,215 @@
// File: TopOpeBRepBuild_SplitEdge.hxx
// Created: Tue Sep 12 14:32:37 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile
#define _TopOpeBRepBuild_SplitEdge_HeaderFile
//=======================================================================
//function : SplitEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitEdge(const TopoDS_Shape& E,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
#ifdef DEB
if ( TopOpeBRepBuild_GetcontextSF2() ) {
SplitEdge2(E,ToBuild1,ToBuild2);
return;
}
#endif
SplitEdge1(E,ToBuild1,ToBuild2);
return;
}
//=======================================================================
//function : SplitEdge1
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitEdge1(const TopoDS_Shape& Eoriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
// work on a FORWARD edge <Eforward>
#ifdef DEB
TopAbs_Orientation Eori =
#endif
Eoriented.Orientation();
#ifdef DEB
Standard_Integer io = 0;
if ( Eori == TopAbs_FORWARD ) {
io = 1;
}
else if ( Eori == TopAbs_REVERSED ) {
io = 2;
}
else if ( Eori == TopAbs_INTERNAL ) {
io = 3;
}
else if ( Eori == TopAbs_EXTERNAL ) {
io = 4;
}
#endif
TopoDS_Shape Eforward = Eoriented;
Eforward.Orientation(TopAbs_FORWARD);
Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);
#ifdef DEB
Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
if(tSPS){
cout<<endl;
GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge ");
cout<<endl;
}
#endif
if ( ! tosplit ) return;
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
Standard_Boolean ConnectTo1 = Standard_True;
Standard_Boolean ConnectTo2 = Standard_False;
// build the list of edges to split : LE1, LE2
TopTools_ListOfShape LE1,LE2;
LE1.Append(Eforward);
FindSameDomain(LE1,LE2);
Standard_Integer n1 = LE1.Extent();
Standard_Integer n2 = LE2.Extent();
#ifdef DEB
if(tSPS){GdumpSAMDOM(LE1, (char *) "1 : ");}
if(tSPS){GdumpSAMDOM(LE2, (char *) "2 : ");}
if(tSPS){cout<<endl;}
if(tSPS){cout<<"V of edge ";TopAbs::Print(Eforward.Orientation(),cout);}
if(tSPS){cout<<endl;}
if(tSPS){GdumpEDG(Eforward);}
#endif
// SplitEdge on a edge having other same domained edges on the
// other shape : do not reverse orientation of edges in FillEdge
if (!n2) RevOri1 = Standard_False;
if (!n1) RevOri2 = Standard_False;
// Make a PaveSet <PVS> on edge <Eforward>
TopOpeBRepBuild_PaveSet PVS(Eforward);
// Add the points/vertices found on edge <Eforward> in <PVS>
TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
FillVertexSet(EPIT,ToBuild1,PVS);
TopOpeBRepBuild_PaveClassifier VCL(Eforward);
Standard_Boolean equalpar = PVS.HasEqualParameters();
if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
// ------------------------------------------
// before return if PVS has no vertices,
// mark <Eforward> as split <ToBuild1>
// ------------------------------------------
MarkSplit(Eforward,ToBuild1);
PVS.InitLoop();
if ( !PVS.MoreLoop() ) {
#ifdef DEB
if(tSPS) {
cout<<"NO VERTEX split "; TopAbs::Print(ToBuild1,cout);cout<<endl;
}
#endif
return;
}
// build the new edges
TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
// Build the new edges
// -------------------
TopTools_ListOfShape& EdgeList = ChangeMerged(Eforward,ToBuild1);
MakeEdges(Eforward,EBU,EdgeList);
TopTools_ListIteratorOfListOfShape itLE1,itLE2;
// connect new edges as edges built <ToBuild1> on LE1 edge
// --------------------------------------------------------
for (itLE1.Initialize(LE1); itLE1.More(); itLE1.Next()) {
TopoDS_Shape Ecur = itLE1.Value();
MarkSplit(Ecur,ToBuild1);
TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild1);
if ( ConnectTo1 ) EL = EdgeList;
}
// connect new edges as edges built <ToBuild2> on LE2 edges
// --------------------------------------------------------
for (itLE2.Initialize(LE2); itLE2.More(); itLE2.Next()) {
TopoDS_Shape Ecur = itLE2.Value();
MarkSplit(Ecur,ToBuild2);
TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild2);
if ( ConnectTo2 ) EL = EdgeList;
}
} // SplitEdge1
//=======================================================================
//function : SplitEdge2
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented,
const TopAbs_State ToBuild1,
const TopAbs_State /*ToBuild2*/)
{
Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);
if ( ! tosplit ) return;
// work on a FORWARD edge <Eforward>
TopoDS_Shape Eforward = Eoriented;
myBuildTool.Orientation(Eforward,TopAbs_FORWARD);
#ifdef DEB
Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
if(tSPS){cout<<endl;}
if(tSPS){GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge2 ");}
#endif
// Make a PaveSet <PVS> on edge <Eforward>
// Add the points/vertices found on edge <Eforward> in <PVS>
TopOpeBRepBuild_PaveSet PVS(Eforward);
TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
FillVertexSet(EPIT,ToBuild1,PVS);
TopOpeBRepBuild_PaveClassifier VCL(Eforward);
Standard_Boolean equalpar = PVS.HasEqualParameters();
if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
// ------------------------------------------
// before return if PVS has no vertices,
// mark <Eforward> as split <ToBuild1>
// ------------------------------------------
MarkSplit(Eforward,ToBuild1);
PVS.InitLoop();
if ( !PVS.MoreLoop() ) {
#ifdef DEB
if(tSPS) {cout<<"NO VERTEX split ";TopAbs::Print(ToBuild1,cout);cout<<endl;}
#endif
return;
}
// build the new edges
TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
// connect the new edges as split parts <ToBuild1> built on <Eforward>
TopTools_ListOfShape& EL = ChangeSplit(Eforward,ToBuild1);
MakeEdges(Eforward,EBU,EL);
} // SplitEdge2
//#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile
#endif

View File

@@ -0,0 +1,453 @@
// File: TopOpeBRepBuild_SplitFace.hxx
// Created: Tue Sep 12 16:21:36 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#ifndef _TopOpeBRepBuild_SplitFace_HeaderFile
#define _TopOpeBRepBuild_SplitFace_HeaderFile
#include <TopOpeBRepBuild_WireEdgeSet.hxx>
#include <TopOpeBRepBuild_FaceBuilder.hxx>
#ifdef DEB
Standard_EXPORT void debspf(const Standard_Integer i) {cout<<"++ debspf"<<i<<endl;}
#endif
//=======================================================================
//function : SplitFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitFace(const TopoDS_Shape& Foriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
#ifdef DEB
if(TopOpeBRepBuild_GetcontextSF2()){
SplitFace2(Foriented,ToBuild1,ToBuild2);
return;
}
#endif
SplitFace1(Foriented,ToBuild1,ToBuild2);
return;
}
//=======================================================================
//function : SplitFace1
//purpose : tout dans le meme edge set
//=======================================================================
void TopOpeBRepBuild_Builder::SplitFace1(const TopoDS_Shape& Foriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
// process connect connect
// operation tobuild1 tobuild2 face F to 1 to 2
// --------- -------- -------- ------- ------- -------
// common IN IN yes yes yes
// fuse OUT OUT yes yes yes
// cut 1-2 OUT IN yes yes no
// cut 2-1 IN OUT yes yes no
//
Standard_Boolean tosplit = ToSplit(Foriented,ToBuild1);
if ( ! tosplit ) return;
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
Standard_Boolean ConnectTo1 = Standard_True;
Standard_Boolean ConnectTo2 = Standard_False;
// work on a FORWARD face <Fforward>
TopoDS_Shape Fforward = Foriented;
myBuildTool.Orientation(Fforward,TopAbs_FORWARD);
// build the list of faces to split : LF1, LF2
TopTools_ListOfShape LF1,LF2;
LF1.Append(Fforward);
FindSameDomain(LF1,LF2);
Standard_Integer n1 = LF1.Extent();
Standard_Integer n2 = LF2.Extent();
// SplitFace on a face having other same domained faces on the
// other shape : do not reverse orientation of faces in FillFace
if (!n2) RevOri1 = Standard_False;
if (!n1) RevOri2 = Standard_False;
// Create an edge set <WES> connected by vertices
// ----------------------------------------------
TopOpeBRepBuild_WireEdgeSet WES(Fforward,this);
#ifdef DEB
Standard_Boolean tSPF=TopOpeBRepBuild_GettraceSPF();
Standard_Integer iFace=myDataStructure->Shape(Foriented);
if(tSPF){cout<<endl;GdumpSHASTA(Foriented,ToBuild1,"=== SplitFace ");}
if(tSPF){GdumpSAMDOM(LF1, (char *) "1 : ");GdumpSAMDOM(LF2, (char *) "2 : ");}
if(tSPF) debspf(iFace);
#endif
TopTools_ListIteratorOfListOfShape itLF1,itLF2;
for (itLF1.Initialize(LF1); itLF1.More(); itLF1.Next()) {
const TopoDS_Shape& Fcur = itLF1.Value();
// myDataStructure->Shape(Fcur);//DEB
FillFace(Fcur,ToBuild1,LF2,ToBuild2,WES,RevOri1);
}
for (itLF2.Initialize(LF2); itLF2.More(); itLF2.Next()) {
const TopoDS_Shape& Fcur = itLF2.Value();
// myDataStructure->Shape(Fcur);//DEB
FillFace(Fcur,ToBuild2,LF1,ToBuild1,WES,RevOri2);
}
// Add the intersection edges to edge set WES
// -----------------------------------------
AddIntersectionEdges(Fforward,ToBuild1,RevOri1,WES);
#ifdef DEB
Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(Fforward,iF);
if(tSPS) WES.DumpSS();
#endif
// Create a Face Builder FBU
// ------------------------
TopOpeBRepBuild_FaceBuilder FBU;
FBU.InitFaceBuilder(WES,Fforward,Standard_False); //forceclass = False
// Build the new faces
// -------------------
TopTools_ListOfShape& FaceList = ChangeMerged(Fforward,ToBuild1);
MakeFaces(Fforward,FBU,FaceList);
// connect new faces as faces built <ToBuild1> on LF1 faces
// --------------------------------------------------------
for (itLF1.Initialize(LF1); itLF1.More(); itLF1.Next()) {
TopoDS_Shape Fcur = itLF1.Value();
MarkSplit(Fcur,ToBuild1);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild1);
if ( ConnectTo1 ) FL = FaceList;
}
// connect new faces as faces built <ToBuild2> on LF2 faces
// --------------------------------------------------------
for (itLF2.Initialize(LF2); itLF2.More(); itLF2.Next()) {
TopoDS_Shape Fcur = itLF2.Value();
MarkSplit(Fcur,ToBuild2);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild2);
if ( ConnectTo2 ) FL = FaceList;
}
} // SplitFace1
//=======================================================================
//function : SplitFace2
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitFace2(const TopoDS_Shape& Foriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
// process connect connect
// operation tobuild1 tobuild2 face F to 1 to 2
// --------- -------- -------- ------- ------- -------
// common IN IN yes yes yes
// fuse OUT OUT yes yes yes
// cut 1-2 OUT IN yes yes no
// cut 2-1 IN OUT yes yes no
//
Standard_Boolean tosplit = ToSplit(Foriented,ToBuild1);
if ( ! tosplit ) return;
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
Standard_Boolean ConnectTo1 = Standard_True;
Standard_Boolean ConnectTo2 = Standard_False;
// work on a FORWARD face <Fforward>
TopoDS_Shape Fforward = Foriented;
myBuildTool.Orientation(Fforward,TopAbs_FORWARD);
TopTools_ListOfShape LF1 ; //liste des faces de 1 samedomain
TopTools_ListOfShape LF2 ; //liste des faces de 2 samedomain
LF1.Append(Fforward);
FindSameDomain(LF1,LF2);
Standard_Integer n1 = LF1.Extent();
Standard_Integer n2 = LF2.Extent();
#ifdef DEB
Standard_Boolean tSPF = TopOpeBRepBuild_GettraceSPF();
// Standard_Integer iFace = myDataStructure->Shape(Foriented);
if (tSPF) {
cout<<endl;
GdumpSHASTA(Foriented,ToBuild1,"=== SplitFace ");
GdumpSAMDOM(LF1, (char *) "samedomain 1 : ");
GdumpSAMDOM(LF2, (char *) "samedomain 2 : ");
}
#endif
// SplitFace on a face having other same domained faces on the
// other shape : do not reverse orientation of faces in FillFace
if (!n2) RevOri1 = Standard_False;
if (!n1) RevOri2 = Standard_False;
TopTools_ListOfShape LFSO; //liste des faces de 1,2 samedomainsameorientation
TopTools_ListOfShape LFOO; //liste des faces de 1,2 samedomainoppositeorient
// LFSO : faces des shapes 1 ou 2, de meme orientation que Fforward.
// LFOO : faces des shapes 1 ou 2, d'orientation contraire que Fforward.
LFSO.Append(Fforward);
FindSameDomainSameOrientation(LFSO,LFOO);
TopTools_ListOfShape LFSO1,LFOO1; // same domain, same orientation, et du shape de F
TopTools_ListOfShape LFSO2,LFOO2; // "" "",du shape autre que celui de F
// on construit les parties ToBuild1 de F
Standard_Integer rankF = ShapeRank(Foriented);
Standard_Integer rankX = (rankF) ? ((rankF == 1) ? 2 : 1) : 0;
FindSameRank(LFSO,rankF,LFSO1);
FindSameRank(LFOO,rankF,LFOO1);
FindSameRank(LFSO,rankX,LFSO2);
FindSameRank(LFOO,rankX,LFOO2);
#ifdef DEB
if ( tSPF ) {
GdumpSAMDOM(LFSO1, (char *) "LFSO1 : ");
GdumpSAMDOM(LFOO1, (char *) "LFOO1 : ");
GdumpSAMDOM(LFSO2, (char *) "LFSO2 : ");
GdumpSAMDOM(LFOO2, (char *) "LFOO2 : ");
}
#endif
TopAbs_State tob1 = ToBuild1;
TopAbs_State tob2 = ToBuild2;
TopAbs_State tob1comp = (ToBuild1 == TopAbs_IN) ? TopAbs_OUT : TopAbs_IN;
TopAbs_State tob2comp = (ToBuild2 == TopAbs_IN) ? TopAbs_OUT : TopAbs_IN;
TopTools_ListIteratorOfListOfShape itLF ;
// --------------------------------------------------------------------
// traitement des faces de meme orientation que Fforward dans WireEdgeSet WES1
// --------------------------------------------------------------------
TopOpeBRepBuild_WireEdgeSet WES1(Fforward,this);
// traitement des faces de 1 same domain, same orientation que F : LFSO1
for (itLF.Initialize(LFSO1); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 2
FillFace(Fcur,tob1,LF2,tob2,WES1,RevOri1);
}
// traitement des faces de 2 same domain, same orientation que F : LFSO2
for (itLF.Initialize(LFSO2); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 1
FillFace(Fcur,tob2,LF1,tob1,WES1,RevOri2);
}
// traitement des faces de 1 same domain, oppo orientation que F : LFOO1
for (itLF.Initialize(LFOO1); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 2
FillFace(Fcur,tob1comp,LF2,ToBuild2,WES1,!RevOri1);
}
// traitement des faces de 2 same domain, oppo orientation que F : LFOO2
for (itLF.Initialize(LFOO2); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 1
FillFace(Fcur,tob2comp,LF1,ToBuild1,WES1,!RevOri2);
}
// Add the intersection edges to edge set WES1
// ------------------------------------------
AddIntersectionEdges(Fforward,ToBuild1,RevOri1,WES1);
// Create a Face Builder FBU1
// ------------------------
TopOpeBRepBuild_FaceBuilder FBU1(WES1,Fforward);
// Build the new faces
// -------------------
TopTools_ListOfShape& FaceList1 = ChangeMerged(Fforward,ToBuild1);
MakeFaces(Fforward,FBU1,FaceList1);
// connect new faces as faces built <ToBuild1> on LF1 faces
// --------------------------------------------------------
for (itLF.Initialize(LF1); itLF.More(); itLF.Next()) {
TopoDS_Shape Fcur = itLF.Value();
MarkSplit(Fcur,ToBuild1);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild1);
if ( ConnectTo1 ) FL = FaceList1;
}
// --------------------------------------------------------------------
// traitement des faces de meme orientation que Fforward dans WireEdgeSet WES2
// --------------------------------------------------------------------
TopOpeBRepBuild_WireEdgeSet WES2(Fforward,this);
// traitement des faces de 1 same domain, same orientation que F : LFSO1
for (itLF.Initialize(LFSO1); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 2
FillFace(Fcur,tob1comp,LF2,tob2,WES2,!RevOri1);
}
// traitement des faces de 2 same domain, same orientation que F : LFSO2
for (itLF.Initialize(LFSO2); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 1
FillFace(Fcur,tob2comp,LF1,tob1,WES2,!RevOri2);
}
// traitement des faces de 1 same domain, oppo orientation que F : LFOO1
for (itLF.Initialize(LFOO1); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 2
FillFace(Fcur,tob1,LF2,ToBuild2,WES2,RevOri1);
}
// traitement des faces de 2 same domain, oppo orientation que F : LFOO2
for (itLF.Initialize(LFOO2); itLF.More(); itLF.Next()) {
const TopoDS_Shape& Fcur = itLF.Value();
// myDataStructure->Shape(Fcur);//DEB
// les wires de Fcur sont a comparer avec les faces de 1
FillFace(Fcur,tob2,LF1,ToBuild1,WES2,RevOri2);
}
// Add the intersection edges to edge set WES2
// ------------------------------------------
AddIntersectionEdges(Fforward,ToBuild2,RevOri2,WES2);
// Create a Face Builder FBU2
// -------------------------
TopOpeBRepBuild_FaceBuilder FBU2(WES2,Fforward);
// Build the new faces
// -------------------
TopTools_ListOfShape& FaceList2 = ChangeMerged(Fforward,ToBuild2);
MakeFaces(Fforward,FBU2,FaceList2);
// connect new faces as faces built <ToBuild2> on LF2 faces
// --------------------------------------------------------
for (itLF.Initialize(LF2); itLF.More(); itLF.Next()) {
TopoDS_Shape Fcur = itLF.Value();
MarkSplit(Fcur,ToBuild2);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild2);
if ( ConnectTo2 ) FL = FaceList2;
}
} // SplitFace2
#if 0
//=======================================================================
//function : SplitFaceOK
//purpose : tout dans le meme edge set
//=======================================================================
void TopOpeBRepBuild_Builder::SplitFaceOK(const TopoDS_Shape& Foriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
// process connect connect
// operation tobuild1 tobuild2 face F to 1 to 2
// --------- -------- -------- ------- ------- -------
// common IN IN yes yes yes
// fuse OUT OUT yes yes yes
// cut 1-2 OUT IN yes yes no
// cut 2-1 IN OUT yes yes no
//
Standard_Boolean tosplit = ToSplit(Foriented,ToBuild1);
if ( ! tosplit ) return;
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
Standard_Boolean ConnectTo1 = Standard_True;
Standard_Boolean ConnectTo2 = Standard_False;
// work on a FORWARD face <Fforward>
TopoDS_Shape Fforward = Foriented;
myBuildTool.Orientation(Fforward,TopAbs_FORWARD);
// build the list of faces to split : LF1, LF2
TopTools_ListOfShape LF1,LF2;
LF1.Append(Fforward);
FindSameDomain(LF1,LF2);
Standard_Integer n1 = LF1.Extent();
Standard_Integer n2 = LF2.Extent();
// SplitFace on a face having other same domained faces on the
// other shape : do not reverse orientation of faces in FillFace
if (!n2) RevOri1 = Standard_False;
if (!n1) RevOri2 = Standard_False;
// Create an edge set <WES> connected by vertices
// ---------------------------------------------
TopOpeBRepBuild_WireEdgeSet WES(Fforward,this);
#ifdef DEB
Standard_Boolean tSPF = TopOpeBRepBuild_GettraceSPF();
Standard_Integer iFace = myDataStructure->Shape(Foriented);
if(tSPF){cout<<endl;GdumpSHASTA(Foriented,ToBuild1,"=== SplitFaceOK ");}
if(tSPF){GdumpSAMDOM(LF1,"1 : ");GdumpSAMDOM(LF2,"2 : ");}
#endif
TopTools_ListIteratorOfListOfShape itLF1,itLF2;
for (itLF1.Initialize(LF1); itLF1.More(); itLF1.Next()) {
const TopoDS_Shape& Fcur = itLF1.Value();
Standard_Integer icur = myDataStructure->Shape(Fcur);//DEB
FillFace(Fcur,ToBuild1,LF2,ToBuild2,WES,RevOri1);
}
for (itLF2.Initialize(LF2); itLF2.More(); itLF2.Next()) {
const TopoDS_Shape& Fcur = itLF2.Value();
Standard_Integer icur = myDataStructure->Shape(Fcur);//DEB
FillFace(Fcur,ToBuild2,LF1,ToBuild1,WES,RevOri2);
}
// Add the intersection edges to edge set WES
// -----------------------------------------
AddIntersectionEdges(Fforward,ToBuild1,RevOri1,WES);
// Create a Face Builder FBU
// ------------------------
TopOpeBRepBuild_FaceBuilder FBU(WES,Fforward);
// Build the new faces
// -------------------
TopTools_ListOfShape& FaceList = ChangeMerged(Fforward,ToBuild1);
MakeFaces(Fforward,FBU,FaceList);
// connect new faces as faces built <ToBuild1> on LF1 faces
// --------------------------------------------------------
for (itLF1.Initialize(LF1); itLF1.More(); itLF1.Next()) {
TopoDS_Shape Fcur = itLF1.Value();
MarkSplit(Fcur,ToBuild1);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild1);
if ( ConnectTo1 ) FL = FaceList;
}
// connect new faces as faces built <ToBuild2> on LF2 faces
// --------------------------------------------------------
for (itLF2.Initialize(LF2); itLF2.More(); itLF2.Next()) {
TopoDS_Shape Fcur = itLF2.Value();
MarkSplit(Fcur,ToBuild2);
TopTools_ListOfShape& FL = ChangeSplit(Fcur,ToBuild2);
if ( ConnectTo2 ) FL = FaceList;
}
} // SplitFaceOK
// #if 0
#endif
//#ifndef _TopOpeBRepBuild_SplitFace_HeaderFile
#endif

View File

@@ -0,0 +1,150 @@
// File: TopOpeBRepBuild_SplitShapes.hxx
// Created: Fri Mar 1 16:24:40 1996
// Author: Modelistation
// <model@mentox>
#ifndef _TopOpeBRepBuild_SplitShapes_HeaderFile
#define _TopOpeBRepBuild_SplitShapes_HeaderFile
#include <Standard_ProgramError.hxx>
static Standard_Boolean FUN_touched(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& EOR)
{
TopoDS_Vertex vf,vl; TopExp::Vertices(EOR,vf,vl);
Standard_Boolean hvf = BDS.HasShape(vf);
Standard_Boolean hvl = BDS.HasShape(vl);
return (hvf || hvl);
}
//=======================================================================
//function : SplitShapes
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitShapes(TopOpeBRepTool_ShapeExplorer& Ex,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2,
TopOpeBRepBuild_ShapeSet& aSet,
const Standard_Boolean RevOri)
{
TopoDS_Shape aShape;
TopAbs_Orientation newori;
for (; Ex.More(); Ex.Next()) {
aShape = Ex.Current();
// compute new orientation <newori> to give to the new shapes
newori = Orient(myBuildTool.Orientation(aShape),RevOri);
TopAbs_ShapeEnum t = aShape.ShapeType();
#ifdef DEB
if (TopOpeBRepBuild_GettraceSHEX()) GdumpEXP(Ex);
#endif
if ( t == TopAbs_SOLID || t == TopAbs_SHELL )
SplitSolid(aShape,ToBuild1,ToBuild2);
else if ( t == TopAbs_FACE ) SplitFace(aShape,ToBuild1,ToBuild2);
else if ( t == TopAbs_EDGE ) SplitEdge(aShape,ToBuild1,ToBuild2);
else continue;
if ( IsSplit(aShape,ToBuild1) ) {
TopoDS_Shape newShape;
TopTools_ListIteratorOfListOfShape It;
//----------------------- IFV
Standard_Boolean IsLSon = Standard_False;
//----------------------- IFV
const TopTools_ListOfShape& LS = Splits(aShape,ToBuild1);
//----------------------- IFV
if(t == TopAbs_EDGE && ToBuild1 == TopAbs_IN && LS.Extent() == 0) {
const TopTools_ListOfShape& LSon = Splits(aShape,TopAbs_ON);
It.Initialize(LSon);
IsLSon = Standard_True;
}
else {
It.Initialize(LS);
}
//----------------------- IFV
for (; It.More(); It.Next()) {
newShape = It.Value();
myBuildTool.Orientation(newShape,newori);
#ifdef DEB
// TopAbs_ShapeEnum tns = TopType(newShape);
#endif
//----------------------- IFV
if(IsLSon) {
Standard_Boolean add = Standard_True;
if ( !myListOfFace.IsEmpty()) { // 2d pur
add = KeepShape(newShape,myListOfFace,ToBuild1);
}
if(add) aSet.AddStartElement(newShape);
}
else {
//----------------------- IFV
aSet.AddStartElement(newShape);
}
}
}
else {
// aShape n'a pas de devenir de split par ToBuild1
// on construit les parties ToBuild1 de aShape (de S1)
Standard_Boolean add = Standard_True;
Standard_Boolean testkeep = Standard_False;
Standard_Boolean isedge = (t == TopAbs_EDGE);
Standard_Boolean hs = (myDataStructure->HasShape(aShape));
Standard_Boolean hg = (myDataStructure->HasGeometry(aShape));
testkeep = isedge && hs && (!hg);
// xpu010399 : USA60299 (!hs)&&(!hg), but vertex on bound is touched (v7)
// -> testkeep
Standard_Boolean istouched = isedge && (!hs) && (!hg);
if (istouched) istouched = FUN_touched(myDataStructure->DS(),TopoDS::Edge(aShape));
testkeep = testkeep || istouched;
if (testkeep) {
if ( !myListOfFace.IsEmpty()) { // 2d pur
Standard_Boolean keep = KeepShape(aShape,myListOfFace,ToBuild1);
add = keep;
}
else { // 3d
// on classifie en solide uniqt si
// E dans la DS et E a ete purgee de ses interfs car en bout
TopoDS_Shape sol;
if (STATIC_SOLIDINDEX == 1) sol = myShape2;
else sol = myShape1;
if ( !sol.IsNull() ) {
Standard_Real first,last;
Handle(Geom_Curve) C3D;
C3D = BRep_Tool::Curve(TopoDS::Edge(aShape),first,last);
if ( !C3D.IsNull() ) {
Standard_Real tt = 0.127956477;
Standard_Real par = (1-tt)*first + tt*last;
gp_Pnt P3D = C3D->Value(par);
Standard_Real tol3d = Precision::Confusion();
BRepClass3d_SolidClassifier SCL(sol,P3D,tol3d);
TopAbs_State state = SCL.State();
add = (state == ToBuild1);
}
else {
Standard_ProgramError::Raise("SplitShapes no 3D curve on edge");
// NYI pas de courbe 3d : prendre un point sur (courbe 2d,face)
}
}
else { // sol.IsNull
add = Standard_True;
}
}
}
if ( add ) {
myBuildTool.Orientation(aShape,newori);
aSet.AddElement(aShape);
}
}
} // Ex.More
} // SplitShapes
#endif

View File

@@ -0,0 +1,157 @@
// File: TopOpeBRepBuild_SplitSolid.hxx
// Created: Tue Sep 12 16:27:50 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#ifndef TopOpeBRepBuild_SplitSolid_INCLUDED
#define TopOpeBRepBuild_SplitSolid_INCLUDED
#include <TopOpeBRepBuild_ShellFaceSet.hxx>
#include <TopOpeBRepBuild_SolidBuilder.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
#define DEBSHASET(sarg,meth,shaset,str) TCollection_AsciiString sarg((meth));(sarg)=(sarg)+(shaset).DEBNumber()+(str);
Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
Standard_EXPORT void debsplitf(const Standard_Integer i);
Standard_EXPORT void debspanc(const Standard_Integer i);
//Standard_IMPORT extern Standard_Integer GLOBAL_iexF;
Standard_IMPORT Standard_Integer GLOBAL_iexF;
#endif
//=======================================================================
//function : SplitSolid
//purpose :
//=======================================================================
void TopOpeBRepBuild_Builder::SplitSolid(const TopoDS_Shape& S1oriented,
const TopAbs_State ToBuild1,
const TopAbs_State ToBuild2)
{
//modified by IFV for treating shell
Standard_Boolean tosplit = Standard_False;
Standard_Boolean IsShell = (S1oriented.ShapeType() == TopAbs_SHELL);
if(IsShell) {
TopExp_Explorer ex;
ex.Init(S1oriented, TopAbs_FACE);
for (; ex.More(); ex.Next()) {
const TopoDS_Shape& sh = ex.Current();
tosplit = ToSplit(sh,ToBuild1);
if(tosplit) break;
}
}
else tosplit = ToSplit(S1oriented,ToBuild1);
if ( ! tosplit ) return;
// end IFV
Standard_Boolean RevOri1 = Reverse(ToBuild1,ToBuild2);
Standard_Boolean RevOri2 = Reverse(ToBuild2,ToBuild1);
Standard_Boolean ConnectTo1 = Standard_True;
Standard_Boolean ConnectTo2 = Standard_False;
// work on a FORWARD solid <S1forward>
TopoDS_Shape S1forward = S1oriented;
myBuildTool.Orientation(S1forward,TopAbs_FORWARD);
// build the list of solids to split : LS1, LS2
TopTools_ListOfShape LS1,LS2;
LS1.Append(S1forward);
FindSameDomain(LS1,LS2);
Standard_Integer n1 = LS1.Extent();
Standard_Integer n2 = LS2.Extent();
if (!n2) RevOri1 = Standard_False;
if (!n1) RevOri2 = Standard_False;
// Create a face set <FS> connected by edges
// -----------------------------------------
TopOpeBRepBuild_ShellFaceSet SFS;
#ifdef DEB
Standard_Boolean tSPS = TopOpeBRepBuild_GettraceSPS();
// Standard_Integer iSolid = myDataStructure->Shape(S1oriented);
if (tSPS) {
cout<<endl;
GdumpSHASTA(S1oriented,ToBuild1,"___ SplitSolid ");
GdumpSAMDOM(LS1, (char *) "1 : ");
GdumpSAMDOM(LS2, (char *) "2 : ");
}
SFS.DEBNumber(GdumpSHASETindex());
#endif
STATIC_SOLIDINDEX = 1;
TopTools_ListIteratorOfListOfShape itLS1;
for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) {
TopoDS_Shape Scur = itLS1.Value();
FillSolid(Scur,ToBuild1,LS2,ToBuild2,SFS,RevOri1);
}
STATIC_SOLIDINDEX = 2;
TopTools_ListIteratorOfListOfShape itLS2;
for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) {
TopoDS_Shape Scur = itLS2.Value();
FillSolid(Scur,ToBuild2,LS1,ToBuild1,SFS,RevOri2);
}
// Add the intersection surfaces
// -----------------------------
if (myDataStructure->NbSurfaces() > 0) {
TopOpeBRepDS_SurfaceIterator SSurfaces = myDataStructure->SolidSurfaces(S1forward);
for (; SSurfaces.More(); SSurfaces.Next()) {
Standard_Integer iS = SSurfaces.Current();
const TopTools_ListOfShape& LnewF = NewFaces(iS);
for (TopTools_ListIteratorOfListOfShape Iti(LnewF); Iti.More(); Iti.Next()) {
TopoDS_Shape aFace = Iti.Value();
TopAbs_Orientation ori = SSurfaces.Orientation(ToBuild1);
myBuildTool.Orientation(aFace,ori);
#ifdef DEB
if (tSPS){
DEBSHASET(ss,"--- SplitSolid ",SFS," AddElement SFS+ face ");
GdumpSHA(aFace,(Standard_Address)ss.ToCString());
cout<<" ";TopAbs::Print(ToBuild1,cout)<<" : 1 face ";
TopAbs::Print(ori,cout); cout<<endl;
}
#endif
SFS.AddElement(aFace);
}
}
}
// Create a Solid Builder SOBU
// -------------------------
TopOpeBRepBuild_SolidBuilder SOBU(SFS);
// Build the new solids on S1
// --------------------------
TopTools_ListOfShape& SolidList = ChangeMerged(S1oriented,ToBuild1);
if(IsShell)
MakeShells(SOBU,SolidList);
else
MakeSolids(SOBU,SolidList);
// connect list of new solids <SolidList> as solids built on LS1 solids
// --------------------------------------------------------------------
for (itLS1.Initialize(LS1); itLS1.More(); itLS1.Next()) {
TopoDS_Shape Scur = itLS1.Value();
MarkSplit(Scur,ToBuild1);
TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild1);
if ( ConnectTo1 ) SL = SolidList;
}
// connect list of new solids <SolidList> as solids built on LS2 solids
// --------------------------------------------------------------------
for (itLS2.Initialize(LS2); itLS2.More(); itLS2.Next()) {
TopoDS_Shape Scur = itLS2.Value();
MarkSplit(Scur,ToBuild2);
TopTools_ListOfShape& SL = ChangeSplit(Scur,ToBuild2);
if ( ConnectTo2 ) SL = SolidList;
}
} // SplitSolid
//#ifndef TopOpeBRepBuild_SplitSolid_INCLUDED
#endif

View File

@@ -0,0 +1,178 @@
-- File: TopOpeBRepBuild_Tools.cdl
-- Created: Tue Nov 2 15:21:24 1999
-- Author: Peter KURNEV
-- <pkv@irinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class Tools from TopOpeBRepBuild
---Purpose: Auxiliary methods used in TopOpeBRepBuild_Builder1 class
uses
Shape from TopoDS,
Face from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Vec from gp,
State from TopAbs,
ShapeEnum from TopAbs,
IndexedDataMapOfShapeListOfShape from TopTools,
IndexedMapOfShape from TopTools,
MapOfShape from TopTools,
DataMapOfShapeState from TopOpeBRepDS,
IndexedDataMapOfShapeWithState from TopOpeBRepDS,
IndexedMapOfOrientedShape from TopTools,
IndexedDataMapOfShapeShape from TopTools,
ShapeClassifier from TopOpeBRepTool
is
DumpMapOfShapeWithState (myclass;
iP:Integer from Standard;
aMapOfShapeWithState: IndexedDataMapOfShapeWithState from TopOpeBRepDS);
FindState (myclass;
aVertex: Shape from TopoDS;
aState : State from TopAbs;
aShapeEnum:ShapeEnum from TopAbs;
aMapVertexEdges:IndexedDataMapOfShapeListOfShape from TopTools;
aMapProcessedVertices:out MapOfShape from TopTools;
aMapVs:out DataMapOfShapeState from TopOpeBRepDS);
PropagateState (myclass;
aSplEdgesState:DataMapOfShapeState from TopOpeBRepDS;
anEdgesToRestMap:IndexedMapOfShape from TopTools;
aShapeEnum1:ShapeEnum from TopAbs;
aShapeEnum2:ShapeEnum from TopAbs;
aShapeClassifier:in out ShapeClassifier from TopOpeBRepTool;
aMapOfShapeWithState:out IndexedDataMapOfShapeWithState from TopOpeBRepDS;
anUnkStateShapes:MapOfShape from TopTools);
FindStateThroughVertex (myclass;
aShape :Shape from TopoDS;
aShapeClassifier:in out ShapeClassifier from TopOpeBRepTool;
aMapOfShapeWithState:out IndexedDataMapOfShapeWithState from TopOpeBRepDS;
anAvoidSubshMap: MapOfShape from TopTools)
returns State from TopAbs;
PropagateStateForWires (myclass;
aFacesToRestMap:IndexedMapOfShape from TopTools;
aMapOfShapeWithState:out IndexedDataMapOfShapeWithState from TopOpeBRepDS);
SpreadStateToChild (myclass;
aShape:Shape from TopoDS;
aState:State from TopAbs;
aMapOfShapeWithState:out IndexedDataMapOfShapeWithState from TopOpeBRepDS);
FindState1 (myclass;
anEdge:Shape from TopoDS;
aState:State from TopAbs;
aMapEdgesFaces:IndexedDataMapOfShapeListOfShape from TopTools;
aMapProcessedVertices:out MapOfShape from TopTools;
aMapVs:out DataMapOfShapeState from TopOpeBRepDS);
FindState2 (myclass;
anEdge:Shape from TopoDS;
aState:State from TopAbs;
aMapEdgesFaces:IndexedDataMapOfShapeListOfShape from TopTools;
aMapProcessedEdges:out MapOfShape from TopTools;
aMapVs:out DataMapOfShapeState from TopOpeBRepDS);
GetAdjacentFace (myclass;
aFaceObj:Shape from TopoDS;
anEObj :Shape from TopoDS;
anEdgeFaceMap:IndexedDataMapOfShapeListOfShape from TopTools;
anAdjFaceObj :out Shape from TopoDS)
returns Boolean from Standard;
GetNormalToFaceOnEdge (myclass;
aFObj :Face from TopoDS;
anEdgeObj:Edge from TopoDS;
aDirNormal:out Vec from gp);
GetNormalInNearestPoint(myclass; aFace : Face from TopoDS;
anEdge : Edge from TopoDS;
aNormal: out Vec from gp);
---Purpose: This function used to compute normal in point which is located
--- near the point with param UV (used for computation of normals where the normal in the point UV equal to zero).
GetTangentToEdgeEdge (myclass;
aFObj :Face from TopoDS;
anEdgeObj:Edge from TopoDS;
aOriEObj :Edge from TopoDS;
aTangent :out Vec from gp)
returns Boolean from Standard;
GetTangentToEdge (myclass;
anEdgeObj:Edge from TopoDS;
aTangent:out Vec from gp)
returns Boolean from Standard;
UpdatePCurves (myclass;
aWire : Wire from TopoDS;
fromFace : Face from TopoDS;
toFace : Face from TopoDS);
---Purpose : Recompute PCurves of the all edges from the wire on the <toFace>
UpdateEdgeOnPeriodicalFace(myclass;
aEdgeToUpdate : Edge from TopoDS;
OldFace : Face from TopoDS;
NewFace : Face from TopoDS);
---Purpose : recompute PCurves of the closing (SIM , with 2 PCurves) edge on the NewFace
UpdateEdgeOnFace(myclass;
aEdgeToUpdate : Edge from TopoDS;
OldFace : Face from TopoDS;
NewFace : Face from TopoDS);
---Purpose : recompute PCurve of the edge on the NewFace
IsDegEdgesTheSame (myclass;
anE1: Shape from TopoDS;
anE2: Shape from TopoDS)
returns Boolean from Standard;
NormalizeFace(myclass; oldFace : Shape from TopoDS;
corrFace : out Shape from TopoDS);
---Purpose : test if <oldFace> does not contain INTERNAL or EXTERNAL edges
--- and remove such edges in case of its presence. The result is stored in <corrFace>
CorrectFace2d(myclass; oldFace : Shape from TopoDS;
corrFace : out Shape from TopoDS;
aSourceShapes: IndexedMapOfOrientedShape from TopTools;
aMapOfCorrect2dEdges:out IndexedDataMapOfShapeShape from TopTools);
---Purpose: test if UV representation of <oldFace> is good (i.e. face is closed in 2d).
-- if face is not closed , this method will try to close such face and will
-- return corrected edges in the <aMapOfCorrect2dEdges>. Parameter <aSourceShapes>
-- used to fix the edge (or wires) which should be correct (Corrector used it as a start shapes).
-- NOTE : Parameter corrFace doesn't mean anything. If you want to use this method , rebuild resulting face
-- after by yourself using corrected edges.
--modified by NIZNHY-PKV Fri Feb 11 17:20:08 2000 from
------------------------------------------------------------
-- Tools to correct tolerances Fri Feb 11 17:20:08 NIZNHY-PKV
CorrectTolerances (myclass;
aS: Shape from TopoDS;
aTolMax: Real from Standard =0.0001);
CorrectCurveOnSurface (myclass;
aS: Shape from TopoDS;
aTolMax: Real from Standard =0.0001);
CorrectPointOnCurve (myclass;
aS: Shape from TopoDS;
aTolMax: Real from Standard =0.0001);
--modified by NIZNHY-PKV Fri Feb 11 17:20:20 2000 to
CheckFaceClosed2d (myclass;
theFace: Face from TopoDS)
returns Boolean from Standard;
---Purpose: Checks if <theFace> has the properly closed in 2D boundary(ies)
end Tools;

View File

@@ -0,0 +1,977 @@
// File: TopOpeBRepBuild_Tools.cxx
// Created: Tue Nov 2 15:50:35 1999
// Author: Peter KURNEV
// <pkv@irinox.nnov.matra-dtv.fr>
#include <TopOpeBRepBuild_Tools.ixx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <GeomProjLib.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepDS_DataStructure.hxx>
#include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
#include <TopOpeBRepDS_ShapeWithState.hxx>
#include <TopOpeBRepDS_DataMapOfShapeState.hxx>
#include <TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState.hxx>
#include <TopOpeBRepTool_CurveTool.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TCollection_AsciiString.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <TopOpeBRepBuild_CorrectFace2d.hxx>
#include <Precision.hxx>
#include <stdio.h>
//define parameter division number as 10*e^(-PI) = 0.43213918
const Standard_Real PAR_T = 0.43213918;
//=======================================================================
//function TopOpeBRepBuild_Tools::DumpMapOfShapeWithState
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::DumpMapOfShapeWithState(const Standard_Integer iP,
const TopOpeBRepDS_IndexedDataMapOfShapeWithState&
aMapOfShapeWithState)
{
static Standard_Integer cnt=0;
TCollection_AsciiString aFName1 ("/DEBUG/TOPOPE/"), postfix;
Standard_CString ShapeType [9] = {"COMPO", "COMPS", "SOLID", "SHELL", "FACE ", "WIRE ", "EDGE ", "VERTX"};
Standard_CString ShapeState[4] = {"IN ", "OUT", "ON ", "UNKNOWN"};
printf("\n\n********************************\n");
printf("* *\n");
Standard_Integer i, n=aMapOfShapeWithState.Extent();
if (!iP) {
printf("* Object comparing with TOOL *\n");
postfix=TCollection_AsciiString("Obj");
}
else {
printf("* Tool comparing with Object *\n");
postfix=TCollection_AsciiString("Tool");
}
printf("* *\n");
printf("********************************\n");
printf("*** aMapOfShapeWithState.Extent()=%d\n", n);
printf(" C O N T E N T S\n");
TCollection_AsciiString aFName;
aFName+=aFName1;
aFName+=postfix;
for (i=1; i<=n; i++) {
TCollection_AsciiString aI(i), aName;;
aName+=aFName; aName+=aI;
const TopoDS_Shape& aShape=aMapOfShapeWithState.FindKey(i);
const TopOpeBRepDS_ShapeWithState& aShapeWithState=
aMapOfShapeWithState.FindFromIndex(i);
BRepTools::Write (aShape, aName.ToCString());
TCollection_AsciiString ann;
ann+=postfix; ann+=aI;
printf("Key: %-8s , " , ann.ToCString());
printf("%s, ", ShapeType[aShape.ShapeType()]);
if (!iP)
printf("State comp.with Tool=%s\n", ShapeState[aShapeWithState.State()]);
else
printf("State comp.with Obj =%s\n", ShapeState[aShapeWithState.State()]);
if (aShapeWithState.IsSplitted()) {
const TopTools_ListOfShape& aListOfShape=aShapeWithState.Part(TopAbs_IN);
TopTools_ListIteratorOfListOfShape anIt(aListOfShape);
for (;anIt.More(); anIt.Next()) {
const TopoDS_Shape& aS=anIt.Value();
TCollection_AsciiString cn(cnt), prefix("_S_"), sn;
sn+=aFName; sn+=prefix; sn+=cn;
BRepTools::Write (aS, sn.ToCString());
TCollection_AsciiString an;//=postfix+prefix+cn;
an+=postfix; an+=prefix; an+=cn;
printf(" -> Splitted Part IN : %s\n", an.ToCString());
cnt++;
}
const TopTools_ListOfShape& aListOfShapeOut=aShapeWithState.Part(TopAbs_OUT);
anIt.Initialize (aListOfShapeOut);
for (;anIt.More(); anIt.Next()) {
const TopoDS_Shape& aS=anIt.Value();
TCollection_AsciiString cn(cnt), prefix("_S_"), sn;//=aFName+prefix+cn;
sn+=aFName; sn+=prefix; sn+=cn;
BRepTools::Write (aS, sn.ToCString());
TCollection_AsciiString an;//=postfix+prefix+cn;
an+=postfix; an+=prefix; an+=cn;
printf(" -> Splitted Part OUT: %-s\n", an.ToCString());
cnt++;
}
const TopTools_ListOfShape& aListOfShapeOn=aShapeWithState.Part(TopAbs_ON);
anIt.Initialize (aListOfShapeOn);
for (;anIt.More(); anIt.Next()) {
const TopoDS_Shape& aS=anIt.Value();
TCollection_AsciiString cn(cnt), prefix("_S_"), sn;//=aFName+prefix+cn;
sn+=aFName; sn+=prefix; sn+=cn;
BRepTools::Write (aS, sn.ToCString());
TCollection_AsciiString an;//=postfix+prefix+cn;
an+=postfix; an+=prefix; an+=cn;
printf(" -> Splitted Part ON : %s\n", an.ToCString());
cnt++;
}
}
}
cnt=0;
}
//=======================================================================
//function TopOpeBRepBuild_Tools::FindState
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::FindState (const TopoDS_Shape& aSubsh,
const TopAbs_State aState,
const TopAbs_ShapeEnum aSubshEnum,
const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc,
TopTools_MapOfShape& aMapProcessedSubsh,
TopOpeBRepDS_DataMapOfShapeState& aMapSS)
{
Standard_Integer i, nSub;
const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh);
TopTools_ListIteratorOfListOfShape anIt(aListOfShapes);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aS=anIt.Value();
TopTools_IndexedMapOfShape aSubshMap;
TopExp::MapShapes (aS, aSubshEnum, aSubshMap);
nSub=aSubshMap.Extent();
for (i=1; i<=nSub; i++) {
const TopoDS_Shape& aSS=aSubshMap(i);
if (! aMapProcessedSubsh.Contains(aSS)) {
aMapProcessedSubsh.Add(aSS);
aMapSS.Bind (aSS, aState);
FindState (aSS, aState, aSubshEnum, aMapSubshAnc, aMapProcessedSubsh, aMapSS);
}
}
}
}
//=======================================================================
//function TopOpeBRepBuild_Tools::PropagateState
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::PropagateState (const TopOpeBRepDS_DataMapOfShapeState& aSplShapesState,
const TopTools_IndexedMapOfShape& aShapesToRestMap,
const TopAbs_ShapeEnum aSubshEnum,// Vertex
const TopAbs_ShapeEnum aShapeEnum,//Edge
TopOpeBRepTool_ShapeClassifier& aShapeClassifier,
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState,
const TopTools_MapOfShape& anAvoidSubshMap)
{
Standard_Integer j, nSub, nRest;
TopOpeBRepDS_DataMapOfShapeState aMapSS, aMapSS1;
TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState anItSS (aSplShapesState);
for (; anItSS.More(); anItSS.Next()) {
const TopoDS_Shape& aShape= anItSS.Key();
TopAbs_State aState = anItSS.Value();
TopTools_IndexedMapOfShape aSubshapes;
TopExp::MapShapes (aShape, aSubshEnum, aSubshapes);
nSub=aSubshapes.Extent();
for (j=1; j<=nSub; j++)
if (!anAvoidSubshMap.Contains(aSubshapes(j))) // MSV: enforce subshapes avoidance
aMapSS.Bind (aSubshapes(j), aState);
}
aMapSS1=aMapSS;
// 1. Build the Map of ShapesAndAncestors for ShapesToRest
TopTools_IndexedDataMapOfShapeListOfShape aMapSubshAnc;
nRest=aShapesToRestMap.Extent();
for (j=1; j<=nRest; j++)
TopExp::MapShapesAndAncestors(aShapesToRestMap(j), aSubshEnum, aShapeEnum, aMapSubshAnc);
// 2. Make Map Of all subshapes aMapSS
TopTools_MapOfShape aProcessedSubshapes;
anItSS.Initialize (aMapSS1);
for (; anItSS.More(); anItSS.Next()) {
const TopoDS_Shape& aSubsh = anItSS.Key();
TopAbs_State aState = anItSS.Value();
if (aMapSubshAnc.Contains (aSubsh)) {
aProcessedSubshapes.Add (aSubsh);
FindState (aSubsh, aState, aSubshEnum, aMapSubshAnc, aProcessedSubshapes, aMapSS);
}
}
// 3. Propagate the states on ShapesToRestMap
TopoDS_Shape aNullShape;
TopTools_MapOfShape aNonPassedShapes;
nRest=aShapesToRestMap.Extent();
for (j=1; j<=nRest; j++) {
const TopoDS_Shape& aS=aShapesToRestMap.FindKey(j);
TopTools_IndexedMapOfShape aSubshMap;
TopExp::MapShapes (aS, aSubshEnum, aSubshMap);
const TopoDS_Shape& aSubsh=aSubshMap(1);
if (aMapSS.IsBound(aSubsh)) {
TopAbs_State aState=aMapSS.Find(aSubsh);
if (aState==TopAbs_ON) {
aState=aShapeClassifier.StateShapeReference(aS, aNullShape);
}
// Add the Rest Shape to aMapOfShapeWithState
TopOpeBRepDS_ShapeWithState aShapeWithState;
aShapeWithState.SetState (aState);
aShapeWithState.SetIsSplitted (Standard_False);
aMapOfShapeWithState.Add (aS, aShapeWithState);
}
else {
aNonPassedShapes.Add(aS);
}
}
// 4. Define the states for aNonPassedShapes
// (for faces themselves and for theirs Wires, Edges):
if (aNonPassedShapes.Extent()) {
// Build the Map of ShapesAndAncestors for aNonPassedShapes
aMapSubshAnc.Clear();
TopTools_MapIteratorOfMapOfShape aMapIt;
aMapIt.Initialize (aNonPassedShapes);
for (; aMapIt.More(); aMapIt.Next())
TopExp::MapShapesAndAncestors (aMapIt.Key(), aSubshEnum, aShapeEnum, aMapSubshAnc);
aMapSS.Clear();
aMapIt.Initialize (aNonPassedShapes);
for (; aMapIt.More(); aMapIt.Next()) {
// Face
const TopoDS_Shape& aNonPassedShape=aMapIt.Key();
if (!aMapSS.IsBound(aNonPassedShape)) {
TopAbs_State aState = FindStateThroughVertex (aNonPassedShape, aShapeClassifier,
aMapOfShapeWithState,anAvoidSubshMap);
aMapSS.Bind (aNonPassedShape, aState);
// First Subshape
TopTools_IndexedMapOfShape aTmpMap;
TopExp::MapShapes (aNonPassedShape, aSubshEnum, aTmpMap);
TopoDS_Shape aFirstSubsh;
for (j=1; j <= aTmpMap.Extent() && aFirstSubsh.IsNull(); j++)
if (!anAvoidSubshMap.Contains(aTmpMap(j)))
aFirstSubsh = aTmpMap(j);
if (aFirstSubsh.IsNull()) continue;
aMapSS.Bind (aFirstSubsh, aState);
// Propagation of aState for subshapes
TopTools_MapOfShape aMapProcessedSubsh;
if (aSubshEnum==TopAbs_EDGE)
FindState1 (aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS);
else // if (aSubshEnum==TopAbs_VERTEX)
FindState2 (aFirstSubsh, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS);
}
}
// Fill aShapeWithState
TopOpeBRepDS_ShapeWithState aShapeWithState;
aShapeWithState.SetIsSplitted (Standard_False);
TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeState anII(aMapSS);
for (; anII.More(); anII.Next()) {
aShapeWithState.SetState (anII.Value());
if (anII.Key().ShapeType() != TopAbs_VERTEX)
aMapOfShapeWithState.Add (anII.Key(), aShapeWithState);
}
}
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::FindState2
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::FindState2 (const TopoDS_Shape& aSubsh,
const TopAbs_State aState,
const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc,
TopTools_MapOfShape& aMapProcessedSubsh,
TopOpeBRepDS_DataMapOfShapeState& aMapSS)
{
Standard_Integer i, nSub;
const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh);
TopTools_ListIteratorOfListOfShape anIt(aListOfShapes);
for (; anIt.More(); anIt.Next()) {
//Shape
const TopoDS_Shape& aShape=anIt.Value();
aMapSS.Bind (aShape, aState);
//Subshape
TopTools_IndexedMapOfShape aSubshMap;
TopExp::MapShapes (aShape, TopAbs_VERTEX, aSubshMap);
nSub=aSubshMap.Extent();
for (i=1; i<=nSub; i++) {
const TopoDS_Shape& aSS=aSubshMap(i);
if (! aMapProcessedSubsh.Contains(aSS)) {
aMapProcessedSubsh.Add(aSS);
aMapSS.Bind (aSS, aState);
FindState2 (aSS, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS);
}
}
}
}
//=======================================================================
//function :TopOpeBRepBuild_Tools::FindState1
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::FindState1 (const TopoDS_Shape& aSubsh,
const TopAbs_State aState,
const TopTools_IndexedDataMapOfShapeListOfShape& aMapSubshAnc,
TopTools_MapOfShape& aMapProcessedSubsh,
TopOpeBRepDS_DataMapOfShapeState& aMapSS)
{
Standard_Integer i, nSub, j, nW;
const TopTools_ListOfShape& aListOfShapes=aMapSubshAnc.FindFromKey(aSubsh);
TopTools_ListIteratorOfListOfShape anIt(aListOfShapes);
for (; anIt.More(); anIt.Next()) {
//Face
const TopoDS_Shape& aShape=anIt.Value();
aMapSS.Bind (aShape, aState);
//Wire
TopTools_IndexedMapOfShape aWireMap;
TopExp::MapShapes (aShape, TopAbs_WIRE, aWireMap);
nW=aWireMap.Extent();
for (j=1; j<=nW; j++) aMapSS.Bind (aWireMap(j), aState);
//Edge
TopTools_IndexedMapOfShape aSubshMap;
TopExp::MapShapes (aShape, TopAbs_EDGE, aSubshMap);
nSub=aSubshMap.Extent();
for (i=1; i<=nSub; i++) {
const TopoDS_Shape& aSS=aSubshMap(i);
if (! aMapProcessedSubsh.Contains(aSS)) {
aMapProcessedSubsh.Add(aSS);
aMapSS.Bind (aSS, aState);
FindState1 (aSS, aState, aMapSubshAnc, aMapProcessedSubsh, aMapSS);
}
}
}
}
//=======================================================================
//function :TopOpeBRepBuild_Tools::FindStateThroughVertex
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_Tools::FindStateThroughVertex (const TopoDS_Shape& aShape,
TopOpeBRepTool_ShapeClassifier& aShapeClassifier,
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState,
const TopTools_MapOfShape& anAvoidSubshMap)
{
TopTools_IndexedMapOfShape aSubshMap;
TopExp::MapShapes (aShape, TopAbs_VERTEX, aSubshMap);
TopoDS_Shape aSubsh;
Standard_Integer i;
for (i=1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++)
if (!anAvoidSubshMap.Contains (aSubshMap(i)) )
aSubsh = aSubshMap(i);
if (aSubsh.IsNull()) {
// try an edge
aSubshMap.Clear();
TopExp::MapShapes (aShape, TopAbs_EDGE, aSubshMap);
for (i=1; i <= aSubshMap.Extent() && aSubsh.IsNull(); i++)
if (!anAvoidSubshMap.Contains (aSubshMap(i)) )
aSubsh = aSubshMap(i);
if (aSubsh.IsNull()) {
#ifdef DEB
cout<<"FindStateThroughVertex: warning: all vertices are avoided"<<endl;
#endif
return TopAbs_UNKNOWN; // failure
}
}
TopoDS_Shape aNullShape;
TopAbs_State aState=aShapeClassifier.StateShapeReference(aSubsh, aNullShape);
TopOpeBRepDS_ShapeWithState aShapeWithState;
aShapeWithState.SetState (aState);
aShapeWithState.SetIsSplitted (Standard_False);
aMapOfShapeWithState.Add(aShape, aShapeWithState);
SpreadStateToChild (aShape, aState, aMapOfShapeWithState);
return aState;
}
//=======================================================================
//function :TopOpeBRepBuild_Tools::SpreadStateToChild
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::SpreadStateToChild (const TopoDS_Shape& aShape,
const TopAbs_State aState,
TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithState)
{
TopTools_IndexedMapOfShape aChildMap;
TopExp::MapShapes (aShape, TopAbs_FACE, aChildMap);
TopExp::MapShapes (aShape, TopAbs_WIRE, aChildMap);
TopExp::MapShapes (aShape, TopAbs_EDGE, aChildMap);
TopOpeBRepDS_ShapeWithState aShapeWithState;
aShapeWithState.SetState (aState);
aShapeWithState.SetIsSplitted (Standard_False);
Standard_Integer i, n=aChildMap.Extent();
for (i=1; i<=n; i++) {
aMapOfShapeWithState.Add(aChildMap(i), aShapeWithState);
}
}
//=======================================================================
//function :TopOpeBRepBuild_Tools::PropagateStateForWires
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::PropagateStateForWires(const TopTools_IndexedMapOfShape& aFacesToRestMap,
TopOpeBRepDS_IndexedDataMapOfShapeWithState&
aMapOfShapeWithState)
{
Standard_Integer i, j, nF, nW, k, nE;
nF=aFacesToRestMap.Extent();
for (i=1; i<=nF; i++) {
const TopoDS_Shape& aF=aFacesToRestMap(i);
if (aMapOfShapeWithState.Contains (aF)) {
const TopOpeBRepDS_ShapeWithState& aSWS=aMapOfShapeWithState.FindFromKey(aF);
TopAbs_State aSt=aSWS.State();
TopTools_IndexedMapOfShape aWireMap;
TopExp::MapShapes (aF, TopAbs_WIRE, aWireMap);
nW=aWireMap.Extent();
for (j=1; j<=nW; j++) {
const TopoDS_Shape& aW=aWireMap(j);
TopOpeBRepDS_ShapeWithState aWireSWS;
aWireSWS.SetState(aSt);
aWireSWS.SetIsSplitted (Standard_False);
aMapOfShapeWithState.Add(aW, aWireSWS);
TopTools_IndexedMapOfShape aEdgeMap;
TopExp::MapShapes (aW, TopAbs_EDGE, aEdgeMap);
nE=aEdgeMap.Extent();
for (k=1; k<=nE; k++) {
const TopoDS_Shape& aE=aEdgeMap(k);
if (!aMapOfShapeWithState.Contains (aE)) {
TopOpeBRepDS_ShapeWithState anEdgeSWS;
anEdgeSWS.SetState(aSt);
anEdgeSWS.SetIsSplitted (Standard_False);
aMapOfShapeWithState.Add(aE, anEdgeSWS);
}
}
}
}
}
}
//=======================================================================
//function :TopOpeBRepBuild_Tools:: GetNormalToFaceOnEdge
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (const TopoDS_Face& aFObj,
const TopoDS_Edge& anEdgeObj,
gp_Vec& aNormal)
{
TopoDS_Edge aEd=anEdgeObj;
TopoDS_Face aFS=aFObj;
Standard_Real tolE = 0., f2 = 0., l2 = 0., tolpc = 0., tol = 0., f = 0., l = 0., par = 0.;
tolE=BRep_Tool::Tolerance(aEd);
Handle(Geom2d_Curve) C2D=FC2D_CurveOnSurface(aEd,aFS,f2,l2,tolpc, Standard_True);
tol = Max(tolE,tolpc);
BRepAdaptor_Curve aCA(aEd);
f=aCA.FirstParameter();
l=aCA.LastParameter();
par= f*PAR_T + (1 - PAR_T)*l;
gp_Pnt2d aUV1 ;
C2D -> D0(par, aUV1);
gp_Pnt aP;
gp_Vec aTg1, aTg2;
BRepAdaptor_Surface aSA1(aFS);
aSA1.D1(aUV1.X(), aUV1.Y(), aP, aTg1, aTg2);
aNormal = aTg1^aTg2;
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::GetNormalInNearestPoint
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::GetNormalInNearestPoint(const TopoDS_Face& F,
const TopoDS_Edge& E,
gp_Vec& aNormal)
{
Standard_Real f2 = 0., l2 = 0., tolpc = 0., par = 0.;
gp_Vec2d aTangent;
Handle(Geom2d_Curve) C2D = FC2D_CurveOnSurface(E, F, f2, l2, tolpc, Standard_True);
par = f2*PAR_T + (1 - PAR_T)*l2;
gp_Pnt2d aP;
C2D -> D1(par, aP, aTangent);
Standard_Real Xnorm = -aTangent.Y();
Standard_Real Ynorm = aTangent.X();
Standard_Real step = TopOpeBRepTool_TOOL::minDUV(F); step *= 1e-2;
gp_Vec2d aPV(aP.X(), aP.Y());
gp_Dir2d aStepV(Xnorm, Ynorm);
gp_Vec2d aNorm2d = aPV + gp_Vec2d(step*aStepV);
Standard_Real newU = aNorm2d.X();
Standard_Real newV = aNorm2d.Y();
gp_Vec aTg1, aTg2;
gp_Pnt aP1;
BRepAdaptor_Surface BS(F);
BS.D1(newU, newV, aP1, aTg1, aTg2);
gp_Pnt2d aP2d(newU, newV);
BRepTopAdaptor_FClass2d FC(F, Precision::PConfusion());
TopAbs_State aState = FC.Perform(aP2d);
//point out of face: try to go at another direction
if(aState == TopAbs_OUT) {
aStepV.Reverse();
aNorm2d = aPV + gp_Vec2d(step*aStepV);
newU = aNorm2d.X();
newV = aNorm2d.Y();
BS.D1(newU, newV, aP1, aTg1, aTg2);
//in principle, we must check again
// aP2d.SetX(newU); aP2d.SetY(newV);
// BRepClass_FaceClassifier FC(Fex, aP2d, 1e-7);
// TopAbs_State aState = FC.State();
}
aNormal = aTg1^aTg2;
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::GetTangentToEdgeEdge
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Tools::GetTangentToEdgeEdge (const TopoDS_Face& ,//aFObj,
const TopoDS_Edge& anEdgeObj,
const TopoDS_Edge& aOriEObj,
gp_Vec& aTangent)
{
if (BRep_Tool::Degenerated(aOriEObj) ||
BRep_Tool::Degenerated(anEdgeObj)) {
return TopOpeBRepBuild_Tools::GetTangentToEdge (anEdgeObj, aTangent) ;
}
TopoDS_Edge aEd=anEdgeObj, aEOri = aOriEObj;
Standard_Real f = 0., l = 0., par = 0., parOri = 0.;
BRepAdaptor_Curve aCA(aEd);
BRepAdaptor_Curve aCAOri(aEOri);
f=aCA.FirstParameter();
l=aCA.LastParameter();
par= f*PAR_T + (1 - PAR_T)*l;
gp_Pnt aP;
gp_Vec aTgPiece;
aCA.D1(par, aP, aTgPiece);
aTangent = aTgPiece;
gp_Pnt aPOri;
gp_Vec aTgOri;
/////
Handle (Geom_Curve) GCOri=aCAOri.Curve().Curve();
Handle (Geom_Curve) aCopyCurve = Handle(Geom_Curve)::DownCast(GCOri -> Copy());
const TopLoc_Location& aLoc = aEOri.Location();
gp_Trsf aTrsf = aLoc.Transformation();
aCopyCurve -> Transform(aTrsf);
GeomAPI_ProjectPointOnCurve aPP(aP, aCopyCurve, aCopyCurve->FirstParameter(), aCopyCurve->LastParameter());
#ifdef DEB
// gp_Pnt aNP = aPP.NearestPoint();
#endif
parOri = aPP.LowerDistanceParameter();
aCopyCurve -> D1(parOri, aPOri, aTgOri);// aPOri must be equal aNP !
//printf(" aNP ={%lf, %lf, %lf}\n", aNP.X(), aNP.Y(), aNP.Z());
//printf(" aPOri={%lf, %lf, %lf}\n", aPOri.X(), aPOri.Y(), aPOri.Z());
if (aEd.Orientation() == TopAbs_REVERSED)
aTangent.Reverse();
if(aTgOri*aTgPiece < 0.) {
aTangent.Reverse();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::GetTangentToEdge
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Tools::GetTangentToEdge (const TopoDS_Edge& anEdgeObj,
gp_Vec& aTangent)
{
TopoDS_Edge aEd=anEdgeObj;
Standard_Real f = 0., l = 0., par = 0.;
BRepAdaptor_Curve aCA(aEd);
f=aCA.FirstParameter();
l=aCA.LastParameter();
par= f*PAR_T + (1 - PAR_T)*l;
gp_Pnt aP;
aCA.D1(par, aP, aTangent);
return Standard_True;
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::GetAdjacentFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Tools::GetAdjacentFace (const TopoDS_Shape& aFaceObj,
const TopoDS_Shape& anEObj,
const TopTools_IndexedDataMapOfShapeListOfShape& anEdgeFaceMap,
TopoDS_Shape& anAdjFaceObj)
{
const TopTools_ListOfShape& aListOfAdjFaces=anEdgeFaceMap.FindFromKey(anEObj);
TopTools_ListIteratorOfListOfShape anIt(aListOfAdjFaces);
TopoDS_Shape anAdjShape;
for (; anIt.More(); anIt.Next()) {
if (anIt.Value()!=aFaceObj) {
anAdjShape=anIt.Value();
break;
}
}
if (!anAdjShape.IsNull()) {
anAdjFaceObj=TopoDS::Face(anAdjShape);
return Standard_True;
}
else {
return Standard_False;
}
}
//=======================================================================
//function : UpdatePCurves
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::UpdatePCurves(const TopoDS_Wire& aWire,
const TopoDS_Face& fromFace,
const TopoDS_Face& toFace)
{
TopExp_Explorer aExp(aWire, TopAbs_EDGE);
for(; aExp.More(); aExp.Next()) {
TopoDS_Shape aEdge = aExp.Current();
UpdateEdgeOnFace(TopoDS::Edge(aEdge), fromFace, toFace);
}
}
//=======================================================================
//function : UpdateEdgeOnFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::UpdateEdgeOnFace(const TopoDS_Edge& aEdgeToUpdate,
const TopoDS_Face& fromFace,
const TopoDS_Face& toFace)
{
BRep_Builder BB;
Standard_Real tolE = BRep_Tool::Tolerance(TopoDS::Edge(aEdgeToUpdate));
Standard_Real f2 = 0.,l2 = 0.,tolpc = 0.;
Handle(Geom2d_Curve) C2D;
if(BRep_Tool::Degenerated(aEdgeToUpdate)) {
//we can not compute PCurve for Degenerated Edge
//so we take as it was on old face and after (in CorrectFace2D)
// we will adjust this PCurve
C2D = FC2D_CurveOnSurface(aEdgeToUpdate, fromFace,
f2, l2, tolpc, Standard_True);
Standard_Real tol = Max(tolE, tolpc);
Handle(Geom2d_Curve) C2Dn = Handle(Geom2d_Curve)::DownCast(C2D -> Copy());
Handle(Geom2d_TrimmedCurve) newC2D = new Geom2d_TrimmedCurve(C2Dn, f2, l2);
BB.UpdateEdge(aEdgeToUpdate ,newC2D, toFace , tol);
}
else { //not degenerated edge
if(BRep_Tool::IsClosed(aEdgeToUpdate, fromFace)) {
UpdateEdgeOnPeriodicalFace(aEdgeToUpdate, fromFace, toFace);
}
else {
C2D = FC2D_CurveOnSurface(aEdgeToUpdate, toFace , f2, l2, tolpc, Standard_True);
Standard_Real tol = Max(tolE,tolpc);
BB.UpdateEdge(aEdgeToUpdate ,C2D, toFace , tol);
}
}
}
//=======================================================================
//function : UpdateEdgeOnPeriodicalFace
//purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::UpdateEdgeOnPeriodicalFace(const TopoDS_Edge& aEdgeToUpdate,
const TopoDS_Face& fromFace,
const TopoDS_Face& toFace)
{
Standard_Boolean DiffOriented = Standard_False;
BRep_Builder BB;
TopoDS_Edge newE = aEdgeToUpdate; //newE.Orientation(TopAbs_FORWARD);
TopoDS_Face fFace = fromFace; //fFace.Orientation(TopAbs_FORWARD);
TopoDS_Face tFace = toFace; //tFace.Orientation(TopAbs_FORWARD);
Standard_Real fc = 0., lc = 0.;
Handle(Geom2d_Curve) cc = BRep_Tool::CurveOnSurface(newE, tFace, fc, lc);
if(!cc.IsNull()) {
//cout << "Pcurves exist" << endl;
return;
}
gp_Vec aN1, aN2;
TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(fromFace),
TopoDS::Edge(aEdgeToUpdate), aN1);
TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(toFace),
TopoDS::Edge(aEdgeToUpdate), aN2);
if(aN1*aN2 < 0)
DiffOriented = Standard_True;
Standard_Real tolE = BRep_Tool::Tolerance(newE);
Standard_Real f2 = 0., l2 = 0., tolpc = 0., tol = 0.;
//first PCurve
Handle(Geom2d_Curve) C2D = FC2D_CurveOnSurface(newE,
tFace, f2,
l2, tolpc, Standard_True);
tol = Max(tolpc, tolE);
BRepAdaptor_Surface aBAS(fFace);
gp_Vec2d aTrV;
Standard_Real ff = 0., lf = 0., fr = 0., lr = 0.;
gp_Pnt2d aUVf, aUVr;
Handle(Geom2d_Curve) oldC2DFor = BRep_Tool::CurveOnSurface(newE, //FC2D_CurveOnSurface(newE,
fFace, ff,
lf);//, tolpc, Standard_True);
newE.Reverse();
Handle(Geom2d_Curve) oldC2DRev = BRep_Tool::CurveOnSurface(newE, //FC2D_CurveOnSurface(newE,
fFace, fr,
lr);//, tolpc, Standard_True);
oldC2DFor -> D0(ff, aUVf);
oldC2DRev -> D0(fr, aUVr);
if(!DiffOriented)
aTrV = gp_Vec2d(aUVf, aUVr);
else
aTrV = gp_Vec2d(aUVr, aUVf);
gp_Vec2d aux(gp_Pnt2d(0., 0.), gp_Pnt2d(1., 1.));
Standard_Real scalar = aux*aTrV;
Standard_Boolean dir = (scalar >= 0.) ? Standard_True : Standard_False;
//compute right order of pcurves
gp_Vec2d aYVec(gp_Pnt2d(0., 0.), gp_Pnt2d(0., 1.));
gp_Pnt2d aUVfv, aUVlv;
C2D -> D0(f2, aUVfv);
C2D -> D0(l2, aUVlv);
gp_Vec2d C2DVec(aUVfv, aUVlv);
Standard_Boolean firstOrder = Standard_True;
scalar = aYVec*C2DVec;
if(fabs(scalar) <= 1e-10) {// compute along X axe
gp_Vec2d aXVec(gp_Pnt2d(0., 0.), gp_Pnt2d(1., 0.));
scalar = aXVec*C2DVec;
firstOrder = (scalar >= 0.) ? Standard_True : Standard_False;
}
else
firstOrder = (scalar > 0.) ? Standard_False : Standard_True;
Handle(Geom2d_Curve) aTrC = Handle(Geom2d_Curve)::DownCast(C2D->Copy());
aTrC -> Translate(aTrV);
if(dir) {
if(firstOrder)
BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol);
else
BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol);
}
else {
if(!firstOrder)
BB.UpdateEdge(aEdgeToUpdate, C2D, aTrC, toFace, tol);
else
BB.UpdateEdge(aEdgeToUpdate, aTrC, C2D, toFace, tol);
}
}
//=======================================================================
//function : TopOpeBRepBuild_Tools::IsDegEdgesTheSame
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Tools::IsDegEdgesTheSame (const TopoDS_Shape& anE1,
const TopoDS_Shape& anE2)
{
TopTools_IndexedMapOfShape aVMap1, aVMap2;
TopExp::MapShapes(anE1, TopAbs_VERTEX, aVMap1);
TopExp::MapShapes(anE2, TopAbs_VERTEX, aVMap2);
if (!aVMap1.Extent() || !aVMap2.Extent())
return Standard_False;
if (aVMap1(1).IsSame(aVMap2(1)))
return Standard_True;
else
return Standard_False;
}
//=======================================================================
//function : NormalizeFace
//purpose : remove all INTERNAL and EXTERNAL edges from the face
//=======================================================================
void TopOpeBRepBuild_Tools::NormalizeFace(const TopoDS_Shape& oldFace,
TopoDS_Shape& corrFace)
{
Standard_Real tolF1;
TopLoc_Location Loc;
TopoDS_Face aF1 = TopoDS::Face(oldFace),
aNewFace;
aF1.Orientation(TopAbs_FORWARD);
Handle(Geom_Surface) Surf = BRep_Tool::Surface(aF1, Loc);
tolF1 = BRep_Tool::Tolerance(aF1);
BRep_Builder BB;
BB.MakeFace(aNewFace, Surf, Loc, tolF1);
TopExp_Explorer aFExp(aF1, TopAbs_WIRE);
for (; aFExp.More(); aFExp.Next()) {
Standard_Integer NbGoodEdges = 0;
TopoDS_Shape aWire=aFExp.Current();
aWire.Orientation(TopAbs_FORWARD);
TopoDS_Wire aNewWire;
BB.MakeWire(aNewWire);
TopExp_Explorer aWExp(aWire, TopAbs_EDGE);
for (; aWExp.More(); aWExp.Next()) {
TopoDS_Shape anEdge=aWExp.Current();
if (anEdge.Orientation()==TopAbs_EXTERNAL ||
anEdge.Orientation()==TopAbs_INTERNAL)
continue;
BB.Add (aNewWire, TopoDS::Edge(anEdge));
NbGoodEdges++;
}
//keep wire orientation
aNewWire.Orientation(aFExp.Current().Orientation());//aWire.Orientation());
if(NbGoodEdges) //we add new wire only if it contains at least one edge
BB.Add (aNewFace, aNewWire);
}
//keep face orientation
aNewFace.Orientation(oldFace.Orientation());
corrFace = aNewFace;
}
//=======================================================================
//function : CorrectFace2d
//purpose : adjust PCurves of periodical face in 2d
//=======================================================================
void TopOpeBRepBuild_Tools::CorrectFace2d (const TopoDS_Shape& oldFace,
TopoDS_Shape& corrFace,
const TopTools_IndexedMapOfOrientedShape& aSourceShapes,
TopTools_IndexedDataMapOfShapeShape& aMapOfCorrect2dEdges)
{
TopOpeBRepBuild_CorrectFace2d aCorrectFace2d(TopoDS::Face(oldFace),
aSourceShapes,
aMapOfCorrect2dEdges);
aCorrectFace2d.Perform();
corrFace=oldFace;
}

View File

@@ -0,0 +1,29 @@
-- File: TopOpeBRepBuild_Tools2d.cdl
-- Created: Mon Nov 29 12:32:59 1999
-- Author: Peter KURNEV
-- <pkv@irinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class Tools2d from TopOpeBRepBuild
---Purpose:
uses
IndexedDataMapOfShapeVertexInfo from TopOpeBRepBuild,
Wire from TopoDS,
ListOfShape from TopTools
is
MakeMapOfShapeVertexInfo (myclass;
aWire:Wire from TopoDS;
aMap:out IndexedDataMapOfShapeVertexInfo from TopOpeBRepBuild);
DumpMapOfShapeVertexInfo (myclass;
aMap: IndexedDataMapOfShapeVertexInfo from TopOpeBRepBuild);
Path (myclass; aWire:Wire from TopoDS; aResList:out ListOfShape from TopTools);
end Tools2d;

View File

@@ -0,0 +1,208 @@
// File: TopOpeBRepBuild_Tools2d.cxx
// Created: Mon Nov 29 12:36:31 1999
// Author: Peter KURNEV
// <pkv@irinox.nnov.matra-dtv.fr>
#include <TopOpeBRepBuild_Tools2d.ixx>
#include <TopoDS_Wire.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepBuild_VertexInfo.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <stdio.h>
static
void BuildPath (const TopoDS_Vertex& myVertex0,
const TopoDS_Edge& myEdge,
const TopoDS_Vertex& myVertex,
const Standard_Integer aNbEdges,
TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo& M,
Standard_Integer anEdgesCount,
Standard_Integer& aBreakFlag,
TopTools_ListOfShape& myResList);
//=======================================================================
// function :TopOpeBRepBuild_Tools2d::Path
// purpose:
//=======================================================================
void TopOpeBRepBuild_Tools2d::Path(const TopoDS_Wire& aWire, TopTools_ListOfShape& aResList)
{
Standard_Integer anEdgesCount=0, aNbEdges=0, aBreakFlag=0;
TopTools_ListOfShape myResList;
TopoDS_Vertex myVertex, myVertex0;
TopoDS_Edge myEdge, aNullEdge;
TopExp_Explorer ex(aWire,TopAbs_EDGE);
for (; ex.More(); ex.Next()) aNbEdges++;
myResList.Clear();
TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo M;
TopOpeBRepBuild_Tools2d::MakeMapOfShapeVertexInfo(aWire, M);
myEdge=aNullEdge;
myVertex0=TopoDS::Vertex(M.FindKey(1));
myVertex=myVertex0;
BuildPath (myVertex0, myEdge, myVertex, aNbEdges, M, anEdgesCount, aBreakFlag, myResList);
//
aResList.Clear();
aResList=myResList;
}
//=======================================================================
// function :BuildPath
// purpose:
//=======================================================================
void BuildPath (const TopoDS_Vertex& myVertex0,
const TopoDS_Edge& myInputEdge,
const TopoDS_Vertex& myInputVertex,
const Standard_Integer aNbEdges,
TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo& M,
Standard_Integer anEdgesCount,
Standard_Integer& aBreakFlag,
TopTools_ListOfShape& myResList)
{
Standard_Integer j = 1, aFoundOut, aNbCases, stopFlag=0;
TopoDS_Edge myEdge;
TopoDS_Vertex myVertex;
if (aBreakFlag==1) return;
TopOpeBRepBuild_VertexInfo& aVInfo=M.ChangeFromKey(myInputVertex);
//
aVInfo.SetCurrentIn (myInputEdge);
aVInfo.Prepare(myResList);
aNbCases=aVInfo.NbCases();
if (!aNbCases) aBreakFlag=2;
for (j=1; j<=aNbCases; j++) {
myEdge=aVInfo.CurrentOut();
aFoundOut=aVInfo.FoundOut();
if (!aFoundOut) { //FondOut=0 TUPICK
aBreakFlag=2;
return;
}
else {
if (stopFlag) { // if previous path was wrong
aVInfo.RemovePassed();
myResList.RemoveFirst();
stopFlag=0;
anEdgesCount--;
}
aVInfo.AppendPassed (myEdge);
myResList.Prepend (myEdge);
anEdgesCount++;
myVertex=(myEdge.Orientation()==TopAbs_FORWARD)?
TopExp::LastVertex(myEdge) : TopExp::FirstVertex(myEdge);
if (myVertex.IsSame(myVertex0) && anEdgesCount==aNbEdges) {
aBreakFlag=1;
return;
}
BuildPath (myVertex0, myEdge, myVertex, aNbEdges, M, anEdgesCount, aBreakFlag, myResList);
////
if (aBreakFlag==1) {
return;
}
if (aBreakFlag==2) {// Come back
if (j==aNbCases) {
aVInfo.RemovePassed();
myResList.RemoveFirst();
anEdgesCount--;
////
return;
}
else {
stopFlag=1;
aBreakFlag=0; // Next j if possible
}
} // end of if (aBreakFlag==2)
} // end of else .i.e. aFoundOut#0
} // end of for (j=1; j<=aNbCases; j++)
}
//=======================================================================
// function :TopOpeBRepBuild_Tools2d::MakeMapOfShapeVertexInfo
// purpose:
//=======================================================================
void TopOpeBRepBuild_Tools2d::MakeMapOfShapeVertexInfo(const TopoDS_Wire& aWire,
TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo& M)
{
TopOpeBRepBuild_VertexInfo empty;
TopExp_Explorer exa(aWire,TopAbs_EDGE);
for (; exa.More(); exa.Next()) {
const TopoDS_Edge& anEdge = TopoDS::Edge(exa.Current());
TopExp_Explorer exs(anEdge, TopAbs_VERTEX);
for (; exs.More(); exs.Next()) {
const TopoDS_Vertex& aVertex= TopoDS::Vertex(exs.Current());
Standard_Integer index = M.FindIndex(aVertex);
if (!index)
index = M.Add(aVertex, empty);
TopOpeBRepBuild_VertexInfo& aVInfo= M(index);
aVInfo.SetVertex (aVertex);
TopAbs_Orientation anOr=aVertex.Orientation();
if (anOr==TopAbs_FORWARD ) aVInfo.AddOut (anEdge);
else if (anOr==TopAbs_REVERSED) aVInfo.AddIn (anEdge);
}
}
Standard_Integer i, aNb;
aNb=M.Extent();
for (i=1; i<=aNb; i++) {
TopOpeBRepBuild_VertexInfo& aVInfo=M(i);
const TopTools_IndexedMapOfOrientedShape& EdgesIn =aVInfo.EdgesIn();
const TopTools_IndexedMapOfOrientedShape& EdgesOut =aVInfo.EdgesOut();
Standard_Integer aNbEdgesIn, aNbEdgesOut;
aNbEdgesIn =EdgesIn.Extent();
aNbEdgesOut =EdgesOut.Extent();
if (aNbEdgesIn!=1 && aNbEdgesOut!=1) {
aVInfo.SetSmart (Standard_True);
}
}
}
//=======================================================================
// function :TopOpeBRepBuild_Tools2d::DumpMapOfShapeVertexInfo
// purpose:
//=======================================================================
void TopOpeBRepBuild_Tools2d::DumpMapOfShapeVertexInfo(const TopOpeBRepBuild_IndexedDataMapOfShapeVertexInfo& M)
{
Standard_Integer i, aNb, aNbEdgesIn, aNbEdgesOut;
aNb=M.Extent();
for (i=1; i<=aNb; i++) {
const TopOpeBRepBuild_VertexInfo& aVInfo=M(i);
const TopTools_IndexedMapOfOrientedShape& EdgesIn =aVInfo.EdgesIn();
const TopTools_IndexedMapOfOrientedShape& EdgesOut =aVInfo.EdgesOut();
aNbEdgesIn =EdgesIn.Extent();
aNbEdgesOut =EdgesOut.Extent();
printf(" Vert.#%d, ", i);
const TopTools_ListOfShape& aList=aVInfo.ListPassed();
if (aList.Extent()) {
TopTools_ListIteratorOfListOfShape anIt(aList);
for (; anIt.More(); anIt.Next()) {
printf("pass,");
}
}
else {
printf("none");
}
printf("\n");
}
}

View File

@@ -0,0 +1,549 @@
// File: TopOpeBRepBuild_Tools_1.cxx
// Created: Fri Feb 11 17:21:51 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <TopOpeBRepBuild_Tools.ixx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <TopLoc_Location.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_PointRepresentation.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom2dAdaptor.hxx>
#include <GeomProjLib.hxx>
#include <gp_Pnt.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <BRepCheck_Wire.hxx>
static
void CheckEdge (const TopoDS_Edge& E,
const Standard_Real aMaxTol);
static
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol);
static
Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
const Standard_Real Tol,
const Standard_Boolean SameParameter,
Standard_Real& aNewTolerance);
//=======================================================================
// Function : CorrectTolerances
// purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::CorrectTolerances(const TopoDS_Shape& aShape,
const Standard_Real aMaxTol)
{
TopOpeBRepBuild_Tools::CorrectPointOnCurve(aShape, aMaxTol);
TopOpeBRepBuild_Tools::CorrectCurveOnSurface(aShape, aMaxTol);
}
//=======================================================================
// Function : CorrectPointOnCurve
// purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::CorrectPointOnCurve(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
{
Standard_Integer i, aNb;
TopTools_IndexedMapOfShape Edges;
TopExp::MapShapes (S, TopAbs_EDGE, Edges);
aNb=Edges.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Edge& E= TopoDS::Edge(Edges(i));
CheckEdge(E, aMaxTol);
}
}
//=======================================================================
// Function : CorrectCurveOnSurface
// purpose :
//=======================================================================
void TopOpeBRepBuild_Tools::CorrectCurveOnSurface(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
{
Standard_Integer i, aNbFaces, j, aNbEdges;
TopTools_IndexedMapOfShape Faces;
TopExp::MapShapes (S, TopAbs_FACE, Faces);
aNbFaces=Faces.Extent();
for (i=1; i<=aNbFaces; i++) {
const TopoDS_Face& F= TopoDS::Face(Faces(i));
TopTools_IndexedMapOfShape Edges;
TopExp::MapShapes (F, TopAbs_EDGE, Edges);
aNbEdges=Edges.Extent();
for (j=1; j<=aNbEdges; j++) {
const TopoDS_Edge& E= TopoDS::Edge(Edges(j));
CorrectEdgeTolerance (E, F, aMaxTol);
}
}
}
//=======================================================================
// Function : CorrectEdgeTolerance
// purpose : Correct tolerances for Edge
//=======================================================================
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol)
{
//
// 1. Minimum of conditions to Perform
Handle (BRep_CurveRepresentation) myCref;
Handle (Adaptor3d_HCurve) myHCurve;
myCref.Nullify();
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
Standard_Boolean Degenerated, SameParameter, SameRange;
Standard_Integer unique = 0;
Degenerated = TE->Degenerated();
SameParameter = TE->SameParameter();
SameRange = TE->SameRange();
if (!SameRange && SameParameter) {
return;
}
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurve3D()) {
unique++;
if (myCref.IsNull() && !cr->Curve3D().IsNull()) {
myCref = cr;
}
}
itcr.Next();
}
if (unique==0) {
return;//...No3DCurve
}
if (unique>1) {
return;//...Multiple3DCurve;
}
if (myCref.IsNull() && !Degenerated) {
itcr.Initialize(TE->Curves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface()) {
myCref = cr;
break;
}
itcr.Next();
}
}
else if (!myCref.IsNull() && Degenerated){
return ;//...InvalidDegeneratedFlag;
}
if (!myCref.IsNull()) {
const Handle(BRep_GCurve)& GCref = *((Handle(BRep_GCurve)*)&myCref);
Standard_Real First,Last;
GCref->Range(First,Last);
if (Last<=First) {
myCref.Nullify();
return ;//InvalidRange;
}
else {
if (myCref->IsCurve3D()) {
Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
(myCref->Curve3D()->Transformed (myCref->Location().Transformation()));
GeomAdaptor_Curve GAC3d(C3d,First,Last);
myHCurve = new GeomAdaptor_HCurve(GAC3d);
}
else { // curve on surface
Handle(Geom_Surface) Sref = myCref->Surface();
Sref = Handle(Geom_Surface)::DownCast(Sref->Transformed(myCref->Location().Transformation()));
const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref = new Geom2dAdaptor_HCurve(PCref, First, Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
}
}
}
//===============================================
// 2. Tolerances in InContext
{
if (myCref.IsNull())
return;
Standard_Boolean ok=Standard_True;
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));
Standard_Real aNewTol=Tol;
Standard_Real First = myHCurve->FirstParameter();
Standard_Real Last = myHCurve->LastParameter();
Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
const TopLoc_Location& Floc = S.Location();
const TopLoc_Location& TFloc = TF->Location();
const Handle(Geom_Surface)& Su = TF->Surface();
TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
// Standard_Boolean checkclosed = Standard_False;
Standard_Boolean pcurvefound = Standard_False;
itcr.Initialize(TE->Curves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
pcurvefound = Standard_True;
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
Standard_Real f,l;
GC->Range(f,l);
if (SameRange && (f != First || l != Last)) {
return ;//BRepCheck_InvalidSameRangeFlag);
if (SameParameter) {
return; //BRepCheck_InvalidSameParameterFlag);
}
}
Handle(Geom_Surface) Sb = cr->Surface();
Sb = Handle(Geom_Surface)::DownCast (Su->Transformed(L.Transformation()));
Handle(Geom2d_Curve) PC = cr->PCurve();
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb);
Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
ok = Validate(myHCurve->Curve(), ACS, Tol, SameParameter, aNewTol);
if (ok) {
if (cr->IsCurveOnClosedSurface()) {
//return ;// BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
}
else {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
}
if (SameParameter) {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
// printf("(Edge,1) Tolerance=%15.10lg\n", aNewTol);
if (aNewTol<aMaxTol)
TE->UpdateTolerance(aNewTol);
}
if (cr->IsCurveOnClosedSurface()) {
// checkclosed = Standard_True;
GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds
ACS.Load(GAHS); // sans doute inutile
ACS.Load(GHPC); // meme remarque...
ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter, aNewTol);
if (ok) {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
if (SameParameter) {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
// printf("(Edge,2) Tolerance=%15.10lg\n", aNewTol);
if (aNewTol<aMaxTol)
TE->UpdateTolerance(aNewTol);
}
}
}
itcr.Next();
}
if (!pcurvefound) {
Handle(Geom_Plane) P;
Handle(Standard_Type) styp = Su->DynamicType();
if (styp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
P = Handle(Geom_Plane)::DownCast(Handle(Geom_RectangularTrimmedSurface)::
DownCast(Su)->BasisSurface());
}
else {
P = Handle(Geom_Plane)::DownCast(Su);
}
if (P.IsNull()) { // not a plane
return;//BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface);
}
else {// on fait la projection a la volee, comme BRep_Tool
P = Handle(Geom_Plane)::DownCast(P->Transformed(L.Transformation()));
//on projette Cref sur ce plan
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P);
// Dub - Normalement myHCurve est une GeomAdaptor_HCurve
GeomAdaptor_Curve& Gac = Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve();
Handle(Geom_Curve) C3d = Gac.Curve();
Handle(Geom_Curve) ProjOnPlane = GeomProjLib::ProjectOnPlane
(new Geom_TrimmedCurve(C3d,First,Last), P, P->Position().Direction(), Standard_True);
Handle(GeomAdaptor_HCurve) aHCurve = new GeomAdaptor_HCurve(ProjOnPlane);
ProjLib_ProjectedCurve proj(GAHS,aHCurve);
Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
Handle(Geom2dAdaptor_HCurve) GHPC =
new Geom2dAdaptor_HCurve(PC, myHCurve->FirstParameter(), myHCurve->LastParameter());
Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
ok = Validate(myHCurve->Curve(),ACS,
Tol,Standard_True, aNewTol); // voir dub...
if (ok) {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
// printf("(Edge,3) Tolerance=%15.10lg\n", aNewTol);
if (aNewTol<aMaxTol)
TE->UpdateTolerance(aNewTol);
}
}
}//end of if (!pcurvefound) {
} // end of 2. Tolerances in InContext
}
#define NCONTROL 23
//=======================================================================
//function : Validate
//purpose :
//=======================================================================
Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
const Standard_Real Tol,
const Standard_Boolean SameParameter,
Standard_Real& aNewTolerance)
{
Standard_Real First, Last, MaxDistance, aD;
First = CRef.FirstParameter();
Last = CRef.LastParameter();
MaxDistance = Tol*Tol;
Standard_Integer i, aNC1=NCONTROL-1;
Standard_Boolean aFlag=Standard_False;
Standard_Boolean proj = (!SameParameter ||
First != Other.FirstParameter() ||
Last != Other.LastParameter());
//
// 1.
if (!proj) {
for (i = 0; i < NCONTROL; i++) {
Standard_Real prm = ((aNC1-i)*First + i*Last)/aNC1;
gp_Pnt pref = CRef.Value(prm);
gp_Pnt pother = Other.Value(prm);
aD=pref.SquareDistance(pother);
if (aD > MaxDistance) {
MaxDistance=aD;
aFlag=Standard_True;
}
}
}
//
// 2.
else {
Extrema_LocateExtPC refd,otherd;
Standard_Real OFirst, OLast;
OFirst = Other.FirstParameter();
OLast = Other.LastParameter();
gp_Pnt pd = CRef.Value(First);
gp_Pnt pdo = Other.Value(OFirst);
aD = pd.SquareDistance(pdo);
if (aD > MaxDistance) {
MaxDistance=aD;
aFlag=Standard_True;
}
pd = CRef.Value(Last);
pdo = Other.Value(OLast);
aD = pd.SquareDistance(pdo);
if (aD > MaxDistance) {
MaxDistance=aD;
aFlag=Standard_True;
}
refd.Initialize(CRef, First, Last, CRef.Resolution(Tol));
otherd.Initialize(Other, OFirst, OLast, Other.Resolution(Tol));
for (i = 2; i< aNC1; i++) {
Standard_Real rprm = ((aNC1-i)*First + i*Last)/aNC1;
gp_Pnt pref = CRef.Value(rprm);
Standard_Real oprm = ((aNC1-i)*OFirst + i*OLast)/aNC1;
gp_Pnt pother = Other.Value(oprm);
refd.Perform(pother,rprm);
if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) {
if (refd.IsDone()) {
aD=refd.SquareDistance();
if (aD > MaxDistance) {
aFlag=Standard_True;
MaxDistance=aD;
}
}
}
otherd.Perform(pref,oprm);
if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) {
if (otherd.IsDone()) {
aD=otherd.SquareDistance();
if (aD > MaxDistance) {
aFlag=Standard_True;
MaxDistance=aD;
}
}
}
}
}
if (aFlag) {
aD=sqrt (MaxDistance);
aNewTolerance=aD*1.05;
}
return aFlag;
}
//=======================================================================
// Function : CheckEdge
// purpose : Correct tolerances for Vertices on Edge
//=======================================================================
void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
{
TopoDS_Edge E=Ed;
E.Orientation(TopAbs_FORWARD);
gp_Pnt Controlp;
TopExp_Explorer aVExp;
aVExp.Init(E, TopAbs_VERTEX);
for (; aVExp.More(); aVExp.Next()) {
TopoDS_Vertex aVertex= TopoDS::Vertex(aVExp.Current());
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &aVertex.TShape());
const gp_Pnt& prep = TV->Pnt();
Standard_Real Tol, aD2, aNewTolerance, dd;
Tol =BRep_Tool::Tolerance(aVertex);
Tol = Max(Tol, BRep_Tool::Tolerance(E));
dd=0.1*Tol;
Tol*=Tol;
const TopLoc_Location& Eloc = E.Location();
BRep_ListIteratorOfListOfPointRepresentation itpr;
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
const TopLoc_Location& loc = cr->Location();
TopLoc_Location L = (Eloc * loc).Predivided(aVertex.Location());
if (cr->IsCurve3D()) {
const Handle(Geom_Curve)& C = cr->Curve3D();
if (!C.IsNull()) {
itpr.Initialize(TV->Points());
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
if (pr->IsPointOnCurve(C,L)) {
Controlp = C->Value(pr->Parameter());
Controlp.Transform(L.Transformation());
aD2=prep.SquareDistance(Controlp);
if (aD2 > Tol) {
aNewTolerance=sqrt(aD2)+dd;
// printf("(Vert,1) Tolerance=%15.10lg\n", aNewTolerance);
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
}
}
itpr.Next();
}
TopAbs_Orientation orv = aVertex.Orientation();
if (orv == TopAbs_FORWARD || orv == TopAbs_REVERSED) {
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
if (orv==TopAbs_FORWARD)
Controlp = C->Value(GC->First());
else
Controlp = C->Value(GC->Last());
Controlp.Transform(L.Transformation());
aD2=prep.SquareDistance(Controlp);
if (aD2 > Tol) {
aNewTolerance=sqrt(aD2)+dd;
// printf("(Vert,2) Tolerance=%15.10lg\n", aNewTolerance);
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
}
}
}
}
itcr.Next();
}
}
}
//=======================================================================
//function : CheckFaceClosed2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepBuild_Tools::CheckFaceClosed2d(const TopoDS_Face& theFace)
{
Standard_Boolean isClosed = Standard_True;
TopExp_Explorer ex(theFace,TopAbs_WIRE);
for (; ex.More() && isClosed; ex.Next()) {
const TopoDS_Wire& aW = TopoDS::Wire(ex.Current());
BRepCheck_Wire aWChk(aW);
BRepCheck_Status aStatus = aWChk.Orientation(theFace);
if (aStatus != BRepCheck_NoError)
isClosed = Standard_False;
}
return isClosed;
}

View File

@@ -0,0 +1,87 @@
-- File: TopOpeBRepBuild_VertexInfo.cdl
-- Created: Mon Nov 29 12:05:52 1999
-- Author: Peter KURNEV
-- <pkv@irinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class VertexInfo from TopOpeBRepBuild
---Purpose:
uses
Vertex from TopoDS,
Edge from TopoDS,
SequenceOfInteger from TColStd,
IndexedMapOfOrientedShape from TopTools,
ListOfShape from TopTools
--raises
is
Create returns VertexInfo from TopOpeBRepBuild;
SetVertex (me:out; aV:Vertex from TopoDS);
Vertex (me) returns Vertex from TopoDS;
---C++: return const &
SetSmart (me:out; aFlag: Boolean from Standard);
Smart (me) returns Boolean from Standard;
NbCases (me) returns Integer from Standard;
FoundOut (me) returns Integer from Standard;
AddIn (me:out; anE: Edge from TopoDS);
AddOut (me:out; anE: Edge from TopoDS);
SetCurrentIn (me:out; anE: Edge from TopoDS);
EdgesIn (me) returns IndexedMapOfOrientedShape from TopTools;
---C++: return const &
EdgesOut (me) returns IndexedMapOfOrientedShape from TopTools;
---C++: return const &
ChangeEdgesOut (me:out) returns IndexedMapOfOrientedShape from TopTools;
---C++: return &
Dump (me);
CurrentOut (me:out) returns Edge from TopoDS;
---C++: return const &
AppendPassed (me:out; anE: Edge from TopoDS);
RemovePassed (me:out);
ListPassed (me) returns ListOfShape from TopTools;
---C++: return const &
Prepare(me: out; aL : ListOfShape from TopTools);
fields
myVertex : Vertex from TopoDS;
myCurrent : Edge from TopoDS;
myCurrentIn : Edge from TopoDS;
mySmart : Boolean from Standard;
myEdgesIn : IndexedMapOfOrientedShape from TopTools;
myEdgesOut : IndexedMapOfOrientedShape from TopTools;
myLocalEdgesOut : IndexedMapOfOrientedShape from TopTools;
myEdgesPassed : ListOfShape from TopTools;
myFoundOut : Integer from Standard;
end VertexInfo;

View File

@@ -0,0 +1,218 @@
#include <TopOpeBRepBuild_VertexInfo.ixx>
#include <TopoDS.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <stdio.h>
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo
// purpose:
//=======================================================================
TopOpeBRepBuild_VertexInfo::TopOpeBRepBuild_VertexInfo()
{
mySmart=Standard_False;
myFoundOut=0;
myEdgesPassed.Clear();
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::SetVertex
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::SetVertex(const TopoDS_Vertex& aV)
{
myVertex=aV;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::Vertex
// purpose:
//=======================================================================
const TopoDS_Vertex& TopOpeBRepBuild_VertexInfo::Vertex() const
{
return myVertex;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::SetSmart
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::SetSmart(const Standard_Boolean aFlag)
{
mySmart=aFlag;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo:Smart
// purpose:
//=======================================================================
Standard_Boolean TopOpeBRepBuild_VertexInfo::Smart() const
{
return mySmart;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo:NbCases
// purpose:
//=======================================================================
Standard_Integer TopOpeBRepBuild_VertexInfo::NbCases() const
{//myCurrentIn
return myLocalEdgesOut.Extent();
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo:FoundOut
// purpose:
//=======================================================================
Standard_Integer TopOpeBRepBuild_VertexInfo::FoundOut () const
{
return myFoundOut;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::AddIn
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::AddIn(const TopoDS_Edge& anE)
{
myEdgesIn.Add(anE);
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::AddOut
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::AddOut(const TopoDS_Edge& anE)
{
myEdgesOut.Add(anE);
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::SetCurrentIn
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::SetCurrentIn(const TopoDS_Edge& anE)
{
myCurrentIn=anE;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::EdgesIn
// purpose:
//=======================================================================
const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesIn() const
{
return myEdgesIn;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::EdgesOut
// purpose:
//=======================================================================
const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesOut() const
{
return myEdgesOut;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::ChangeEdgesOut
// purpose:
//=======================================================================
TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::ChangeEdgesOut()
{
return myEdgesOut;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::Dump
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::Dump() const
{
printf(" *** Dump the Vertex Info ***\n");
printf(" mySmart : %d\n", mySmart);
printf(" Edges : %d In, %d Out\n", myEdgesIn.Extent(), myEdgesOut.Extent());
printf("\n");
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::AppendPassed
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::AppendPassed(const TopoDS_Edge& anE)
{
myEdgesPassed.Prepend(anE);
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::RemovePassed
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::RemovePassed()
{
myEdgesPassed.RemoveFirst();
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::ListPassed
// purpose:
//=======================================================================
const TopTools_ListOfShape& TopOpeBRepBuild_VertexInfo::ListPassed() const
{
return myEdgesPassed;
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo::Prepare
// purpose:
//=======================================================================
void TopOpeBRepBuild_VertexInfo::Prepare(const TopTools_ListOfShape& aL)
{
myLocalEdgesOut.Clear();
TopTools_IndexedMapOfOrientedShape tmpMap;
TopTools_ListIteratorOfListOfShape anIt(aL);
for (; anIt.More(); anIt.Next()) {
tmpMap.Add(anIt.Value());
}
Standard_Integer i = 1, nb = myEdgesOut.Extent();
for(; i <= nb; i++) {
const TopoDS_Shape& aE = myEdgesOut(i);
if(!tmpMap.Contains(aE))
myLocalEdgesOut.Add(aE);
}
tmpMap.Clear();
}
//=======================================================================
// function :TopOpeBRepBuild_VertexInfo:CurrentOut
// purpose:
//=======================================================================
const TopoDS_Edge& TopOpeBRepBuild_VertexInfo::CurrentOut ()
{
Standard_Integer i, aNbOut, aNbPassed ;
aNbOut =myLocalEdgesOut.Extent();
aNbPassed=myEdgesPassed.Extent();
TopTools_IndexedMapOfOrientedShape aMapPassed;
TopTools_ListIteratorOfListOfShape anIt(myEdgesPassed);
for (; anIt.More(); anIt.Next()) {
aMapPassed.Add (anIt.Value());
}
for (i=1; i<=aNbOut; i++) {
if (!aMapPassed.Contains(myLocalEdgesOut(i))) {
myCurrent=TopoDS::Edge(myLocalEdgesOut(i));
myFoundOut=1;
return myCurrent;
}
}
myFoundOut=0;
TopoDS_Edge aS;
myCurrent=aS;
return myCurrent;
}

View File

@@ -0,0 +1,70 @@
-- File: TopOpeBRepBuild_WireEdgeClassifier.cdl
-- Created: Thu Jun 17 10:15:32 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class WireEdgeClassifier from TopOpeBRepBuild
inherits CompositeClassifier from TopOpeBRepBuild
---Purpose:
-- Classify edges and wires.
-- shapes are Wires, Element are Edge.
uses
ShapeEnum from TopAbs,
State from TopAbs,
Shape from TopoDS,
Pnt2d from gp,
Edge from BRepClass,
FacePassiveClassifier from BRepClass,
BlockBuilder from TopOpeBRepBuild,
Loop from TopOpeBRepBuild
is
Create(F : Shape from TopoDS;
BB : BlockBuilder) returns WireEdgeClassifier;
---Purpose: Creates a classifier on edge <F>.
-- Used to compare edges and wires on the edge <F>.
Compare(me : in out; L1,L2 : Loop) returns State from TopAbs
is redefined;
LoopToShape(me : in out; L : Loop)
returns Shape from TopoDS;
CompareShapes(me : in out; B1,B2 : Shape from TopoDS)
---Purpose: classify wire <B1> with wire <B2>
returns State from TopAbs;
CompareElementToShape(me : in out; E,B : Shape from TopoDS)
---Purpose: classify edge <E> with wire <B>
returns State from TopAbs;
ResetShape(me : in out; B : Shape from TopoDS);
---Purpose: prepare classification involving wire <B>
-- calls ResetElement on first edge of <B>
ResetElement(me : in out; E : Shape from TopoDS);
---Purpose: prepare classification involving edge <E>
-- define 2D point (later used in Compare()) on first vertex of edge <E>.
CompareElement(me : in out; E : Shape from TopoDS);
---Purpose: Add the edge <E> in the set of edges used in 2D point
-- classification.
State(me : in out) returns State from TopAbs;
---Purpose: Returns state of classification of 2D point, defined by
-- ResetElement, with the current set of edges, defined by Compare.
fields
myFirstCompare : Boolean;
myPoint2d : Pnt2d from gp;
myBCEdge : Edge from BRepClass;
myFPC : FacePassiveClassifier from BRepClass;
myShape : Shape from TopoDS;
end WireEdgeClassifier from TopOpeBRepBuild;

View File

@@ -0,0 +1,461 @@
// File: TopOpeBRepBuild_WireEdgeClassifier.cxx
// Created: Thu Jun 17 18:52:50 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepBuild_WireEdgeClassifier.ixx>
#ifdef DRAW
#include <DBRep.hxx>
#endif
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <Geom2d_Curve.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <Standard_ProgramError.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec2d.hxx>
#include <BRep_Builder.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_SC.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_CurveTool.hxx>
#include <TopOpeBRepBuild_Builder.hxx>
#include <TopOpeBRepBuild_define.hxx>
#ifdef DEB
#define TSTRA TopOpeBRepDS_GettraceSTRANGE()
static TCollection_AsciiString PRODINS("dins ");
Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
#endif
//Standard_IMPORT extern TopOpeBRepBuild_Builder* GLOBAL_PBUILDER;
Standard_IMPORT TopOpeBRepBuild_Builder* GLOBAL_PBUILDER;
#define MYBB ((TopOpeBRepBuild_BlockBuilder*)myBlockBuilder)
#define SAME (-1)
#define DIFF (-2)
#define UNKNOWN ( 0)
#define oneINtwo ( 1)
#define twoINone ( 2)
//=======================================================================
//function : TopOpeBRepBuild_WireEdgeClassifier
//purpose :
//=======================================================================
TopOpeBRepBuild_WireEdgeClassifier::TopOpeBRepBuild_WireEdgeClassifier
(const TopoDS_Shape& F,
const TopOpeBRepBuild_BlockBuilder& BB) :
TopOpeBRepBuild_CompositeClassifier(BB)
{
myBCEdge.Face() = TopoDS::Face(F);
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::Compare
(const Handle(TopOpeBRepBuild_Loop)& L1,
const Handle(TopOpeBRepBuild_Loop)& L2)
{
TopAbs_State state = TopAbs_UNKNOWN;
Standard_Boolean isshape1 = L1->IsShape();
Standard_Boolean isshape2 = L2->IsShape();
if ( isshape2 && isshape1 ) { // L1 is Shape , L2 is Shape
const TopoDS_Shape& s1 = L1->Shape();
const TopoDS_Shape& s2 = L2->Shape();
state = CompareShapes(s1,s2);
}
else if ( isshape2 && !isshape1 ) { // L1 is Block , L2 is Shape
TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
Bit1.Initialize();
Standard_Boolean yena1 = Bit1.More();
while (yena1) {
const TopoDS_Shape& s1 = MYBB->Element(Bit1);
const TopoDS_Shape& s2 = L2->Shape();
state = CompareElementToShape(s1,s2);
yena1 = Standard_False;
if (state == TopAbs_UNKNOWN) {
if (Bit1.More()) Bit1.Next();
yena1 = Bit1.More();
}
}
}
else if ( !isshape2 && isshape1 ) { // L1 is Shape , L2 is Block
const TopoDS_Shape& s1 = L1->Shape();
ResetShape(s1);
TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
const TopoDS_Shape& s2 = MYBB->Element(Bit2);
CompareElement(s2);
}
state = State();
}
else if ( !isshape2 && !isshape1 ) { // L1 is Block , L2 is Block
if (state == TopAbs_UNKNOWN) {
TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
Bit1.Initialize();
Standard_Boolean yena1 = Bit1.More();
while (yena1) {
const TopoDS_Shape& s1 = MYBB->Element(Bit1);
ResetElement(s1);
TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
const TopoDS_Shape& s2 = MYBB->Element(Bit2);
CompareElement(s2);
}
state = State();
yena1 = Standard_False;
if (state == TopAbs_UNKNOWN) {
if (Bit1.More()) Bit1.Next();
yena1 = Bit1.More();
}
}
} //UNKNOWN
if (state == TopAbs_UNKNOWN) {
#ifdef DEB
if (TSTRA) cout<<"TopOpeBRepBuild_Builder::WES::Compare UNKNOWN -> ShapeClassifier "<<endl;
#endif
}
if (state == TopAbs_UNKNOWN) {
TopoDS_Shape s1 = LoopToShape(L1); if (s1.IsNull()) return state;
TopoDS_Shape s2 = LoopToShape(L2); if (s2.IsNull()) return state;
TopOpeBRepTool_ShapeClassifier& SC = FSC_GetPSC();
Standard_Integer samedomain = SC.SameDomain(); SC.SameDomain(1);
SC.SetReference(s2);
const TopoDS_Shape& AvS = s2;
state = SC.StateShapeReference(s1,AvS);
SC.SameDomain(samedomain);
} // UNKNOWN
}
return state;
}
//=======================================================================
//function : LoopToShape
//purpose :
//=======================================================================
TopoDS_Shape TopOpeBRepBuild_WireEdgeClassifier::LoopToShape(const Handle(TopOpeBRepBuild_Loop)& L)
{
myShape.Nullify();
TopOpeBRepBuild_BlockIterator Bit = L->BlockIterator();
Bit.Initialize();
if ( !Bit.More() ) return myShape;
TopoDS_Shape aLocalShape = myBCEdge.Face();
const TopoDS_Face& F1 = TopoDS::Face(aLocalShape);
// const TopoDS_Face& F1 = TopoDS::Face(myBCEdge.Face());
aLocalShape = F1.EmptyCopied();
TopoDS_Face F = TopoDS::Face(aLocalShape);
// TopoDS_Face F = TopoDS::Face(F1.EmptyCopied());
BRep_Builder BB; TopoDS_Wire W; BB.MakeWire(W);
for (; Bit.More(); Bit.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(MYBB->Element(Bit));
Standard_Real tolE; tolE = BRep_Tool::Tolerance(E);
Standard_Boolean haspc = FC2D_HasCurveOnSurface(E,F);
if (!haspc) {
Standard_Real f,l,tolpc;Handle(Geom2d_Curve) C2D;
C2D = FC2D_CurveOnSurface(E,F,f,l,tolpc);
if (!C2D.IsNull()) {
Standard_Real tol = Max(tolpc,tolE);
BB.UpdateEdge(E,C2D,F,tol);
}
}
BB.Add(W,E);
}
BB.Add(F,W);
myShape = F;
return myShape;
}
static gp_Vec FUN_tgINE(const TopoDS_Vertex& v, const TopoDS_Vertex& vl, const TopoDS_Edge& e)
// tg oriented INSIDE 1d(e)
// vl : last vertex of e
{
Standard_Real par = BRep_Tool::Parameter(v,e);
gp_Vec tg; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(par,e,tg);
if (!ok) return gp_Vec(0.,0.,0.); //NYIRAISE
if (v.IsSame(vl)) tg.Reverse();
return tg;
}
//=======================================================================
//function : CompareShapes
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::CompareShapes
(const TopoDS_Shape& B1, const TopoDS_Shape& B2)
{
// evolution xpu101198 : - cto009K4, regularisation de f24,
// on classifie 1 wire / 1 des wires connexes.
// (face rectangulaire - face circulaire tangente aux bords) -
// WEC completement aleatoire : depend du choix de e1 dans le cas
// ou e1 est tangent a E. - e1 droite touche l'autre wire -
// on fait l'hypothese que les shapes B1 et B2 proviennent du meme shape,
// et que si ils ne se touchent pas, on ne passe pas par le WEC.
// INCOMPLET!!!
#ifdef DEB
// TopAbs_ShapeEnum t1 = B1.ShapeType();
// TopAbs_ShapeEnum t2 = B2.ShapeType();
#endif
TopAbs_State state = TopAbs_UNKNOWN;
TopExp_Explorer ex1(B1,TopAbs_EDGE);
if ( !ex1.More() ) return state;
for ( ; ex1.More(); ex1.Next() ) {
const TopoDS_Edge& e1 = TopoDS::Edge(ex1.Current());
TopoDS_Vertex vf1,vl1; TopExp::Vertices(e1,vf1,vl1);//xpu101198
Standard_Boolean e1clo = vf1.IsSame(vl1);
TopTools_IndexedMapOfShape mapv1; mapv1.Add(vf1); mapv1.Add(vl1);
ResetShape(e1);
Standard_Integer iE = 0; Standard_Boolean indy = Standard_False;
TopExp_Explorer Ex;
for(Ex.Init(B2,TopAbs_EDGE); Ex.More(); Ex.Next()) {
// for(TopExp_Explorer Ex(B2,TopAbs_EDGE); Ex.More(); Ex.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(Ex.Current());
if (E.IsSame(e1)) { state = TopAbs_UNKNOWN; break; } // eap occ416
TopoDS_Vertex vf,vl; TopExp::Vertices(E,vf,vl);//xpu101198
Standard_Boolean Eclo = vf.IsSame(vl);//xpu101198
Standard_Boolean hasf = mapv1.Contains(vf);//xpu101198
Standard_Boolean hasl = mapv1.Contains(vl);//xpu101198
Standard_Boolean filter = (hasf || hasl) && (!e1clo) && (!Eclo);// nyi : Eclo || e1clo
if (filter) {//xpu101198
TopoDS_Vertex vshared; if (hasf) vshared=vf; if (hasl) vshared=vl;
gp_Vec tg1 = FUN_tgINE(vshared,vl1,e1);
gp_Vec tg = FUN_tgINE(vshared,vl,E);
Standard_Real dot = tg1.Dot(tg);
Standard_Real tol = Precision::Angular()*1.e4; // nyixpu
Standard_Boolean undecided = (Abs(1+dot) < tol);
if (undecided) {indy = Standard_True;}
}//xpu101198
if (indy) {state = TopAbs_UNKNOWN; break;}
CompareElement(E);
state = State();
iE++;
} // ex(B2,EDGE)
if (state != TopAbs_UNKNOWN) {
break;
}
}// ex1
Standard_Boolean resta = (state == TopAbs_UNKNOWN);
resta = resta && (B2.ShapeType()==TopAbs_WIRE) && (B1.ShapeType()==TopAbs_WIRE);
if (resta) {
TopTools_IndexedMapOfShape mape1; TopExp::MapShapes(B1,TopAbs_EDGE,mape1);
// recall : avoid auto-intersection wires (ie B1 and B2 are disjoint)
TopExp_Explorer ex2(B2,TopAbs_EDGE);
for (; ex2.More(); ex2.Next()){
const TopoDS_Edge& E2 = TopoDS::Edge(ex2.Current());
if (mape1.Contains(E2)) continue;
const TopoDS_Face& theFace = myBCEdge.Face();
BRep_Builder BB;
// p2d on E2 of B2, E2 not shared by B1
TopoDS_Shape aLocalShape = theFace.Oriented(TopAbs_FORWARD);
TopoDS_Face ftmp = TopoDS::Face(aLocalShape);
// TopoDS_Face ftmp = TopoDS::Face(theFace.Oriented(TopAbs_FORWARD));
aLocalShape = ftmp.EmptyCopied();
TopoDS_Face F2 = TopoDS::Face(aLocalShape);
// TopoDS_Face F2 = TopoDS::Face(ftmp.EmptyCopied());
BB.Add(F2,TopoDS::Wire(B2));
BRepAdaptor_Curve2d BC2d(E2,F2);
Standard_Real f,l; FUN_tool_bounds(E2,f,l); Standard_Real x = 0.45678; Standard_Real p2 = (1-x)*l + x*f;
gp_Pnt2d p2d = BC2d.Value(p2);
aLocalShape = ftmp.EmptyCopied();
TopoDS_Face F1 = TopoDS::Face(aLocalShape);
// TopoDS_Face F1 = TopoDS::Face(ftmp.EmptyCopied());
BB.Add(F1,TopoDS::Wire(B1));
Standard_Real tolF1 = BRep_Tool::Tolerance(F1);
BRepClass_FaceClassifier Fclass(F1, p2d, tolF1);
state = Fclass.State();
return state;
} // ex2
}
/*if (state == TopAbs_UNKNOWN) {
const TopoDS_Face& F = TopoDS::Face(myBCEdge.Face());
Bnd_Array1OfBox2d bnd(1,2);
FUN_tool_mkBnd2d(B1,F,bnd(1)); FUN_tool_mkBnd2d(B2,F,bnd(2));
TopTools_Array1OfShape B(1,2);
B(1)=B1; B(2)=B2;
// Standard_Boolean chklarge=Standard_True; Standard_Integer isma = 0; TopAbs_State osta = FUN_tool_classiBnd2d(bnd,isma,chklarge);
// if (osta == TopAbs_OUT) return TopAbs_OUT;
// if (osta == TopAbs_IN) {
// if (isma == 2) return TopAbs_IN; //B2 is IN B1
// else return TopAbs_OUT; //B2 is OUT B1 (contains B1)
// }
Standard_Boolean chklarge=Standard_True; Standard_Integer sta = FUN_tool_classiBnd2d(bnd,chklarge);
if ((sta == SAME)||(sta == UNKNOWN)) sta = FUN_tool_classiwithp2d(B);
if ((sta == SAME)||(sta == UNKNOWN)) return TopAbs_UNKNOWN;
if (sta == DIFF) return TopAbs_OUT; // B1 OUT B2
Standard_Integer isma = (sta == oneINtwo) ? 1 : 2;
if (isma == 2) return TopAbs_IN; //B2 is IN B1
else return TopAbs_OUT; //B2 is OUT B1 (contains B1)
}*/
return state;
}
//=======================================================================
//function : CompareElementToShape
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::CompareElementToShape
(const TopoDS_Shape& EE,const TopoDS_Shape& B)
{
// isEdge : edge E inits myPoint2d
ResetElement(EE);
TopExp_Explorer Ex;
for(Ex.Init(B,TopAbs_EDGE); Ex.More(); Ex.Next()) {
const TopoDS_Shape& E = Ex.Current();
CompareElement(E);
}
TopAbs_State state = State();
return state;
}
//=======================================================================
//function : ResetShape
//purpose :
//=======================================================================
void TopOpeBRepBuild_WireEdgeClassifier::ResetShape(const TopoDS_Shape& B)
{
if (B.ShapeType() == TopAbs_EDGE) {
ResetElement(B);
}
else {
TopExp_Explorer ex(B,TopAbs_EDGE);
if (ex.More()) {
const TopoDS_Shape& E = ex.Current();
ResetElement(E);
}
}
}
//=======================================================================
//function : ResetElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_WireEdgeClassifier::ResetElement(const TopoDS_Shape& EE)
{
const TopoDS_Edge& E = TopoDS::Edge(EE);
const TopoDS_Face& F = myBCEdge.Face();
Standard_Real f2,l2,tolpc;Handle(Geom2d_Curve) C2D; //jyl980406+
Standard_Boolean haspc = FC2D_HasCurveOnSurface(E,F); //jyl980406+
if (!haspc) { //jyl980406+
Standard_Boolean trim3d = Standard_True; C2D = FC2D_CurveOnSurface(E,F,f2,l2,tolpc,trim3d); //jyl980406+
Standard_Real tolE = BRep_Tool::Tolerance(E); //jyl980406+
Standard_Real tol = Max(tolE,tolpc); //jyl980406+
BRep_Builder BB; BB.UpdateEdge(E,C2D,F,tol); //jyl980406+
} //jyl980406+
C2D = FC2D_CurveOnSurface(E,F,f2,l2,tolpc);
if (C2D.IsNull()) Standard_ProgramError::Raise("WEC : ResetElement");
Standard_Real t = 0.397891143689; Standard_Real par = ((1-t)*f2 + t*l2);
myPoint2d = C2D->Value(par);
#ifdef DEB
Standard_Real f3,l3; Handle(Geom_Curve) C3D = BRep_Tool::Curve(E,f3,l3);
gp_Pnt P3D; if (!C3D.IsNull()) P3D = C3D->Value(par);
#endif
myFirstCompare = Standard_True;
}
//=======================================================================
//function : CompareElement
//purpose :
//=======================================================================
void TopOpeBRepBuild_WireEdgeClassifier::CompareElement(const TopoDS_Shape& EE)
{
const TopoDS_Edge& E = TopoDS::Edge(EE);
const TopoDS_Face& F = myBCEdge.Face();
Standard_Real f2,l2,tolpc;Handle(Geom2d_Curve) C2D; //jyl980402+
Standard_Boolean haspc = FC2D_HasCurveOnSurface(E,F); //jyl980402+
if (!haspc) { //jyl980402+
Standard_Boolean trim3d = Standard_True; C2D = FC2D_CurveOnSurface(E,F,f2,l2,tolpc,trim3d); //jyl980406+
// C2D = FC2D_CurveOnSurface(E,F,f2,l2,tolpc,trim3d); //jyl980406-
Standard_Real tolE = BRep_Tool::Tolerance(E); //jyl980402+
Standard_Real tol = Max(tolE,tolpc); //jyl980402+
BRep_Builder BB; BB.UpdateEdge(E,C2D,F,tol); //jyl980402+
} //jyl980402+
if (myFirstCompare) {
C2D = FC2D_CurveOnSurface(E,F,f2,l2,tolpc);
Standard_Real t = 0.33334567; Standard_Real par = ((1-t)*f2 + t*l2);
gp_Pnt2d p2d = C2D->Value(par);
#ifdef DEB
Standard_Real f3,l3; Handle(Geom_Curve) C3D = BRep_Tool::Curve(E,f3,l3);
gp_Pnt P3D; if (!C3D.IsNull()) P3D = C3D->Value(par);
#endif
// NYI : p2d peut etre un point ou la courbe n'est pas C1.
// NYI : voir TopOpeBRepTool_ShapeClassifier_FindAPointInTheFace
gp_Vec2d v2d(myPoint2d,p2d);
gp_Lin2d l2d(myPoint2d,v2d);
Standard_Real dist = myPoint2d.Distance(p2d);
Standard_Real tol2d = Precision::PConfusion(); // NYI : a voir
myFPC.Reset(l2d,dist,tol2d);
myFirstCompare = Standard_False;
}
myBCEdge.Edge() = E;
TopAbs_Orientation Eori = E.Orientation();
myFPC.Compare(myBCEdge,Eori);
#ifdef DEB
// TopAbs_State state = myFPC.State();
#endif
}
//=======================================================================
//function : State
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepBuild_WireEdgeClassifier::State()
{
TopAbs_State state = myFPC.State();
return state;
}

Some files were not shown because too many files have changed in this diff Show More