From: vsr Date: Fri, 14 May 2010 20:41:49 +0000 (+0000) Subject: Merge from V5_1_main branch 14/05/2010 X-Git-Tag: V6_1_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3ad098eb76ef9a8b8c531a588e52c7cc1d2abb62;p=modules%2Fgeom.git Merge from V5_1_main branch 14/05/2010 --- diff --git a/doc/salome/gui/GEOM/static/header.html b/doc/salome/gui/GEOM/static/header.html deleted file mode 100755 index a70a95e30..000000000 --- a/doc/salome/gui/GEOM/static/header.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - $title - - -
-
-SALOME documentation central -
-
diff --git a/doc/salome/tui/images/occ.gif b/doc/salome/tui/images/occ.gif deleted file mode 100755 index ce017c8ae..000000000 Binary files a/doc/salome/tui/images/occ.gif and /dev/null differ diff --git a/doc/salome/tui/static/myheader.html b/doc/salome/tui/static/myheader.html deleted file mode 100755 index d2efb75fa..000000000 --- a/doc/salome/tui/static/myheader.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Main Page - - - - -  - - diff --git a/src/GEOMDS/GEOMDS_Commands.cxx b/src/GEOMDS/GEOMDS_Commands.cxx deleted file mode 100644 index fa858673d..000000000 --- a/src/GEOMDS/GEOMDS_Commands.cxx +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// File : GeomDS_Commands.cxx -// Author : Yves FRICAUD/Lucien PIGNOLONI -// Module : GEOM -// $Header$ -// -using namespace std; -#include "utilities.h" -#include "GEOMDS_Commands.ixx" - -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : GEOMDS_Commands -//purpose : -//======================================================================= -GEOMDS_Commands::GEOMDS_Commands(const TDF_Label& Main) - : myLab(Main) -{ -} - - -//======================================================================= -// function : Generated() -// purpose : -//======================================================================= -TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S, - const TCollection_ExtendedString& Name) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Generated(S); - TDataStd_Name::Set(NewLab,Name); - return NewLab; -} - - - -//======================================================================= -// function : Generated() -// purpose : -//======================================================================= -TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - const TCollection_ExtendedString& Name) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Generated(S1,S2); - TDataStd_Name::Set(NewLab,Name); - return NewLab; -} - - - -//======================================================================= -// function : AddShape() -// purpose : -//======================================================================= -TDF_Label GEOMDS_Commands::AddShape(const TopoDS_Shape& S, - const TCollection_ExtendedString& Name) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Select(S,S); - TDataStd_Name::Set(NewLab,Name); - return NewLab; -} - - -//======================================================================= -// function : AddIndependentShape() -// purpose : SAME than AddShape() : will be renamed later -//======================================================================= -TDF_Label GEOMDS_Commands::AddIndependentShape(const TopoDS_Shape& S, - const TCollection_AsciiString& nameIOR) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Select(S,S); - TDataStd_Name::Set(NewLab, nameIOR); - return NewLab; -} - - -//======================================================================= -// function : AddDependentShape() -// purpose : -//======================================================================= -TDF_Label GEOMDS_Commands::AddDependentShape(const TopoDS_Shape& S, - const TCollection_AsciiString& nameIOR, - const TDF_Label& mainLab) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Select(S,S); - TDataStd_Name::Set(NewLab, nameIOR); - /* NewLab has a reference attribute to mainLab (the main shape in fact) */ - TDF_Reference::Set(NewLab, mainLab) ; - return NewLab; -} - - - -//======================================================================= -// function : AddConstructiveElement() -// purpose : -//======================================================================= -TDF_Label GEOMDS_Commands::AddConstructiveElement(const TopoDS_Shape& S, - const TCollection_ExtendedString& nameIOR, - const GEOMDS_ConstructiveType& aType) -{ - TDF_Label NewLab = myLab.NewChild(); - TNaming_Builder B(NewLab); - B.Select(S,S); - TDataStd_Name::Set(NewLab, nameIOR); - /* Add the Attribute Constructive Element coded with a TDataStd_Integer from an enum */ - TDataStd_Integer::Set(NewLab, Standard_Integer(aType)); - return NewLab; -} - - -//======================================================================= -// function : AddIORNameAttribute() -// purpose : Add attribute TDataStd_Name to a label -// : this attribute represents the name/IOR of object -// : Return false if attribute exist before -//======================================================================= -Standard_Boolean GEOMDS_Commands::AddIORNameAttribute(const TDF_Label& aLabel, - const TCollection_ExtendedString& nameIOR) -{ - if( this->HasIOR(aLabel) ) - return false ; - TDataStd_Name::Set(aLabel, nameIOR); - return true ; -} - - - -//======================================================================= -// function : IsConstructiveElement() 1/2 -// purpose : Return true if 'aLabel' is a constructive element -//======================================================================= -Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel) -{ - Handle(TDataStd_Integer) anAttType ; - if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType ) ) - return true ; - return false; -} - - -//======================================================================= -// function : IsConstructiveElement() 2/2 -// purpose : Return true if 'aLabel' is a constructive element and return the -// : topology ' returnTopo' and type 'returnType' -//======================================================================= -Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel, - TopoDS_Shape& returnTopo, - GEOMDS_ConstructiveType& returnType) -{ - Handle(TDataStd_Integer) anAttType ; - Handle(TNaming_NamedShape) anAttTopo ; - - if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType) && aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) { - - returnTopo = TNaming_Tool::GetShape(anAttTopo) ; - returnType = GEOMDS_ConstructiveType( anAttType->Get() ) ; - return true ; - } - return false; -} - - -//======================================================================= -// function : GetShape() -// purpose : return true and 'returnTopo' if a topology is found on 'aLabel' -//======================================================================= -Standard_Boolean GEOMDS_Commands::GetShape(const TDF_Label& aLabel, - TopoDS_Shape& returnTopo) -{ - Handle(TNaming_NamedShape) anAttTopo ; - if( aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) { - returnTopo = TNaming_Tool::GetShape(anAttTopo) ; - return true ; - } - return false; -} - - -//======================================================================= -// function : IsDependentShape() -// purpose : return true if the shape in the label is dependant (a sub shape) -//======================================================================= -Standard_Boolean GEOMDS_Commands::IsDependentShape(const TDF_Label& aLabel) -{ - Handle(TDF_Reference) anAttRef ; - if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef)) - return true ; - return false; -} - - - -//======================================================================= -// function : GetMainShapeLabel() -// purpose : return true if an attribute Reference is found for 'aLabel' -// : so 'returnMainLabel' is defined. 'aLabel' is supposed to be -// : a dependent object, otherwise return false. -//======================================================================= -Standard_Boolean GEOMDS_Commands::GetMainShapeLabel(const TDF_Label& aLabel, - TDF_Label& returnMainLabel) -{ - Handle(TDF_Reference) anAttRef ; - if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef)) { - returnMainLabel = anAttRef->Get() ; - return true ; - } - return false; -} - - -//======================================================================= -// function : ClearAllIOR() -// purpose : Clear all IOR from aLabel usually the main label. -// : Useful before reconstruction after a load of a document. -// : IOR is the attribute often called 'name' or 'nameIOR' -//======================================================================= -Standard_Boolean GEOMDS_Commands::ClearAllIOR(const TDF_Label& aLabel) -{ - TDF_ChildIterator it; - Handle(TDataStd_Name) anAttName ; - bool notTested = false ; - for( it.Initialize(aLabel, Standard_False); it.More(); it.Next() ) { - TDF_Label L = it.Value() ; - if( L.FindAttribute(TDataStd_Name::GetID(), anAttName) ) { - notTested = L.ForgetAttribute(TDataStd_Name::GetID()) ; - if(notTested) - MESSAGE("in GEOMDS_Commands::ClearAllIOR : IOR CLEARED" ) - ClearAllIOR(L); - } - } - return true ; -} - - -//======================================================================= -// function : HasIOR() -// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR) -//======================================================================= -Standard_Boolean GEOMDS_Commands::HasIOR(const TDF_Label& aLabel) -{ - Handle(TDataStd_Name) anAttName ; - if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) ) - return false ; - return true ; -} - -//======================================================================= -// function : ReturnNameIOR() -// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR) -// : and define 'returnNameIOR' -//======================================================================= -Standard_Boolean GEOMDS_Commands::ReturnNameIOR(const TDF_Label& aLabel, - TCollection_ExtendedString& returnNameIOR) -{ - Handle(TDataStd_Name) anAttName ; - if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) ) - return false ; - else { - returnNameIOR = anAttName->Get() ; - return true ; - } -} diff --git a/src/GEOMDS/GEOMDS_Commands.jxx b/src/GEOMDS/GEOMDS_Commands.jxx deleted file mode 100644 index 662528e63..000000000 --- a/src/GEOMDS/GEOMDS_Commands.jxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// File : GEOMDS_Commands.jxx -// Module : GEOM -// -#ifndef _TDF_Label_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TCollection_ExtendedString_HeaderFile -#include -#endif -#ifndef _GEOMDS_Commands_HeaderFile -#include "GEOMDS_Commands.hxx" -#endif diff --git a/src/NMTAlgo/Makefile.am b/src/NMTAlgo/Makefile.am deleted file mode 100644 index 407b7510b..000000000 --- a/src/NMTAlgo/Makefile.am +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# GEOM NMTAlgo : partition algorithm -# File : Makefile.in -# Author : Julia DOROVSKIKH -# Modified by : Alexander BORODIN (OCN) - autotools usage -# Module : GEOM -# $Header$ -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# header files -salomeinclude_HEADERS = \ - NMTAlgo_Splitter1.hxx \ - NMTAlgo_Splitter1.ixx \ - NMTAlgo_Splitter1.jxx \ - NMTAlgo_Splitter.hxx \ - NMTAlgo_Splitter.ixx \ - NMTAlgo_Splitter.jxx \ - NMTAlgo_Builder.hxx \ - NMTAlgo_Builder.ixx \ - NMTAlgo_Builder.jxx \ - NMTAlgo_Algo.hxx \ - NMTAlgo_Algo.ixx \ - NMTAlgo_Algo.jxx \ - NMTAlgo_Loop3d.hxx \ - NMTAlgo_Loop3d.ixx \ - NMTAlgo_Loop3d.jxx \ - NMTAlgo_Tools.hxx \ - NMTAlgo_Tools.ixx \ - NMTAlgo_Tools.jxx - -# Libraries targets -lib_LTLIBRARIES = libNMTAlgo.la - -dist_libNMTAlgo_la_SOURCES = \ - NMTAlgo_Algo.cxx \ - NMTAlgo_Builder.cxx \ - NMTAlgo_Loop3d.cxx \ - NMTAlgo_Splitter.cxx \ - NMTAlgo_Splitter1.cxx \ - NMTAlgo_Splitter_1.cxx \ - NMTAlgo_Splitter_2.cxx \ - NMTAlgo_Tools.cxx - -# additional information to compile and link file - -libNMTAlgo_la_CPPFLAGS = \ - $(CAS_CPPFLAGS) \ - $(KERNEL_CXXFLAGS) \ - -I$(srcdir)/../NMTDS \ - -I$(srcdir)/../NMTTools - -libNMTAlgo_la_LDFLAGS = \ - $(STDLIB) \ - $(CAS_LDPATH) -lTKBool -lTKBO \ - $(KERNEL_LDFLAGS) \ - ../NMTTools/libNMTTools.la diff --git a/src/NMTAlgo/NMTAlgo.cdl b/src/NMTAlgo/NMTAlgo.cdl deleted file mode 100644 index 1af7ea7e2..000000000 --- a/src/NMTAlgo/NMTAlgo.cdl +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo.cdl --- Created: Tue Jan 27 14:39:05 2004 --- Author: Peter KURNEV - - -package NMTAlgo - - ---Purpose: - -uses - TCollection, - TColStd, - gp, - TopAbs, - TopoDS, - TopTools, - - BooleanOperations, - BOPTColStd, - IntTools, - BOPTools, - BOP, - - NMTDS, - NMTTools, - - BRep, - BRepAlgo - -is - deferred class Algo; - class Splitter; - class Splitter1; --modified by NIZNHY-PKV Wed Feb 11 14:28:50 2004 - class Builder; - class Tools; - class Loop3d; - -end NMTAlgo; diff --git a/src/NMTAlgo/NMTAlgo.pro b/src/NMTAlgo/NMTAlgo.pro deleted file mode 100644 index 213e5be2b..000000000 --- a/src/NMTAlgo/NMTAlgo.pro +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -TEMPLATE = lib -TARGET = NMTAlgo -DESTDIR = ../../lib -MOC_DIR = ../../moc -OBJECTS_DIR = ../../obj/$$TARGET - -CASROOT = $$(CASROOT) -CAS_CPPFLAGS = $${CASROOT}/inc - -KERNEL_CXXFLAGS = $$(KERNEL_ROOT_DIR)/include/salome - -STDLIB = -lstdc++ - -CAS_LDPATH = -L$$(CASROOT)/Linux/lib - -KERNEL_LDFLAGS = -L$$(KERNEL_ROOT_DIR)/lib/salome - -INCLUDEPATH += $${CAS_CPPFLAGS} $${KERNEL_CXXFLAGS} ../NMTDS ../NMTTools - -LIBS += $${STDLIB} $${CAS_LDPATH} -lTKBool -lTKBO $${KERNEL_LDFLAGS} -L$$(GEOM_ROOT_DIR)/lib -lNMTTools - -CONFIG -= debug release debug_and_release -CONFIG += qt thread debug dll shared - -win32:DEFINES += WIN32 -DEFINES += OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS - -HEADERS = NMTAlgo_Splitter1.hxx -HEADERS += NMTAlgo_Splitter.hxx -HEADERS += NMTAlgo_Builder.hxx -HEADERS += NMTAlgo_Algo.hxx - -SOURCES = NMTAlgo_Algo.cxx -SOURCES += NMTAlgo_Builder.cxx -SOURCES += NMTAlgo_Loop3d.cxx -SOURCES += NMTAlgo_Splitter.cxx -SOURCES += NMTAlgo_Splitter1.cxx -SOURCES += NMTAlgo_Splitter_1.cxx -SOURCES += NMTAlgo_Splitter_2.cxx -SOURCES += NMTAlgo_Tools.cxx - -includes.files = $$HEADERS -includes.path = ../../include - -INSTALLS += includes diff --git a/src/NMTAlgo/NMTAlgo_Algo.cdl b/src/NMTAlgo/NMTAlgo_Algo.cdl deleted file mode 100644 index 546ab20e8..000000000 --- a/src/NMTAlgo/NMTAlgo_Algo.cdl +++ /dev/null @@ -1,78 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo_Algo.cdl --- Created: Tue Jan 27 14:41:04 2004 --- Author: Peter KURNEV - - -deferred class Algo from NMTAlgo - - ---Purpose: - -uses - Shape from TopoDS, - - DSFiller from NMTTools, - PDSFiller from NMTTools - ---raises - -is - Initialize - returns Algo from NMTAlgo; - ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Algo();" - - - SetFiller(me:out; - aDSF: DSFiller from NMTTools); - - Filler(me) - returns DSFiller from NMTTools; - ---C++: return const & - - ComputeWithFiller(me:out; - aDSF: DSFiller from NMTTools) - is virtual; - - Clear (me:out) - is virtual; - - Shape (me) - returns Shape from TopoDS; - ---C++: return const & - - IsDone(me) - returns Boolean from Standard; - - ErrorStatus (me) - returns Integer from Standard; - -fields - myDSFiller : PDSFiller from NMTTools is protected; - myShape : Shape from TopoDS is protected; - -- - myIsDone : Boolean from Standard is protected; - myIsComputed : Boolean from Standard is protected; - myErrorStatus : Integer from Standard is protected; - myDraw : Integer from Standard is protected; - -end Algo; diff --git a/src/NMTAlgo/NMTAlgo_Algo.cxx b/src/NMTAlgo/NMTAlgo_Algo.cxx deleted file mode 100644 index 50b59e90b..000000000 --- a/src/NMTAlgo/NMTAlgo_Algo.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Algo.cxx -// Created: Tue Jan 27 14:58:21 2004 -// Author: Peter KURNEV -// -// -#include -#include -//======================================================================= -// function: NMTAlgo_Algo::NMTAlgo_Algo -// purpose: -//======================================================================= - NMTAlgo_Algo::NMTAlgo_Algo() -: - myDSFiller(NULL), - myIsDone(Standard_False), - myIsComputed(Standard_False), - myErrorStatus(1) -{ - myDraw=0; - // - char* xr=getenv("MDISP"); - if (xr!=NULL) { - if (!strcmp (xr, "yes")) { - myDraw=1; - } - } -} -//======================================================================= -// function: NMTAlgo_Algo -// purpose: -//======================================================================= - NMTAlgo_Algo::~NMTAlgo_Algo() -{ - Clear(); -} -//======================================================================= -// function: Clear -// purpose: -//======================================================================= - void NMTAlgo_Algo::Clear() -{ - myIsDone=Standard_False; - myIsComputed=Standard_False; - myErrorStatus=1; -} -//======================================================================= -// function: SetFiller -// purpose: -//======================================================================= - void NMTAlgo_Algo::SetFiller(const NMTTools_DSFiller& aDSF) -{ - myDSFiller=(NMTTools_DSFiller *)&aDSF; -} -//======================================================================= -// function: Filler -// purpose: -//======================================================================= - const NMTTools_DSFiller& NMTAlgo_Algo::Filler()const -{ - return *myDSFiller; -} -//======================================================================= -// function: ComputeWithFiller -// purpose: -//======================================================================= - void NMTAlgo_Algo::ComputeWithFiller(const NMTTools_DSFiller& aDSF) -{ - SetFiller(aDSF); -} -//======================================================================= -// function: Shape -// purpose: -//======================================================================= - const TopoDS_Shape& NMTAlgo_Algo::Shape()const -{ - return myShape; -} -//======================================================================= -// function: IsDone -// purpose: -//======================================================================= - Standard_Boolean NMTAlgo_Algo::IsDone()const -{ - return myIsDone; -} -//======================================================================= -// function: ErrorStatus -// purpose: -//======================================================================= - Standard_Integer NMTAlgo_Algo::ErrorStatus()const -{ - return myErrorStatus; -} -/* -//======================================================================= -// function: Compute -// purpose: -//======================================================================= - void NMTAlgo_Algo::Compute() -{ -} -//======================================================================= -// function: SetCompositeShape -// purpose: -//======================================================================= - void NMTAlgo_Algo::SetCompositeShape(const TopoDS_Shape& aS) -{ - myCompositeShape=aS; -} -//======================================================================= -// function: CompositeShape -// purpose: -//======================================================================= - const TopoDS_Shape& NMTAlgo_Algo::CompositeShape()const -{ - return myCompositeShape; -} -*/ diff --git a/src/NMTAlgo/NMTAlgo_Algo.hxx b/src/NMTAlgo/NMTAlgo_Algo.hxx deleted file mode 100644 index dc73c1088..000000000 --- a/src/NMTAlgo/NMTAlgo_Algo.hxx +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Algo_HeaderFile -#define _NMTAlgo_Algo_HeaderFile - -#ifndef _NMTTools_PDSFiller_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -class NMTTools_DSFiller; -class TopoDS_Shape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Algo { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT void SetFiller(const NMTTools_DSFiller& aDSF) ; -Standard_EXPORT const NMTTools_DSFiller& Filler() const; -Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; -Standard_EXPORT virtual void Clear() ; -Standard_EXPORT const TopoDS_Shape& Shape() const; -Standard_EXPORT Standard_Boolean IsDone() const; -Standard_EXPORT Standard_Integer ErrorStatus() const; - - - - - -protected: - - // Methods PROTECTED - // -Standard_EXPORT NMTAlgo_Algo(); -Standard_EXPORT virtual ~NMTAlgo_Algo(); - - - // Fields PROTECTED - // -NMTTools_PDSFiller myDSFiller; -TopoDS_Shape myShape; -Standard_Boolean myIsDone; -Standard_Boolean myIsComputed; -Standard_Integer myErrorStatus; -Standard_Integer myDraw; - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Algo.ixx b/src/NMTAlgo/NMTAlgo_Algo.ixx deleted file mode 100644 index cb4c135df..000000000 --- a/src/NMTAlgo/NMTAlgo_Algo.ixx +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include diff --git a/src/NMTAlgo/NMTAlgo_Algo.jxx b/src/NMTAlgo/NMTAlgo_Algo.jxx deleted file mode 100644 index fc8787025..000000000 --- a/src/NMTAlgo/NMTAlgo_Algo.jxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTTools_DSFiller_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Algo_HeaderFile -#include -#endif diff --git a/src/NMTAlgo/NMTAlgo_Builder.cdl b/src/NMTAlgo/NMTAlgo_Builder.cdl deleted file mode 100644 index 9527e0a21..000000000 --- a/src/NMTAlgo/NMTAlgo_Builder.cdl +++ /dev/null @@ -1,98 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo_Builder.cdl --- Created: Tue Jan 27 15:09:45 2004 --- Author: Peter KURNEV - - -class Builder from NMTAlgo - inherits Algo from NMTAlgo - - ---Purpose: - -uses - Shape from TopoDS, - Face from TopoDS, - Edge from TopoDS, - IndexedMapOfShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools, - IndexedDataMapOfShapeShape from TopTools, - Image from BRepAlgo, - DSFiller from NMTTools ---raises - -is - Create - returns Builder from NMTAlgo; - ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Builder();" - - Clear (me:out) - is redefined; - - ComputeWithFiller(me:out; - aDSF: DSFiller from NMTTools) - is redefined; - - FillImagesEdges (me:out) - is protected; - - FillIn2DParts (me:out) - is protected; - - FillImagesFaces (me:out) - is protected; - - FillSDFaces (me:out) - is protected; - - --- Queries - SplitVertices (me:out) - is protected; - - IsSectionEdge (me; - E : Edge from TopoDS) - returns Boolean from Standard - is protected; - - HasSameDomainF(me; - F : Face from TopoDS) - returns Boolean from Standard - is protected; - - IsSameDomainF(me; - F1 : Face from TopoDS; - F2 : Face from TopoDS) - returns Boolean from Standard - is protected; - -fields - - myImagesEdges : Image from BRepAlgo is protected; - myImagesFaces : Image from BRepAlgo is protected; - - myQueryShapes : IndexedMapOfShape from TopTools is protected; - -- - myIn2DParts : IndexedDataMapOfShapeListOfShape from TopTools is protected; - mySectionParts : IndexedDataMapOfShapeListOfShape from TopTools is protected; - mySDFaces : IndexedDataMapOfShapeShape from TopTools is protected; - -- -end Builder; diff --git a/src/NMTAlgo/NMTAlgo_Builder.cxx b/src/NMTAlgo/NMTAlgo_Builder.cxx deleted file mode 100644 index 07128bb63..000000000 --- a/src/NMTAlgo/NMTAlgo_Builder.cxx +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Inter3d.cxx -// Created: Tue Jan 27 15:14:13 2004 -// Author: Peter KURNEV -// -// -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -//======================================================================= -// function: NMTAlgo_Inter3d::NMTAlgo_Inter3d() -// purpose: -//======================================================================= - NMTAlgo_Builder::NMTAlgo_Builder() -: - NMTAlgo_Algo() -{ -} -//======================================================================= -// function: ~NMTAlgo_Builder -// purpose: -//======================================================================= - NMTAlgo_Builder::~NMTAlgo_Builder() -{ - Clear(); -} -//======================================================================= -// function: Clear -// purpose: -//======================================================================= - void NMTAlgo_Builder::Clear() -{ - NMTAlgo_Algo::Clear(); - // - myImagesEdges.Clear(); - myImagesFaces.Clear(); - myIn2DParts.Clear(); - mySectionParts.Clear(); - mySDFaces.Clear(); -} -//======================================================================= -// function: ComputeWithFiller -// purpose: -//======================================================================= - void NMTAlgo_Builder::ComputeWithFiller(const NMTTools_DSFiller& aDSF) -{ - myErrorStatus=0; - myIsDone=Standard_False; - // - SetFiller(aDSF); - // edges - FillImagesEdges(); - // faces - FillIn2DParts(); - FillImagesFaces(); - FillSDFaces(); -} - -//======================================================================= -// function: FillSDFaces -// purpose: -//======================================================================= - void NMTAlgo_Builder::FillSDFaces() -{ - const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); - NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); - BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); - IntTools_Context& aCtx= pPF->ChangeContext(); - // - Standard_Boolean bIsSDF; - Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC; - TopTools_ListIteratorOfListOfShape aItF1, aItF2; - NMTTools_ListOfCoupleOfShape aLCS; - // - mySDFaces.Clear(); - // - // 1. For each FF find among images of faces - // all pairs of same domain faces (SDF) [=> aLCS] - aNbFF=aFFs.Extent(); - for (i=1; i<=aNbFF; ++i) { - BOPTools_SSInterference& aFF=aFFs(i); - aFF.Indices(nF1, nF2); - // - const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); - const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); - // - // if there are no in/on 2D split parts the faces nF1, nF2 - // can not be SDF - const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); - aNbPBInOn=aLPBInOn.Extent(); - if (!aNbPBInOn) { - continue; - } - // - // if there is at least one section edge between faces nF1, nF2 - // they can not be SDF - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbC=aSC.Length(); - if (aNbC) { - continue; - } - // - // the faces are suspected to be SDF. - // Try to find SDF among images of nF1, nF2 - const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); - const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2); - // - aItF1.Initialize(aLF1); - for (; aItF1.More(); aItF1.Next()) { - const TopoDS_Face& aF1x=TopoDS::Face(aItF1.Value()); - // - aItF2.Initialize(aLF2); - for (; aItF2.More(); aItF2.Next()) { - const TopoDS_Face& aF2y=TopoDS::Face(aItF2.Value()); - bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx); - if (bIsSDF) { - NMTTools_CoupleOfShape aCS; - // - aCS.SetShape1(aF1x); - aCS.SetShape2(aF2y); - aLCS.Append(aCS); - } - } - } - }//for (i=1; i<=aNbFF; ++i) - // - aNbC=aLCS.Extent(); - if (!aNbC) { - return; - } - // - // 2. Find Chains - NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC; - // - NMTTools_Tools::FindChains(aLCS, aMC); - // - // 3. Fill the map of SDF mySDFaces - aNbC=aMC.Extent(); - for (i=1; i<=aNbC; ++i) { - const TopoDS_Shape& aF=aMC.FindKey(i); - const TopTools_IndexedMapOfShape& aMSDF=aMC(i); - // - aNbFF=aMSDF.Extent(); - for (j=1; j<=aNbFF; ++j) { - const TopoDS_Shape& aFSD=aMSDF(j); - mySDFaces.Add(aFSD, aF); - } - } - // -} -//======================================================================= -// function: FillImagesFaces -// purpose: -//======================================================================= - void NMTAlgo_Builder::FillImagesFaces() -{ - const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); - NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); - IntTools_Context& aCtx= pPF->ChangeContext(); - // - Standard_Integer i, j, aNb, aNbE; - TopTools_IndexedMapOfShape aMFence, aME; - TColStd_IndexedMapOfInteger aMFP; - // - // 1. Select Faces to process (MFP) - aNb=aDS.NumberOfShapesOfTheObject(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aF=aDS.Shape(i); - if (aF.ShapeType()!=TopAbs_FACE) { - continue; - } - if (aMFence.Contains(aF)) { - continue; - } - aMFence.Add(aF); - // - if (myIn2DParts.Contains(aF)) { - aMFP.Add(i); - continue; - } - // - if (mySectionParts.Contains(aF)) { - aMFP.Add(i); - continue; - } - // - aME.Clear(); - TopExp::MapShapes(aF, TopAbs_EDGE, aME); - // - aNbE=aME.Extent(); - for(j=1; j<=aNbE; ++j) { - const TopoDS_Shape& aE=aME(j); - // - if (myImagesEdges.HasImage(aE)) { - aMFP.Add(i); - break; - } - } - }// for (i=1; i<=aNb; ++i) - // - // 2. ProcessFaces - Standard_Boolean bToReverse, bIsClosed, bIsDegenerated; - Standard_Integer aNbF, nF; - TopoDS_Face aFF; - TopoDS_Edge aSp; - TopExp_Explorer anExp; - TopTools_ListIteratorOfListOfShape aIt; - BRepAlgo_Image aImagesFaces; - TopAbs_Orientation anOriF; - // - aNbF=aMFP.Extent(); - for (i=1; i<=aNbF; ++i) { - nF=aMFP(i); - const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF)); - anOriF=aF.Orientation(); - aFF=aF; - aFF.Orientation(TopAbs_FORWARD); - // - aMFence.Clear(); - // - // 2.1. Fill WES - BOP_WireEdgeSet aWES; - aWES.Initialize(aFF); - // - // 2.1.1. Add Split parts - anExp.Init(aFF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); - // - if (!myImagesEdges.HasImage(aE)) { - aWES.AddStartElement(aE); - continue; - } - // - bIsDegenerated=BRep_Tool::Degenerated(aE); - bIsClosed=BRep_Tool::IsClosed(aE, aF); - // - const TopTools_ListOfShape& aLIE=myImagesEdges.Image(aE); - aIt.Initialize(aLIE); - for (; aIt.More(); aIt.Next()) { - aSp=TopoDS::Edge(aIt.Value()); - // - if (bIsDegenerated) { - aSp.Orientation(aE.Orientation()); - aWES.AddStartElement(aSp); - continue; - } - // - if (bIsClosed){ - if (!aMFence.Contains(aSp)){ - aMFence.Add(aSp); - // - if (!BRep_Tool::IsClosed(aSp, aF)){ - BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF); - } - // - aSp.Orientation(TopAbs_FORWARD); - aWES.AddStartElement(aSp); - // - aSp.Orientation(TopAbs_REVERSED); - aWES.AddStartElement(aSp); - continue; - } - } - // - bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx); - if (bToReverse) { - aSp.Reverse(); - } - aWES.AddStartElement(aSp); - } - } - // - // 2.1.2. Add In2D Parts - if (myIn2DParts.Contains(aF)) { - const TopTools_ListOfShape& aLE=myIn2DParts.FindFromKey(aF); - aIt.Initialize(aLE); - for (; aIt.More(); aIt.Next()) { - aSp=TopoDS::Edge(aIt.Value()); - // - aSp.Orientation(TopAbs_FORWARD); - aWES.AddStartElement(aSp); - // - aSp.Orientation(TopAbs_REVERSED); - aWES.AddStartElement(aSp); - } - } - // - // 2.1.3. Add Section Parts - if (mySectionParts.Contains(aF)) { - const TopTools_ListOfShape& aLE=mySectionParts.FindFromKey(aF); - aIt.Initialize(aLE); - for (; aIt.More(); aIt.Next()) { - aSp=TopoDS::Edge(aIt.Value()); - // - aSp.Orientation(TopAbs_FORWARD); - aWES.AddStartElement(aSp); - // - aSp.Orientation(TopAbs_REVERSED); - aWES.AddStartElement(aSp); - } - } - // - // 2.2. Build images Faces - BOP_FaceBuilder aFB; - // - aFB.SetTreatment(0); // 0-Do Internal Edges - aFB.SetTreatSDScales(0); // what is 0 ?? - // - aFB.Do(aWES); - // - TopTools_ListOfShape aLFR; - // - const TopTools_ListOfShape& aLF=aFB.NewFaces(); - - aIt.Initialize(aLF); - for (; aIt.More(); aIt.Next()) { - TopoDS_Shape& aFR=aIt.Value(); - if (anOriF==TopAbs_REVERSED) { - aFR.Orientation(TopAbs_REVERSED); - } - aLFR.Append(aFR); - } - - // - // 2.3. Collect images Faces - myImagesFaces.Bind(aF, aLFR); - }//for (i=1; i<=aNbF; ++i) -} -//======================================================================= -// function: FillIn2DParts -// purpose: -//======================================================================= - void NMTAlgo_Builder::FillIn2DParts() -{ - const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); - NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); - BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); - BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); - // - Standard_Integer i, j, aNb, nF1, nF2, aNbFF, iFF, nSpIn, nSpSc, aNbCurves; - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; - BOPTools_ListOfPaveBlock aLPBIn, aLPBSc; - BOPTools_ListIteratorOfListOfPaveBlock aItPBIn, aItPBSc; - TopTools_IndexedMapOfShape aMF, aMFence; - TopTools_ListOfShape aLSpIn, aLSpSc; - // - BOP_BuilderTools::DoMap(aFFs, aFFMap); - // - // 1. Collect Splits In 2D (myIn2DParts) and - // Section Edges (mySectionParts) - // for each source face that involved in FF - aNb=aFFMap.Extent(); - for (i=1; i<=aNb; ++i) { - nF1=aFFMap.FindKey(i); - const TopoDS_Shape& aF=aDS.Shape(nF1); - // - if (aMF.Contains(aF)) { - continue; - } - aMF.Add(aF); - // - aLPBIn.Clear(); - aLPBSc.Clear(); - // - const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); - // - aNbFF=aFFIndicesMap.Extent(); - for (j=1; j<=aNbFF; ++j) { - iFF=aFFIndicesMap(j); - BOPTools_SSInterference& aFF=aFFs(iFF); - nF2=aFF.OppositeIndex(nF1); - // - // In 2D - pPF->RealSplitsInFace(0, nF2, nF1, aLPBIn); - // - // Sections - BOPTools_SequenceOfCurves& aSC=aFF.Curves(); - aNbCurves=aSC.Length(); - if (!aNbCurves) { - continue; - } - // - const BOPTools_Curve& aBC=aSC(1); - const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); - // - aItPBSc.Initialize(aLPB); - for (; aItPBSc.More(); aItPBSc.Next()) { - const BOPTools_PaveBlock& aPBSc=aItPBSc.Value(); - aLPBSc.Append(aPBSc); - } - }// for (j=1; j<=aNbFF; ++j) - // - // In 2D Parts - aMFence.Clear(); - // - aLSpIn.Clear(); - aItPBIn.Initialize(aLPBIn); - for (; aItPBIn.More(); aItPBIn.Next()) { - const BOPTools_PaveBlock& aPBR=aItPBIn.Value(); - nSpIn=aPBR.Edge(); - const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn); - if (!aMFence.Contains(aSpIn)){ - aMFence.Add(aSpIn); - aLSpIn.Append(aSpIn); - } - } - myIn2DParts.Add(aF, aLSpIn); - // - // Section Parts - aLSpSc.Clear(); - aItPBSc.Initialize(aLPBSc); - for (; aItPBSc.More(); aItPBSc.Next()) { - const BOPTools_PaveBlock& aPBSc=aItPBSc.Value(); - nSpSc=aPBSc.Edge(); - const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc); - if (!aMFence.Contains(aSpSc)){ - aMFence.Add(aSpSc); - aLSpSc.Append(aSpSc); - } - } - mySectionParts.Add(aF, aLSpSc); - } //for (i=1; i<=aNb; ++i) -} - -//======================================================================= -// function: FillImagesEdges -// purpose: -//======================================================================= - void NMTAlgo_Builder::FillImagesEdges() -{ - const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); - NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); - const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool(); - // - Standard_Integer nE, aNb, aNbSp, nSp; - BOPTools_ListIteratorOfListOfPaveBlock aIt; - TopTools_IndexedMapOfShape aMFence; - TopTools_ListOfShape aLSp; - // - aNb=aDS.NumberOfShapesOfTheObject(); - for (nE=1; nE<=aNb; ++nE) { - const TopoDS_Shape& aE=aDS.Shape(nE); - if (aE.ShapeType()!=TopAbs_EDGE) { - continue; - } - if (aMFence.Contains(aE)) { - continue; - } - aMFence.Add(aE); - // - const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE)); - aNbSp=aLPB.Extent(); - // - if (!aNbSp) {// no splits - //myImagesEdges.Bind(aE, aE); - continue; - } - // - //modified by NIZNHY-PKV Fri Jan 21 17:01:10 2005 f - if (aNbSp==1) { - const BOPTools_PaveBlock& aPB1=aLPB.First(); - const BOPTools_PaveBlock& aPBR1=pPF->RealPaveBlock(aPB1); - nSp=aPBR1.Edge(); - const TopoDS_Shape& aSp1=aDS.Shape(nSp); - if (aSp1.IsSame(aE)) { - continue; - } - } - //modified by NIZNHY-PKV Fri Jan 21 17:01:14 2005 t - // - aLSp.Clear(); - aIt.Initialize(aLPB); - for (; aIt.More(); aIt.Next()) { - const BOPTools_PaveBlock& aPB=aIt.Value(); - const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB); - nSp=aPBR.Edge(); - const TopoDS_Shape& aSp=aDS.Shape(nSp); - aLSp.Append(aSp); - } - myImagesEdges.Bind(aE, aLSp); - } -} -//======================================================================= -// function: SplitVertices -// purpose: -//======================================================================= - void NMTAlgo_Builder::SplitVertices() -{ - const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); - NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); - const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool(); - // - Standard_Integer nE, aNb, aNbSp, nV1, nV2; - BOPTools_ListIteratorOfListOfPaveBlock aIt; - // - myQueryShapes.Clear(); - // - aNb=aDS.NumberOfShapesOfTheObject(); - for (nE=1; nE<=aNb; ++nE) { - const TopoDS_Shape& aE=aDS.Shape(nE); - if (aE.ShapeType()!=TopAbs_EDGE) { - continue; - } - // - const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE)); - aNbSp=aLPB.Extent(); - // - if (!aNbSp) {// no splits - continue; - } - // - aIt.Initialize(aLPB); - for (; aIt.More(); aIt.Next()) { - const BOPTools_PaveBlock& aPB=aIt.Value(); - const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB); - // - nV1=aPBR.Pave1().Index(); - if (aDS.IsNewShape(nV1)) { - const TopoDS_Shape& aV1=aDS.Shape(nV1); - myQueryShapes.Add(aV1); - } - // - nV2=aPBR.Pave2().Index(); - if (aDS.IsNewShape(nV2)) { - const TopoDS_Shape& aV2=aDS.Shape(nV2); - myQueryShapes.Add(aV2); - } - } - } -} -//======================================================================= -// function: IsSectionEdge -// purpose: -//======================================================================= - Standard_Boolean NMTAlgo_Builder::IsSectionEdge(const TopoDS_Edge& aE)const -{ - return myImagesEdges.HasImage(aE); -} -//======================================================================= -// function: IsSameDomainF -// purpose: -//======================================================================= - Standard_Boolean NMTAlgo_Builder::HasSameDomainF(const TopoDS_Face& aF1)const -{ - Standard_Boolean bFlag=Standard_False; - TopTools_ListIteratorOfListOfShape aItF1; - // - const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); - aItF1.Initialize(aLF1); - for (; aItF1.More(); aItF1.Next()) { - const TopoDS_Shape& aF1x=aItF1.Value(); - // - if (mySDFaces.Contains(aF1x)){ - return !bFlag; - } - } - return bFlag; -} -//======================================================================= -// function: IsSameDomainF -// purpose: -//======================================================================= - Standard_Boolean NMTAlgo_Builder::IsSameDomainF(const TopoDS_Face& aF1, - const TopoDS_Face& aF2)const -{ - Standard_Boolean bFlag=Standard_False; - TopTools_ListIteratorOfListOfShape aItF1, aItF2; - // - const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); - const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2); - // - aItF1.Initialize(aLF1); - for (; aItF1.More(); aItF1.Next()) { - const TopoDS_Shape& aF1x=aItF1.Value(); - // - if (!mySDFaces.Contains(aF1x)){ - continue; - } - const TopoDS_Shape& aFSD1x=mySDFaces.FindFromKey(aF1x); - // - aItF2.Initialize(aLF2); - for (; aItF2.More(); aItF2.Next()) { - const TopoDS_Shape& aF2y=aItF2.Value(); - if (!mySDFaces.Contains(aF2y)){ - continue; - } - const TopoDS_Shape& aFSD2y=mySDFaces.FindFromKey(aF2y); - if (aFSD1x.IsSame(aFSD2y)) { - return !bFlag; - } - } - } - return bFlag; -} diff --git a/src/NMTAlgo/NMTAlgo_Builder.hxx b/src/NMTAlgo/NMTAlgo_Builder.hxx deleted file mode 100644 index a5df73c8e..000000000 --- a/src/NMTAlgo/NMTAlgo_Builder.hxx +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Builder_HeaderFile -#define _NMTAlgo_Builder_HeaderFile - -#ifndef _BRepAlgo_Image_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedMapOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedDataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Algo_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class NMTTools_DSFiller; -class TopoDS_Edge; -class TopoDS_Face; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Builder : public NMTAlgo_Algo { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT NMTAlgo_Builder(); -Standard_EXPORT virtual ~NMTAlgo_Builder(); -Standard_EXPORT virtual void Clear() ; -Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; - - - - - -protected: - - // Methods PROTECTED - // -Standard_EXPORT void FillImagesEdges() ; -Standard_EXPORT void FillIn2DParts() ; -Standard_EXPORT void FillImagesFaces() ; -Standard_EXPORT void FillSDFaces() ; -Standard_EXPORT void SplitVertices() ; -Standard_EXPORT Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const; -Standard_EXPORT Standard_Boolean HasSameDomainF(const TopoDS_Face& F) const; -Standard_EXPORT Standard_Boolean IsSameDomainF(const TopoDS_Face& F1,const TopoDS_Face& F2) const; - - - // Fields PROTECTED - // -BRepAlgo_Image myImagesEdges; -BRepAlgo_Image myImagesFaces; -TopTools_IndexedMapOfShape myQueryShapes; -TopTools_IndexedDataMapOfShapeListOfShape myIn2DParts; -TopTools_IndexedDataMapOfShapeListOfShape mySectionParts; -TopTools_IndexedDataMapOfShapeShape mySDFaces; - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Builder.ixx b/src/NMTAlgo/NMTAlgo_Builder.ixx deleted file mode 100644 index 283ec7648..000000000 --- a/src/NMTAlgo/NMTAlgo_Builder.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - - - - diff --git a/src/NMTAlgo/NMTAlgo_Builder.jxx b/src/NMTAlgo/NMTAlgo_Builder.jxx deleted file mode 100644 index f3e4dbe5a..000000000 --- a/src/NMTAlgo/NMTAlgo_Builder.jxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTTools_DSFiller_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Builder_HeaderFile -#include -#endif diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.cdl b/src/NMTAlgo/NMTAlgo_Loop3d.cdl deleted file mode 100644 index 190825523..000000000 --- a/src/NMTAlgo/NMTAlgo_Loop3d.cdl +++ /dev/null @@ -1,87 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- - -class Loop3d from NMTAlgo - - ---Purpose: Builds the shells from a set of faces. - -- Provides methods for comparing faces mutual - -- location. - -uses - Vec from gp, - MapOfOrientedShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools, - Face from TopoDS, - Edge from TopoDS, - ListOfShape from TopTools, - Shape from TopoDS - -is - - Create - returns Loop3d from NMTAlgo ; - - AddConstFaces (me:out; - S : Shape from TopoDS) - ---Purpose: Add faces of as unique faces in the result. - is static; - - AddSectionFaces (me:out; - S : Shape from TopoDS) - ---Purpose: Add faces of as double faces in the result. - is static; - - MakeShells (me:out; - AvoidFacesMap : MapOfOrientedShape from TopTools) - returns ListOfShape from TopTools is static; - ---Purpose: Make and return shells. - -- can contain faces that must not be - -- added to result shells. - ---C++: return const & - - - ---Category: class methods - - IsInside (myclass; E : Edge from TopoDS; - F1, F2 : Face from TopoDS; - CountDot : Boolean from Standard; - Dot : in out Real from Standard; - GoodOri : in out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: check if is inside by edge . - -- if , compute : scalar production of - -- normalized vectors pointing inside faces, and - -- check if faces are oriented well for sewing - - Normal (myclass; E : Edge from TopoDS; - F : Face from TopoDS) - returns Vec from gp; - - -fields - - myNewShells : ListOfShape from TopTools; -- result - - myFaces : ListOfShape from TopTools; - myEFMap : IndexedDataMapOfShapeListOfShape from TopTools; - -end Loop3d; diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.cxx b/src/NMTAlgo/NMTAlgo_Loop3d.cxx deleted file mode 100644 index fd7ebe256..000000000 --- a/src/NMTAlgo/NMTAlgo_Loop3d.cxx +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//using namespace std; -// -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static - TopoDS_Edge FindEinF(const TopoDS_Edge&, const TopoDS_Face&); -static - gp_Vec NextNormal(const TopoDS_Edge&, const TopoDS_Face&); - -//======================================================================= -//function : -//purpose : -//======================================================================= - NMTAlgo_Loop3d::NMTAlgo_Loop3d() -{ -} - -//======================================================================= -//function : AddConstFaces -//purpose : Add faces of as unique faces in the result. -//======================================================================= - void NMTAlgo_Loop3d::AddConstFaces(const TopoDS_Shape& S) -{ - TopExp_Explorer FaceExp(S, TopAbs_FACE); - for (; FaceExp.More(); FaceExp.Next()){ - myFaces.Append( FaceExp.Current() ); - } - TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap); -} - -//======================================================================= -//function : AddSectionFaces -//purpose : Add faces of as double faces in the result. -//======================================================================= - void NMTAlgo_Loop3d::AddSectionFaces(const TopoDS_Shape& S) -{ - AddConstFaces( S ); - AddConstFaces( S.Reversed() ); -} - -//======================================================================= -//function : MakeShells -//purpose : Make and return shells. -// can contain faces that must not be -// added to result shells. -//======================================================================= - const TopTools_ListOfShape& NMTAlgo_Loop3d::MakeShells - (const TopTools_MapOfOrientedShape& AvoidFacesMap) -{ - myNewShells.Clear(); - - BRep_Builder Builder; - TopTools_MapOfShape CheckedEdgesMap; - TopTools_MapOfOrientedShape AddedFacesMap; - - TopTools_ListIteratorOfListOfShape itF (myFaces); - for (; itF.More(); itF.Next()) { - const TopoDS_Shape& FF = itF.Value(); - if (AvoidFacesMap.Contains( FF ) || - ! AddedFacesMap.Add( FF ) ) - continue; - - // make a new shell - TopoDS_Shell Shell; - Builder.MakeShell(Shell); - Builder.Add(Shell,FF); - - // clear the maps from shapes added to previous Shell - TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap); - for (; itEM.More(); itEM.Next()) { - TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key()); - TopTools_ListIteratorOfListOfShape it (FL); - while ( it.More()) { - if (AddedFacesMap.Contains( it.Value())) - FL.Remove( it ); - else - it.Next(); - } - } - CheckedEdgesMap.Clear(); - - - // loop on faces added to Shell; add their neighbor faces to Shell and so on - TopoDS_Iterator itAddedF (Shell); - for (; itAddedF.More(); itAddedF.Next()){ - const TopoDS_Face& F = TopoDS::Face (itAddedF.Value()); - - // loop on edges of F; find a good neighbor face of F by E - TopExp_Explorer EdgeExp(F, TopAbs_EDGE); - for (; EdgeExp.More(); EdgeExp.Next()){ - const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current()); - if (! CheckedEdgesMap.Add( E )) - continue; - - // candidate faces list - const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E); - if (FL.IsEmpty()) - continue; - // select one of neighbors - TopoDS_Face SelF; - if (FL.Extent() == 2) { - if (! F.IsSame( FL.First() )) - SelF = TopoDS::Face( FL.First() ); - else if (!F.IsSame( FL.Last() )) - SelF = TopoDS::Face( FL.Last() ); - } - else { - // check if a face already added to Shell shares E - TopTools_ListIteratorOfListOfShape it (FL); - Standard_Boolean found = Standard_False; - for (; !found && it.More(); it.Next()) - if (F != it.Value()) - found = AddedFacesMap.Contains( it.Value() ); - if (found) - continue; - // select basing on geometrical check - Standard_Boolean GoodOri, inside; - Standard_Real dot, MaxDot = -100; - TopTools_ListOfShape TangFL; // tangent faces - for ( it.Initialize( FL ) ; it.More(); it.Next()) { - const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); - if (NeighborF.IsSame( F )) - continue; - inside = NMTAlgo_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri); - if (!GoodOri) - continue; - if (!inside) - dot = -dot - 3; - if (dot < MaxDot) - continue; - if ( IsEqual( dot, MaxDot)) - TangFL.Append(SelF); - else - TangFL.Clear(); - MaxDot = dot; - SelF = NeighborF; - } - if (!TangFL.IsEmpty()) { - for (it.Initialize( TangFL ); it.More(); it.Next()) { - const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); - if (NMTAlgo_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri)) - SelF = NeighborF; - } - } - } - if (!SelF.IsNull() && - AddedFacesMap.Add( SelF ) && - !AvoidFacesMap.Contains( SelF )) - Builder.Add( Shell, SelF); - - } // loop on edges of F - - } // loop on the faces added to Shell - - // Shell is complete - myNewShells.Append( Shell ); - - } // loop on myFaces - - - // prepare to the next call - myFaces.Clear(); - myEFMap.Clear(); - - return myNewShells; -} -//======================================================================= -//function : Normal -//purpose : -//======================================================================= - gp_Vec NMTAlgo_Loop3d::Normal(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - gp_Vec Norm, V1, V2; - Standard_Real First, Last; - gp_Pnt Ps; - - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); - Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); - - gp_Pnt2d p = C2d->Value( 0.5*(First+Last) ); - Sf->D1(p.X(), p.Y(), Ps, V1, V2); - Norm = V1.Crossed(V2); - - if (F.Orientation() == TopAbs_REVERSED ) - Norm.Reverse(); - - return Norm; -} -//======================================================================= -//function : IsInside -//purpose : check if is inside by edge . -// if , compute : scalar production of -// normalized vectors pointing inside faces, and -// check if faces are oriented well for sewing -//======================================================================= - Standard_Boolean NMTAlgo_Loop3d::IsInside(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Boolean CountDot, - Standard_Real& Dot, - Standard_Boolean& GoodOri) -{ - Standard_Real f, l; - gp_Pnt P; - gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2; - Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); - Curve->D1( 0.5*(f + l), P, Vc2); - TopoDS_Edge E1, E2 = FindEinF (E, F2); - if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse(); - - Nf1 = Normal(E,F1); - Nf2 = Normal(E,F2); - - Standard_Real sin = - Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude(); - Standard_Boolean tangent = sin < 0.001; - - Standard_Boolean inside = 0; - if (tangent) { - E1 = FindEinF (E, F1); - gp_Vec NNf1 = NextNormal(E1,F1); - gp_Vec NNf2 = NextNormal(E2,F2); - Vin2 = NNf2.Crossed(Vc2); - inside = Vin2 * NNf1 < 0; - } - else { - Vin2 = Nf2.Crossed(Vc2); - inside = Vin2 * Nf1 < 0; - } - - if (!CountDot) return inside; - - if (tangent) - Vin2 = Nf2.Crossed(Vc2); - else - E1 = FindEinF (E, F1); - - Vc1 = Vc2; - if (E1.Orientation() != E2.Orientation()) - Vc1.Reverse(); - Vin1 = Nf1.Crossed(Vc1); - - if (tangent) { - Standard_Real N1N2 = Nf1 * Nf2; - GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0; - } - else { - Standard_Real V1N2 = Vin1 * Nf2; - GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0); - } - - Vin1.Normalize(); - Vin2.Normalize(); - - Dot = Vin2 * Vin1; - - return inside; -} -//======================================================================= -//function : NextNormal -//purpose : find normal to F at point a little inside F near the middle of E -//warning : E must be properly oriented in F. -//======================================================================= -gp_Vec NextNormal(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - Standard_Real First, Last; - - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); - Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); - - gp_Pnt2d p; - gp_Vec2d v; - C2d->D1( 0.5*(First+Last), p, v); - if (E.Orientation() != F.Orientation()) - v.Reverse(); - gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F - - Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if - // resolutionUV of compared faces is very different. To have a good result, - //it is necessary to get normal to faces at points equidistant from E in 3D - - p.SetX( p.X() + dir.X()*duv ); - p.SetY( p.Y() + dir.Y()*duv ); - - gp_Pnt Ps; - gp_Vec Norm, V1, V2; - Sf->D1( p.X(), p.Y(), Ps, V1, V2); - Norm = V1.Crossed(V2); - - if (F.Orientation() == TopAbs_REVERSED ) - Norm.Reverse(); - - return Norm; -} -//======================================================================= -//function : FindEinF -//purpose : find E in F -//======================================================================= -TopoDS_Edge FindEinF(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - TopExp_Explorer expl (F, TopAbs_EDGE); - for (; expl.More(); expl.Next()) - if( E.IsSame( expl.Current() )) - return TopoDS::Edge(expl.Current()); - TopoDS_Edge nullE; - return nullE; -} diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.hxx b/src/NMTAlgo/NMTAlgo_Loop3d.hxx deleted file mode 100644 index b0dfb5adb..000000000 --- a/src/NMTAlgo/NMTAlgo_Loop3d.hxx +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Loop3d_HeaderFile -#define _NMTAlgo_Loop3d_HeaderFile - -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -class TopoDS_Shape; -class TopTools_ListOfShape; -class TopTools_MapOfOrientedShape; -class TopoDS_Edge; -class TopoDS_Face; -class gp_Vec; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Loop3d { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT NMTAlgo_Loop3d(); -Standard_EXPORT void AddConstFaces(const TopoDS_Shape& S) ; -Standard_EXPORT void AddSectionFaces(const TopoDS_Shape& S) ; -Standard_EXPORT const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ; -Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ; -Standard_EXPORT static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -TopTools_ListOfShape myNewShells; -TopTools_ListOfShape myFaces; -TopTools_IndexedDataMapOfShapeListOfShape myEFMap; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.ixx b/src/NMTAlgo/NMTAlgo_Loop3d.ixx deleted file mode 100644 index 97c229d65..000000000 --- a/src/NMTAlgo/NMTAlgo_Loop3d.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - - - - diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.jxx b/src/NMTAlgo/NMTAlgo_Loop3d.jxx deleted file mode 100644 index 02c10b8dd..000000000 --- a/src/NMTAlgo/NMTAlgo_Loop3d.jxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfOrientedShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _gp_Vec_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Loop3d_HeaderFile -#include -#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cdl b/src/NMTAlgo/NMTAlgo_Splitter.cdl deleted file mode 100644 index 48f5dbd6e..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter.cdl +++ /dev/null @@ -1,200 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo_Splitter.cdl --- Created: Tue Jan 27 15:09:45 2004 --- Author: Peter KURNEV - - -class Splitter from NMTAlgo - inherits Builder from NMTAlgo - - ---Purpose: - -uses - Builder from BRep, - ShapeEnum from TopAbs, - Compound from TopoDS, - Face from TopoDS, - Edge from TopoDS, - Shape from TopoDS, - MapOfOrientedShape from TopTools, - IndexedMapOfShape from TopTools, - DataMapOfShapeShape from TopTools, - DataMapOfShapeListOfShape from TopTools, - ListOfShape from TopTools, - MapOfShape from TopTools, - AsDes from BRepAlgo, - Image from BRepAlgo, - - DSFiller from NMTTools - ---raises - -is - Create - returns Splitter from NMTAlgo; - ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Splitter();" - - AddShape (me:out; - S : Shape from TopoDS) - is virtual; - - AddTool (me:out; - S : Shape from TopoDS) - is virtual; - - Compute(me:out) - is virtual; - - Build (me:out; - aLimit:ShapeEnum from TopAbs=TopAbs_SHAPE) - is virtual; - - ComputeWithFiller(me:out; - aDSF: DSFiller from NMTTools) - is redefined; - -----vv - KeepShapesInside (me:out; - S : Shape from TopoDS); - ---Purpose: remove shapes that are outside of S from result. - -- S should be an object shape. - ---Warning: call it after Build() - - RemoveShapesInside (me:out; - S : Shape from TopoDS); - ---Purpose: remove shapes that are inside S from result. - -- S should be an object shape. - ---Warning: call it after Build() - - Modified(me:out; - S : Shape from TopoDS) - returns ListOfShape from TopTools; - ---Purpose: Returns the list of shapes modified from the shape . - ---C++: return const & - ---Level: Public - - Generated(me:out; - S : Shape from TopoDS) - returns ListOfShape from TopTools; - ---Purpose: Returns the list of shapes generated from the shape . - ---C++: return const & - ---Level: Public - - IsDeleted (me:out; - S : Shape from TopoDS) - returns Boolean from Standard; -----^^ - - Clear (me:out) - is redefined; - - SourceShapes(me) - returns ListOfShape from TopTools; - ---C++: return const & - - FillResult(me:out) - is protected; - - FillImageShape(me:out) - is protected; - - SplittedFaces (me:out) - is protected; - - SplittedWires (me:out) - is protected; - - SplitsAndSections (me:out) - is protected; - - ShellsAndSolids(me:out) - is protected; - - MakeShells(me:out; - aS :Shape from TopoDS; - aLNS:out ListOfShape from TopTools) - is protected; - - MakeSolids (me:out; - Solid : Shape from TopoDS; - Shells: out ListOfShape from TopTools) - is protected; - - FindFacesInside (me:out; - S : Shape from TopoDS; - CheckClosed : Boolean from Standard= Standard_False; - All : Boolean from Standard= Standard_False) - returns Shape from TopoDS - is protected; - - IsInside (myclass; - S1,S2 : Shape from TopoDS) - returns Boolean from Standard is protected; - ---Purpose: Return True if the first vertex of S1 inside S2. - -- If S1.IsNull(), check infinite point against S2. - - GetOriginalShape(me; - aShape : Shape from TopoDS) - returns Shape from TopoDS - is protected; - ---modified by NIZNHY-PKV Tue Feb 1 10:24:39 2005f - FindImage(me:out; - aS : Shape from TopoDS; - aLIms: out ListOfShape from TopTools) - is protected; ---modified by NIZNHY-PKV Tue Feb 1 10:24:47 2005t - -fields - myDoneStep : ShapeEnum from TopAbs is protected; -- rebuilt level - myBuilder : Builder from BRep is protected; - - myListShapes : ListOfShape from TopTools is protected; -- object shapes - myMapFaces : MapOfShape from TopTools is protected; -- object faces - myMapTools : MapOfShape from TopTools is protected; -- tool faces - myEqualEdges : MapOfShape from TopTools is protected; -- equal splits - myNewSection : MapOfShape from TopTools is protected; -- new secton edges - myClosedShapes : MapOfShape from TopTools is protected; - myWrappingSolid: MapOfShape from TopTools is protected; -- solids having other shapes inside - myFaceShapeMap : DataMapOfShapeShape from TopTools is protected; -- to find a shape by face - - myInternalFaces: DataMapOfShapeShape from TopTools is protected; -- shape and its internal faces - myIntNotClFaces: DataMapOfShapeShape from TopTools is protected; -- internal but not closed - - myImageShape : Image from BRepAlgo is protected; - - -- avoid rebuilding twice commont part of solids - myAddedFacesMap: MapOfOrientedShape from TopTools is protected; - --***-- - mySourceShapes : ListOfShape from TopTools is protected; - myLimit : ShapeEnum from TopAbs is protected; - myToolShapes : MapOfShape from TopTools is protected; - myObjShapes : MapOfShape from TopTools is protected; - myMapSIFC : DataMapOfShapeShape from TopTools is protected; -----vv - myGenerated : ListOfShape from TopTools is protected; - --modified by NIZNHY-PKV Mon Jan 24 09:45:10 2005f - myModifiedFaces: DataMapOfShapeListOfShape from TopTools is protected; - --modified by NIZNHY-PKV Mon Jan 24 09:45:14 2005t -----^^ -end Splitter; diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cxx b/src/NMTAlgo/NMTAlgo_Splitter.cxx deleted file mode 100644 index fdb6500ea..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter.cxx +++ /dev/null @@ -1,632 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Splitter.cxx -// Created: Thu Jan 29 17:13:03 2004 -// Author: Peter KURNEV -// -// -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -// -#include -#include -#include -#include - - -static - Standard_Boolean isClosed(const TopoDS_Shape& theShape); - -//======================================================================= -//function : NMTAlgo_Spliter::NMTAlgo_Splitter -//purpose : -//======================================================================= - NMTAlgo_Splitter::NMTAlgo_Splitter() -: - NMTAlgo_Builder() -{ - myErrorStatus=0; -} -//======================================================================= -// function: ~NMTAlgo_Splitter -// purpose: -//======================================================================= - NMTAlgo_Splitter::~NMTAlgo_Splitter() -{ - Clear(); - - if (myDSFiller){ - delete myDSFiller; - } -} -//======================================================================= -// function: SourceShapes -// purpose: -//======================================================================= - const TopTools_ListOfShape& NMTAlgo_Splitter::SourceShapes()const -{ - return mySourceShapes; -} -//======================================================================= -//function : Clear -//purpose : -//======================================================================= - void NMTAlgo_Splitter::Clear() -{ - NMTAlgo_Builder::Clear(); - // - myListShapes.Clear(); - myMapFaces.Clear(); - myMapTools.Clear(); - myClosedShapes.Clear(); - myEqualEdges.Clear(); - myNewSection.Clear(); - myWrappingSolid.Clear(); - myFaceShapeMap.Clear(); - myInternalFaces.Clear(); - myIntNotClFaces.Clear(); - // - myImageShape.Clear(); - myAddedFacesMap.Clear(); - // - myDoneStep = TopAbs_SHAPE; - myIsComputed=Standard_False; - mySourceShapes.Clear(); - myObjShapes.Clear(); - myToolShapes.Clear(); - myMapSIFC.Clear(); - //modified by NIZNHY-PKV Mon Jan 24 09:47:37 2005f - myModifiedFaces.Clear(); - //modified by NIZNHY-PKV Mon Jan 24 09:47:41 2005t - myErrorStatus=0; -} -//======================================================================= -//function : AddShape -//purpose : add object Shape to be splited -//======================================================================= - void NMTAlgo_Splitter::AddShape(const TopoDS_Shape& aS) -{ - myErrorStatus=0; - if (myIsComputed) { - // DS is already computed - myErrorStatus=100; - return; - } - // - if (aS.IsNull()){ - // Null shape is not allowed here - myErrorStatus=101; - return; - } - // - TopAbs_ShapeEnum aType=aS.ShapeType(); - // - if (aType < TopAbs_SOLID) { - // compound or compsolid - TopoDS_Iterator it (aS); - for (; it.More(); it.Next()) { - const TopoDS_Shape& aSS=it.Value(); - AddShape(aSS); - // to know compound by shape - myFaceShapeMap.Bind(aSS, aS); - } - return; - } - //--- - myObjShapes.Add(aS); - mySourceShapes.Append(aS); - //--- - // - TopExp_Explorer exp(aS, TopAbs_FACE); - if (!exp.More()) { - // do not split edges and vertices - return; - } - // not to add twice the same S - Standard_Integer nbFacesBefore = myMapFaces.Extent(); - // - for (; exp.More(); exp.Next()) { - const TopoDS_Shape& aFace = exp.Current(); - if (!myFaceShapeMap.IsBound(aFace)) { - // keep shape of tool face added as object - myFaceShapeMap.Bind(aFace, aS); - } - if (myMapFaces.Add(aFace)){ - myImagesFaces.SetRoot(aFace); - } - } - // - if (nbFacesBefore == myMapFaces.Extent()){ - return; - } - // solids must be processed before all - if (aType==TopAbs_SOLID){ - myListShapes.Prepend(aS); - } - else{ - myListShapes.Append(aS); - } - if (isClosed(aS)){ - myClosedShapes.Add(aS); - } -} -//======================================================================= -//function : AddTool -//purpose : add cutting tool that will _NOT_ be in result -//======================================================================= - void NMTAlgo_Splitter::AddTool(const TopoDS_Shape& aS) -{ - myErrorStatus=0; - if (myIsComputed) { - // DS is already computed - myErrorStatus=100; - return; - } - // - if (aS.IsNull()){ - // Null shape is not allowed here - myErrorStatus=101; - return; - } - // - TopAbs_ShapeEnum aType=aS.ShapeType(); - - if (aType < TopAbs_SOLID) { // compound or compsolid - TopoDS_Iterator it (aS); - for (; it.More(); it.Next()) { - const TopoDS_Shape& aSS=it.Value(); - AddTool(aSS); - myFaceShapeMap.Bind(aSS, aS); // to know compound by shape - } - return; - } - //--- - myToolShapes.Add(aS); - mySourceShapes.Append(aS); - //--- - // - TopExp_Explorer exp(aS, TopAbs_FACE); - for (; exp.More(); exp.Next()) { - const TopoDS_Shape& aFace = exp.Current(); - myMapTools.Add(aFace); - myFaceShapeMap.Bind(aFace, aS); - } - // - // solids must be processed before all - if (aType==TopAbs_SOLID){ - myListShapes.Prepend(aS); - } - else{ - myListShapes.Append(aS); - } - // - if (isClosed(aS)) { - myClosedShapes.Add(aS); - } -} -//======================================================================= -// function: Compute -// purpose: -//======================================================================= - void NMTAlgo_Splitter::Compute() -{ - if (!mySourceShapes.Extent()){ - // No source shapes to treat - myErrorStatus=103; - return; - } - // - BRep_Builder aBB; - TopoDS_Compound aCS; - TopTools_ListIteratorOfListOfShape aIt; - // - aBB.MakeCompound(aCS); - // - aIt.Initialize(mySourceShapes); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - aBB.Add(aCS, aS); - } - // - NMTTools_DSFiller* pDSF=new NMTTools_DSFiller; - // - pDSF->SetCompositeShape(aCS); - pDSF->Perform(); - // - myIsComputed=Standard_False; - // - NMTAlgo_Splitter::ComputeWithFiller(*pDSF); -} -//======================================================================= -// function: ComputeWithFiller -// purpose: -//======================================================================= - void NMTAlgo_Splitter::ComputeWithFiller(const NMTTools_DSFiller& aDSF) -{ - myErrorStatus=0; - // - if (myIsComputed) { - // DS is already computed - myErrorStatus=100; - return; - } - // - if (!mySourceShapes.Extent()) { - // No source shapes to treat - myErrorStatus=103; - return; - } - // - if (!aDSF.IsDone()) { - // NMTTools_DSFiller failed - myErrorStatus=104; - return; - } - // - NMTAlgo_Builder::ComputeWithFiller(aDSF); - // - myIsComputed=Standard_True; -} -//======================================================================= -//function : Build -//purpose : -//======================================================================= - void NMTAlgo_Splitter::Build(const TopAbs_ShapeEnum aLimit) -{ - myErrorStatus=0; - myLimit=aLimit; - // - if (!myIsComputed){ - myErrorStatus=102;// DS is not computed - return; - } - // - TopoDS_Compound aCShape; - // - myBuilder.MakeCompound(aCShape); - myShape=aCShape; - // - // 1. VERTEX - // - if (myLimit==TopAbs_VERTEX) { - SplitVertices(); - FillResult(); - return; - } - // - // 2. EDGE - if (myLimit==TopAbs_EDGE) { - SplitsAndSections(); - FillResult(); - return; - } - // - // 3. WIRE - FillImageShape(); - // - if (myLimit==TopAbs_WIRE) { - SplittedWires(); - FillResult(); - return; - } - // - // 4. FACE - // - if (myLimit==TopAbs_FACE) { - SplittedFaces(); - FillResult(); - return; - } - // - // 5.6. SHELL / SOLID - ShellsAndSolids(); - BOP_CorrectTolerances::CorrectTolerances(myShape, 0.01); -} -//======================================================================= -// function: SplitsAndSections -// purpose: -//======================================================================= - void NMTAlgo_Splitter::SplitsAndSections() -{ - Standard_Integer i, aNbE, aNbF; - TopTools_ListIteratorOfListOfShape aItLS, aIt; - TopTools_IndexedMapOfShape aME, aMF; - // - myQueryShapes.Clear(); - // - // 1. Splits / no splits - aItLS.Initialize(myListShapes); - for ( ;aItLS.More(); aItLS.Next()) { - const TopoDS_Shape& aS=aItLS.Value(); - // - if (myToolShapes.Contains(aS)) { - continue; // skip tool Shapes - } - // - TopExp::MapShapes(aS, TopAbs_EDGE, aME); - TopExp::MapShapes(aS, TopAbs_FACE, aMF); - } - // - // 1. Splits / no splits - aNbE=aME.Extent(); - for (i=1; i<=aNbE; ++i) { - const TopoDS_Shape& aE=aME(i); - // - if (!myImagesEdges.HasImage(aE)) { - myQueryShapes.Add(aE); - } - else { - const TopTools_ListOfShape& aLSp=myImagesEdges.Image(aE); - // - aIt.Initialize(aLSp); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSp=aIt.Value(); - myQueryShapes.Add(aSp); - } - } - } - // - // 2. Sections - aNbF=aMF.Extent(); - for (i=1; i<=aNbF; ++i) { - const TopoDS_Shape& aF=aMF(i); - if (mySectionParts.Contains(aF)) { - const TopTools_ListOfShape& aLSc=mySectionParts.FindFromKey(aF); - aIt.Initialize(aLSc); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSc=aIt.Value(); - myQueryShapes.Add(aSc); - } - } - } -} -//======================================================================= -// function: SplittedWires -// purpose: -//======================================================================= - void NMTAlgo_Splitter::SplittedWires() -{ - Standard_Integer i, aNbF; - TopoDS_Iterator aIt; - TopTools_IndexedMapOfShape aMF; - // - SplittedFaces(); - // - aMF=myQueryShapes; - myQueryShapes.Clear(); - // - aNbF=aMF.Extent(); - for (i=1; i<=aNbF; ++i) { - const TopoDS_Shape& aF=aMF(i); - aIt.Initialize(aF); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aW=aIt.Value(); - myQueryShapes.Add(aW); - } - } -} -//======================================================================= -// function: SplittedFaces -// purpose: -//======================================================================= - void NMTAlgo_Splitter::SplittedFaces() -{ - TopTools_ListIteratorOfListOfShape aIt; - TopoDS_Iterator aItF; - // - myQueryShapes.Clear(); - // - aIt.Initialize(myListShapes); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - // - if (myToolShapes.Contains(aS)) { - continue; - } - // - const TopoDS_Shape& aFC = myImageShape.Image(aS).First(); - aItF.Initialize(aFC); - for (; aItF.More(); aItF.Next()) { - const TopoDS_Shape& aF=aItF.Value(); - myQueryShapes.Add(aF); - } - } -} -//======================================================================= -//function : FillImageShape -//purpose : -//======================================================================= - void NMTAlgo_Splitter::FillImageShape() -{ - Standard_Integer i, aNbF, iSense; - TopTools_ListIteratorOfListOfShape aItS, aItFI; - TopExp_Explorer aExp; - TopAbs_Orientation aOriFS; - TopoDS_Face aFIx, aFIy; - BRep_Builder aBB; - // - myImageShape.Clear(); - //modified by NIZNHY-PKV Mon Jan 24 09:48:15 2005f - myModifiedFaces.Clear(); - //modified by NIZNHY-PKV Mon Jan 24 09:48:18 2005t - // - aItS.Initialize(myListShapes); - for ( ;aItS.More(); aItS.Next()) { - const TopoDS_Shape& aS=aItS.Value(); - // - myQueryShapes.Clear(); - // - aExp.Init(aS, TopAbs_FACE); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Face& aFS=TopoDS::Face(aExp.Current()); - aOriFS= aFS.Orientation(); - // - if (!myImagesFaces.HasImage(aFS)) { - myQueryShapes.Add(aFS); - //modified by NIZNHY-PKV Mon Jan 24 09:50:42 2005 f - if (!myModifiedFaces.IsBound(aFS)) { - TopTools_ListOfShape aLS; - // - aLS.Append(aFS); - myModifiedFaces.Bind(aFS, aLS); - } - //modified by NIZNHY-PKV Mon Jan 24 09:50:44 2005 t - continue; - } - // - const TopTools_ListOfShape& aLFI=myImagesFaces.Image(aFS); - aItFI.Initialize(aLFI); - for (; aItFI.More(); aItFI.Next()) { - const TopoDS_Face& aFI=TopoDS::Face(aItFI.Value()); - aFIx=aFI; - aFIx.Orientation(aOriFS); - // - if (mySDFaces.Contains(aFIx)) { - const TopoDS_Face& aFSDI=TopoDS::Face(mySDFaces.FindFromKey(aFIx)); - TopoDS_Face aFSDIx=aFSDI; - // - iSense=NMTAlgo_Tools::Sense(aFIx, aFSDIx); - // - if (iSense < 0) { - aFSDIx.Reverse(); - } - myQueryShapes.Add(aFSDIx); - //modified by NIZNHY-PKV Mon Jan 24 09:56:06 2005f - aFIy=aFSDIx; - //modified by NIZNHY-PKV Mon Jan 24 09:56:09 2005t - } - else { - myQueryShapes.Add(aFIx); - //modified by NIZNHY-PKV Mon Jan 24 09:56:06 2005f - aFIy=aFIx; - //modified by NIZNHY-PKV Mon Jan 24 09:56:09 2005t - } - //modified by NIZNHY-PKV Mon Jan 24 09:53:38 2005f - if (!myModifiedFaces.IsBound(aFS)) { - TopTools_ListOfShape aLS; - // - aLS.Append(aFIy); - myModifiedFaces.Bind(aFS, aLS); - } - else { - TopTools_ListOfShape& aLS=myModifiedFaces.ChangeFind(aFS); - aLS.Append(aFIy); - } - //modified by NIZNHY-PKV Mon Jan 24 09:53:43 2005t - } - }//for (; aExp.More(); aExp.Next()) { - // - TopoDS_Compound aCompound; - // - aBB.MakeCompound(aCompound); - // - aNbF=myQueryShapes.Extent(); - for (i=1; i<=aNbF; ++i) { - const TopoDS_Shape& aF=myQueryShapes(i); - aBB.Add(aCompound, aF); - } - // - myImageShape.Bind(aS, aCompound); - }// for ( ;aItS.More(); aItS.Next()) - // - myQueryShapes.Clear(); -} -//======================================================================= -//function : FillResult -//purpose : -//======================================================================= - void NMTAlgo_Splitter::FillResult() -{ - Standard_Integer i, aNb; - // - aNb=myQueryShapes.Extent(); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=myQueryShapes(i); - myBuilder.Add (myShape, aS); - } - BOP_CorrectTolerances::CorrectTolerances(myShape, 0.01); -} -//======================================================================= -//function : isClosed -//purpose : check id a shape is closed, ie is a solid or a closed shell -//======================================================================= - Standard_Boolean isClosed(const TopoDS_Shape& theShape) -{ - Standard_Boolean isClosed = (theShape.ShapeType() == TopAbs_SOLID); - // - if (!isClosed && theShape.ShapeType() == TopAbs_SHELL) { - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, MEF); - for (Standard_Integer i=1; isClosed && i<=MEF.Extent(); ++i) - isClosed = ( MEF(i).Extent() != 1 ); - } - // - return isClosed; -} -// -// myErrorStatus -// -// 100 - DS is already computed -// 101 - Null shape is not allowed here -// 102 - DS is not computed -// 103 - No source shapes to treat -// 104 - NMTTools_DSFiller failed diff --git a/src/NMTAlgo/NMTAlgo_Splitter.hxx b/src/NMTAlgo/NMTAlgo_Splitter.hxx deleted file mode 100644 index 64aa244e4..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter.hxx +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Splitter_HeaderFile -#define _NMTAlgo_Splitter_HeaderFile - -#ifndef _TopAbs_ShapeEnum_HeaderFile -#include -#endif -#ifndef _BRep_Builder_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _BRepAlgo_Image_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfOrientedShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Builder_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class TopoDS_Shape; -class NMTTools_DSFiller; -class TopTools_ListOfShape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Splitter : public NMTAlgo_Builder { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT NMTAlgo_Splitter(); -Standard_EXPORT virtual ~NMTAlgo_Splitter(); -Standard_EXPORT virtual void AddShape(const TopoDS_Shape& S) ; -Standard_EXPORT virtual void AddTool(const TopoDS_Shape& S) ; -Standard_EXPORT virtual void Compute() ; -Standard_EXPORT virtual void Build(const TopAbs_ShapeEnum aLimit = TopAbs_SHAPE) ; -Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; -Standard_EXPORT void KeepShapesInside(const TopoDS_Shape& S) ; -Standard_EXPORT void RemoveShapesInside(const TopoDS_Shape& S) ; -Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& S) ; -Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; -Standard_EXPORT Standard_Boolean IsDeleted(const TopoDS_Shape& S) ; -Standard_EXPORT virtual void Clear() ; -Standard_EXPORT const TopTools_ListOfShape& SourceShapes() const; - - - - - -protected: - - // Methods PROTECTED - // -Standard_EXPORT void FillResult() ; -Standard_EXPORT void FillImageShape() ; -Standard_EXPORT void SplittedFaces() ; -Standard_EXPORT void SplittedWires() ; -Standard_EXPORT void SplitsAndSections() ; -Standard_EXPORT void ShellsAndSolids() ; -Standard_EXPORT void MakeShells(const TopoDS_Shape& aS,TopTools_ListOfShape& aLNS) ; -Standard_EXPORT void MakeSolids(const TopoDS_Shape& Solid,TopTools_ListOfShape& Shells) ; -Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ; -Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& S1,const TopoDS_Shape& S2) ; -Standard_EXPORT TopoDS_Shape GetOriginalShape(const TopoDS_Shape& aShape) const; -Standard_EXPORT void FindImage(const TopoDS_Shape& aS,TopTools_ListOfShape& aLIms) ; - - - // Fields PROTECTED - // -TopAbs_ShapeEnum myDoneStep; -BRep_Builder myBuilder; -TopTools_ListOfShape myListShapes; -TopTools_MapOfShape myMapFaces; -TopTools_MapOfShape myMapTools; -TopTools_MapOfShape myEqualEdges; -TopTools_MapOfShape myNewSection; -TopTools_MapOfShape myClosedShapes; -TopTools_MapOfShape myWrappingSolid; -TopTools_DataMapOfShapeShape myFaceShapeMap; -TopTools_DataMapOfShapeShape myInternalFaces; -TopTools_DataMapOfShapeShape myIntNotClFaces; -BRepAlgo_Image myImageShape; -TopTools_MapOfOrientedShape myAddedFacesMap; -TopTools_ListOfShape mySourceShapes; -TopAbs_ShapeEnum myLimit; -TopTools_MapOfShape myToolShapes; -TopTools_MapOfShape myObjShapes; -TopTools_DataMapOfShapeShape myMapSIFC; -TopTools_ListOfShape myGenerated; -TopTools_DataMapOfShapeListOfShape myModifiedFaces; - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter.ixx b/src/NMTAlgo/NMTAlgo_Splitter.ixx deleted file mode 100644 index 53377eb6e..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - - - - diff --git a/src/NMTAlgo/NMTAlgo_Splitter.jxx b/src/NMTAlgo/NMTAlgo_Splitter.jxx deleted file mode 100644 index f76213b04..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter.jxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _NMTTools_DSFiller_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Splitter_HeaderFile -#include -#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.cdl b/src/NMTAlgo/NMTAlgo_Splitter1.cdl deleted file mode 100644 index 8449ca340..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter1.cdl +++ /dev/null @@ -1,92 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo_Splitter1.cdl --- Created: Wed Feb 11 14:23:25 2004 --- Author: Peter KURNEV - - -class Splitter1 from NMTAlgo - inherits Splitter from NMTAlgo - - ---Purpose: - -uses - ShapeEnum from TopAbs, - Shape from TopoDS, - DataMapOfShapeInteger from TopTools - ---raises - -is - Create - returns Splitter1 from NMTAlgo; - ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Splitter1();" - - Clear (me:out) - is redefined; - - AddShape (me:out; - aS : Shape from TopoDS) - is redefined; - - - AddTool(me:out; - aS : Shape from TopoDS) - is redefined; - - - SetMaterial (me:out; - aS : Shape from TopoDS; - aM : Integer from Standard=0); - - SetRemoveWebs(me:out; - bFlag:Boolean from Standard); - - RemoveWebs(me) - returns Boolean from Standard; - - GetMaterialTable(me) - returns DataMapOfShapeInteger from TopTools; - ---C++: return const & - - Build (me:out; - Limit:ShapeEnum from TopAbs=TopAbs_SHAPE) - is redefined; - - -- protected block - TreatSolids (me:out) - is protected; - - TreatWebs (me:out) - is protected; - - RestParts (me:out) - is protected; - - -fields - myRemoveWebs : Boolean from Standard is protected; - myMapSWM : DataMapOfShapeInteger from TopTools is protected; - myMapSWMOut : DataMapOfShapeInteger from TopTools is protected; - myRestParts : Shape from TopoDS is protected; - -end Splitter1; diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.cxx b/src/NMTAlgo/NMTAlgo_Splitter1.cxx deleted file mode 100644 index 0277e0c1c..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter1.cxx +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Splitter1.cxx -// Created: Wed Feb 11 14:26:27 2004 -// Author: Peter KURNEV -// -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : NMTAlgo_Spliter1::NMTAlgo_Splitter1 -//purpose : -//======================================================================= - NMTAlgo_Splitter1::NMTAlgo_Splitter1() -: - NMTAlgo_Splitter() -{ - myRemoveWebs=Standard_False; -} -//======================================================================= -// function: ~NMTAlgo_Splitter1 -// purpose: -//======================================================================= - NMTAlgo_Splitter1::~NMTAlgo_Splitter1() -{ - Clear(); -} -//======================================================================= -//function : Clear -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::Clear() -{ - NMTAlgo_Splitter::Clear(); - // - myRemoveWebs=Standard_False; - myMapSWM.Clear(); - myMapSWMOut.Clear(); -} -//======================================================================= -//function : SetRemoveWebs -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::SetRemoveWebs(const Standard_Boolean bFlag) -{ - myRemoveWebs=bFlag; -} -//======================================================================= -//function : RemoveWebs -//purpose : -//======================================================================= - Standard_Boolean NMTAlgo_Splitter1::RemoveWebs()const -{ - return myRemoveWebs; -} -//======================================================================= -//function : GetMaterialTable -//purpose : -//======================================================================= - const TopTools_DataMapOfShapeInteger& NMTAlgo_Splitter1::GetMaterialTable()const -{ - return myMapSWMOut; -} -//======================================================================= -//function : SetMaterial -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::SetMaterial(const TopoDS_Shape& aS, - const Standard_Integer iMt) -{ - TopExp_Explorer aExp; - // - aExp.Init(aS, TopAbs_SOLID); - for(; aExp.More(); aExp.Next()) { - const TopoDS_Shape& aSd=aExp.Current(); - myMapSWM.Bind(aSd, iMt); - } -} -//======================================================================= -//function : AddShape -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::AddShape(const TopoDS_Shape& aS) -{ - SetMaterial(aS, 0); - NMTAlgo_Splitter::AddShape(aS); -} -//======================================================================= -//function : AddToolWithMaterial -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::AddTool(const TopoDS_Shape& aS) - -{ - SetMaterial(aS, 0); - NMTAlgo_Splitter::AddTool(aS); -} -//======================================================================= -//function : Build -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::Build(const TopAbs_ShapeEnum aLimit) -{ - NMTAlgo_Splitter::Build(aLimit); - // - myMapSWMOut.Clear(); - // - TreatSolids(); - // - if (myRemoveWebs && myMapSWMOut.Extent()) { - RestParts(); - TreatWebs(); - } -} -//======================================================================= -//function : TreatWebs -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::TreatWebs() -{ - Standard_Integer nMt; - TopTools_DataMapOfIntegerListOfShape aMMLS; - TopoDS_Iterator aIt; - TopTools_DataMapIteratorOfDataMapOfShapeInteger aIt2; - TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape aIt1; - TopTools_ListIteratorOfListOfShape aItS; - TopoDS_Compound aCx; - TopoDS_Shape aCSR; - // - aIt2.Initialize(myMapSWMOut); - for (; aIt2.More(); aIt2.Next()) { - const TopoDS_Shape& aS=aIt2.Key(); - nMt=aIt2.Value(); - // - if (aMMLS.IsBound(nMt)){ - TopTools_ListOfShape& aLS=aMMLS.ChangeFind(nMt); - aLS.Append(aS); - } - else { - TopTools_ListOfShape aLS; - aLS.Append(aS); - aMMLS.Bind(nMt, aLS); - } - } - // - myMapSWMOut.Clear(); - myBuilder.MakeCompound(aCx); - // - aIt1.Initialize(aMMLS); - for (; aIt1.More(); aIt1.Next()) { - nMt=aIt1.Key(); - // - TopoDS_Compound aCS; - myBuilder.MakeCompound(aCS); - const TopTools_ListOfShape& aLS=aIt1.Value(); - aItS.Initialize(aLS); - for (; aItS.More(); aItS.Next()) { - const TopoDS_Shape& aS=aItS.Value(); - myBuilder.Add(aCS, aS); - } - // - NMTAlgo_Tools::BreakWebs(aCS, aCSR); - // - aIt.Initialize(aCSR); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - myBuilder.Add(aCx, aS); - // - myMapSWMOut.Bind(aS, nMt); - } - } - // - aIt.Initialize(myRestParts); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - myBuilder.Add(aCx, aS); - } - // - myShape=aCx; -} - -//======================================================================= -//function : RestParts -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::RestParts() -{ - TopoDS_Iterator aIt; - TopoDS_Compound aR; - // - myBuilder.MakeCompound(aR); - // - aIt.Initialize(myShape); - for(; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - if (aS.ShapeType()==TopAbs_SOLID){ - if (myMapSWMOut.IsBound(aS)) { - continue; - } - } - myBuilder.Add(aR, aS); - } - myRestParts=aR; -} -//======================================================================= -//function : TreatSolids -//purpose : -//======================================================================= - void NMTAlgo_Splitter1::TreatSolids() -{ - Standard_Integer i, j, aNbSd, aNbSdx, nMtMax, nMt; - TopAbs_ShapeEnum aType; - TopoDS_Iterator aIt; - TopTools_IndexedMapOfShape aMSo, aMSd; - TopTools_IndexedDataMapOfShapeListOfShape aMFS; - TopTools_ListIteratorOfListOfShape aItS, aItLS; - NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCS; - // - TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); - TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo); - // - aNbSd=aMSo.Extent(); - if (!aNbSd) { - return; - } - // - aItS.Initialize(myListShapes); - for ( ;aItS.More(); aItS.Next()) { - const TopoDS_Shape& aS=aItS.Value(); - // - aType=aS.ShapeType(); - if (aType != TopAbs_SOLID) { - continue; - } - // - if (myToolShapes.Contains(aS)) { - continue; - } - // - if (!myMapSIFC.IsBound(aS)){ - continue; - } - // - aMSd.Clear(); - // - const TopoDS_Shape& aIFC=myMapSIFC.Find(aS); - // - aIt.Initialize(aIFC); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aIF=aIt.Value(); - if (aMFS.Contains(aIF)) { - const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF); - aItLS.Initialize(aLS); - for ( ;aItLS.More(); aItLS.Next()) { - const TopoDS_Shape& aSd=aItLS.Value(); - if (!aMSd.Contains(aSd)) { - aMSd.Add(aSd); - } - } - } - } - // - aNbSd=aMSd.Extent(); - if (!aNbSd) { - //modified by NIZNHY-PKV Thu Dec 23 15:07:46 2004 f - Standard_Boolean bFound; - //modified by NIZNHY-PKV Thu Dec 23 15:07:49 2004 t - TopoDS_Shape aSd; - // - const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); - //modified by NIZNHY-PKV Thu Dec 23 15:08:17 2004 f - //NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); - //aMSd.Add(aSd); - bFound=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); - if (!aSd.IsNull()) { - aMSd.Add(aSd); - } - //modified by NIZNHY-PKV Thu Dec 23 15:09:02 2004 t - } - aMCS.Add(aS, aMSd); - } //for ( ;aItS.More(); aItS.Next()) - // - aMFS.Clear(); - // - aNbSd=aMCS.Extent(); - for (i=1; i<=aNbSd; ++i) { - const TopoDS_Shape& aSd=aMCS.FindKey(i); - const TopTools_IndexedMapOfShape& aMSdx=aMCS(i); - aNbSdx=aMSdx.Extent(); - for (j=1; j<=aNbSdx; ++j) { - const TopoDS_Shape& aSdx=aMSdx(j); - // - if (aMFS.Contains(aSdx)) { - TopTools_ListOfShape& aLS=aMFS.ChangeFromKey(aSdx); - aLS.Append(aSd); - } - else { - TopTools_ListOfShape aLS; - aLS.Append(aSd); - aMFS.Add(aSdx, aLS); - } - } - } - // - // Assign materials values to subsolids - // - myMapSWMOut.Clear(); - // - aNbSdx=aMFS.Extent(); - for (i=1; i<=aNbSdx; ++i) { - const TopoDS_Shape& aSdx=aMFS.FindKey(i); - const TopTools_ListOfShape& aLS=aMFS(i); - aItLS.Initialize(aLS); - for (j=0; aItLS.More(); aItLS.Next(), ++j) { - const TopoDS_Shape& aSd=aItLS.Value(); - // - if (!myMapSWM.IsBound(aSd)){ - continue; - } - // - nMt=myMapSWM.Find(aSd); - if (!j) { - nMtMax=nMt; - continue; - } - if (nMt>nMtMax) { - nMtMax=nMt; - } - } - myMapSWMOut.Bind(aSdx, nMtMax); - } - // -} diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.hxx b/src/NMTAlgo/NMTAlgo_Splitter1.hxx deleted file mode 100644 index c9e733d3e..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter1.hxx +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Splitter1_HeaderFile -#define _NMTAlgo_Splitter1_HeaderFile - -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Splitter_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _TopAbs_ShapeEnum_HeaderFile -#include -#endif -class TopoDS_Shape; -class TopTools_DataMapOfShapeInteger; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Splitter1 : public NMTAlgo_Splitter { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT NMTAlgo_Splitter1(); -Standard_EXPORT virtual ~NMTAlgo_Splitter1(); -Standard_EXPORT virtual void Clear() ; -Standard_EXPORT virtual void AddShape(const TopoDS_Shape& aS) ; -Standard_EXPORT virtual void AddTool(const TopoDS_Shape& aS) ; -Standard_EXPORT void SetMaterial(const TopoDS_Shape& aS,const Standard_Integer aM = 0) ; -Standard_EXPORT void SetRemoveWebs(const Standard_Boolean bFlag) ; -Standard_EXPORT Standard_Boolean RemoveWebs() const; -Standard_EXPORT const TopTools_DataMapOfShapeInteger& GetMaterialTable() const; -Standard_EXPORT virtual void Build(const TopAbs_ShapeEnum Limit = TopAbs_SHAPE) ; - - - - - -protected: - - // Methods PROTECTED - // -Standard_EXPORT void TreatSolids() ; -Standard_EXPORT void TreatWebs() ; -Standard_EXPORT void RestParts() ; - - - // Fields PROTECTED - // -Standard_Boolean myRemoveWebs; -TopTools_DataMapOfShapeInteger myMapSWM; -TopTools_DataMapOfShapeInteger myMapSWMOut; -TopoDS_Shape myRestParts; - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.ixx b/src/NMTAlgo/NMTAlgo_Splitter1.ixx deleted file mode 100644 index 479cf4180..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter1.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - - - - diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.jxx b/src/NMTAlgo/NMTAlgo_Splitter1.jxx deleted file mode 100644 index c804ba376..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter1.jxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Splitter1_HeaderFile -#include -#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter_1.cxx b/src/NMTAlgo/NMTAlgo_Splitter_1.cxx deleted file mode 100644 index d1f77b888..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter_1.cxx +++ /dev/null @@ -1,948 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Splitter_1.cxx -// Created: Mon Feb 2 14:58:54 2004 -// Author: Peter KURNEV -// -// -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -static - void RefineShells(const TopoDS_Shape& , - TopTools_ListOfShape&); -static - void RefineSolids(const TopoDS_Shape& , - TopTools_ListOfShape&); - -static - void GetPlanes (const TopoDS_Edge& anEx, - const TopTools_IndexedDataMapOfShapeListOfShape& anEFMapx, - const TopoDS_Face& aF1, - TopAbs_State& aStPF1); - -//======================================================================= -//function : ShellsAndSolids -//purpose : -//======================================================================= - void NMTAlgo_Splitter::ShellsAndSolids() -{ - Standard_Boolean bMakeSolids; - TopAbs_ShapeEnum aType; - TopTools_ListIteratorOfListOfShape aItS; - TopTools_ListOfShape aLNS; - // - myAddedFacesMap.Clear(); - bMakeSolids=(myLimit==TopAbs_SHAPE || myLimit TopAbs_SHELL) { - continue;//face,wire,... - } - // - aLNS.Clear(); - // - MakeShells (aS, aLNS); - // - if (bMakeSolids && aType==TopAbs_SOLID) { - MakeSolids(aS, aLNS); - } - // - TopTools_ListIteratorOfListOfShape it (aLNS); - for (; it.More(); it.Next()) { - myBuilder.Add (myShape, it.Value()); - } - } - // - // add split faces - aItS.Initialize(myListShapes); - for ( ;aItS.More(); aItS.Next()) { - const TopoDS_Shape& aS=aItS.Value(); - // - aType=aS.ShapeType(); - if (aType!=TopAbs_FACE || myMapTools.Contains(aS)) { - continue; - } - // - const TopoDS_Shape& aCSF=myImageShape.Image(aS).First(); - TopoDS_Iterator itS(aCSF); - for (; itS.More(); itS.Next()){ - const TopoDS_Shape& aF=itS.Value(); - if (!myAddedFacesMap.Contains(aF)){ - myBuilder.Add (myShape, aF); - } - } - } -} -//======================================================================= -//function : MakeShells -//purpose : split S into compound of shells -//======================================================================= -void NMTAlgo_Splitter::MakeShells(const TopoDS_Shape& aS, - TopTools_ListOfShape& aLNS) -{ - NMTAlgo_Loop3d aShellMaker; - // - // get compound of split faces of aS - const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); - aShellMaker.AddConstFaces(aFC); - // - // add split faces inside aS - TopoDS_Shape aIFC; - if (myClosedShapes.Contains(aS)) { - // - // internal faces compound - aIFC=FindFacesInside(aS, Standard_True); - aShellMaker.AddSectionFaces(aIFC); - } - // - aLNS=aShellMaker.MakeShells(myAddedFacesMap); - // - RefineShells(aS, aLNS); - // - // Add faces added to new shell to myAddedFacesMap: - // avoid rebuilding twice common part of 2 solids. - TopTools_ListIteratorOfListOfShape itS(aLNS); - TopExp_Explorer expF; - for (; itS.More(); itS.Next()) { - const TopoDS_Shape& aSh=itS.Value(); - expF.Init (aSh, TopAbs_FACE); - for (; expF.More(); expF.Next()){ - const TopoDS_Shape& aFx=expF.Current(); - myAddedFacesMap.Add (aFx); - } - } -} -//======================================================================= -//function : MakeSolids -//purpose : make solids out of Shells -//======================================================================= -void NMTAlgo_Splitter::MakeSolids(const TopoDS_Shape& theSolid, - TopTools_ListOfShape& theShellList) -{ - // for a solid wrapping other shells or solids without intersection, - // it is necessary to find shells making holes in it - Standard_Boolean isWrapping; - TopTools_ListOfShape aNewSolids; // result - TopTools_ListOfShape aHoleShells; - TopoDS_Shape anInfinitePointShape; - TopTools_DataMapOfShapeShape aInOutMap; - TopTools_ListIteratorOfListOfShape aShellIt, aSolisIt; - // - isWrapping = myWrappingSolid.Contains(theSolid); - if (!isWrapping && !theShellList.IsEmpty()) { - // check if theSolid initially has internal shells - TopoDS_Iterator aShellExp (theSolid); - aShellExp.Next(); - isWrapping = aShellExp.More(); - } - // - aShellIt.Initialize(theShellList); - for ( ; aShellIt.More(); aShellIt.Next()) { - const TopoDS_Shape & aShell = aShellIt.Value(); - // check if a shell is a hole of theSolid - if (isWrapping && IsInside(anInfinitePointShape, aShell)){ - aHoleShells.Append(aShell); - } - else { - // make a solid from a shell - TopoDS_Solid Solid; - myBuilder.MakeSolid( Solid ); - myBuilder.Add (Solid, aShell); - - aNewSolids.Append (Solid); - } - } - // - // find outer a shell most close to each hole shell - aShellIt.Initialize(aHoleShells); - for (; aShellIt.More(); aShellIt.Next()){ - const TopoDS_Shape & aHole = aShellIt.Value(); - // - aSolisIt.Initialize(aNewSolids); - for ( ; aSolisIt.More(); aSolisIt.Next()) { - const TopoDS_Shape & aSolid = aSolisIt.Value(); - // - if (! IsInside(aHole, aSolid)){ - continue; - } - // - if ( aInOutMap.IsBound (aHole)){ - const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); - if ( IsInside( aSolid, aSolid2 )) { - aInOutMap.UnBind( aHole ); - aInOutMap.Bind ( aHole, aSolid ); - } - } - else{ - aInOutMap.Bind (aHole, aSolid); - } - } - // - // add aHole to a solid - if (aInOutMap.IsBound( aHole )){ - TopoDS_Shape & aSolid=aInOutMap(aHole); - myBuilder.Add (aSolid, aHole); - } - } - // - theShellList.Clear(); - // - RefineSolids(theSolid, aNewSolids); - // - theShellList.Append(aNewSolids); -} - -//======================================================================= -//function : FindFacesInside -//purpose : return compound of faces of other shapes that are -// inside . -// is an object shape. -// makes avoid faces that do not form a -// closed shell -// makes return already added faces -//======================================================================= - TopoDS_Shape NMTAlgo_Splitter::FindFacesInside(const TopoDS_Shape& theShape, - const Standard_Boolean CheckClosed, - const Standard_Boolean All) -{ - TopExp_Explorer expl; - TopAbs_State aState; - // - // ================================================ - // check if internal faces have been already found - // ================================================ - if (myInternalFaces.IsBound(theShape)) { - TopoDS_Shape aIntFComp = myInternalFaces.Find (theShape); - TopoDS_Shape aIntRemFComp = myIntNotClFaces.Find (theShape); - - expl.Init( aIntRemFComp, TopAbs_FACE); - if (CheckClosed || !expl.More()){ - return aIntFComp; - } - // - TopoDS_Compound C; - myBuilder.MakeCompound( C ); - // add removed faces - for (; expl.More(); expl.Next()){ - myBuilder.Add( C, expl.Current() ); - } - // add good internal faces - expl.Init( aIntFComp, TopAbs_FACE); - for (; expl.More(); expl.Next()) { - myBuilder.Add( C, expl.Current() ); - } - // - return C; - } - - // =================================== - // get data for internal faces search - // =================================== - // - // compound of split faces of theShape - const TopoDS_Shape& CSF = myImageShape.Image(theShape).First(); - // - TopTools_MapOfShape MSE, MFP; - //xf - TopTools_IndexedMapOfShape aMFCSF; - //xt - TopTools_DataMapOfShapeListOfShape DMSEFP; - TopTools_MapIteratorOfMapOfShape itm; - TopTools_ListOfShape EmptyL; - TopTools_ListIteratorOfListOfShape itl; - TopTools_IndexedDataMapOfShapeListOfShape DMEF; - // - // MSE filling: map of new section edges of CSF - expl.Init(CSF, TopAbs_EDGE); - for (; expl.More(); expl.Next()) { - const TopoDS_Shape& aE = expl.Current() ; - MSE.Add(aE); - } - // - // DMEF: map edge of CSF - faces of CSF - TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); - //xf - TopExp::MapShapes(CSF, TopAbs_FACE, aMFCSF); - //xt - // - // Fill - // 1. MFP - a map of faces to process: map of resulting faces except - // those of theShape; we`ll add to C those of them which are inside CSF - // 2. DMSEFP - edge of MSE => faces of MFP - // - itl.Initialize(myListShapes); - for (;itl.More(); itl.Next()) { - const TopoDS_Shape& aShape = itl.Value(); - // - if ( theShape.IsSame(aShape)) { - continue; - } - // fill maps - // iterate on split faces of aShape - const TopoDS_Shape& CSF1 = myImageShape.Image(aShape).First(); - TopoDS_Iterator itF (CSF1); - for ( ; itF.More(); itF.Next()) { - const TopoDS_Shape& aF1 = itF.Value(); - MFP.Add(aF1); - // iterate on edges of split faces of aShape, - // add to DMSEFP edges that are new - expl.Init(aF1, TopAbs_EDGE); - for (; expl.More(); expl.Next()) { - TopoDS_Shape aE1 = expl.Current(); - if ( MSE.Contains(aE1)) {// section edge - if (!DMSEFP.IsBound(aE1)) { - DMSEFP.Bind(aE1, EmptyL); - } - DMSEFP(aE1).Append(aF1); - } - } - } - }//for (;itl.More(); itl.Next()) - // - // add tool faces... (is absent) - // - // =========================== - // find faces inside theShape - // =========================== - Standard_Boolean sameDom1, sameDom2; - Standard_Boolean skipAlreadyAdded = Standard_False; - Standard_Boolean GoodOri, inside; - Standard_Real dot; - TopTools_ListOfShape KeepFaces; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; - - // iterate on section edges, check faces of other shapes - // sharing section edges and put internal faces to KeepFaces - Mapit.Initialize(DMSEFP); - for (; Mapit.More() ; Mapit.Next()) { - // a new edge of theShape - const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key()); - // - //Standard_Boolean isSectionE=IsSectionEdge(E);//(OrigE); - // - // split faces of other shapes sharing E - TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E); - // - itl.Initialize( LSF ); - while (itl.More()) { - // a split faces of other shape - TopoDS_Face aFace1 = TopoDS::Face(itl.Value()); - // remove aFace1 form DMSEFP and MFP - LSF.Remove( itl ); // == itl.Next(); - if (!MFP.Remove(aFace1)) { - continue; // was not is MFP (i.e already checked) - } - // - // check if aFace1 was already added to 2 shells - if (!All && - myAddedFacesMap.Contains(aFace1) && - myAddedFacesMap.Contains(aFace1.Reversed())) { - skipAlreadyAdded = Standard_True; - } - // - //xf - if (aMFCSF.Contains(aFace1)) { - // the face aFace1 can not be inside CSF - // if CSF contains the aFace1 - continue; - } - //xt - // - TopoDS_Shape anOrigFace = aFace1; - if (myImagesFaces.IsImage(aFace1)){ - anOrigFace = myImagesFaces.Root(aFace1); - } - // - // <- A was here - // - // check that anOrigFace is not same domain with CSF faces it intersects - // - const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E - // - const TopoDS_Shape& origF1 = myImagesFaces.IsImage(FL.First()) ? - myImagesFaces.Root(FL.First()) : FL.First(); - // - const TopoDS_Shape& origF2 = myImagesFaces.IsImage(FL.Last()) ? - myImagesFaces.Root(FL.Last()) : FL.Last(); - // - sameDom1 = anOrigFace.IsSame( origF1 ); - sameDom2 = anOrigFace.IsSame( origF2 ); - // - if (!(sameDom1 || sameDom2) && HasSameDomainF( TopoDS::Face(anOrigFace) )) { - sameDom1 = IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF1)); - if (origF1 == origF2) { - sameDom2 = sameDom1; - } - } - if (sameDom1 && sameDom2){ - continue; - } - // - if (sameDom1 || sameDom2) { - inside = NMTAlgo_Loop3d::IsInside (E, - TopoDS::Face(FL.First()), - TopoDS::Face(FL.Last()), - 1, dot, GoodOri); - if (inside || (dot + Precision::Angular() >= 1.0)) { - continue; // E is convex between origF1 and origF2 or they are tangent - } - } - // - GetPlanes(E, DMEF, aFace1, aState); - if (aState==TopAbs_IN) { - KeepFaces.Append(aFace1); - } - } //while (itl.More()) { - } //for (; Mapit.More() ; Mapit.Next() ) - - // =================================================== - // add not distributed faces connected with KeepFaces - // =================================================== - - // ultimate list of internal faces - TopTools_ListOfShape KeptFaces; - // - // add to MFP not split tool faces as well, they may be connected with - // tool faces interfering with theShape - /* - itm.Initialize(myMapTools); - for (; itm.More(); itm.Next() ) { - const TopoDS_Shape& aToolFace = itm.Key(); - if (!myImageShape.HasImage(aToolFace)){ - MFP.Add (aToolFace); - } - } - */ - // - if (MFP.IsEmpty()) - KeptFaces.Append (KeepFaces); - // - while (!KeepFaces.IsEmpty()) { - // KeepEdges : map of edges of faces kept last time - TopTools_IndexedMapOfShape KeepEdges; - for ( itl.Initialize(KeepFaces); itl.More(); itl.Next() ) { - TopExp::MapShapes( itl.Value(), TopAbs_EDGE, KeepEdges); - KeptFaces.Append( itl.Value() ); - } - // - KeepFaces.Clear(); - // - // keep faces connected with already kept faces by KeepEdges - for ( itm.Initialize(MFP); itm.More(); itm.Next() ) { - const TopoDS_Shape& FP = itm.Key(); - for (expl.Init(FP,TopAbs_EDGE); expl.More(); expl.Next()) { - const TopoDS_Shape& se = expl.Current(); - if (!MSE.Contains(se) && KeepEdges.Contains(se) ) { - KeepFaces.Append(FP); - MFP.Remove(FP); - break; - } - } - } - } - - // =============================================================== - // here MFP contains faces outer of theShape and those of shapes - // which do not interfere with theShape at all and between which - // there may be those wrapped by theShape and whose faces may be - // needed to be returned as well - // =============================================================== - - Standard_Boolean isSolid = (theShape.ShapeType() == TopAbs_SOLID); - if (All || isSolid) // All is for sub-result removal - { - for ( itm.Initialize( MFP ); itm.More(); itm.Next() ) { - TopoDS_Shape aFace = itm.Key(); - - // find a shape aFace originates from - TopoDS_Shape anOrigShape = GetOriginalShape( aFace ); - - // find out if all faces of anOrigShape are not in MFP - // and by the way remove them from MFP - Standard_Boolean isAllOut = Standard_True; - TopoDS_Shape aSplitFaces = anOrigShape; - if (myImageShape.HasImage(anOrigShape)) - aSplitFaces = myImageShape.Image(anOrigShape).First(); - - TopTools_ListOfShape aSplitFaceL; - for (expl.Init( aSplitFaces, TopAbs_FACE ); expl.More(); expl.Next()) - { - const TopoDS_Shape & aSpFace = expl.Current(); - // a tool face which become object has image but the whole tool shape has not - if (myImageShape.HasImage( aSpFace )) - { - TopExp_Explorer exF (myImageShape.Image( aSpFace ).First(), TopAbs_FACE ); - for ( ; exF.More(); exF.Next() ) - { - aSplitFaceL.Append( exF.Current() ); - if ( ! MFP.Remove( exF.Current() )) - isAllOut = Standard_False; - } - } - else - { - aSplitFaceL.Append( aSpFace ); - if ( ! MFP.Remove( aSpFace )) - isAllOut = Standard_False; - } - } - itm.Initialize( MFP ); - if ( !isAllOut ) - continue; - - // classify anOrigShape against theShape - if (IsInside (anOrigShape, theShape)) { - if (isSolid && myClosedShapes.Contains(anOrigShape)) { - // to make a special care at solid reconstruction - myWrappingSolid.Add ( theShape ); - } - // keep faces of an internal shape anOrigShape - KeptFaces.Append( aSplitFaceL ); - } - } - } - - // ==================================================== - // check if kept faces form a shell without free edges - // ==================================================== - - DMEF.Clear(); // edge - kept faces - MFP.Clear(); // reuse it for wrong faces - if (CheckClosed) { - for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) - TopExp::MapShapesAndAncestors(itl.Value(), TopAbs_EDGE, TopAbs_FACE, DMEF); - - Standard_Integer i, nb = DMEF.Extent(); - Standard_Boolean isClosed = Standard_False; - while (!isClosed) { - isClosed = Standard_True; - for (i=1; isClosed && i<=nb; ++i) { - const TopoDS_Shape& E = DMEF.FindKey( i ); - if (! BRep_Tool::Degenerated( TopoDS::Edge( E )) && - ! MSE.Contains( E )) - isClosed = ( DMEF(i).Extent() != 1 ); - } - if (!isClosed) { - const TopoDS_Shape& F = DMEF.FindFromIndex( i-1 ).First(); // bad face - MFP.Add( F ); - // remove bad face from DMEF - for (expl.Init( F, TopAbs_EDGE); expl.More(); expl.Next()) { - const TopoDS_Shape& E = expl.Current(); - TopTools_ListOfShape& FL = DMEF.ChangeFromKey( E ); - for (itl.Initialize( FL ); itl.More(); itl.Next() ) { - if ( F.IsSame( itl.Value() )) { - FL.Remove( itl ); - break; - } - } - } - } - } - } - - // ============== - // make a result - // ============== - - TopoDS_Compound C; - // compound of removed internal faces - TopoDS_Compound CNotCl; - - myBuilder.MakeCompound(C); - myBuilder.MakeCompound(CNotCl); - - // add to compounds - itl.Initialize(KeptFaces); - for (; itl.More(); itl.Next() ) { - TopoDS_Shape & aIntFace = itl.Value(); - // - if (!All && - myAddedFacesMap.Contains(aIntFace) && - myAddedFacesMap.Contains(aIntFace.Reversed())) { - continue; - } - // - if (! MFP.Contains( aIntFace )){ - myBuilder.Add(C, aIntFace); - } - else{ - myBuilder.Add(CNotCl, aIntFace); - } - } - // - if (!skipAlreadyAdded && CheckClosed) { - myInternalFaces.Bind(theShape, C); - myIntNotClFaces.Bind(theShape, CNotCl); - } - // - // - if (!myMapSIFC.IsBound(theShape)) { - TopoDS_Compound aCIF; - myBuilder.MakeCompound(aCIF); - // - itl.Initialize(KeptFaces); - for (; itl.More(); itl.Next() ) { - TopoDS_Shape & aIntFace = itl.Value(); - if (! MFP.Contains(aIntFace )){ - myBuilder.Add(aCIF, aIntFace); - } - } - myMapSIFC.Bind(theShape, aCIF); - } - // - return C; -} -//======================================================================= -//function : IsInside -//purpose : Return True if the first vertex of S1 inside S2. -// If S1.IsNull(), check infinite point against S2. -//======================================================================= -Standard_Boolean NMTAlgo_Splitter::IsInside (const TopoDS_Shape& theS1, - const TopoDS_Shape& theS2) -{ - BRepClass3d_SolidClassifier aClassifier( theS2 ); - // - TopExp_Explorer expl(theS1, TopAbs_VERTEX); - // - if (!expl.More()){ - aClassifier.PerformInfinitePoint( ::RealSmall()); - } - else { - const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); - aClassifier.Perform (BRep_Tool::Pnt( aVertex ), - BRep_Tool::Tolerance( aVertex )); - } - // - return ( aClassifier.State() == TopAbs_IN ); -} -//======================================================================= -//function : GetOriginalShape -//purpose : Return the shape aShape originates from. aShape -// should be a face or more complex result shape -//======================================================================= -TopoDS_Shape NMTAlgo_Splitter::GetOriginalShape(const TopoDS_Shape& theShape) const -{ - TopoDS_Shape anOrigShape; - - TopExp_Explorer expl( theShape, TopAbs_FACE); - if (expl.More()) { - TopoDS_Shape aFace = expl.Current(); - if (myImagesFaces.IsImage( aFace )) - aFace = myImagesFaces.Root( aFace ); - anOrigShape = myFaceShapeMap.Find( aFace ); - } - return anOrigShape; -} -//======================================================================= -//function :RefineShells -//purpose : -//======================================================================= -void RefineShells(const TopoDS_Shape& aS, - TopTools_ListOfShape& aLNS) -{ - Standard_Boolean bFound; - Standard_Integer iS, jS, aNbSOrs, aNbSIms, aNbFOrs, aNbFIms, kFOrs, aNb; - TopTools_ListIteratorOfListOfShape aIt; - TopTools_IndexedMapOfShape aMSOrs, aMSIms, aMFOrs, aMFIms; - TopTools_IndexedDataMapOfShapeShape aMImOr; - TopTools_ListOfShape aLS; - // - TopExp::MapShapes(aS, TopAbs_SHELL, aMSOrs); - aIt.Initialize(aLNS); - for (;aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSh=aIt.Value(); - aMSIms.Add(aSh); - } - // - aNbSOrs=aMSOrs.Extent(); - aNbSIms=aMSIms.Extent(); - // - for (iS=1; iS<=aNbSOrs; ++iS) { - const TopoDS_Shape& aSOr=aMSOrs(iS); - aMFOrs.Clear(); - TopExp::MapShapes(aSOr, TopAbs_FACE, aMFOrs); - aNbFOrs=aMFOrs.Extent(); - // - for (jS=1; jS<=aNbSIms; ++jS) { - const TopoDS_Shape& aSIm=aMSIms(jS); - if (aMImOr.Contains(aSIm)) { - continue; - } - // - aMFIms.Clear(); - TopExp::MapShapes(aSIm, TopAbs_FACE, aMFIms); - aNbFIms=aMFIms.Extent(); - // - if (aNbFIms==aNbFOrs) { - bFound=Standard_True; - for (kFOrs=1; kFOrs<=aNbFOrs; ++kFOrs) { - const TopoDS_Shape& aFOr=aMFOrs(kFOrs); - if (!aMFIms.Contains(aFOr)) { - bFound=Standard_False; - break; //next aSIm - } - } - if (bFound){ - aMImOr.Add(aSIm, aSOr); - break; //next aSOr - } - } //if (aNbFIms==aNbFOrs) - } - } - // - aNb=aMImOr.Extent(); - aIt.Initialize(aLNS); - for (;aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSh=aIt.Value(); - if (aMImOr.Contains(aSh)) { - const TopoDS_Shape& aSOr=aMImOr.FindFromKey(aSh); - aLS.Append(aSOr); - } - else { - aLS.Append(aSh); - } - } - // - aLNS.Clear(); - aLNS.Append(aLS); -} - -//======================================================================= -//function :RefineSolids -//purpose : -//======================================================================= -void RefineSolids(const TopoDS_Shape& aSolidOr, - TopTools_ListOfShape& aLNS) -{ - Standard_Integer aNb, iS, aNbSOrs, aNbSIms; - TopoDS_Shape aSolidIm; - TopTools_IndexedMapOfShape aMSOrs, aMSIms; - // - aNb=aLNS.Extent(); - if (aNb!=1) { - return; - } - // - aSolidIm=aLNS.First(); - - TopExp::MapShapes(aSolidOr, TopAbs_SHELL, aMSOrs); - TopExp::MapShapes(aSolidIm, TopAbs_SHELL, aMSIms); - aNbSOrs=aMSOrs.Extent(); - aNbSIms=aMSIms.Extent(); - if (aNbSOrs!=aNbSIms) { - return; - } - // - for (iS=1; iS<=aNbSOrs; ++iS) { - const TopoDS_Shape& aSOr=aMSOrs(iS); - if (!aMSIms.Contains(aSOr)) { - return; - } - } - // - aLNS.Clear(); - aLNS.Append(aSolidOr); -} -//======================================================================= -//function : GetPlanes -//purpose : -//======================================================================= -void GetPlanes (const TopoDS_Edge& anEx, - const TopTools_IndexedDataMapOfShapeListOfShape& anEFMapx, - const TopoDS_Face& aF1, - TopAbs_State& aStPF1) - -{ - Standard_Boolean bIsAdjExists; - Standard_Real aT, aT1, aT2; - TopAbs_Orientation anOrEx, anOr; - gp_Dir aDNFx1, aDNFx2, aDNF1; - gp_Pnt aPx, aPx1, aPx2, aPF1; - TopoDS_Edge aERight, aSpxSimm; - TopoDS_Face aFx1, aFx2, aFF1; - TopTools_ListIteratorOfListOfShape anIt; - // - // Point on Edge - Handle(Geom_Curve)aC3D =BRep_Tool::Curve(anEx, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - - aC3D->D0(aT, aPx); - // - anOrEx=anEx.Orientation(); - - aSpxSimm=anEx; - if (anOrEx==TopAbs_FORWARD) { - aSpxSimm.Orientation(TopAbs_REVERSED); - } - else if (anOrEx==TopAbs_REVERSED){ - aSpxSimm.Orientation(TopAbs_FORWARD); - } - // - const TopTools_ListOfShape& aLF=anEFMapx.FindFromKey(anEx); - anIt.Initialize(aLF); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aFE=anIt.Value(); - aFx1=TopoDS::Face(aFE); - anOr=BOPTools_Tools3D::Orientation(anEx, aFx1); - if (anOr==anOrEx){ - break; - } - } - // - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (anEx, aFx1, aT, aPx1, aDNFx1); - // - bIsAdjExists=BOPTools_Tools3D::GetAdjacentFace (aFx1, anEx, anEFMapx, aFx2); - if (!bIsAdjExists) { - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aSpxSimm, aFx1, aT, aPx2, aDNFx2); - } - else { - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aSpxSimm, aFx2, aT, aPx2, aDNFx2); - } - // - aFF1=aF1; - aFF1.Orientation(TopAbs_FORWARD); - BOPTools_Tools3D::OrientEdgeOnFace (anEx, aFF1, aERight); - BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aERight, aFF1, aT, aPF1, aDNF1); - // - { - Standard_Real d12, d1, anAlfa12, anAlfa1, aTwoPI; - - aTwoPI=Standard_PI+Standard_PI; - - gp_Vec aVx1(aPx, aPx1); - gp_Dir aDBx1 (aVx1); - gp_Pln aPlnToCompare (aPx, aDNFx1); - - gp_Vec aVx2(aPx, aPx2); - gp_Dir aDBx2 (aVx2); - - anAlfa12=aDBx1.Angle(aDBx2); - d12=BOPTools_Tools3D::SignDistance(aPx2, aPlnToCompare); - if (d12 < 0.) { - anAlfa12=aTwoPI-anAlfa12; - } - - gp_Vec aVF1(aPx, aPF1); - gp_Dir aDBF1 (aVF1); - anAlfa1=aDBx1.Angle(aDBF1); - d1=BOPTools_Tools3D::SignDistance(aPF1, aPlnToCompare); - if (d1 < 0.) { - anAlfa1=aTwoPI-anAlfa1; - } - - aStPF1=TopAbs_OUT; - if (anAlfa1 > anAlfa12) { - aStPF1=TopAbs_IN; - } - } -} - -//modified by NIZNHY-PKV Fri Feb 25 17:00:03 2005t XX -/* - A - // - TopoDS_Shape aFace2; - if ( !isSectionE ) { - while (itl.More()) { - aFace2 = itl.Value(); - // - TopoDS_Shape anOrigFace2 = aFace2; - if (myImagesFaces.IsImage(aFace2)) { - anOrigFace2 = myImagesFaces.Root(aFace2); - } - // - if (!MFP.Contains( aFace2 )) { - LSF.Remove( itl ); - continue; - } - //if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) - if (anOrigFace.IsSame(anOrigFace2)) { - break; - } - itl.Next(); - } - if (itl.More()) { // aFace2 found, remove it from maps - LSF.Remove( itl ); - MFP.Remove(aFace2); - } - else{ - aFace2.Nullify(); - } - itl.Initialize( LSF ); - } - */ diff --git a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx deleted file mode 100644 index f9aa64398..000000000 --- a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx +++ /dev/null @@ -1,680 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Splitter_2.cxx -// Created: Mon Feb 9 15:07:51 2004 -// Author: Igor FEOKTISTOV -// -// -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -//======================================================================= -//function : KeepShapesInside -//purpose : remove shapes that are outside of S from result -//======================================================================= - void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S) -{ - TopoDS_Iterator it; - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - for (it.Initialize( S ); it.More(); it.Next()) - KeepShapesInside( it.Value()); - return; - } - - Standard_Boolean isTool = Standard_False; - if (!myImageShape.HasImage( S )) { - //isTool = CheckTool( S ); - //if (!isTool) return; - return; - } - - // build map of internal faces - TopTools_IndexedMapOfShape MIF; - TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); - TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF ); - - TopoDS_Compound C; - myBuilder.MakeCompound(C); - - TopAbs_ShapeEnum anInternalShapeType = TopAbs_SHAPE; - if (!MIF.IsEmpty()) - { - // leave in the result only those shapes having a face in MIF - for (it.Initialize( myShape ); it.More(); it.Next()) { - const TopoDS_Shape & aResShape = it.Value(); - TopExp_Explorer expResF( aResShape, TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) { - if ( MIF.Contains( expResF.Current())) { - myBuilder.Add( C, aResShape ); - if (aResShape.ShapeType() < anInternalShapeType) - anInternalShapeType = aResShape.ShapeType(); - break; - } - } - } - } - - // may be S was not split by internal faces then it is missing - // in myShape, add it - if (!isTool && - (anInternalShapeType > TopAbs_SOLID || S.ShapeType() > TopAbs_SOLID)) - { - TopTools_IndexedMapOfShape MSF; // map of split faces of S - TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MSF); - - // find a shape having all faces in MSF - for (it.Initialize( myShape ); it.More(); it.Next()) { - TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) { - if (! MSF.Contains( expResF.Current())) - break; - } - if (! expResF.More()) { - myBuilder.Add( C, it.Value() ); - break; - } - } - } - - myShape = C; -} - -//======================================================================= -//function : RemoveShapesInside -//purpose : remove shapes that are inside S from result -//======================================================================= - void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S) -{ - TopoDS_Iterator it; - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - it.Initialize( S ); - for (; it.More(); it.Next()) { - RemoveShapesInside( it.Value()); - } - return; - } - // - Standard_Boolean isTool; - TopoDS_Shape IntFacesComp; - TopoDS_Compound C; - TopTools_IndexedMapOfShape MIF; // map of internal faces - TopTools_MapOfShape RFM; - TopTools_MapIteratorOfMapOfShape itF; - // - isTool=myToolShapes.Contains(S); - //isTool = Standard_False; - if (!myImageShape.HasImage( S )) { - return; - } - // - IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); - // - TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF); - if (MIF.IsEmpty()) { - return; - } - // add to MIF split faces of S - const TopoDS_Shape& aSIm=myImageShape.Image(S).First(); - TopExp::MapShapes(aSIm, TopAbs_FACE, MIF); - // - // leave in the result only those shapes not having all face in MIF - myBuilder.MakeCompound(C); - // - // RFM : faces of removed shapes that encounter once - it.Initialize(myShape); - for (; it.More(); it.Next()) { - TopExp_Explorer expResF; - // - const TopoDS_Shape& aSR=it.Value(); - // - expResF.Init(aSR, TopAbs_FACE); - for (; expResF.More(); expResF.Next()) { - const TopoDS_Shape& aFR=expResF.Current(); - if (!MIF.Contains(aFR)) { - break; - } - } - // - if (expResF.More()) { - // add shape to result - myBuilder.Add(C, aSR); - } - else { - // add faces of a removed shape to RFM - for (expResF.ReInit(); expResF.More(); expResF.Next()) { - const TopoDS_Shape& aF = expResF.Current(); - if (!RFM.Remove(aF)) { - RFM.Add(aF); - } - } - } - }// for (; it.More(); it.Next()) - // - // - TopoDS_Compound aCx; - // - myBuilder.MakeCompound(aCx); - itF.Initialize (RFM); - for (; itF.More(); itF.Next()) { - const TopoDS_Shape& aF=itF.Key(); - myBuilder.Add(aCx, aF); - } - // - if (!isTool) { - // rebuild S, it must remain in the result - Standard_Boolean isClosed = Standard_False; - switch (S.ShapeType()) { - case TopAbs_SOLID : - isClosed = Standard_True; break; - case TopAbs_SHELL: { - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF); - Standard_Integer i; - for (i=1; isClosed && i<=MEF.Extent(); ++i) { - isClosed = ( MEF(i).Extent() != 1 ); - } - break; - } - default: - isClosed = Standard_False; - } - // - if (isClosed) { - // add to a new shape external faces of removed shapes, ie those in RFM - TopoDS_Shell Shell; - myBuilder.MakeShell(Shell); - // exclude redundant internal face with edges encounterd only once - TopTools_IndexedDataMapOfShapeListOfShape MEF; - // - itF.Initialize (RFM); - for ( ; itF.More(); itF.Next()) { - const TopoDS_Shape& aF=itF.Key(); - TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, MEF); - } - // add only faces forming a closed shell - for (itF.Reset() ; itF.More(); itF.Next()) { - const TopoDS_Shape& aF=itF.Key(); - TopExp_Explorer expE (aF, TopAbs_EDGE); - for (; expE.More(); expE.Next()) { - if (MEF.FindFromKey(expE.Current()).Extent() == 1) { - break; - } - } - if (!expE.More()) { - myBuilder.Add( Shell, aF); - } - else { - //int a=0; - } - } - - if (S.ShapeType() == TopAbs_SOLID) { - TopoDS_Solid Solid; - myBuilder.MakeSolid( Solid ); - myBuilder.Add (Solid, Shell); - myBuilder.Add (C, Solid); - } - else { - myBuilder.Add (C, Shell); - } - } // if (isClosed) { - else { - it.Initialize(aSIm); - for (; it.More(); it.Next()) { - myBuilder.Add (C, it.Value()); - } - } - } - // - myShape = C; -} -// -//modified by NIZNHY-PKV Tue Feb 1 16:02:29 2005 f -//======================================================================= -//function : Modified -//purpose : -//======================================================================= -const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S) - -{ - TopAbs_ShapeEnum aType; - // - myGenerated.Clear(); - // - aType=S.ShapeType(); - // - switch (aType) { - case TopAbs_SOLID: - case TopAbs_FACE: - case TopAbs_EDGE: - case TopAbs_VERTEX: - FindImage(S, myGenerated); - break; - - case TopAbs_SHELL: - break; - - case TopAbs_WIRE: - break; - - default: - break; - } - // - return myGenerated; -} -//modified by NIZNHY-PKV Tue Feb 1 16:02:33 2005 t -//======================================================================= -//function : IsDeleted -//purpose : -//======================================================================= -Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S) - -{ - const TopTools_ListOfShape& aL = Modified(S); - if(aL.Extent() != 0) return Standard_False; - - TopTools_MapOfShape aMap; - TopExp_Explorer anExp; - - TopAbs_ShapeEnum aType = S.ShapeType(); - - if(aType == TopAbs_VERTEX || - aType == TopAbs_EDGE || - aType == TopAbs_FACE ) { - - anExp.Init(myShape, aType); - for(; anExp.More(); anExp.Next()) { - if(S.IsSame(anExp.Current())) return Standard_False; - } - - } - - return Standard_True; -} -//======================================================================= -//function : Generated -//purpose : -//======================================================================= -const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S) -{ - myGenerated.Clear(); - TopTools_ListIteratorOfListOfShape it; - TopTools_MapOfShape aMap; - TopExp_Explorer anExp; - Standard_Boolean bCheckVert = Standard_False; - - if(S.ShapeType() == TopAbs_FACE) { - if (mySectionParts.Contains(S)) { - it.Initialize(mySectionParts.FindFromKey(S)); - anExp.Init(myShape, TopAbs_EDGE); - - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - - for (; it.More(); it.Next()) { - if(aMap.Contains(it.Value())) { - myGenerated.Append(it.Value()); - } - } - } - - NMTTools_PaveFiller& aPF = myDSFiller->ChangePaveFiller(); - const NMTDS_ShapesDataStructure& aDS = myDSFiller->DS(); - const BOPTools_PInterferencePool& anIP = aPF.InterfPool(); - - Standard_Integer aNbS = aDS.NumberOfSourceShapes(); - Standard_Integer anIndex = 0, i; - - for(i = 1; i <= aNbS; ++i) { - - const TopoDS_Shape& aS = aDS.Shape(i); - if(S.IsSame(aS)) { - anIndex = i; - break; - } - - } - - if(anIndex == 0) return myGenerated; - if(!anIP->HasInterference(anIndex)) return myGenerated; - - const BOPTools_CArray1OfESInterference& aESs = anIP->ESInterferences(); - Standard_Integer aNbI = aESs.Extent(); - - if(aNbI == 0) return myGenerated; - - for(i = 1; i <= aNbI; ++i) { - - const BOPTools_ESInterference& aES = aESs(i); - Standard_Integer ind1, ind2; - aES.Indices(ind1, ind2); - - if(ind1 == anIndex || ind2 == anIndex) { - - Standard_Integer aNSI = aES.NewShape(); - if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { - myGenerated.Append(aDS.Shape(aNSI)); - bCheckVert = Standard_True; - } - - } - - } - - if(bCheckVert) { - aMap.Clear(); - anExp.Init(myShape, TopAbs_VERTEX); - - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - - it.Initialize(myGenerated); - for (; it.More(); it.Next()) { - - if(it.Value().ShapeType() != TopAbs_VERTEX) continue; - - if(!aMap.Contains(it.Value())) { - myGenerated.Remove(it); - } - - } - } - - return myGenerated; - } - - if(S.ShapeType() == TopAbs_EDGE) { - - NMTTools_PaveFiller& aPF = myDSFiller->ChangePaveFiller(); - const NMTDS_ShapesDataStructure& aDS = myDSFiller->DS(); - const BOPTools_PInterferencePool& anIP = aPF.InterfPool(); - - Standard_Integer aNbS = aDS.NumberOfSourceShapes(); - Standard_Integer anIndex = 0, i; - - for(i = 1; i <= aNbS; ++i) { - - const TopoDS_Shape& aS = aDS.Shape(i); - if(S.IsSame(aS)) { - anIndex = i; - break; - } - - } - - if(anIndex == 0) return myGenerated; - if(!anIP->HasInterference(anIndex)) return myGenerated; - - const BOPTools_CArray1OfEEInterference& aEEs = anIP->EEInterferences(); - Standard_Integer aNbI = aEEs.Extent(); - - for(i = 1; i <= aNbI; ++i) { - - const BOPTools_EEInterference& aEE = aEEs(i); - Standard_Integer ind1, ind2; - aEE.Indices(ind1, ind2); - - if(ind1 == anIndex || ind2 == anIndex) { - - Standard_Integer aNSI = aEE.NewShape(); - if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { - myGenerated.Append(aDS.Shape(aNSI)); - bCheckVert = Standard_True; - } - - } - - } - - const BOPTools_CArray1OfESInterference& aESs = anIP->ESInterferences(); - aNbI = aESs.Extent(); - - for(i = 1; i <= aNbI; ++i) { - - const BOPTools_ESInterference& aES = aESs(i); - Standard_Integer ind1, ind2; - aES.Indices(ind1, ind2); - - if(ind1 == anIndex || ind2 == anIndex) { - - Standard_Integer aNSI = aES.NewShape(); - if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { - myGenerated.Append(aDS.Shape(aNSI)); - bCheckVert = Standard_True; - } - - } - - } - - if(bCheckVert) { - aMap.Clear(); - anExp.Init(myShape, TopAbs_VERTEX); - - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - - it.Initialize(myGenerated); - for (; it.More(); it.Next()) { - - if(!aMap.Contains(it.Value())) { - myGenerated.Remove(it); - } - } - } - return myGenerated; - } - return myGenerated; -} -//modified by NIZNHY-PKV Tue Feb 1 10:26:18 2005f -//======================================================================= -//function : FindImage -//purpose : -//======================================================================= -void NMTAlgo_Splitter::FindImage(const TopoDS_Shape& aS, - TopTools_ListOfShape& aLIms) -{ - TopAbs_ShapeEnum aType; - // - aType=aS.ShapeType(); - // - if (aType==TopAbs_SOLID) { - Standard_Boolean bHasImage, bHasInternalFaces; - Standard_Integer i, aNbSd; - TopTools_IndexedMapOfShape aMSo, aMSd; - TopoDS_Iterator aIt; - TopTools_IndexedDataMapOfShapeListOfShape aMFS; - TopTools_ListIteratorOfListOfShape aItLS; - // - bHasInternalFaces=myMapSIFC.IsBound(aS); - if (bHasInternalFaces){ - TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); - // - const TopoDS_Shape& aIFC=myMapSIFC.Find(aS); - // - aIt.Initialize(aIFC); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aIF=aIt.Value(); - if (aMFS.Contains(aIF)) { - const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF); - // - aItLS.Initialize(aLS); - for (; aItLS.More(); aItLS.Next()) { - const TopoDS_Shape& aSx=aItLS.Value(); - aMSd.Add(aSx); - } - } - } - // - aNbSd=aMSd.Extent(); - if (aNbSd) { - for (i=1; i<=aNbSd; ++i) { - const TopoDS_Shape& aSx=aMSd(i); - if (!aSx.IsSame(aS)) { - aLIms.Append(aSx); - } - } - return; - } - } - // - bHasImage=myImageShape.HasImage(aS); - if (!bHasImage) { - return; - } - // - TopoDS_Shape aSd; - // - TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo); - // - const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); - bHasImage=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); - if (bHasImage) { - if (!aSd.IsSame(aS)) { - aLIms.Append(aSd); - } - } - } //if (aType==TopAbs_SOLID) { - //== - else if (aType==TopAbs_FACE) { - TopTools_MapOfShape aMap; - TopTools_ListIteratorOfListOfShape aIt; - TopExp_Explorer anExp; - // - if (myModifiedFaces.IsBound(aS)) { - anExp.Init(myShape, aType); - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - // - const TopTools_ListOfShape& aLS=myModifiedFaces.Find(aS); - aIt.Initialize(aLS); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aFx=aIt.Value(); - if (!aFx.IsSame(aS)) { - if (aMap.Contains(aFx)) { - aLIms.Append(aFx); - } - } - } - } - } // else if (aType==TopAbs_FACE) - //== - else if (aType==TopAbs_EDGE) { - TopTools_MapOfShape aMap; - TopTools_ListIteratorOfListOfShape aIt; - TopExp_Explorer anExp; - // - if (myImagesEdges.HasImage(aS)) { - anExp.Init(myShape, aType); - for(; anExp.More(); anExp.Next()) { - aMap.Add(anExp.Current()); - } - // - const TopTools_ListOfShape& aLE=myImagesEdges.Image(aS); - aIt.Initialize(aLE); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aEx=aIt.Value(); - if (!aEx.IsSame(aS)) { - if(aMap.Contains(aEx)) { - aLIms.Append(aEx); - } - } - } - } - }// else if (aType==TopAbs_EDGE) - //== - else if (aType==TopAbs_VERTEX) { - Standard_Integer aNbS, anIndex, i, aSDVInd; - TopExp_Explorer anExp; - // - const NMTTools_DSFiller& aDSF = Filler(); - const NMTTools_PaveFiller& aPF = aDSF.PaveFiller(); - const NMTDS_ShapesDataStructure& aDS = aDSF.DS(); - // - aNbS = aDS.NumberOfSourceShapes(); - anIndex = 0; - // - for(i=1; i<=aNbS; ++i) { - const TopoDS_Shape& aSx = aDS.Shape(i); - if(aS.IsSame(aSx)) { - anIndex = i; - break; - } - } - // - if(!anIndex) { - return; - } - // - aSDVInd=aPF.FindSDVertex(anIndex); - if(!aSDVInd) { - return; - } - // - const TopoDS_Shape& aSDV=aDS.Shape(aSDVInd); - // - anExp.Init(myShape, aType); - for(; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aVx=anExp.Current(); - if(aSDV.IsSame(aVx)) { - aLIms.Append(aSDV); - break; - } - } - }// else if (aType==TopAbs_VERTEX) -} -//modified by NIZNHY-PKV Tue Feb 1 10:26:22 2005t - diff --git a/src/NMTAlgo/NMTAlgo_Tools.cdl b/src/NMTAlgo/NMTAlgo_Tools.cdl deleted file mode 100644 index b27b601a1..000000000 --- a/src/NMTAlgo/NMTAlgo_Tools.cdl +++ /dev/null @@ -1,90 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File: NMTAlgo_Tools.cdl --- Created: Fri Jan 30 16:29:14 2004 --- Author: Peter KURNEV - - -class Tools from NMTAlgo - - ---Purpose: - -uses - Orientation from TopAbs, - - Shape from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Shell from TopoDS, - - ListOfShape from TopTools, - IndexedMapOfShape from TopTools ---raises - -is - OrientFacesOnShell (myclass; - aShell: Shell from TopoDS; - aShellNew: out Shell from TopoDS); - - OrientFacesOnShell (myclass; - aF : Face from TopoDS; - aSh : out Shell from TopoDS); - - Orientation(myclass; - aE: Edge from TopoDS; - aF: Face from TopoDS) - returns Orientation from TopAbs; - - Sense (myclass; - aF1: Face from TopoDS; - aF2: Face from TopoDS) - returns Integer from Standard; - - IsInside (myclass; - aS1: Shape from TopoDS; - aS2: Shape from TopoDS) - returns Boolean from Standard; - - MakeShells(myclass; - aFC:Shape from TopoDS; - aLS:out ListOfShape from TopTools); - - MakeSolids(myclass; - aLS:out ListOfShape from TopTools); - - MakeSolids(myclass; - aFC:Shape from TopoDS; - aLS:out ListOfShape from TopTools); - - BreakWebs (myclass; - aS1: Shape from TopoDS; - aS2:out Shape from TopoDS); - - FindImageSolid (myclass; - aFC : Shape from TopoDS; - aMSo : IndexedMapOfShape from TopTools; - aSo : out Shape from TopoDS) - returns Boolean from Standard; - ---fields - -end Tools; diff --git a/src/NMTAlgo/NMTAlgo_Tools.cxx b/src/NMTAlgo/NMTAlgo_Tools.cxx deleted file mode 100644 index d221bc3f4..000000000 --- a/src/NMTAlgo/NMTAlgo_Tools.cxx +++ /dev/null @@ -1,519 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File: NMTAlgo_Tools.cxx -// Created: Fri Jan 30 16:30:45 2004 -// Author: Peter KURNEV -// -// -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - - -//======================================================================= -// function: Sense -// purpose: -//======================================================================= - Standard_Integer NMTAlgo_Tools::Sense (const TopoDS_Face& aF1, - const TopoDS_Face& aF2) -{ - Standard_Integer iSense=0; - gp_Dir aDNF1, aDNF2; - TopoDS_Edge aE1, aE2; - TopExp_Explorer anExp; - // - anExp.Init(aF1, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - aE1=TopoDS::Edge(anExp.Current()); - if (!BRep_Tool::Degenerated(aE1)) { - if (!BRep_Tool::IsClosed(aE1, aF1)) { - break; - } - } - } - // - anExp.Init(aF2, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - aE2=TopoDS::Edge(anExp.Current()); - if (!BRep_Tool::Degenerated(aE2)) { - if (!BRep_Tool::IsClosed(aE2, aF2)) { - if (aE2.IsSame(aE1)) { - iSense=1; - break; - } - } - } - } - // - if (!iSense) { - return iSense; - } - // - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE1, aF1, aDNF1); - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE2, aF2, aDNF2); - // - iSense=BOPTools_Tools3D::SenseFlag(aDNF1, aDNF2); - // - return iSense; -} - -//======================================================================= -// function: OrientFacesOnShell -// purpose: -//======================================================================= - void NMTAlgo_Tools::OrientFacesOnShell (const TopoDS_Face& aF1, - TopoDS_Shell& aSh) -{ - Standard_Integer aNbFSh, iSenseFlag; - gp_Dir aDNF1, aDNF2; - TopExp_Explorer anExp; - TopoDS_Edge aE1, aESh; - TopTools_IndexedDataMapOfShapeListOfShape aMEFSh; - // - anExp.Init(aF1, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - aE1=TopoDS::Edge(anExp.Current()); - if (!BRep_Tool::Degenerated(aE1)) { - break; - } - } - // - BOPTools_Tools3D::GetNormalToFaceOnEdge(aE1, aF1, aDNF1); - // - TopExp::MapShapesAndAncestors(aSh, TopAbs_EDGE, TopAbs_FACE, aMEFSh); - if (aMEFSh.Contains(aE1)) { - const TopTools_ListOfShape& aLFSh=aMEFSh.FindFromKey(aE1); - aNbFSh=aLFSh.Extent(); - if (aNbFSh==1) { - const TopoDS_Face& aFSh=TopoDS::Face(aLFSh.First()); - // - BOPTools_Tools3D::OrientEdgeOnFace(aE1, aFSh, aESh); - BOPTools_Tools3D::GetNormalToFaceOnEdge(aESh, aFSh, aDNF2); - // - iSenseFlag=BOPTools_Tools3D::SenseFlag(aDNF1, aDNF2); - if (iSenseFlag==1) { - return; - } - // - anExp.Init(aSh, TopAbs_FACE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Shape& aFx=anExp.Current(); - TopoDS_Shape *pFx=(TopoDS_Shape *)&aFx; - pFx->Reverse(); - } - } - } -} -//======================================================================= -// function: OrientFacesOnShell -// purpose: -//======================================================================= - void NMTAlgo_Tools::OrientFacesOnShell (const TopoDS_Shell& aShell, - TopoDS_Shell& aShellNew) -{ - Standard_Boolean bIsProcessed1, bIsProcessed2; - Standard_Integer i, aNbE, aNbF, j; - TopAbs_Orientation anOrE1, anOrE2; - - TopTools_IndexedDataMapOfShapeListOfShape aEFMap; - TopTools_IndexedMapOfShape aProcessedFaces; - BRep_Builder aBB; - - aBB.MakeShell(aShellNew); - - TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aEFMap); - - aNbE=aEFMap.Extent(); - // - // One seam edge in aEFMap contains 2 equivalent faces. - for (i=1; i<=aNbE; i++) { - TopTools_ListOfShape& aLF=aEFMap.ChangeFromIndex(i); - - if (aLF.Extent()>1) { - TopTools_ListOfShape aLFTmp; - TopTools_IndexedMapOfShape aFM; - - TopTools_ListIteratorOfListOfShape anIt(aLF); - for (; anIt.More(); anIt.Next()) { - const TopoDS_Shape& aF=anIt.Value(); - if (!aFM.Contains(aF)) { - aFM.Add(aF); - aLFTmp.Append(aF); - } - } - aLF.Clear(); - aLF=aLFTmp; - } - } - // - // Do - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); - - if (BRep_Tool::Degenerated(aE)) { - continue; - } - - const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); - aNbF=aLF.Extent(); - - if (aNbF==2) { - TopoDS_Face& aF1=TopoDS::Face(aLF.First()); - TopoDS_Face& aF2=TopoDS::Face(aLF.Last() ); - - - bIsProcessed1=aProcessedFaces.Contains(aF1); - bIsProcessed2=aProcessedFaces.Contains(aF2); - - if (bIsProcessed1 && bIsProcessed2) { - continue; - } - - if (!bIsProcessed1 && !bIsProcessed2) { - aProcessedFaces.Add(aF1); - aBB.Add(aShellNew, aF1); - - bIsProcessed1=!bIsProcessed1; - } - - // - TopoDS_Face aF1x, aF2x; - - aF1x=aF1; - if (bIsProcessed1) { - j=aProcessedFaces.FindIndex(aF1); - aF1x=TopoDS::Face(aProcessedFaces.FindKey(j)); - } - - aF2x=aF2; - if (bIsProcessed2) { - j=aProcessedFaces.FindIndex(aF2); - aF2x=TopoDS::Face(aProcessedFaces.FindKey(j)); - } - // - - anOrE1=NMTAlgo_Tools::Orientation(aE, aF1x); - anOrE2=NMTAlgo_Tools::Orientation(aE, aF2x); - - if (bIsProcessed1 && !bIsProcessed2) { - - if (anOrE1==anOrE2) { - if (!BRep_Tool::IsClosed(aE, aF1) && - !BRep_Tool::IsClosed(aE, aF2)) { - aF2.Reverse(); - } - } - aProcessedFaces.Add(aF2); - aBB.Add(aShellNew, aF2); - } - - else if (!bIsProcessed1 && bIsProcessed2) { - if (anOrE1==anOrE2) { - if (!BRep_Tool::IsClosed(aE, aF1) && - !BRep_Tool::IsClosed(aE, aF2)) { - aF1.Reverse(); - } - } - aProcessedFaces.Add(aF1); - aBB.Add(aShellNew, aF1); - } - } - } - // - // - for (i=1; i<=aNbE; i++) { - const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); - - if (BRep_Tool::Degenerated(aE)) { - continue; - } - - const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); - aNbF=aLF.Extent(); - if (aNbF!=2) { - TopTools_ListIteratorOfListOfShape anIt(aLF); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); - if (!aProcessedFaces.Contains(aF)) { - aProcessedFaces.Add(aF); - aBB.Add(aShellNew, aF); - } - } - } - } -} -//======================================================================= -//function : Orientation -//purpose : -//======================================================================= - TopAbs_Orientation NMTAlgo_Tools::Orientation(const TopoDS_Edge& anE, - const TopoDS_Face& aF) -{ - TopAbs_Orientation anOr=TopAbs_INTERNAL; - - TopExp_Explorer anExp; - anExp.Init(aF, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); - if (anEF1.IsSame(anE)) { - anOr=anEF1.Orientation(); - break; - } - } - return anOr; -} -//======================================================================= -//function : IsInside -//purpose : Return True if the first vertex of S1 inside S2. -// If S1.IsNull(), check infinite point against S2. -//======================================================================= - Standard_Boolean NMTAlgo_Tools::IsInside (const TopoDS_Shape& theS1, - const TopoDS_Shape& theS2) -{ - BRepClass3d_SolidClassifier aClassifier( theS2 ); - // - TopExp_Explorer expl(theS1, TopAbs_VERTEX); - // - if (!expl.More()){ - aClassifier.PerformInfinitePoint( ::RealSmall()); - } - else { - const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); - aClassifier.Perform (BRep_Tool::Pnt( aVertex ), - BRep_Tool::Tolerance( aVertex )); - } - // - return ( aClassifier.State() == TopAbs_IN ); -} -//======================================================================= -//function : MakeShells -//purpose : -//======================================================================= - void NMTAlgo_Tools::MakeShells (const TopoDS_Shape& aFC, - TopTools_ListOfShape& aLNS) -{ - NMTAlgo_Loop3d aShellMaker; - TopTools_MapOfOrientedShape aMTmp; - // - aShellMaker.AddConstFaces(aFC); - aLNS=aShellMaker.MakeShells(aMTmp); -} -//======================================================================= -//function : MakeSolids -//purpose : -//======================================================================= - void NMTAlgo_Tools::MakeSolids(const TopoDS_Shape& aFC, - TopTools_ListOfShape& theShellList) -{ - NMTAlgo_Tools::MakeShells(aFC, theShellList); - NMTAlgo_Tools::MakeSolids(theShellList); -} -//======================================================================= -//function : MakeSolids -//purpose : -//======================================================================= - void NMTAlgo_Tools::MakeSolids(TopTools_ListOfShape& theShellList) -{ - TopTools_ListOfShape aHoleShells, aNewSolids; - TopoDS_Shape anInfinitePointShape; - TopTools_DataMapOfShapeShape aInOutMap; - TopTools_ListIteratorOfListOfShape aShellIt, aSolisIt; - BRep_Builder aBB; - // - aShellIt.Initialize(theShellList); - for ( ; aShellIt.More(); aShellIt.Next()) { - const TopoDS_Shape & aShell = aShellIt.Value(); - // check if a shell is a hole of theSolid - if (NMTAlgo_Tools::IsInside(anInfinitePointShape, aShell)){ - aHoleShells.Append(aShell); - } - else { - // make a solid from a shell - TopoDS_Solid Solid; - aBB.MakeSolid( Solid ); - aBB.Add (Solid, aShell); - aNewSolids.Append (Solid); - } - } - // - // find outer a shell most close to each hole shell - aShellIt.Initialize(aHoleShells); - for (; aShellIt.More(); aShellIt.Next()){ - const TopoDS_Shape & aHole = aShellIt.Value(); - // - aSolisIt.Initialize(aNewSolids); - for ( ; aSolisIt.More(); aSolisIt.Next()) { - const TopoDS_Shape & aSolid = aSolisIt.Value(); - // - if (! NMTAlgo_Tools::IsInside(aHole, aSolid)){ - continue; - } - // - if ( aInOutMap.IsBound (aHole)){ - const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); - if ( IsInside( aSolid, aSolid2 )) { - aInOutMap.UnBind( aHole ); - aInOutMap.Bind ( aHole, aSolid ); - } - } - else{ - aInOutMap.Bind (aHole, aSolid); - } - } - // - // add aHole to a solid - if (aInOutMap.IsBound( aHole )){ - TopoDS_Shape & aSolid=aInOutMap(aHole); - aBB.Add (aSolid, aHole); - } - } - theShellList.Clear(); - theShellList.Append( aNewSolids ); -} -//======================================================================= -//function : BreakWebs -//purpose : -//======================================================================= - void NMTAlgo_Tools::BreakWebs(const TopoDS_Shape& aCS, - TopoDS_Shape& aCSR) -{ - Standard_Integer i, aNbF, aNbS; - TopTools_IndexedDataMapOfShapeListOfShape aMFS; - TopTools_MapOfShape aMF; - - TopoDS_Compound aFC, aCR; - BRep_Builder aBB; - // - aBB.MakeCompound(aFC); - TopExp::MapShapesAndAncestors(aCS, TopAbs_FACE, TopAbs_SOLID, aMFS); - // - aNbF=aMFS.Extent(); - for (i=1; i<=aNbF; ++i) { - const TopoDS_Shape& aF=aMFS.FindKey(i); - const TopTools_ListOfShape& aLS=aMFS(i); - aNbS=aLS.Extent(); - if (aNbS==2) { - aMF.Add(aF); - } - else { - aBB.Add(aFC, aF); - } - } - // - if (!aMF.Extent()) { - aCSR=aCS; - return; - } - // - TopTools_ListOfShape aLNS; - TopTools_ListIteratorOfListOfShape aItS; - // - NMTAlgo_Tools::MakeShells(aFC, aLNS); - NMTAlgo_Tools::MakeSolids(aLNS); - // - aBB.MakeCompound(aCR); - aItS.Initialize(aLNS); - for ( ;aItS.More(); aItS.Next()) { - const TopoDS_Shape& aS=aItS.Value(); - aBB.Add(aCR, aS); - } - aCSR=aCR; -} -//======================================================================= -//function : FindImageSolid -//purpose : -//======================================================================= - Standard_Boolean NMTAlgo_Tools::FindImageSolid(const TopoDS_Shape& aFC, - const TopTools_IndexedMapOfShape& aMSo, - TopoDS_Shape& aSox) -{ - Standard_Boolean bFound=Standard_False; - Standard_Integer i, j, aNbSo, aNbF, aNbFSo; - TopoDS_Iterator aIt; - TopTools_IndexedMapOfShape aMFC, aMFSo; - // - aIt.Initialize(aFC); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aF=aIt.Value(); - aMFC.Add(aF); - } - // - aNbF=aMFC.Extent(); - aNbSo=aMSo.Extent(); - for (i=1; i<=aNbSo; ++i) { - const TopoDS_Shape& aSo=aMSo(i); - // - bFound=Standard_True; - aMFSo.Clear(); - TopExp::MapShapes(aSo, TopAbs_FACE, aMFSo); - // - aNbFSo=aMFSo.Extent(); - if (aNbFSo!=aNbF) { - bFound=Standard_False; - continue; - } - // - for (j=1; j<=aNbFSo; ++j) { - const TopoDS_Shape& aFSo=aMFSo(j); - if (!aMFC.Contains(aFSo)) { - bFound=Standard_False; - break; - } - } - if (bFound) { - aSox=aSo; - return bFound; - } - } - return bFound; -} diff --git a/src/NMTAlgo/NMTAlgo_Tools.hxx b/src/NMTAlgo/NMTAlgo_Tools.hxx deleted file mode 100644 index d804a886e..000000000 --- a/src/NMTAlgo/NMTAlgo_Tools.hxx +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _NMTAlgo_Tools_HeaderFile -#define _NMTAlgo_Tools_HeaderFile - -#ifndef _TopAbs_Orientation_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class TopoDS_Shell; -class TopoDS_Face; -class TopoDS_Edge; -class TopoDS_Shape; -class TopTools_ListOfShape; -class TopTools_IndexedMapOfShape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class NMTAlgo_Tools { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT static void OrientFacesOnShell(const TopoDS_Shell& aShell,TopoDS_Shell& aShellNew) ; -Standard_EXPORT static void OrientFacesOnShell(const TopoDS_Face& aF,TopoDS_Shell& aSh) ; -Standard_EXPORT static TopAbs_Orientation Orientation(const TopoDS_Edge& aE,const TopoDS_Face& aF) ; -Standard_EXPORT static Standard_Integer Sense(const TopoDS_Face& aF1,const TopoDS_Face& aF2) ; -Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ; -Standard_EXPORT static void MakeShells(const TopoDS_Shape& aFC,TopTools_ListOfShape& aLS) ; -Standard_EXPORT static void MakeSolids(TopTools_ListOfShape& aLS) ; -Standard_EXPORT static void MakeSolids(const TopoDS_Shape& aFC,TopTools_ListOfShape& aLS) ; -Standard_EXPORT static void BreakWebs(const TopoDS_Shape& aS1,TopoDS_Shape& aS2) ; -Standard_EXPORT static Standard_Boolean FindImageSolid(const TopoDS_Shape& aFC,const TopTools_IndexedMapOfShape& aMSo,TopoDS_Shape& aSo) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/NMTAlgo/NMTAlgo_Tools.ixx b/src/NMTAlgo/NMTAlgo_Tools.ixx deleted file mode 100644 index 90f39ea0d..000000000 --- a/src/NMTAlgo/NMTAlgo_Tools.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - - - - diff --git a/src/NMTAlgo/NMTAlgo_Tools.jxx b/src/NMTAlgo/NMTAlgo_Tools.jxx deleted file mode 100644 index 080737905..000000000 --- a/src/NMTAlgo/NMTAlgo_Tools.jxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Shell_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedMapOfShape_HeaderFile -#include -#endif -#ifndef _NMTAlgo_Tools_HeaderFile -#include -#endif diff --git a/src/PARTITION/Makefile.in b/src/PARTITION/Makefile.in deleted file mode 100644 index eee795478..000000000 --- a/src/PARTITION/Makefile.in +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# GEOM PARTITION : partition algorithm -# File : Makefile.in -# Author : Marc Tajchman (CEA) -# Module : GEOM -# $Header$ -# -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@ - - -@COMMENCE@ - -# Libraries targets -LIB = libGEOMPartition.la -LIB_SRC = Partition_Inter2d.cxx \ - Partition_Inter3d.cxx \ - Partition_Loop2d.cxx \ - Partition_Loop3d.cxx \ - Partition_Spliter.cxx - -LIB_CLIENT_IDL = -LIB_SERVER_IDL = - -# header files -EXPORT_HEADERS = Partition_Spliter.hxx \ - Partition_Inter3d.hxx - -# idl files -EXPORT_IDLS= - - -CPPFLAGS += $(OCC_INCLUDES) $(KERNEL_CXXFLAGS) -CXXFLAGS += $(OCC_CXXFLAGS) $(KERNEL_CXXFLAGS) -LDFLAGS += $(CAS_LDPATH) -lTKBool $(KERNEL_LDFLAGS) - -%_moc.cxx: %.h - $(MOC) $< -o $@ - -@CONCLUDE@ diff --git a/src/PARTITION/Partition.cdl b/src/PARTITION/Partition.cdl deleted file mode 100644 index 1f4c8ed30..000000000 --- a/src/PARTITION/Partition.cdl +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -package Partition - -uses - TopoDS, - TopTools, - TopAbs, - BRepAlgo, - BRep, - gp -is - class Spliter; - class Inter3d; - class Inter2d; - class Loop2d; - class Loop3d; - -end Partition; diff --git a/src/PARTITION/Partition_Inter2d.cdl b/src/PARTITION/Partition_Inter2d.cdl deleted file mode 100644 index 31ed37847..000000000 --- a/src/PARTITION/Partition_Inter2d.cdl +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Inter2d.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -class Inter2d from Partition - - ---Purpose: Computes the intersections between edges on a face - -- stores result is SD as AsDes from BRepAlgo. - -uses - AsDes from BRepAlgo, - Edge from TopoDS, - Face from TopoDS, - Vertex from TopoDS, - MapOfShape from TopTools, - Real from Standard, - ListOfShape from TopTools - -is - CompletPart2d(myclass ; AsDes : mutable AsDes from BRepAlgo; - F : Face from TopoDS; - NewEdges : MapOfShape from TopTools); - - ---Purpose: Computes the intersections between the edges stored - -- is AsDes as descendants of . Intersections is computed - -- between two edges if one of them is bound in NewEdges. - - - FindEndVertex(myclass; VertList : ListOfShape from TopTools; - f,l : Real from Standard; - E : Edge from TopoDS; - First : out Boolean from Standard; - DU : out Real from Standard) - returns Vertex from TopoDS; - ---Purpose: Returns a vertex from having parameter on - -- most close to or . is True if - -- found vertex is closer to . returns parameter - -- difference. - - AddVonE(myclass; V : Vertex from TopoDS; - E1,E2 : Edge from TopoDS; - AsDes : mutable AsDes from BRepAlgo; - F: Face from TopoDS) - returns Vertex from TopoDS; - ---Purpose: Put V in AsDes as intersection of E1 and E2. - -- Check that vertex equal to V already exists on one - -- of edges, in such a case, V is not added but - -- existing vertex is updated to be on E1 and E2 and - -- is returned insead of V. - -- Optional F is a face E1 and E2 are on. If F is - -- provided, it is used to find new vertices on E1 - -- and E2 resulting from intersection of new edges on - -- the two other faces the F interferes with and - -- through which E1 and E2 pass too. This helps to - -- avoid small edges. - - - GetTolerance(myclass; theV : Vertex from TopoDS; - theU : Real from Standard; - theE : Edge from TopoDS; - theAsDes : AsDes from BRepAlgo) - returns Real from Standard; - ---Purpose: Returns tolerance theV must have atfer its - -- addition to theE with theU parameter. theAsDes is - -- used to find pcurves of theE - -end Inter2d; - diff --git a/src/PARTITION/Partition_Inter2d.cxx b/src/PARTITION/Partition_Inter2d.cxx deleted file mode 100644 index 4469bb5b8..000000000 --- a/src/PARTITION/Partition_Inter2d.cxx +++ /dev/null @@ -1,673 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter2d.cxx -// Author : Benedicte MARTIN -// Module : GEOM -// $Header$ -// -#include "Partition_Inter2d.ixx" - -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEB -static Standard_Boolean TestEdges = 0; -static Standard_Integer NbF2d = 0; -static Standard_Integer NbE2d = 0; -#endif - -using namespace std; - -//======================================================================= -//function : getOtherShape -//purpose : -//======================================================================= - -static TopoDS_Shape getOtherShape(const TopoDS_Shape& theS, - const TopTools_ListOfShape& theSList) -{ - TopTools_ListIteratorOfListOfShape anIt( theSList ); - for ( ; anIt.More(); anIt.Next() ) - if (!theS.IsSame( anIt.Value() )) - return anIt.Value(); - - return TopoDS_Shape(); -} - -//======================================================================= -//function : findVOnE -//purpose : on theE, find a vertex close to theV, such that an edge -// passing through it is an itersection of theF1 and theF2. -// theE intersects theE2 at theV -//======================================================================= - -static Standard_Boolean findVOnE(const TopoDS_Vertex & theV, - const TopoDS_Edge& theE, - const TopoDS_Edge& theE2, - const TopoDS_Shape& theF1, - const TopoDS_Shape& theF2, - const Handle(BRepAlgo_AsDes)& theAsDes, - TopoDS_Vertex & theFoundV) -{ - Standard_Real MinDist2 = ::RealLast(); - gp_Pnt P; - - // check all vertices on theE - const TopTools_ListOfShape& aVList = theAsDes->Descendant( theE ); - TopTools_ListIteratorOfListOfShape anIt( aVList ); - if (anIt.More()) - P = BRep_Tool::Pnt( theV ); - for ( ; anIt.More(); anIt.Next() ) - { - // check by distance - TopoDS_Vertex & V = TopoDS::Vertex( anIt.Value() ); - Standard_Real dist2 = P.SquareDistance( BRep_Tool::Pnt( V )); - if (dist2 < MinDist2) - MinDist2 = dist2; - else - continue; - - // V is a candidate if among edges passing through V there is one - // which is an intersection of theF1 and theF2 - TopTools_ListIteratorOfListOfShape anEIt( theAsDes->Ascendant( V )); - Standard_Boolean isOk = Standard_False; - for ( ; !isOk && anEIt.More(); anEIt.Next() ) - { - const TopoDS_Shape & E2 = anEIt.Value(); - if ( theE2.IsSame( E2 )) - continue; - const TopTools_ListOfShape & aFList = theAsDes->Ascendant( E2 ); - if (aFList.IsEmpty()) - continue; - if ( theF1.IsSame( aFList.First() )) - isOk = theF2.IsSame( aFList.Last() ); - else - isOk = theF2.IsSame( aFList.First() ) && theF1.IsSame( aFList.Last() ); - } - if (isOk) - theFoundV = V; - } - - if (theFoundV.IsNull()) - return Standard_False; - - // check that MinDist2 is not too large - Standard_Real f, l; - TopLoc_Location L; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve( theE, L, f, l ); - gp_Pnt P1 = aCurve->Value( f ); - gp_Pnt P2 = aCurve->Value( 0.3 * f + 0.7 * l ); - //gp_Pnt P2 = aCurve->Value( 0.5 * ( f + l )); - if (MinDist2 > P1.SquareDistance( P2 )) - return Standard_False; - -#ifdef DEB - MESSAGE("findVOnE: found MinDist = " << sqrt (MinDist2)); -#endif - - return Standard_True; -} - -//======================================================================= -//function : AddVonE -//purpose : Put V in AsDes as intersection of E1 and E2. -// Check that vertex equal to V already exists on one -// of edges, in such a case, V is not added but -// existing vertex is updated to be on E1 and E2 and -// is returned insead of V. -//======================================================================= - -TopoDS_Vertex Partition_Inter2d::AddVonE(const TopoDS_Vertex& theV, - const TopoDS_Edge& E1, - const TopoDS_Edge& E2, - const Handle(BRepAlgo_AsDes)& AsDes, - const TopoDS_Face& theF) - -{ - //------------------------------------------------------------- - // test if the points of intersection already exist. If not, - // add as descendants of the edges. - // nb: theses points are only vertices of intersection. - //------------------------------------------------------------- - const TopTools_ListOfShape& VOnE1 = AsDes->Descendant(E1); - const TopTools_ListOfShape& VOnE2 = AsDes->Descendant(E2); - gp_Pnt P1,P2; - TopoDS_Vertex V1,V2; - TopTools_ListIteratorOfListOfShape it; - BRep_Builder B; - TopAbs_Orientation O1,O2; - Standard_Real U1,U2; - Standard_Real Tol,Tol1,Tol2; - Standard_Boolean OnE1,OnE2; - - TopoDS_Vertex V = theV; - - U1 = BRep_Tool::Parameter(V,E1); - U2 = BRep_Tool::Parameter(V,E2); - O1 = V.Orientation(); - O2 = O1; - P1 = BRep_Tool::Pnt(V); - Tol = BRep_Tool::Tolerance( V ); - OnE1 = OnE2 = Standard_False; - - //----------------------------------------------------------------- - // Search if the point of intersection is a vertex of E1. - //----------------------------------------------------------------- - for (it.Initialize(VOnE1); it.More(); it.Next()) { - const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() ); - if (V.IsSame( CV )) { - V1 = V; - OnE1 = Standard_True; - break; - } - P2 = BRep_Tool::Pnt( CV ); - Tol1 = 1.1*(Tol + BRep_Tool::Tolerance( CV )); - if (P1.SquareDistance(P2) <= Tol1*Tol1) { - V = CV; - V1 = V; - OnE1 = Standard_True; - break; - } - } - if (OnE1) { - //----------------------------------------------------------------- - // Search if the vertex found is still on E2. - //----------------------------------------------------------------- - for (it.Initialize(VOnE2); it.More(); it.Next()) { - if (V.IsSame( it.Value() )) { - OnE2 = Standard_True; - V2 = V; - break; - } - } - } - if (!OnE2) { - for (it.Initialize(VOnE2); it.More(); it.Next()) { - //----------------------------------------------------------------- - // Search if the point of intersection is a vertex of E2. - //----------------------------------------------------------------- - const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() ); - P2 = BRep_Tool::Pnt( CV ); - Tol2 = 1.1*(Tol + BRep_Tool::Tolerance( CV )); - if (P1.SquareDistance(P2) <= Tol2*Tol2) { - V = CV; - V2 = V; - OnE2 = Standard_True; - break; - } - } - } - - - if (!OnE1 && !OnE2 && !theF.IsNull()) - { - // if 3 faces intersects each others, 3 new edges on them must pass - // through one vertex but real intersection points of each - // pair of edges are sometimes more far than a tolerance. - // Try to analitically find vertices that E1 and E2 must pass trough - - TopoDS_Shape F1 = getOtherShape( theF, AsDes->Ascendant( E1 )); - TopoDS_Shape F2 = getOtherShape( theF, AsDes->Ascendant( E2 )); - if (!F1.IsNull() && !F2.IsNull() && !F1.IsSame( F2 )) - { - OnE1 = findVOnE ( theV, E1, E2, F1, F2, AsDes, V1 ); - OnE2 = findVOnE ( theV, E2, E1, F1, F2, AsDes, V2 ); - if (OnE2) V = V2; - if (OnE1) V = V1; - } - } - - if (OnE1 && OnE2) { - if (!V1.IsSame(V2)) { - // replace V1 with V2 on all edges V1 is on - Standard_Real UV1; - TopoDS_Edge EWE1; - TopoDS_Vertex VI; - const TopTools_ListOfShape& EdgeWithV1 = AsDes->Ascendant(V1); - - for (it.Initialize(EdgeWithV1); it.More(); it.Next()) { - EWE1 = TopoDS::Edge(it.Value()); - VI = V1; - VI.Orientation(TopAbs_INTERNAL); - UV1 = BRep_Tool::Parameter(VI,EWE1); - VI = V2; - VI.Orientation(TopAbs_INTERNAL); - B.UpdateVertex( VI, UV1, EWE1, GetTolerance( VI, UV1, EWE1, AsDes)); - } - AsDes->Replace(V1,V2); - V = V2; - } - } - - // add existing vertices instead of new ones - if (!OnE1) { - if (OnE2) { - V.Orientation(TopAbs_INTERNAL); - B.UpdateVertex (V, U1, E1, GetTolerance( V, U1, E1, AsDes)); - } - V.Orientation(O1); - AsDes->Add(E1,V); - } - if (!OnE2) { - if (OnE1) { - V.Orientation(TopAbs_INTERNAL); - B.UpdateVertex (V, U2, E2, GetTolerance( V, U2, E2, AsDes )); - } - V.Orientation(O2); - AsDes->Add(E2,V); - } - - return V; -} - -//======================================================================= -//function : FindEndVertex -//purpose : Returns a vertex from having parameter on -// closest to or . is True if -// found vertex is closer to . returns parameter -// difference. -//======================================================================= - -TopoDS_Vertex Partition_Inter2d::FindEndVertex(const TopTools_ListOfShape& LV, - const Standard_Real f, - const Standard_Real l, - const TopoDS_Edge& E, - Standard_Boolean& isFirst, - Standard_Real& minDU) -{ - TopoDS_Vertex endV; - Standard_Real U, endU, min; - minDU = 1.e10; - - TopTools_ListIteratorOfListOfShape it; - it.Initialize(LV); - for (; it.More(); it.Next()) { - const TopoDS_Vertex& v = TopoDS::Vertex(it.Value()); - U = BRep_Tool::Parameter(v, E); - min = Min( Abs(U-f), Abs(U-l) ); - if (min < minDU) { - endV = v; - endU = U; - minDU = min; - } - } - if (Abs(endU-f) < Abs(endU-l)) - isFirst = Standard_True; - else - isFirst = Standard_False; - - return endV; -} - -//======================================================================= -//function : treatClosed -//purpose : add second vertex to closed edge. Vertex is one of -//======================================================================= - -static void treatClosed (const TopoDS_Edge& E1, - const Standard_Real f, - const Standard_Real l, - TopTools_ListOfShape& LV1, - TopTools_ListOfShape& /*LV2*/) -{ - Standard_Boolean isFirst=0; - Standard_Real minDU = 1.e10; - TopoDS_Vertex endV; - endV = Partition_Inter2d::FindEndVertex(LV1, f,l, E1, isFirst,minDU); - - if (minDU > Precision::PConfusion()) - return; // not end point - - Standard_Real newU; - if (isFirst) - newU = f + (l - f); - else - newU = l - (l - f); - - // update end parameter - BRep_Builder B; - endV.Orientation(TopAbs_INTERNAL); - B.UpdateVertex(endV,newU,E1,BRep_Tool::Tolerance(endV)); -} - -//======================================================================= -//function : EdgesPartition -//purpose : -//======================================================================= - -static void EdgesPartition(const TopoDS_Face& F, - const TopoDS_Edge& E1, - const TopoDS_Edge& E2, - const Handle(BRepAlgo_AsDes)& AsDes, - const TopTools_MapOfShape& NewEdges, - const Standard_Boolean WithOri) -{ - - Standard_Real f[3],l[3]; - Standard_Real MilTol2; - Standard_Real Tol = Max (BRep_Tool::Tolerance(E1), - BRep_Tool::Tolerance(E2)); - MilTol2 = Tol * Tol * 10; - - BRep_Tool::Range(E1, f[1], l[1]); - BRep_Tool::Range(E2, f[2], l[2]); - - BRepAdaptor_Curve CE1(E1,F); - BRepAdaptor_Curve CE2(E2,F); - - TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2; - TopTools_ListOfShape LV1; // new vertices at intersections on E1 - TopTools_ListOfShape LV2; // ... on E2 - BRep_Builder B; - - // if E1 and E2 are results of intersection of F and two connex faces then - // no need to intersect edges, they can contact by vertices only - // (encounted an exception in TopOpeBRep_EdgesIntersector in such a case) - Standard_Boolean intersect = Standard_True; - TopTools_IndexedMapOfShape ME; - TopExp::MapShapes(F, TopAbs_EDGE, ME); - if (!ME.Contains(E1) && ! ME.Contains(E2)) { // if E1 and E2 are new on F - TopoDS_Shape F1, F2; - const TopTools_ListOfShape& LF1 = AsDes->Ascendant( E1 ); - F1 = F.IsSame( LF1.First() ) ? LF1.Last() : LF1.First(); - const TopTools_ListOfShape& LF2 = AsDes->Ascendant( E2 ); - F2 = F.IsSame( LF2.First() ) ? LF2.Last() : LF2.First(); - if (!F.IsSame(F2) && !F.IsSame(F1) ) { - TopExp_Explorer exp(F2, TopAbs_EDGE); - TopExp::MapShapes(F1, TopAbs_EDGE, ME); - for (; exp.More(); exp.Next()) { - if (ME.Contains( exp.Current())) { - intersect = Standard_False; - break; - } - } - } - } - - if (intersect) { - //------------------------------------------------------ - // compute the points of Intersection in 2D - //----------------------------------------------------- - // i.e. fill LV1 and LV2 - TopOpeBRep_EdgesIntersector EInter; - EInter.SetFaces(F,F); - Standard_Real TolDub = 1.e-7; - EInter.ForceTolerances(TolDub,TolDub); - Standard_Boolean reducesegments = Standard_False; - EInter.Perform (E1,E2,reducesegments); - - Standard_Boolean rejectreducedsegmentpoints = Standard_False; - EInter.InitPoint(rejectreducedsegmentpoints); - for ( ; EInter.MorePoint(); EInter.NextPoint() ) - { - const TopOpeBRep_Point2d& P2D = EInter.Point(); - const gp_Pnt& P = P2D.Value(); - TopoDS_Vertex V = BRepLib_MakeVertex(P); - - //------------------------- - // control the point found. - //------------------------- - gp_Pnt P1 = CE1.Value(P2D.Parameter(1)); - gp_Pnt P2 = CE2.Value(P2D.Parameter(2)); - Standard_Real sqd1 = P1.SquareDistance(P); - Standard_Real sqd2 = P2.SquareDistance(P); - if (sqd1 > MilTol2 || sqd2 > MilTol2 ) - continue; - - // add a new vertex to the both edges - Standard_Real toler = Max( Tol, sqrt( Max( sqd1, sqd2 ))); - Standard_Integer i; - for (i = 1; i <= 2; i++) { - Standard_Real U = P2D.Parameter(i); - V.Orientation(TopAbs_INTERNAL); - B.UpdateVertex( V,U,EI[i], toler); - TopAbs_Orientation OO = TopAbs_REVERSED; - if (WithOri) { - if (P2D.IsVertex(i)) - OO = P2D.Vertex(i).Orientation(); - else if (P2D.Transition(i).Before() == TopAbs_OUT) { - OO = TopAbs_FORWARD; - } - V.Orientation(OO); - if (i == 1) LV1.Append(V); - else LV2.Append(V); - } - } - } - } // if (intersect) - - //---------------------------------- - // Test the extremities of the edges. - //---------------------------------- - // add to LV* vertices for vertex-vertex closeness - Standard_Real U1,U2; - Standard_Real TolConf2, TolConf; - TopoDS_Vertex V1[2],V2[2]; - TopExp::Vertices(E1,V1[0],V1[1]); - TopExp::Vertices(E2,V2[0],V2[1]); - - Standard_Integer i,j,k; - for (j = 0; j < 2; j++) { - if (V1[j].IsNull()) continue; - for ( k = 0; k < 2; k++) { - if (V2[k].IsNull()) continue; - gp_Pnt P1 = BRep_Tool::Pnt(V1[j]); - gp_Pnt P2 = BRep_Tool::Pnt(V2[k]); - TolConf = BRep_Tool::Tolerance(V1[j]) + BRep_Tool::Tolerance(V2[k]); - TolConf = Max (Tol, TolConf); - TolConf2 = TolConf * TolConf; - if (!intersect) - TolConf2 *= 100; - Standard_Real SqDist = P1.SquareDistance(P2); - - if (SqDist <= TolConf2) { - TopoDS_Vertex V = BRepLib_MakeVertex(P1); - V.Orientation(TopAbs_INTERNAL); - U1 = (j == 0) ? f[1] : l[1]; - U2 = (k == 0) ? f[2] : l[2]; - B.UpdateVertex(V,U1,E1,TolConf); - B.UpdateVertex(V,U2,E2,TolConf); - LV1.Prepend(V.Oriented(V1[j].Orientation())); - LV2.Prepend(V.Oriented(V2[k].Orientation())); - } - } - } - - Standard_Boolean AffichPurge = Standard_False; - - if ( LV1.IsEmpty()) return; - - //---------------------------------- - // Purge of all the vertices. - //---------------------------------- - // remove one of close vertices - TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1; - gp_Pnt P1,P2; - Standard_Boolean Purge = Standard_True; - - while (Purge) { - i = 1; - Purge = Standard_False; - for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2); - it1LV1.More(); - it1LV1.Next(),it1LV2.Next()) { - j = 1; - it2LV1.Initialize(LV1); - while (j < i) { - const TopoDS_Vertex& VE1 = TopoDS::Vertex(it1LV1.Value()); - const TopoDS_Vertex& VE2 = TopoDS::Vertex(it2LV1.Value()); - Standard_Real Tol1 = BRep_Tool::Tolerance( VE1 ); - Standard_Real Tol2 = BRep_Tool::Tolerance( VE2 ); - P1 = BRep_Tool::Pnt( VE1 ); - P2 = BRep_Tool::Pnt( VE2 ); - if (P1.IsEqual(P2, Tol1 + Tol2)) { - LV1.Remove(it1LV1); - LV2.Remove(it1LV2); - Purge = Standard_True; - break; - } - j++; - it2LV1.Next(); - } - if (Purge) break; - i++; - } - } - - // care of new closed edges, they always intersect with seam at end - if (V1[0].IsSame( V1[1] ) && NewEdges.Contains(E1) ) - treatClosed (E1, f[1], l[1], LV1, LV2); - if (V2[0].IsSame( V2[1] ) && NewEdges.Contains(E2) ) - treatClosed (E2, f[2], l[2], LV2, LV1); - - //---------------- - // Stocking vertex - //---------------- - - for ( it1LV1.Initialize( LV1 ); it1LV1.More(); it1LV1.Next()) - Partition_Inter2d::AddVonE (TopoDS::Vertex( it1LV1.Value()), - E1, E2, AsDes, F); -} - -//======================================================================= -//function : CompletPart2d -//purpose : Computes the intersections between the edges stored -// is AsDes as descendants of . Intersections is computed -// between two edges if one of them is bound in NewEdges. -//======================================================================= - -void Partition_Inter2d::CompletPart2d (const Handle(BRepAlgo_AsDes)& AsDes, - const TopoDS_Face& F, - const TopTools_MapOfShape& NewEdges) -{ - -#ifdef DEB - NbF2d++; - NbE2d = 0; -#endif - - //Do not intersect the edges of a face - TopTools_IndexedMapOfShape EdgesOfFace; - TopExp::MapShapes( F, TopAbs_EDGE , EdgesOfFace); - - //------------------------------------------------------------------- - // compute the intersection2D on the faces touched by the intersection3D - //------------------------------------------------------------------- - TopTools_ListIteratorOfListOfShape it1LE ; - TopTools_ListIteratorOfListOfShape it2LE ; - - //----------------------------------------------- - // Intersection edge-edge. - //----------------------------------------------- - const TopTools_ListOfShape& LE = AsDes->Descendant(F); - TopoDS_Vertex V1,V2; - Standard_Integer j, i = 1; - - TopoDS_Face FF = F; - FF.Orientation(TopAbs_FORWARD); - - for ( it1LE.Initialize(LE) ; it1LE.More(); it1LE.Next()) { - const TopoDS_Edge& E1 = TopoDS::Edge(it1LE.Value()); - j = 1; - it2LE.Initialize(LE); - - while (j < i && it2LE.More()) { - const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value()); - //---------------------------------------------------------- - // Intersections of the new edges obtained by intersection - // between them and with the restrictions edges - //---------------------------------------------------------- - if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) && - (NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) { - EdgesPartition(FF,E1,E2,AsDes,NewEdges,Standard_True); - } - it2LE.Next(); - j++; - } - i++; - } -} - -//======================================================================= -//function : GetTolerance -//purpose : Returns tolerance theV must have atfer its -// addition to theE with theU parameter. theAsDes is -// used to find pcurves of theE -//======================================================================= - -Standard_Real Partition_Inter2d::GetTolerance - (const TopoDS_Vertex & theV, - const Standard_Real theU, - const TopoDS_Edge & theE, - const Handle(BRepAlgo_AsDes)& theAsDes) -{ - Standard_Real aTol = BRep_Tool::Tolerance( theV ); - gp_Pnt aPnt = BRep_Tool::Pnt( theV ); - - // check point on 3D curve - Standard_Real f,l; - Handle(Geom_Curve) C = BRep_Tool::Curve( theE, f, l ); - if (!C.IsNull()) - aTol = Max ( aTol, aPnt.Distance( C->Value( theU ))); - - // check points on pcurves - const TopTools_ListOfShape& aFList = theAsDes->Ascendant( theE ); - TopTools_ListIteratorOfListOfShape aFIt( aFList ); - for ( ; aFIt.More(); aFIt.Next() ) - { - const TopoDS_Face& F = TopoDS::Face( aFIt.Value() ); - Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( theE, F, f, l ); - if (!pcurve.IsNull()) - { - gp_Pnt2d aPnt2d = pcurve->Value( theU ); - TopLoc_Location L; - Handle(Geom_Surface) S = BRep_Tool::Surface( F, L ); - gp_Pnt aPntOnS = S->Value( aPnt2d.X(), aPnt2d.Y() ); - if (!L.IsIdentity()) - aPntOnS.Transform( L.Transformation() ); - aTol = Max ( aTol, aPnt.Distance( aPntOnS )); - } - } - - return aTol; -} diff --git a/src/PARTITION/Partition_Inter2d.hxx b/src/PARTITION/Partition_Inter2d.hxx deleted file mode 100644 index 5942fcf14..000000000 --- a/src/PARTITION/Partition_Inter2d.hxx +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter2d.hxx -// Module : GEOM -// -#ifndef _Partition_Inter2d_HeaderFile -#define _Partition_Inter2d_HeaderFile - -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class BRepAlgo_AsDes; -class TopoDS_Face; -class TopTools_MapOfShape; -class TopoDS_Vertex; -class TopTools_ListOfShape; -class TopoDS_Edge; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Inter2d { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT static void CompletPart2d(const Handle(BRepAlgo_AsDes)& AsDes,const TopoDS_Face& F,const TopTools_MapOfShape& NewEdges) ; -Standard_EXPORT static TopoDS_Vertex FindEndVertex(const TopTools_ListOfShape& VertList,const Standard_Real f,const Standard_Real l,const TopoDS_Edge& E,Standard_Boolean& First,Standard_Real& DU) ; -Standard_EXPORT static TopoDS_Vertex AddVonE(const TopoDS_Vertex& V,const TopoDS_Edge& E1,const TopoDS_Edge& E2,const Handle(BRepAlgo_AsDes)& AsDes,const TopoDS_Face& F) ; -Standard_EXPORT static Standard_Real GetTolerance(const TopoDS_Vertex& theV,const Standard_Real theU,const TopoDS_Edge& theE,const Handle(BRepAlgo_AsDes)& theAsDes) ; - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Inter2d.ixx b/src/PARTITION/Partition_Inter2d.ixx deleted file mode 100644 index 954e70da9..000000000 --- a/src/PARTITION/Partition_Inter2d.ixx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter2d.ixx -// Module : GEOM -// -#include "Partition_Inter2d.jxx" - - - - diff --git a/src/PARTITION/Partition_Inter2d.jxx b/src/PARTITION/Partition_Inter2d.jxx deleted file mode 100644 index 30cc24a04..000000000 --- a/src/PARTITION/Partition_Inter2d.jxx +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter2d.jxx -// Module : GEOM -// -#ifndef _BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Partition_Inter2d_HeaderFile -#include "Partition_Inter2d.hxx" -#endif diff --git a/src/PARTITION/Partition_Inter3d.cdl b/src/PARTITION/Partition_Inter3d.cdl deleted file mode 100644 index f37cbbb9a..000000000 --- a/src/PARTITION/Partition_Inter3d.cdl +++ /dev/null @@ -1,173 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Inter3d.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -class Inter3d from Partition - - ---Purpose: Computes the intersection face face in a set of faces - -- Store the result in a SD as AsDes. - -uses - Edge from TopoDS, - Vertex from TopoDS, - DataMapOfShapeShape from TopTools, - MapOfShape from TopTools, - Boolean from Standard, - AsDes from BRepAlgo, - Image from BRepAlgo, - Shape from TopoDS, - Face from TopoDS, - ListOfShape from TopTools, - Real from Standard, - State from TopAbs, - DataMapOfShapeListOfShape from TopTools - -is - Create returns Inter3d from Partition; - - Create(AsDes : mutable AsDes from BRepAlgo); - - CompletPart3d (me : in out; SetOfFaces1 : ListOfShape from TopTools; - FaceShapeMap: DataMapOfShapeShape from TopTools) - is static; - - FacesPartition (me : in out; F1, F2 : Face from TopoDS) - is static; - - ---------------------------- - ---Category: Result Querying - ---------------------------- - - IsDone(me ; F1,F2 : Face from TopoDS) - returns Boolean from Standard is static; - ---Purpose: return True if F1-F2 pair has been processed - - TouchedFaces(me : in out) returns MapOfShape from TopTools - ---C++: return & - is static; - ---Purpose: return map of faces cut by new or section edges - - NewEdges(me : in out) returns MapOfShape from TopTools - ---C++: return & - is static; - ---Purpose: return new and section edges - - AsDes(me) returns AsDes from BRepAlgo - is static; - ---Purpose: return an object containing info about - -- Ascendants | Descendants - -- ------------------+--------------------- - -- 1. faces | edges cutting them - -- 2. sectoin edges | new vertices on them - - - ------------------------------- - ---Category: Same domain shapes - ------------------------------- - - HasSameDomainF(me; F : Shape from TopoDS) - returns Boolean from Standard; - ---Purpose: Return true if F has same domain faces - - IsSameDomainF(me; F1, F2 : Shape from TopoDS) - returns Boolean from Standard; - ---Purpose: Return true if F1 and F2 are same domain faces - - SameDomain(me; F : Face from TopoDS) - returns ListOfShape from TopTools; - ---C++: return const & - ---Purpose: Return same domain faces of F - - ReplaceSameDomainV (me; V : Vertex from TopoDS; - E : Edge from TopoDS) - returns Vertex from TopoDS; - ---Purpose: return same domain vertex of V if it was replaced - -- and make this vertex to be on E too, else return V - - -------------------------- - ---Category: Section edges - -------------------------- - - SectionEdgesAD (me) returns AsDes from BRepAlgo - is static; - - IsSectionEdge (me; E : Edge from TopoDS) - returns Boolean from Standard; - ---Purpose: return True if E is an edge of an initial face and - -- E intersects aother face - - HasSectionEdge (me; F : Face from TopoDS) - returns Boolean from Standard; - ---Purpose: return True if F is intersected by an edge of - -- other face - - IsSplitOn (me; NewE, OldE : Edge from TopoDS; - F : Face from TopoDS) - returns Boolean from Standard; - ---Purpose: return True if NewE is split of OldE on F; - -- no check if NewE is split of OldE :) - - SectionEdgeFaces (me; SecE : Edge from TopoDS) - returns ListOfShape from TopTools; - ---C++: return const& - ---Purpose: return faces cut by section edge - - -------------------- - ---Category: Private - -------------------- - - Inter3D (me: in out; F1, F2 : Face from TopoDS; - LInt : in out ListOfShape from TopTools) - is static private; - - StorePart3d(me : in out; F1,F2 : Face from TopoDS; - LInt1 : ListOfShape from TopTools) - is static private; - - SetDone(me : in out; F1,F2 : Face from TopoDS) - is static private; - - Affiche (me; SetOfFaces : ListOfShape from TopTools) - is static private; - -fields - - myAsDes : AsDes from BRepAlgo; - myDone : DataMapOfShapeListOfShape from TopTools; - myTouched : MapOfShape from TopTools; - myNewEdges : MapOfShape from TopTools; - - -- section edges: existing edges that are intersection lines, - -- may be partially. - -- Store as - -- FACE -> SECTION EDGES, SECTION EDGE -> OTHER SECTION EDGE - mySectionEdgesAD : AsDes from BRepAlgo; - - -- same domain shapes - -- faces - mySameDomainFM : DataMapOfShapeListOfShape from TopTools; - -- vertex -> vertex replacement - mySameDomainVM : DataMapOfShapeShape from TopTools; - -end Inter3d; diff --git a/src/PARTITION/Partition_Inter3d.cxx b/src/PARTITION/Partition_Inter3d.cxx deleted file mode 100644 index 56bb3bd72..000000000 --- a/src/PARTITION/Partition_Inter3d.cxx +++ /dev/null @@ -1,939 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter3d.cxx -// Author : Benedicte MARTIN -// Module : GEOM -// $Header$ -// -#include "Partition_Inter2d.hxx" -#include "Partition_Inter3d.ixx" -#include "utilities.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEB -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -//======================================================================= -//function : Partition_Inter3d -//purpose : -//======================================================================= - -Partition_Inter3d::Partition_Inter3d() -{ -} -//======================================================================= -//function : Partition_Inter3d -//purpose : -//======================================================================= - -Partition_Inter3d::Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes) - :myAsDes(AsDes) -{ - mySectionEdgesAD = new BRepAlgo_AsDes; -} - -//======================================================================= -//function : CompletPart3d -//purpose : FaceShapeMap is just to know the shape a face belongs to -//======================================================================= - -void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1, - const TopTools_DataMapOfShapeShape& FaceShapeMap) -{ - if (myAsDes.IsNull()) - myAsDes = new BRepAlgo_AsDes; - - TopTools_ListIteratorOfListOfShape it; - - //--------------------------------------------------------------- - // Construction of bounding boxes. - //--------------------------------------------------------------- - - BRep_Builder B; - TopoDS_Compound CompOS; - B.MakeCompound(CompOS); - for (it.Initialize(SetOfFaces1); it.More(); it.Next()) - B.Add(CompOS, it.Value()); - - TopOpeBRepTool_BoxSort BOS; - BOS.AddBoxesMakeCOB(CompOS,TopAbs_FACE); - - for (it.Initialize(SetOfFaces1); it.More(); it.Next()) { - TopoDS_Face F1 = TopoDS::Face(it.Value()); - - // avoid intersecting faces of one shape - TopoDS_Shape S1; - if (FaceShapeMap.IsBound(F1)) S1 = FaceShapeMap.Find(F1); - - // to filter faces sharing an edge - TopTools_IndexedMapOfShape EM; - TopExp::MapShapes( F1, TopAbs_EDGE, EM); - - TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1); - for (; itLI.More(); itLI.Next()) { - TopoDS_Face F2 = TopoDS::Face(BOS.TouchedShape(itLI)); - if (F1.IsSame(F2) || IsDone(F1,F2)) - continue; - - TopoDS_Shape S2; - if (FaceShapeMap.IsBound(F2)) S2 = FaceShapeMap.Find(F2); - if (!S1.IsNull() && S1.IsSame(S2)) - continue; // descendants of one shape - - TopExp_Explorer expE (F2, TopAbs_EDGE); - for ( ; expE.More(); expE.Next()) - if (EM.Contains( expE.Current() )) - break; - if (expE.More()) - { - // faces have a common edge, check if they are a tool and a face - // generated by the tool in another shape; in that case they are - // to be intersected - TopLoc_Location L1, L2; - Handle(Geom_Surface) S1 = BRep_Tool::Surface( F1, L1 ); - Handle(Geom_Surface) S2 = BRep_Tool::Surface( F2, L2 ); - if ( S1 != S2 || L1 != L2 ) - continue; - } - - F1.Orientation(TopAbs_FORWARD); - F2.Orientation(TopAbs_FORWARD); - FacesPartition(F1,F2); - } - - // mark as modified a face which has at least one new edge - if (!myAsDes->HasDescendant( F1 )) - continue; - TopTools_ListIteratorOfListOfShape itE (myAsDes->Descendant( F1 )); - for ( ; itE.More(); itE.Next()) { - if (myNewEdges.Contains( itE.Value())) { - myTouched.Add( F1 ); - break; - } - } - } -} - -//======================================================================= -//function : PutInBounds -//purpose : -//======================================================================= - -static void PutInBounds (const TopoDS_Face& F, - const TopoDS_Edge& E, - Handle(Geom2d_Curve)& C2d) -{ - Standard_Real umin,umax,vmin,vmax; - Standard_Real f,l; - BRep_Tool::Range(E,f,l); - - TopLoc_Location L; // Recup S avec la location pour eviter la copie. - Handle (Geom_Surface) S = BRep_Tool::Surface(F,L); - - if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface(); - } - if (!S->IsUPeriodic() && !S->IsVPeriodic()) - return; - - BRepTools::UVBounds(F,umin,umax,vmin,vmax); - - gp_Pnt2d Pf = C2d->Value(f); - gp_Pnt2d Pl = C2d->Value(l); - const Standard_Real Um = 0.34*f + 0.66*l; - gp_Pnt2d Pm = C2d->Value( Um ); - - // sometimes on shpere, pcurve is out of domain by V though S is - // UPeriodic, sometimes it is in domain but nontheless it has - // wrong position. - // Check pcurve position by 3D point - if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface ))) - { - // get point on the surface - gp_Pnt Ps = S->Value( Pm.X(), Pm.Y() ); - // get point on the edge - Handle(Geom_Curve) C = BRep_Tool::Curve( E, f, l ); - gp_Pnt Pc = C->Value( Um ); - // compare points - Standard_Real TolE = BRep_Tool::Tolerance( E ); - if ( Pc.SquareDistance( Ps ) * 0.95 < TolE * TolE ) - return; // OK - - // find good UV for Pc: project Pc on S - GeomAdaptor_Surface SA (S); - Extrema_ExtPS anExtPS (Pc, SA, - SA.UResolution( TolE ), SA.VResolution( TolE )); - if (anExtPS.IsDone()) - { - Standard_Integer i, nbExt = anExtPS.NbExt(); - Extrema_POnSurf aPOnSurf; - for (i = 1; i <= nbExt; ++i ) - if (anExtPS.Value( i ) <= TolE) { - aPOnSurf = anExtPS.Point( i ); - break; - } - if (i <= nbExt) { - // a point found - Standard_Real u, v; - aPOnSurf.Parameter( u, v ); - gp_Pnt2d aGoodPm ( u, v ); - C2d->Translate( Pm , aGoodPm ); - } - } - } - - //--------------- - // Recadre en U. - //--------------- - if (S->IsUPeriodic()) { - Standard_Real period = S->UPeriod(); - Standard_Real eps = period*1.e-6; - Standard_Real minC = Min(Pf.X(),Pl.X()); minC = Min(minC,Pm.X()); - Standard_Real maxC = Max(Pf.X(),Pl.X()); maxC = Max(maxC,Pm.X()); - Standard_Real du = 0.; - if (minC< umin - eps) { - du = (int((umin - minC)/period) + 1)*period; - } - if (minC > umax + eps) { - du = -(int((minC - umax)/period) + 1)*period; - } - if (du != 0) { - gp_Vec2d T1(du,0.); - C2d->Translate(T1); - minC += du; maxC += du; - } - // Ajuste au mieux la courbe dans le domaine. - if (maxC > umax +100*eps) { - Standard_Real d1 = maxC - umax; - Standard_Real d2 = umin - minC + period; - if (d2 < d1) du =-period; - if ( du != 0.) { - gp_Vec2d T2(du,0.); - C2d->Translate(T2); - } - } - } - //------------------ - // Recadre en V. - //------------------ - if (S->IsVPeriodic()) { - Standard_Real period = S->VPeriod(); - Standard_Real eps = period*1.e-6; - Standard_Real minC = Min(Pf.Y(),Pl.Y()); minC = Min(minC,Pm.Y()); - Standard_Real maxC = Max(Pf.Y(),Pl.Y()); maxC = Max(maxC,Pm.Y()); - Standard_Real dv = 0.; - if (minC< vmin - eps) { - dv = (int((vmin - minC)/period) + 1)*period; - } - if (minC > vmax + eps) { - dv = -(int((minC - vmax)/period) + 1)*period; - } - if (dv != 0) { - gp_Vec2d T1(0.,dv); - C2d->Translate(T1); - minC += dv; maxC += dv; - } - // Ajuste au mieux la courbe dans le domaine. - if (maxC > vmax +100*eps) { - Standard_Real d1 = maxC - vmax; - Standard_Real d2 = vmin - minC + period; - if (d2 < d1) dv =-period; - if ( dv != 0.) { - gp_Vec2d T2(0.,dv); - C2d->Translate(T2); - } - } - } -} - -//======================================================================= -//function : Inter3D -//purpose : -//======================================================================= - -void Partition_Inter3d::Inter3D(const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_ListOfShape& L) -{ - BRep_Builder B; - - // fill the data Structure - Handle(TopOpeBRepDS_HDataStructure) DatStr = new TopOpeBRepDS_HDataStructure(); - TopOpeBRep_DSFiller DSFiller; - DSFiller.Insert(F1,F2,DatStr); - - // define the GeomTool used by the DSFiller : - // compute BSpline of degree 1 on intersection curves. - Standard_Real tol3dAPPROX = 1e-7; - Standard_Real tol2dAPPROX = 1e-7; - TopOpeBRepTool_GeomTool GT2 (TopOpeBRepTool_APPROX); - GT2.SetTolerances(tol3dAPPROX,tol2dAPPROX); - TopOpeBRepDS_BuildTool BT(GT2); - - // Perform Section - TopOpeBRepBuild_Builder TopB(BT); - TopB.Perform(DatStr); - - // =============== - // Store new edges - // =============== - - L.Clear(); - TopOpeBRepDS_CurveExplorer cex(DatStr->DS()); - for (; cex.More(); cex.Next()) { - const TopOpeBRepDS_Curve& CDS = cex.Curve(); - Standard_Integer ic = cex.Index(); - Handle(Geom2d_Curve) pc1 = CDS.Curve1(); - Handle(Geom2d_Curve) pc2 = CDS.Curve2(); - - TopTools_ListIteratorOfListOfShape itLE = TopB.NewEdges(ic); - while (itLE.More()) { - TopoDS_Edge E = TopoDS::Edge(itLE.Value()); - - PutInBounds (F1,E,pc1); - PutInBounds (F2,E,pc2); - - B.UpdateEdge (E,pc1,F1,0.); - B.UpdateEdge (E,pc2,F2,0.); - - L.Append (E); - - itLE.Next(); - if (itLE.More()) { - pc1 = Handle(Geom2d_Curve)::DownCast(pc1->Copy()); - pc2 = Handle(Geom2d_Curve)::DownCast(pc2->Copy()); - } - } - } - - // ======================== - // store same domain faces - // ======================== - - - if ( DatStr->HasSameDomain( F1 )) - { - TopTools_ListOfShape emptyList; - if (!mySameDomainFM.IsBound(F1)) - mySameDomainFM.Bind(F1,emptyList); - if (!mySameDomainFM.IsBound(F2)) - mySameDomainFM.Bind(F2,emptyList); - mySameDomainFM(F1).Append(F2); - mySameDomainFM(F2).Append(F1); - } - - // ==================== - // Store section edges - // ==================== - - const TopOpeBRepDS_DataStructure& DS = DatStr->DS(); - Standard_Integer j,i,nse = DS.NbSectionEdges(); - if (nse == 0) return; - - - TopoDS_Vertex V, sdeV1, sdeV2; - TopTools_MapOfShape MV; - TopTools_ListOfShape LSE; // list of section edges - TopoDS_Face dummyF; - - for (i = 1; i <= nse; i++) - { - const TopoDS_Edge & se = DS.SectionEdge(i); - if (! TopB.IsSplit(se,TopAbs_ON)) - continue; - LSE.Append( se ); - - // add vertices where section edges interferes with other - // edges as its descendant in myAsDes - - TopoDS_Edge sde, oe; // same domain, other edge - if (DatStr->HasSameDomain(se)) { - sde = TopoDS::Edge( DatStr->SameDomain(se).Value() ); - TopExp::Vertices( sde, sdeV1, sdeV2); - } - TColStd_MapOfInteger MIV; // indices of added edges - TopOpeBRepDS_PointIterator itP (DS.ShapeInterferences( se )); - itP.SupportKind( TopOpeBRepDS_EDGE ); - // loop on intersections of se - for (; itP.More(); itP.Next()) { - oe = TopoDS::Edge( DS.Shape( itP.Support())); - if (itP.IsVertex()) { - // there is a vertex at intersection - if ( !MIV.Add( itP.Current() )) - continue; - V = TopoDS::Vertex( DS.Shape( itP.Current())); - if ( !sde.IsNull() && (V.IsSame(sdeV1) || V.IsSame(sdeV2)) ) - oe = sde; - V = ReplaceSameDomainV( V , oe ); - V.Orientation( TopAbs_INTERNAL); - B.UpdateVertex( V, itP.Parameter(), se, 0.); // AddVonE() sets real U - } - else { - // create a new vertex at the intersection point - const TopOpeBRepDS_Point& DSP = DS.Point( itP.Current()); - V = BRepLib_MakeVertex( DSP.Point() ); - V.Orientation( TopAbs_INTERNAL); - B.UpdateVertex( V, itP.Parameter(), se, DSP.Tolerance()); - // make V be on the other edge - TopOpeBRepDS_PointIterator itOP (DS.ShapeInterferences( oe )); - for (; itOP.More(); itOP.Next()) { - const TopOpeBRepDS_Point& ODSP = DS.Point( itOP.Current()); - if ( DSP.IsEqual (ODSP)) { - B.UpdateVertex( V, itOP.Parameter(), TopoDS::Edge(oe), ODSP.Tolerance()); - break; - } - } - } - // add V on the both intersecting edges - TopoDS_Vertex addedV = Partition_Inter2d::AddVonE( V,se,oe,myAsDes,dummyF); - if (!addedV.IsSame( V )) - mySameDomainVM.Bind (V, addedV); // equal vertex is already there - - MV.Add( addedV ); // to ease storage of vertices of ON splits - } - } - - // add section edge to the face it intersects and find - // splits ON that do not have same domain pair - - TopB.SplitSectionEdges(); // let TopB find ON splits - - TopTools_MapOfShape SPM; // map of ON splits - TopTools_IndexedMapOfShape ME[2]; - TopExp::MapShapes( F1, TopAbs_EDGE, ME[1]); - TopExp::MapShapes( F2, TopAbs_EDGE, ME[0]); - - TopTools_ListIteratorOfListOfShape itSP, itLSE (LSE); - while ( itLSE.More() ) { - - TopoDS_Edge se = TopoDS::Edge( itLSE.Value() ); - - // move itLSE to the next se - Standard_Integer ancRank = DS.AncestorRank(se); - if (ME[ancRank-1].Contains( se )) - { - LSE.Remove( itLSE ); // se is an edge of face it intersects - continue; - } - else - { - itLSE.Next(); - } - - const TopoDS_Face& F = (ancRank == 1) ? F2 : F1; - - // add se to face but dont add twice - TopTools_ListIteratorOfListOfShape itE( myAsDes->Descendant( F )); - if (myAsDes->HasDescendant( F )) { - for ( ; itE.More(); itE.Next()) - if (se.IsSame( itE.Value() )) - break; - } - if (!itE.More()) - { - myAsDes->Add( F, se ); - - // check se pcurve on F - Standard_Real tol, f,l, umin=1e100, umax=-1e100; - Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( se, F, f,l); - if (pc.IsNull()) { - itSP.Initialize( TopB.Splits(se,TopAbs_ON) ); - for ( ; itSP.More(); itSP.Next()) { - const TopoDS_Edge& E = TopoDS::Edge ( itSP.Value()); - BRep_Tool::Range(E, f, l); - umin = Min( umin, f); - umax = Max( umax, l); - } - Handle(Geom_Curve) C3d = BRep_Tool::Curve( se, f, l); - if (umin < umax) // sometimes umin == umax for closed edge - C3d = new Geom_TrimmedCurve( C3d, umin, umax); - pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol); - if (pc.IsNull()) { - MESSAGE (" CANT BUILD PCURVE "); - } - B.UpdateEdge( se, pc, F, tol); - } - } - - // to detect splits that do not have same domain pair - // ie which split a face into parts and not pass by its boundary - itSP.Initialize( TopB.Splits(se,TopAbs_ON) ); - for ( ; itSP.More(); itSP.Next()) { - const TopoDS_Shape& SP = itSP.Value(); - if (!SPM.Add( SP )) - SPM.Remove( SP ); - } - } - - // store vertices of ON splits and bind section edges to faces - - for (itLSE.Initialize (LSE); itLSE.More(); itLSE.Next()) - { - const TopoDS_Shape& se = itLSE.Value(); - - Standard_Integer ancRank = DS.AncestorRank(se); - TopoDS_Face F = (ancRank == 1) ? F2 : F1; - - // add vertices of ON splits which have no same domain pair - Standard_Boolean added = Standard_False; - itSP.Initialize( TopB.Splits(se,TopAbs_ON) ); - for ( ; itSP.More(); itSP.Next()) - { - if (!SPM.Contains( itSP.Value() )) - continue; - - const TopoDS_Edge& S = TopoDS::Edge ( itSP.Value()); - - added = Standard_True; - mySectionEdgesAD->Add( F, se ); - - TopoDS_Vertex VS[2]; - TopExp::Vertices (S, VS[0], VS[1]); - for (j=0; j<2; ++j) - { - if (mySameDomainVM.IsBound( VS[j] )) - VS[j] = TopoDS::Vertex( mySameDomainVM( VS[j] )); - if ( !MV.Contains( VS[j] )) { - // find equal vertex on se - point interference - gp_Pnt P1 = BRep_Tool::Pnt( VS[j] ); - TopTools_ListIteratorOfListOfShape itV( myAsDes->Descendant(se) ); - for (; itV.More(); itV.Next()) { - V = TopoDS::Vertex( itV.Value() ); - if ( V.IsSame( VS[j] )) - break; - gp_Pnt P2 = BRep_Tool::Pnt( V ); - if (P1.IsEqual( P2, Precision::Confusion())) { - mySameDomainVM.Bind (VS[j], V); - VS[j] = V; - break; - } - } - if (!itV.More()) // no interferences with edges - myAsDes->Add( se, VS[j]); - } - - // add ends of ON splits to F in order to detect later - // if a split is on face in IsSplitOn() - mySectionEdgesAD->Add( F, VS[j]); - } - // in the descendants of F, first go ends of an ON split and - // then a split itself - mySectionEdgesAD->Add( F, S ); - } - if (!added) - mySectionEdgesAD->Add( F, se ); - - myNewEdges.Add( se ); - } -} - -//======================================================================= -//function : FacesPartition -//purpose : -//======================================================================= - -void Partition_Inter3d::FacesPartition(const TopoDS_Face& F1, - const TopoDS_Face& F2) - //(const TopTools_DataMapOfShapeListOfShape& /*SetOfFaces2*/) -{ - TopTools_ListOfShape LInt; - - Inter3D (F1,F2,LInt); - - StorePart3d (F1,F2,LInt); -} - -//======================================================================= -//function : SetDone -//purpose : -//======================================================================= - -void Partition_Inter3d::SetDone(const TopoDS_Face& F1, - const TopoDS_Face& F2) -{ - if (!myDone.IsBound(F1)) { - TopTools_ListOfShape emptyList; - myDone.Bind(F1,emptyList); - } - myDone(F1).Append(F2); - if (!myDone.IsBound(F2)) { - TopTools_ListOfShape emptyList; - myDone.Bind(F2,emptyList); - } - myDone(F2).Append(F1); -} - -//======================================================================= -//function : IsDone -//purpose : -//======================================================================= - -Standard_Boolean Partition_Inter3d::IsDone(const TopoDS_Face& F1, - const TopoDS_Face& F2) - - const -{ - if (myDone.IsBound(F1)) { - TopTools_ListIteratorOfListOfShape it (myDone(F1)); - for (; it.More(); it.Next()) { - if (it.Value().IsSame(F2)) return Standard_True; - } - } - return Standard_False; -} - -//======================================================================= -//function : StorePart3d -//purpose : -//======================================================================= - -void Partition_Inter3d::StorePart3d(const TopoDS_Face& F1, - const TopoDS_Face& F2, - const TopTools_ListOfShape& LInt) -{ - if (!LInt.IsEmpty()) { - myAsDes->Add( F1,LInt); - myAsDes->Add( F2,LInt); - - TopTools_ListIteratorOfListOfShape it(LInt); - for (; it.More(); it.Next()) { - - TopoDS_Edge E = TopoDS::Edge(it.Value()); - - BRep_Builder B; - B.SameParameter(E,Standard_False); - BRepLib::SameParameter(E,1.0e-7); - - myNewEdges.Add(E); - } - } - SetDone(F1,F2); -} - -//======================================================================= -//function : TouchedFaces -//purpose : -//======================================================================= - -TopTools_MapOfShape& Partition_Inter3d::TouchedFaces() -{ - return myTouched; -} - -//======================================================================= -//function : AsDes -//purpose : -//======================================================================= - -Handle(BRepAlgo_AsDes) Partition_Inter3d::AsDes() const -{ - return myAsDes; -} - -//======================================================================= -//function : NewEdges -//purpose : -//======================================================================= - -TopTools_MapOfShape& Partition_Inter3d::NewEdges() -{ - return myNewEdges; -} - -//======================================================================= -//function : Affiche -//purpose : -//======================================================================= - -void Partition_Inter3d::Affiche(const TopTools_ListOfShape& SetOfFaces) const -{ -#ifdef DEB - char PSection[1024]; - char *section=PSection; - Standard_Integer i = 0; - Standard_Real j=1; - TopTools_ListOfShape aList; - TopTools_ListIteratorOfListOfShape it; - for (it.Initialize(SetOfFaces); it.More(); it.Next()) { - const TopoDS_Shape& OS = it.Value(); - aList=myAsDes->Descendant(OS); - MESSAGE ( " the number of items stored in the list " << j << " : " << aList.Extent() ) - j++; - TopTools_ListIteratorOfListOfShape itaList; - for (itaList.Initialize(aList); itaList.More(); itaList.Next()) { - const TopoDS_Shape& SS = itaList.Value(); - i++; - sprintf(PSection,"section_%d",i); - DBRep::Set(section,SS); - } - } -#endif -} - -//======================================================================= -//function : SameDomain -//purpose : -//======================================================================= - -const TopTools_ListOfShape& Partition_Inter3d::SameDomain(const TopoDS_Face& F) const -{ - if (mySameDomainFM.IsBound( F )) - return mySameDomainFM (F); - - static TopTools_ListOfShape emptyList; - return emptyList; -} - -//======================================================================= -//function : HasSameDomainF -//purpose : Return true if F has same domain faces -//======================================================================= - -Standard_Boolean Partition_Inter3d::HasSameDomainF(const TopoDS_Shape& F) const -{ - return mySameDomainFM.IsBound( F ); -} - -//======================================================================= -//function : IsSameDomain -//purpose : Return true if F1 and F2 are same domain faces -//======================================================================= - -Standard_Boolean Partition_Inter3d::IsSameDomainF(const TopoDS_Shape& F1, - const TopoDS_Shape& F2) const -{ - if (mySameDomainFM.IsBound( F1 )) { - TopTools_ListIteratorOfListOfShape it (mySameDomainFM( F1 )); - for (; it.More(); it.Next()) - if (F2.IsSame( it.Value())) - return Standard_True; - } - return F1.IsSame( F2 ); -} - -//======================================================================= -//function : ReplaceSameDomainV -//purpose : return same domain vertex of V if it was replaced -// and make this vertex to be on E too, else return V -//======================================================================= - -TopoDS_Vertex Partition_Inter3d::ReplaceSameDomainV(const TopoDS_Vertex& V, - const TopoDS_Edge& E) const -{ - TopoDS_Vertex SDV = V; - if (mySameDomainVM.IsBound( V )) { - - TopoDS_Vertex V1,V2; - TopExp::Vertices(E,V1,V2); - Standard_Boolean isClosed = V1.IsSame( V2 ) && V.IsSame(V1); - - SDV = TopoDS::Vertex( mySameDomainVM(V) ); - Standard_Real tol = BRep_Tool::Tolerance( V ); - BRep_Builder B; - SDV.Orientation( V.Orientation()); - - if (isClosed) { - Standard_Real f, l; - BRep_Tool::Range (E, f, l); - Standard_Boolean isFirst = IsEqual( BRep_Tool::Parameter(V,E), f ); - B.UpdateVertex(SDV, (isFirst ? f : l), E, tol); - SDV.Reverse(); - B.UpdateVertex(SDV, (isFirst ? l : f), E, tol); - } - else - B.UpdateVertex (SDV, BRep_Tool::Parameter(V,E), E, tol); - - } - return SDV; -} - -//======================================================================= -//function : SectionEdgesAD -//purpose : -//======================================================================= - -Handle(BRepAlgo_AsDes) Partition_Inter3d::SectionEdgesAD() const -{ - return mySectionEdgesAD; -} - -//======================================================================= -//function : IsSectionEdge -//purpose : return True if E is an edge of a face and it -// intersects an other face -//======================================================================= - -Standard_Boolean - Partition_Inter3d::IsSectionEdge(const TopoDS_Edge& E) const -{ - return mySectionEdgesAD->HasAscendant(E); -} - -//======================================================================= -//function : HasSectionEdge -//purpose : return True if an edge of F intersects an other -// face or F is intersected by edge of an other face -//======================================================================= - -Standard_Boolean - Partition_Inter3d::HasSectionEdge(const TopoDS_Face& F) const -{ - return mySectionEdgesAD->HasDescendant(F); -} - -//======================================================================= -//function : IsSplitOn -//purpose : return True if NewE is split of OldE on F -//======================================================================= - -Standard_Boolean - Partition_Inter3d::IsSplitOn(const TopoDS_Edge& NewE, - const TopoDS_Edge& OldE, - const TopoDS_Face& F) const -{ - if (! mySectionEdgesAD->HasDescendant(F)) - return Standard_False; - - TopTools_ListIteratorOfListOfShape itE ( mySectionEdgesAD->Descendant(F) ); - for ( ; itE.More(); itE.Next()) { - if ( itE.Value().ShapeType() != TopAbs_EDGE || - ! OldE.IsSame ( itE.Value() )) - continue; - // an edge encountered, its vertices and a split come next - itE.Next(); - if (!itE.More()) break; - const TopoDS_Shape& V3 = itE.Value(); - if (V3.ShapeType() != TopAbs_VERTEX) continue; - itE.Next(); - if (!itE.More()) break; - const TopoDS_Shape& V4 = itE.Value(); - if (V4.ShapeType() != TopAbs_VERTEX) continue; - - TopoDS_Vertex V1, V2; - TopExp::Vertices( OldE, V1, V2); - - if ( V1.IsSame(V2) && - (V1.IsSame(V3) || V1.IsSame(V4)) ) { - // closed old edge; use the split for the test - itE.Next(); - if (!itE.More()) break; - const TopoDS_Edge& split = TopoDS::Edge( itE.Value() ); - // check distance at middle point of NewE - Standard_Real f1,l1, f2,l2; - Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface( split, F ,f1,l1); - if (!PC1.IsNull()) { - Handle(Geom2d_Curve) PC2 = BRep_Tool::CurveOnSurface(NewE, F ,f2,l2); - gp_Pnt2d P = PC2->Value( 0.5*(f2+l2) ); - Geom2dAPI_ProjectPointOnCurve proj (P, PC1, f1, l1); - if (proj.NbPoints() && - proj.LowerDistance() <= Precision::Confusion()) - return Standard_True; - } - else { - Handle(Geom_Curve) C1 = BRep_Tool::Curve( split ,f1,l1); - Handle(Geom_Curve) C2 = BRep_Tool::Curve( NewE ,f2,l2); - gp_Pnt P = C2->Value( 0.5*(f2+l2) ); - GeomAPI_ProjectPointOnCurve proj (P, C1, f1, l1); - if (proj.NbPoints() && - proj.LowerDistance() <= Precision::Confusion()) - return Standard_True; - } - } - else { - Standard_Real u3 = BRep_Tool::Parameter( TopoDS::Vertex(V3), OldE); - Standard_Real u4 = BRep_Tool::Parameter( TopoDS::Vertex(V4), OldE); - - Standard_Real f,l, u; - BRep_Tool::Range( NewE, f,l); - u = 0.5*(f+l); - f = Min(u3,u4); - l = Max(u3,u4); - - if (u <= l && u >= f) - return Standard_True; - } - } - return Standard_False; -} - -//======================================================================= -//function : SectionEdgeFaces -//purpose : return faces cut by section edge -//======================================================================= - -const TopTools_ListOfShape& - Partition_Inter3d::SectionEdgeFaces(const TopoDS_Edge& SecE) const -{ - return mySectionEdgesAD->Ascendant( SecE ); -} diff --git a/src/PARTITION/Partition_Inter3d.hxx b/src/PARTITION/Partition_Inter3d.hxx deleted file mode 100644 index 1573cc5f1..000000000 --- a/src/PARTITION/Partition_Inter3d.hxx +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter3d.hxx -// Module : GEOM -// -#ifndef _Partition_Inter3d_HeaderFile -#define _Partition_Inter3d_HeaderFile - -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class BRepAlgo_AsDes; -class TopTools_ListOfShape; -class TopTools_DataMapOfShapeShape; -class TopoDS_Face; -class TopTools_MapOfShape; -class TopoDS_Shape; -class TopoDS_Vertex; -class TopoDS_Edge; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Inter3d { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT Partition_Inter3d(); -Standard_EXPORT Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes); -Standard_EXPORT void CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,const TopTools_DataMapOfShapeShape& FaceShapeMap) ; -Standard_EXPORT void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ; -Standard_EXPORT Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const; -Standard_EXPORT TopTools_MapOfShape& TouchedFaces() ; -Standard_EXPORT Handle_BRepAlgo_AsDes AsDes() const; -Standard_EXPORT TopTools_MapOfShape& NewEdges() ; -Standard_EXPORT Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const; -Standard_EXPORT Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const; -Standard_EXPORT const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const; -Standard_EXPORT TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const; -Standard_EXPORT Handle_BRepAlgo_AsDes SectionEdgesAD() const; -Standard_EXPORT Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const; -Standard_EXPORT Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const; -Standard_EXPORT Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const; -Standard_EXPORT const TopTools_ListOfShape& SectionEdgeFaces(const TopoDS_Edge& SecE) const; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void Inter3D(const TopoDS_Face& F1,const TopoDS_Face& F2,TopTools_ListOfShape& LInt) ; -Standard_EXPORT void StorePart3d(const TopoDS_Face& F1,const TopoDS_Face& F2,const TopTools_ListOfShape& LInt1) ; -Standard_EXPORT void SetDone(const TopoDS_Face& F1,const TopoDS_Face& F2) ; -Standard_EXPORT void Affiche(const TopTools_ListOfShape& SetOfFaces) const; - - - // Fields PRIVATE - // -Handle_BRepAlgo_AsDes myAsDes; -TopTools_DataMapOfShapeListOfShape myDone; -TopTools_MapOfShape myTouched; -TopTools_MapOfShape myNewEdges; -Handle_BRepAlgo_AsDes mySectionEdgesAD; -TopTools_DataMapOfShapeListOfShape mySameDomainFM; -TopTools_DataMapOfShapeShape mySameDomainVM; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Inter3d.ixx b/src/PARTITION/Partition_Inter3d.ixx deleted file mode 100644 index a760097d0..000000000 --- a/src/PARTITION/Partition_Inter3d.ixx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter3d.ixx -// Module : GEOM -// -#include "Partition_Inter3d.jxx" - - - - diff --git a/src/PARTITION/Partition_Inter3d.jxx b/src/PARTITION/Partition_Inter3d.jxx deleted file mode 100644 index 54e7732e3..000000000 --- a/src/PARTITION/Partition_Inter3d.jxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Inter3d.jxx -// Module : GEOM -// -#ifndef _BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Partition_Inter3d_HeaderFile -#include "Partition_Inter3d.hxx" -#endif diff --git a/src/PARTITION/Partition_Loop.cdl b/src/PARTITION/Partition_Loop.cdl deleted file mode 100644 index 05bbf3e8b..000000000 --- a/src/PARTITION/Partition_Loop.cdl +++ /dev/null @@ -1,85 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Loop.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -class Loop from Partition - - ---Purpose: Builds the loops from a set of edges on a face. - -uses - - Face from TopoDS, - Edge from TopoDS, - ListOfShape from TopTools, - DataMapOfShapeListOfShape from TopTools - -is - - Create; - - Init (me : in out; F : Face from TopoDS) - ---Purpose: Init with the set of edges must have - -- pcurves on . - is static; - - AddEdge (me : in out; E : in out Edge from TopoDS; - LV : ListOfShape from TopTools) - ---Purpose: Add E with . will be copied and trim - -- by vertices in . - is static; - - AddConstEdge (me : in out; E : Edge from TopoDS) - ---Purpose: Add as const edge, E can be in the result. - is static; - - Perform(me : in out) - ---Purpose: Make loops. - is static; - - NewWires (me) - ---Purpose: Returns the list of wires performed. - -- can be an empty list. - ---C++: return const & - returns ListOfShape from TopTools; - - WiresToFaces (me : in out) - ---Purpose: Build faces from the wires result. - is static; - - NewFaces (me) - ---Purpose: Returns the list of faces. - ---Warning: The method as to be called before. - -- can be an empty list. - ---C++: return const & - returns ListOfShape from TopTools; - - -fields - - myFace : Face from TopoDS; - myConstEdges : ListOfShape from TopTools; - myNewWires : ListOfShape from TopTools; - myNewFaces : ListOfShape from TopTools; - -end Loop; diff --git a/src/PARTITION/Partition_Loop.cxx b/src/PARTITION/Partition_Loop.cxx deleted file mode 100644 index a14b233ba..000000000 --- a/src/PARTITION/Partition_Loop.cxx +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop.cxx -// Author : Benedicte MARTIN -// Module : GEOM -// $Header$ -// -#include - -#include "Partition_Loop.ixx" - -#include "utilities.h" - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -using namespace std; - -static char* name = new char[100]; -static int nbe = 0; - -//======================================================================= -//function : Partition_Loop -//purpose : -//======================================================================= -Partition_Loop::Partition_Loop() -{ -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= -void Partition_Loop::Init(const TopoDS_Face& F) -{ - myConstEdges.Clear(); - myNewWires .Clear(); - myNewFaces .Clear(); - myFace = F; -} - -//======================================================================= -//function : AddConstEdge -//purpose : -//======================================================================= -void Partition_Loop::AddConstEdge (const TopoDS_Edge& E) -{ - myConstEdges.Append(E); -} - - -//======================================================================= -//function : FindDelta -//purpose : -//======================================================================= -static Standard_Real FindDelta(TopTools_ListOfShape& LE, - const TopoDS_Face& F) -{ - Standard_Real dist, f, l; - Standard_Real d = Precision::Infinite(); - TopTools_ListIteratorOfListOfShape itl; - - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,f,l); - gp_Pnt2d p = C->Value(f); - gp_Pnt2d pp = C->Value(l); - Standard_Real d1 = p.Distance(pp); - if (d1 connected by the vertex in the list . -// Is erased of the list. If is too in the list -// with the same orientation, it's erased of the list -//======================================================================= -static Standard_Boolean SelectEdge(const TopoDS_Face& F, - const TopoDS_Edge& CE, - const TopoDS_Vertex& CV, - TopoDS_Edge& NE, - TopTools_ListOfShape& LE) -{ - TopTools_ListIteratorOfListOfShape itl; - NE.Nullify(); - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - if (itl.Value().IsEqual(CE)) { - LE.Remove(itl); - break; - } - } - - if (LE.Extent() > 1) { - //-------------------------------------------------------------- - // Several possible edges. - // - Test the edges differents of CE - //-------------------------------------------------------------- - Standard_Real cf, cl, f, l; - TopoDS_Face FForward = F; - Handle(Geom2d_Curve) Cc, C; - FForward.Orientation(TopAbs_FORWARD); - - Cc = BRep_Tool::CurveOnSurface(CE,FForward,cf,cl); - Standard_Real dist,distmin = 100*BRep_Tool::Tolerance(CV); - Standard_Real uc,u; - if (CE.Orientation () == TopAbs_FORWARD) uc = cl; - else uc = cf; - - gp_Pnt2d P2,PV = Cc->Value(uc); - - Standard_Real delta = FindDelta(LE,FForward); - - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - if (!E.IsSame(CE)) { - C = BRep_Tool::CurveOnSurface(E,FForward,f,l); - if (E.Orientation () == TopAbs_FORWARD) u = f; - else u = l; - P2 = C->Value(u); - dist = PV.Distance(P2); - if (dist <= distmin){ - distmin = dist; - } - - } - } - - Standard_Real anglemax = - PI; - TopoDS_Edge SelectedEdge; - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - if (!E.IsSame(CE)) { - C = BRep_Tool::CurveOnSurface(E,FForward,f,l); - if (E.Orientation () == TopAbs_FORWARD) u = f; - else u = l; - P2 = C->Value(u); - dist = PV.Distance(P2); - if (dist <= distmin + (1./3)*delta){ - gp_Pnt2d PC, P; - gp_Vec2d CTg1, CTg2, Tg1, Tg2; - Cc->D2(uc, PC, CTg1, CTg2); - C->D2(u, P, Tg1, Tg2); - - Standard_Real angle; - - if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_FORWARD) { - angle = CTg1.Angle(Tg1.Reversed()); - } - else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_REVERSED) { - angle = (CTg1.Reversed()).Angle(Tg1); - } - else if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_REVERSED) { - angle = CTg1.Angle(Tg1); - } - else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_FORWARD) { - angle = (CTg1.Reversed()).Angle(Tg1.Reversed()); - } - if (angle >= anglemax) { - anglemax = angle ; - SelectedEdge = E; - } - } - } - } - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - if (E.IsEqual(SelectedEdge)) { - NE = TopoDS::Edge(E); - LE.Remove(itl); - break; - } - } - } - else if (LE.Extent() == 1) { - NE = TopoDS::Edge(LE.First()); - LE.RemoveFirst(); - } - else { - return Standard_False; - } - return Standard_True; -} - -//======================================================================= -//function : SamePnt2d -//purpose : -//======================================================================= -static Standard_Boolean SamePnt2d(TopoDS_Vertex V, - TopoDS_Edge& E1, - TopoDS_Edge& E2, - TopoDS_Face& F) -{ - Standard_Real f1,f2,l1,l2; - gp_Pnt2d P1,P2; - TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD); - TopoDS_Face FF = TopoDS::Face(aLocalF); - Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1); - Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2); - if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1); - else P1 = C1->Value(l1); - - if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2); - else P2 = C2->Value(f2); - Standard_Real Tol = 100*BRep_Tool::Tolerance(V); - Standard_Real Dist = P1.Distance(P2); - return Dist < Tol; -} - -//======================================================================= -//function : PurgeNewEdges -//purpose : -//======================================================================= -static void PurgeNewEdges(TopTools_ListOfShape& ConstEdges, - const TopTools_MapOfOrientedShape& UsedEdges) -{ - TopTools_ListIteratorOfListOfShape it(ConstEdges); - while ( it.More()) { - const TopoDS_Shape& NE = it.Value(); - if (!UsedEdges.Contains(NE)) { - ConstEdges.Remove(it); - } - else { - it.Next(); - } - } -} - -//======================================================================= -//function : StoreInMVE -//purpose : -//======================================================================= -static void StoreInMVE (const TopoDS_Face& F, - TopoDS_Edge& E, - TopTools_DataMapOfShapeListOfShape& MVE ) - -{ - TopoDS_Vertex V1, V2; - TopTools_ListOfShape Empty; - - TopExp::Vertices(E,V1,V2); - if (!MVE.IsBound(V1)) { - MVE.Bind(V1,Empty); - } - MVE(V1).Append(E); - - if (!MVE.IsBound(V2)) { - MVE.Bind(V2,Empty); - } - MVE(V2).Append(E); -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -void Partition_Loop::Perform() -{ - - TopTools_DataMapOfShapeListOfShape MVE; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit, Mapit1; - TopTools_ListIteratorOfListOfShape itl; - TopoDS_Vertex V1,V2; - - //----------------------------------- - // Construction map vertex => edges - //----------------------------------- - for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) { - TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - StoreInMVE(myFace,E,MVE); - } - - //---------------------------------------------- - // Construction of all the wires and of all the new faces. - //---------------------------------------------- - TopTools_MapOfOrientedShape UsedEdges; - - while (!MVE.IsEmpty()) { - TopoDS_Vertex VF,CV; - TopoDS_Edge CE,NE,EF; - TopoDS_Wire NW; - BRep_Builder B; - Standard_Boolean End= Standard_False; - - B.MakeWire(NW); - //-------------------------------- - // EF first edge. - //-------------------------------- - Mapit.Initialize(MVE); - EF = CE = TopoDS::Edge(Mapit.Value().First()); - - TopExp::Vertices(CE,V1,V2); - //-------------------------------- - // VF first vertex - //-------------------------------- - if (CE.Orientation() == TopAbs_FORWARD) { - CV = VF = V1; - } - else { - CV = VF = V2; - } - if (!MVE.IsBound(CV)) continue; - for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) { - if (itl.Value().IsEqual(CE)) { - MVE(CV).Remove(itl); - break; - } - } - - int i = 0; - while (!End) { - //------------------------------- - // Construction of a wire. - //------------------------------- - TopExp::Vertices(CE,V1,V2); - if (!CV.IsSame(V1)) CV = V1; else CV = V2; - B.Add (NW,CE); - UsedEdges.Add(CE); - - //-------------- - // stop test - //-------------- - if (!MVE.IsBound(CV) || MVE(CV).IsEmpty() || CV.IsSame(VF) ) { - if (CV.IsSame(VF)) { - if (MVE(CV).Extent() == 1 ) MVE.UnBind(CV); - else { - for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) { - if (itl.Value().IsEqual(CE)) { - MVE(CV).Remove(itl); - break; - } - } - } - } - End=Standard_True; - } - - //-------------- - // select edge - //-------------- - else { - Standard_Boolean find = SelectEdge(myFace,CE,CV,NE,MVE(CV)); - if (find) { - CE=NE; - if (MVE(CV).IsEmpty()) MVE.UnBind(CV); - if (CE.IsNull() ) { - MESSAGE ( " CE is NULL !!! " ) - End=Standard_True; - } - } - else { - MESSAGE ( " edge doesn't exist " ) - End=Standard_True; - } - } - } - - //----------------------------- - // Test if the wire is closed - //----------------------------- - if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) { - } - else{ - MESSAGE ( "wire not closed" ) - } - myNewWires.Append (NW); - } - - PurgeNewEdges(myConstEdges,UsedEdges); - -} - - -//======================================================================= -//function : NewWires -//purpose : -//======================================================================= -const TopTools_ListOfShape& Partition_Loop::NewWires() const -{ - return myNewWires; -} - -//======================================================================= -//function : NewFaces -//purpose : -//======================================================================= -const TopTools_ListOfShape& Partition_Loop::NewFaces() const -{ - return myNewFaces; -} - -//======================================================================= -//function : WiresToFaces -//purpose : -//======================================================================= -void Partition_Loop::WiresToFaces() -{ - if (!myNewWires.IsEmpty()) { - BRepAlgo_FaceRestrictor FR; - - TopAbs_Orientation OriF = myFace.Orientation(); - TopoDS_Shape aLocalS = myFace.Oriented(TopAbs_FORWARD); - - FR.Init (TopoDS::Face(aLocalS),Standard_False); - TopTools_ListIteratorOfListOfShape it(myNewWires); - for (; it.More(); it.Next()) { - FR.Add(TopoDS::Wire(it.Value())); - } - - FR.Perform(); - - if (FR.IsDone()) { - for (; FR.More(); FR.Next()) { - myNewFaces.Append(FR.Current().Oriented(OriF)); - } - } - } -} diff --git a/src/PARTITION/Partition_Loop.hxx b/src/PARTITION/Partition_Loop.hxx deleted file mode 100644 index 6d8113716..000000000 --- a/src/PARTITION/Partition_Loop.hxx +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop.hxx -// Module : GEOM -// -#ifndef _Partition_Loop_HeaderFile -#define _Partition_Loop_HeaderFile - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile -#include -#endif -class TopoDS_Face; -class TopoDS_Edge; -class TopTools_ListOfShape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Loop { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT Partition_Loop(); -Standard_EXPORT void Init(const TopoDS_Face& F) ; -Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ; -Standard_EXPORT void Perform() ; -Standard_EXPORT const TopTools_ListOfShape& NewWires() const; -Standard_EXPORT void WiresToFaces() ; -Standard_EXPORT const TopTools_ListOfShape& NewFaces() const; - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -TopoDS_Face myFace; -TopTools_ListOfShape myConstEdges; -TopTools_ListOfShape myNewWires; -TopTools_ListOfShape myNewFaces; - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Loop.ixx b/src/PARTITION/Partition_Loop.ixx deleted file mode 100644 index 3b69d33db..000000000 --- a/src/PARTITION/Partition_Loop.ixx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop.ixx -// Module : GEOM -// -#include "Partition_Loop.jxx" - - - - diff --git a/src/PARTITION/Partition_Loop.jxx b/src/PARTITION/Partition_Loop.jxx deleted file mode 100644 index a9384fe3a..000000000 --- a/src/PARTITION/Partition_Loop.jxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop.jxx -// Module : GEOM -// -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _Partition_Loop_HeaderFile -#include "Partition_Loop.hxx" -#endif diff --git a/src/PARTITION/Partition_Loop2d.cdl b/src/PARTITION/Partition_Loop2d.cdl deleted file mode 100644 index ee7ac3404..000000000 --- a/src/PARTITION/Partition_Loop2d.cdl +++ /dev/null @@ -1,98 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Loop2d.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -class Loop2d from Partition - - ---Purpose: Builds the loops from a set of edges on a face. - -- It works in supposition that all constant edges - -- are split edges of an initialization face and all - -- section edges are new on the face - -uses - - Orientation from TopAbs, - Boolean from Standard, - Face from TopoDS, - Image from BRepAlgo, - Face from TopoDS, - Edge from TopoDS, - ListOfShape from TopTools, - DataMapOfShapeListOfShape from TopTools, - MapOfShape from TopTools -is - - Create; - - Init (me : in out; F : Face from TopoDS) - ---Purpose: Init with the set of edges must have - -- pcurves on . - is static; - - AddConstEdge (me : in out; E : Edge from TopoDS) - ---Purpose: Add as unique edge in the result. - is static; - - AddSectionEdge (me : in out; E : Edge from TopoDS) - ---Purpose: Add as double edge in the result. - is static; - - Perform(me : in out) - ---Purpose: Make loops. - is static; - - NewWires (me) - ---Purpose: Returns the list of wires performed. - -- can be an empty list. - ---C++: return const & - returns ListOfShape from TopTools; - - WiresToFaces (me : in out; EdgeImage : Image from BRepAlgo) - ---Purpose: Build faces from the wires result. - -- serves to find original edge by new - -- one. - is static; - - NewFaces (me) - ---Purpose: Returns the list of faces. - ---Warning: The method as to be called before. - -- can be an empty list. - ---C++: return const & - returns ListOfShape from TopTools; - - -fields - - myFace : Face from TopoDS; - myFaceOri : Orientation from TopAbs; - myConstEdges : ListOfShape from TopTools; - myNewWires : ListOfShape from TopTools; - myNewFaces : ListOfShape from TopTools; - - -- internal wires do not contain constant edges - myInternalWL : ListOfShape from TopTools; - - mySectionEdges : MapOfShape from TopTools; - -end Loop2d; diff --git a/src/PARTITION/Partition_Loop2d.cxx b/src/PARTITION/Partition_Loop2d.cxx deleted file mode 100644 index 534e76a41..000000000 --- a/src/PARTITION/Partition_Loop2d.cxx +++ /dev/null @@ -1,1155 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop2d.cxx -// Author : Benedicte MARTIN -// Module : GEOM -// $Header$ -// -#include "Partition_Loop2d.ixx" - -#include "utilities.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -//======================================================================= -//function : Partition_Loop2d -//purpose : -//======================================================================= - -Partition_Loop2d::Partition_Loop2d() -{ -} - -//======================================================================= -//function : Init -//purpose : Init with the set of edges must have -// pcurves on . -//======================================================================= - -void Partition_Loop2d::Init(const TopoDS_Face& F) -{ - myConstEdges.Clear(); - myNewWires .Clear(); - myNewFaces .Clear(); - myFace = F; - myFaceOri = myFace.Orientation(); - myFace.Orientation( TopAbs_FORWARD ); -} - -//======================================================================= -//function : AddConstEdge -//purpose : Add as unique edge in the result. -//======================================================================= - -void Partition_Loop2d::AddConstEdge (const TopoDS_Edge& E) -{ -#ifdef DEB - Standard_Real f,l; - Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( E, myFace, f,l); - if (pc.IsNull()) { - INFOS( "AddConstEdge(): EDGE W/O PCURVE on FACE"); - } else -#endif - { - myConstEdges.Append(E); - } -} - -void Partition_Loop2d::AddSectionEdge (const TopoDS_Edge& E) -{ -#ifdef DEB - Standard_Real f,l; - Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( E, myFace, f,l); - if (pc.IsNull()) - pc = BRep_Tool::CurveOnSurface( E, myFace, f,l); - gp_Vec2d Tg1; - gp_Pnt2d PC; - pc->D1(0.5*(f+l), PC, Tg1); - if (Tg1.Magnitude() <= gp::Resolution()) { - MESSAGE (""); - } - if (pc.IsNull()) { - INFOS( "AddConstEdge(): EDGE W/O PCURVE on FACE"); - } else -#endif - { - myConstEdges.Append(E); - myConstEdges.Append(E.Reversed()); - mySectionEdges.Add( E ); - } -} - -//======================================================================= -//function : preciseU -//purpose : find u such that the 3D point on theE is just out of tolerance -// of theV -//======================================================================= - -static Standard_Real preciseU (const BRepAdaptor_Surface& theSurf, - const TopoDS_Edge& theE, - const TopoDS_Vertex& theV, - const Handle(Geom2d_Curve)& theC, - const Standard_Boolean theFirstEnd) -{ - Standard_Boolean isForward = ( theE.Orientation () == TopAbs_FORWARD ); - if (theFirstEnd) isForward = !isForward; - - // find the first point in 2d and 3d - Standard_Real f,l; - BRep_Tool::Range( theE, f, l ); - Standard_Real u0 = isForward ? l : f; - gp_Pnt2d aP2d0 = theC->Value( u0 ); - gp_Pnt aPnt0 = theSurf.Value( aP2d0.X(), aP2d0.Y() ); - - // shift in 2d and 3d - Standard_Real du = ( l - f ) / 100, du3d = 0; - if (isForward) - du = -du; - - // target parameter - Standard_Real u; - - while (du3d < ::RealSmall()) - { - // u for test - u = u0 + du; - du *= 10; // for the next iteration: increase du untill du3d is large enough - - // find out how u is far from u0 in 3D - gp_Pnt2d aP2d = theC->Value( u ); - gp_Pnt aPnt = theSurf.Value( aP2d.X(), aP2d.Y() ); - du3d = aPnt0.Distance( aPnt ); - } - - // find u such that the 3D point is just out of tolerance of theV - Standard_Real tolV = BRep_Tool::Tolerance( theV ) + Precision::Confusion(); - u = u0 + du * tolV / du3d; - - // check that u is within the range - if ( isForward ? (u < f) : (u > l) ) - u = u0 + du; - - return u; -} - -//======================================================================= -//function : SelectEdge -//purpose : Find in the list the edge connected with by -// the vertex . -// is removed from the list. If is in -// with the same orientation, it's removed from the list -//======================================================================= - -static Standard_Boolean SelectEdge(const BRepAdaptor_Surface& Surf, - const TopoDS_Edge& CE, - const TopoDS_Vertex& CV, - TopoDS_Edge& NE, - const TopTools_ListOfShape& LE) -{ - NE.Nullify(); - - if (LE.Extent() > 1) { - //-------------------------------------------------------------- - // Several possible edges. - // - Test the edges differents of CE - //-------------------------------------------------------------- - TopoDS_Face FForward = Surf.Face(); - TopoDS_Edge aPrevNE; - - gp_Vec2d CTg1, Tg1, CTg2, Tg2; - gp_Pnt2d PC, P; - - Standard_Real f, l; - Handle(Geom2d_Curve) Cc, C; - Cc = BRep_Tool::CurveOnSurface(CE,FForward,f,l); - - Standard_Boolean isForward = ( CE.Orientation () == TopAbs_FORWARD ); - Standard_Real uc, u, du = Precision::PConfusion(); - uc = isForward ? ( l - du ) : ( f + du ); - Cc->D1(uc, PC, CTg1); - if (!isForward) CTg1.Reverse(); - - Standard_Real anglemin = 3 * PI, tolAng = 1.e-8; - - // select an edge whose first derivative is most left of CTg1 - // ie an angle between Tg1 and CTg1 is least - TopTools_ListIteratorOfListOfShape itl; - for ( itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - if (E.IsSame(CE)) - continue; - if (! CV.IsSame( TopExp::FirstVertex( E, Standard_True ))) - continue; - - isForward = ( E.Orientation () == TopAbs_FORWARD ); - - // get E curve - C = BRep_Tool::CurveOnSurface(E,FForward,f,l); - // get the first derivative Tg1 - u = isForward ? ( f + du ) : ( l - du ); - C->D1(u, P, Tg1); - if (!isForward) Tg1.Reverse(); - - // -PI < angle < PI - Standard_Real angle = Tg1.Angle(CTg1); - - if (PI - Abs(angle) <= tolAng) - { - // an angle is too close to PI; assure that an angle sign really - // reflects an edge position: +PI - an edge is worst, - // -PI - an edge is best. - u = preciseU( Surf, CE, CV, Cc, Standard_False); - gp_Vec2d CTg; - Cc->D1(u, PC, CTg); - if (CE.Orientation() == TopAbs_REVERSED) CTg.Reverse(); - - u = preciseU( Surf, E, CV, C, Standard_True); - C->D1(u, P, Tg1); - if (!isForward) Tg1.Reverse(); - - angle = Tg1.Angle(CTg); - } - - Standard_Boolean isClose = ( Abs( angle - anglemin ) <= tolAng ); - if (angle <= anglemin) { - if (isClose) - aPrevNE = NE; - else - aPrevNE.Nullify(); - anglemin = angle ; - NE = E; - } - else - if (isClose) - aPrevNE = E; - - } - if (!aPrevNE.IsNull()) { - // select one of close edges, the most left one. - Cc = BRep_Tool::CurveOnSurface( NE, FForward, f, l ); - uc = preciseU( Surf, NE, CV, Cc, Standard_True); - Cc->D1(uc, PC, CTg1); - if (NE.Orientation() != TopAbs_FORWARD) CTg1.Reverse(); - - u = preciseU( Surf, aPrevNE, CV, C, Standard_True); - C->D1(u, P, Tg1); - if (aPrevNE.Orientation() != TopAbs_FORWARD) Tg1.Reverse(); - - if ( Tg1.Angle(CTg1) < 0) - NE = aPrevNE; - } - } - else if (LE.Extent() == 1) { - NE = TopoDS::Edge(LE.First()); - } - else { - return Standard_False; - } - return !NE.IsNull(); -} - -//======================================================================= -//function : SamePnt2d -//purpose : -//======================================================================= - -static Standard_Boolean SamePnt2d(const TopoDS_Vertex& V1, - const TopoDS_Edge& E1, - const TopoDS_Vertex& V2, - const TopoDS_Edge& E2, - const TopoDS_Face& F) -{ - Standard_Real f1,f2,l1,l2; - Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,F,f1,l1); - Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,F,f2,l2); - - gp_Pnt2d P1 = C1->Value( BRep_Tool::Parameter(V1,E1)); - gp_Pnt2d P2 = C2->Value( BRep_Tool::Parameter(V2,E2)); - - Standard_Real Tol = 100 * BRep_Tool::Tolerance(V1); - Standard_Real Dist = P1.Distance(P2); - return Dist < Tol; -} - - -//======================================================================= -//function : StoreInMVE -//purpose : -//======================================================================= - -static void StoreInMVE (const TopoDS_Face& /*F*/, - TopoDS_Edge& E, - TopTools_DataMapOfShapeListOfShape& MVE ) - -{ - TopoDS_Vertex V1, V2; - TopTools_ListOfShape Empty; - - TopExp::Vertices(E,V1,V2); - if (!MVE.IsBound(V1)) { - MVE.Bind(V1,Empty); - } - MVE(V1).Append(E); - - if (!MVE.IsBound(V2)) { - MVE.Bind(V2,Empty); - } - MVE(V2).Append(E); -} - -//======================================================================= -//function : RemoveFromMVE -//purpose : -//======================================================================= - -static void RemoveFromMVE(const TopoDS_Edge& E, - TopTools_DataMapOfShapeListOfShape& MVE) -{ - TopTools_ListIteratorOfListOfShape itl; - TopoDS_Vertex V1,V2; - TopExp::Vertices (E,V1,V2); - if (MVE.IsBound(V1)) - for ( itl.Initialize(MVE(V1)); itl.More(); itl.Next()) { - if (itl.Value().IsEqual(E)) { - MVE(V1).Remove(itl); - break; - } - } - if (MVE.IsBound(V2)) - for ( itl.Initialize(MVE(V2)); itl.More(); itl.Next()) { - if (itl.Value().IsEqual(E)) { - MVE(V2).Remove(itl); - break; - } - } -} -//======================================================================= -//function : addConnected -//purpose : add to all edges reachable from -//======================================================================= - -static void addConnected(const TopoDS_Shape& E, - TopTools_MapOfShape& EM, - TopTools_MapOfShape& VM, - const TopTools_DataMapOfShapeListOfShape& MVE) -{ - // Loop on vertices of E - TopoDS_Iterator itV ( E ); - for ( ; itV.More(); itV.Next()) { - - if ( ! VM.Add ( itV.Value() )) continue; - - // Loop on edges sharing V - TopTools_ListIteratorOfListOfShape itE( MVE( itV.Value() ) ); - for (; itE.More(); itE.Next()) { - if ( EM.Add( itE.Value() )) - addConnected ( itE.Value(), EM, VM, MVE ); - } - } -} -//======================================================================= -//function : canPassToOld -//purpose : -//======================================================================= - -// static Standard_Boolean canPassToOld (const TopoDS_Shape& V, -// TopTools_MapOfShape& UsedShapesMap, -// const TopTools_DataMapOfShapeListOfShape& MVE, -// const TopTools_MapOfShape& SectionEdgesMap) -// { -// TopTools_ListIteratorOfListOfShape itE( MVE(V) ); -// // Loop on edges sharing V -// for (; itE.More(); itE.Next()) { -// if ( !UsedShapesMap.Add( itE.Value() )) -// continue; // already checked - -// if ( !SectionEdgesMap.Contains( itE.Value() )) -// return Standard_True; // WE PASSED - -// TopoDS_Iterator itV( itE.Value() ); -// // Loop on vertices of an edge -// for (; itV.More(); itV.Next()) { -// if ( !UsedShapesMap.Add( itV.Value() )) -// continue; // already checked -// else -// return canPassToOld( itV.Value(), UsedShapesMap, MVE, SectionEdgesMap); -// } -// } -// return Standard_False; -// } - -//======================================================================= -//function : MakeDegenAndSelect -//purpose : Find parameter of intersection of with and -// select an edge with its parameter closest to found one. -// Return new degenerated edge trimming by found parameters -//======================================================================= - -static TopoDS_Edge MakeDegenAndSelect(const TopoDS_Edge& CE, - const TopoDS_Vertex& CV, - TopoDS_Edge& NE, - TopTools_SequenceOfShape& EdgesSeq, - TColStd_SequenceOfReal& USeq, - const TopoDS_Edge& DE) -{ - if (EdgesSeq.Length() < 3) { - if (CE == EdgesSeq.First()) - NE = TopoDS::Edge( EdgesSeq.Last() ); - else - NE = TopoDS::Edge( EdgesSeq.First() ); - return DE; - } - - // find parameter on DE where it intersects CE - - Standard_Real U1; - Standard_Integer i, nb = EdgesSeq.Length(); - for (i=1; i<= nb; ++i) { - if (CE == EdgesSeq(i)) { - U1 = USeq(i); - break; - } - } - - // select NE with param closest to U1 thus finding U2 for a new degen edge - - Standard_Real U2, dU, dUmin = 1.e100; - Standard_Boolean isReversed = ( DE.Orientation() == TopAbs_REVERSED ); - for (i=1; i<= nb; ++i) { - dU = USeq(i) - U1; - if (isReversed ? (dU > 0) : (dU < 0)) - continue; - dU = Abs( dU ); - if ( dU > dUmin || IsEqual( dU, 0.)) - continue; - const TopoDS_Edge& E = TopoDS::Edge ( EdgesSeq(i) ); - if ( ! CV.IsSame( TopExp::FirstVertex( E , Standard_True ))) - continue; - NE = E; - dUmin = dU + Epsilon(dU); - U2 = USeq(i); - } - - // make a new degenerated edge - TopoDS_Edge NewDegen = TopoDS::Edge ( DE.EmptyCopied() ); - - Standard_Real Tol = BRep_Tool::Tolerance( CV ); - TopoDS_Vertex V = CV; - - BRep_Builder B; - V.Orientation( NewDegen.Orientation() ); - B.UpdateVertex( V, U1, NewDegen, Tol); - B.Add ( NewDegen , V ); - - V.Reverse(); - B.UpdateVertex( V, U2, NewDegen, Tol); - B.Add ( NewDegen , V ); - - return NewDegen; -} - -//======================================================================= -//function : prepareDegen -//purpose : Intersect with edges bound to its vertex in -// and store intersection parameter on in -// as well as the edges them-self in . -// Bind to vertex of in -//======================================================================= - -static void prepareDegen (const TopoDS_Edge& DegEdge, - const TopoDS_Face& F, - const TopTools_DataMapOfShapeListOfShape& MVE, - TopTools_SequenceOfShape& EdgesSeq, - TColStd_SequenceOfReal& USeq, - TopTools_DataMapOfShapeInteger& MVDEI, - const Standard_Integer DegEdgeIndex) -{ - const TopoDS_Vertex& V = TopExp::FirstVertex ( DegEdge ); - MVDEI.Bind ( V, DegEdgeIndex ); - - const TopTools_ListOfShape& EdgesList = MVE ( V ); - // if only 2 edges come to degenerated one, no pb in selection and - // no need to intersect them, just simulate asked data - Standard_Boolean doIntersect = ( EdgesList.Extent() > 2 ); - - BRepAdaptor_Curve2d DC, C; - Geom2dInt_GInter InterCC; - Standard_Real Tol = Precision::PConfusion(); - if ( doIntersect ) - DC.Initialize( DegEdge, F ); - - // avoid intersecting twice the same edge - BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() ); - - Standard_Real U, f, l; - BRep_Tool::Range (DegEdge, f, l); - - TopTools_ListIteratorOfListOfShape itE (EdgesList); - for (; itE.More(); itE.Next()) { - - const TopoDS_Edge& E = TopoDS::Edge ( itE.Value() ); - - if ( !doIntersect) { - U = 0.; // it won't be used - } - else if ( BRep_Tool::IsClosed( E, F )) { - // seam edge: select U among f and l - Standard_Boolean first = Standard_True; - if ( V.IsSame ( TopExp::FirstVertex( E, Standard_True ) )) - first = Standard_False; - if ( DegEdge.Orientation() == TopAbs_REVERSED ) - first = !first; - U = first ? f : l; - } - else if ( EUMap.IsBound( E ) ) { - // same edge already bound - U = EUMap( E ); - } - else { - // intersect 2d curves - C.Initialize( E, F ); - InterCC.Perform ( DC, C , Tol, Tol ); - if (! InterCC.IsDone() || InterCC.NbPoints() == 0) { - MESSAGE ( "NO 2d INTERSECTION ON DEGENERATED EDGE" ); - continue; - } - // hope there is only one point of intersection - U = InterCC.Point( 1 ).ParamOnFirst(); - } - USeq.Append ( U ); - EdgesSeq.Append ( E ); - } -} -//======================================================================= -//function : Perform -//purpose : Make loops. -//======================================================================= - -void Partition_Loop2d::Perform() -{ - - Standard_Integer NbConstEdges = myConstEdges.Extent(); - TopTools_DataMapOfShapeListOfShape MVE(NbConstEdges) , MVE2(NbConstEdges); - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; - TopTools_ListIteratorOfListOfShape itl; - TopoDS_Vertex V1,V2; - BRepAdaptor_Surface Surface ( myFace, Standard_False ); - - // degenerated edges and parameters of their 2d intersection with other edges - TopoDS_Edge DE [2]; - TopTools_SequenceOfShape SEID [2]; // seq of edges intersecting degenerated - TColStd_SequenceOfReal SeqU [2]; // n-th U corresponds to n-th edge in SEID - TopTools_DataMapOfShapeInteger MVDEI(2); // map vertex - degenerated edge index - Standard_Integer iDeg = 0; // index of degenerated edge [0,1] - - //--------------------------------------------------------- - // Construction map vertex => edges, find degenerated edges - //--------------------------------------------------------- - for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) { - TopoDS_Edge& E = TopoDS::Edge(itl.Value()); - if ( BRep_Tool::Degenerated( E )) { - if (DE[0].IsNull()) DE[0] = E; - else DE[1] = E; - } - else - StoreInMVE(myFace,E,MVE); - } - - // fill data for degenerated edges - if ( ! DE[0].IsNull() ) - prepareDegen ( DE[0], myFace, MVE, SEID[0], SeqU[0], MVDEI, 0); - if ( ! DE[1].IsNull() ) - prepareDegen ( DE[1], myFace, MVE, SEID[1], SeqU[1], MVDEI, 1); - - - // to detect internal wires - Standard_Boolean isInternCW = 0; - MVE2 = MVE; - - - //------------------------------ - // Construction of all the wires - //------------------------------ - // first, we collect wire edges in WEL list looking for same edges that - // will be then removed possibly exploding a wire into parts; - // second, build wire(s) - - while (!MVE.IsEmpty()) { - - TopoDS_Vertex VF,CV; - TopoDS_Edge CE,NE,EF; - TopoDS_Wire NW; - BRep_Builder B; - Standard_Boolean End = Standard_False; - TopTools_ListOfShape WEL; - - Mapit.Initialize(MVE); - if (Mapit.Value().IsEmpty()) { - MVE.UnBind(Mapit.Key()); - continue; - } - - // EF first edge. - EF = CE = TopoDS::Edge(Mapit.Value().First()); - // VF first vertex - VF = TopExp::FirstVertex( CE, Standard_True); - - isInternCW = Standard_True; - - TopTools_MapOfShape addedEM (NbConstEdges); // map of edges added to WEL - TopTools_MapOfShape doubleEM (NbConstEdges); // edges encountered twice in WEL - - //------------------------------- - // Construction of a wire. - //------------------------------- - while (!End) { - - // only a seam is allowed twice in a wire, the others should be removed - if (addedEM.Add ( CE ) || BRep_Tool::IsClosed( CE, myFace ) ) - WEL.Append( CE ); - else { - doubleEM.Add( CE ); - RemoveFromMVE (CE,MVE2); - TopoDS_Edge CERev = CE; - CERev.Reverse(); - RemoveFromMVE (CERev,MVE2); - } - - RemoveFromMVE (CE,MVE); - - CV = TopExp::LastVertex( CE, Standard_True); - - if (isInternCW && !mySectionEdges.Contains(CE)) - // wire is internal if all edges are section ones - isInternCW = Standard_False; - - if (MVDEI.IsBound( CV )) { // CE comes to the degeneration - iDeg = MVDEI( CV ); - TopoDS_Edge NewDegen; - NewDegen = MakeDegenAndSelect( CE, CV, NE, SEID[iDeg], SeqU[iDeg], DE[iDeg]); - WEL.Append( NewDegen ); - CE = NE; - End = CV.IsSame( VF ); - continue; - } - - //-------------- - // stop test - //-------------- - if (MVE(CV).IsEmpty()) { - End=Standard_True; - MVE.UnBind(CV); - } - else if (CV.IsSame(VF) && SamePnt2d(CV,CE, VF,EF, myFace) ) { - End = Standard_True; - } - else { - //---------------------------- - // select new current edge - //---------------------------- - if (! SelectEdge (Surface,CE,CV,NE,MVE(CV))) { - MESSAGE ( " NOT CLOSED WIRE " ); - End=Standard_True; - } - else - CE = NE; - } - } // while ( !End ) - - - // WEL is built, built wire(s) - - - itl.Initialize( WEL ); - if ( doubleEM.IsEmpty()) { // no double edges - B.MakeWire( NW ); - for (; itl.More(); itl.Next()) - B.Add ( NW, itl.Value()); - if (isInternCW) myInternalWL.Append(NW); - else myNewWires.Append (NW); - } - - else { - // remove double and degenerated edges from WEL - while (itl.More()) { - const TopoDS_Edge& E = TopoDS::Edge ( itl.Value() ); - if ( doubleEM.Contains( E ) || BRep_Tool::Degenerated( E )) - WEL.Remove( itl ); - else - itl.Next(); - } - if ( WEL.IsEmpty()) - continue; - // remove double edges from SEID and SeqU - Standard_Integer i,j; - for (j=0; j<2; ++j) { - for (i=1; i<=SEID[j].Length(); ++i) { - if (doubleEM.Contains( SEID[j].Value(i))) { - SEID[j].Remove( i ); - SeqU[j].Remove( i-- ); - } - } - } - // removal of doulbe edges can explode a wire into parts, - // make new wires of them. - // A Loop like previous one but without 2d check - while ( !WEL.IsEmpty() ) { - CE = TopoDS::Edge( WEL.First() ); - WEL.RemoveFirst(); - B.MakeWire( NW ); - VF = TopExp::FirstVertex ( CE, Standard_True); - - End = Standard_False; - while ( !End) { - B.Add( NW, CE ); - CV = TopExp::LastVertex ( CE, Standard_True); - - if (MVDEI.IsBound( CV )) { // CE comes to the degeneration - iDeg = MVDEI( CV ); - TopoDS_Edge NewDegen; - NewDegen = MakeDegenAndSelect( CE, CV, NE, SEID[iDeg], SeqU[iDeg], DE[iDeg]); - B.Add( NW, NewDegen ); - End = CV.IsSame( VF ); - CE = NE; - if (!NE.IsNull()) { // remove NE from WEL - for (itl.Initialize( WEL ); itl.More(); itl.Next()) - if ( NE == itl.Value()) { - WEL.Remove( itl ); - break; - } - } - } // end degeneration - - else { - if (CV.IsSame( VF )) { - End = Standard_True; - continue; - } - // edges in WEL most often are well ordered - // so try to iterate until the End - Standard_Boolean add = Standard_False; - itl.Initialize(WEL); - while ( itl.More() && !End) { - NE = TopoDS::Edge( itl.Value() ); - if ( CV.IsSame( TopExp::FirstVertex( NE, Standard_True ))) { - WEL.Remove( itl ); - if (add) - B.Add( NW, CE ); - CE = NE; - add = Standard_True; - CV = TopExp::LastVertex( CE, Standard_True); - if (MVDEI.IsBound( CV ) || CV.IsSame( VF )) - break; - } - else - itl.Next(); - } - if (!add) - End = Standard_True; - } - } // !End - - myInternalWL.Append( NW ); - } - } // end building new wire(s) from WEL - - } // end Loop on MVE - - // all wires are built - - - // ============================================================ - // select really internal wires i.e. those from which we can`t - // pass to an old (not section) edge - // ============================================================ - - Standard_Integer nbIW = myInternalWL.Extent(); - if (nbIW == 0) - return; - - if ( myNewWires.Extent() != 1 && nbIW > 1) { - TopTools_MapOfShape outerEM (NbConstEdges); // edges connected to non-section ones - TopTools_MapOfShape visitedVM (NbConstEdges); - for ( itl.Initialize( myConstEdges ); itl.More(); itl.Next()) { - if ( ! mySectionEdges.Contains( itl.Value() )) - addConnected (itl.Value(), outerEM, visitedVM, MVE2); - } - // if an edge of a wire is in , the wire is not internal - TopExp_Explorer expIWE; - TopTools_ListIteratorOfListOfShape itIW ( myInternalWL ); - while (itIW.More()) { - expIWE.Init ( itIW.Value() , TopAbs_EDGE ); - if ( outerEM.Contains( expIWE.Current() )) { - myNewWires.Append ( itIW.Value() ); - myInternalWL.Remove( itIW ); // == itIW.Next() - } - else - itIW.Next(); - } - } -} -//======================================================================= -//function : isHole -//purpose : -//======================================================================= - -static Standard_Boolean isHole (const TopoDS_Wire& W, - const TopoDS_Face& F) -{ - BRep_Builder B; - TopoDS_Shape newFace = F.EmptyCopied(); - B.Add(newFace,W.Oriented(TopAbs_FORWARD)); - BRepTopAdaptor_FClass2d classif (TopoDS::Face(newFace), - Precision::PConfusion()); - return (classif.PerformInfinitePoint() == TopAbs_IN); -} - -//======================================================================= -//function : IsInside -//purpose : check if W1 is inside W2. Suppose W2 is not a hole !!!! -//======================================================================= - -static Standard_Boolean isInside(const TopoDS_Face& F, - const TopoDS_Wire& W1, - const TopoDS_Wire& W2) -{ - // make a face with wire W2 - BRep_Builder B; - TopoDS_Shape aLocalShape = F.EmptyCopied(); - TopoDS_Face newFace = TopoDS::Face(aLocalShape); - B.Add(newFace,W2); - - // get any 2d point of W1 - TopExp_Explorer exp(W1,TopAbs_EDGE); - if (BRep_Tool::Degenerated( TopoDS::Edge( exp.Current() ))) - exp.Next(); - const TopoDS_Edge& e = TopoDS::Edge(exp.Current()); - Standard_Real f,l; - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(e,F,f,l); - gp_Pnt2d pt2d(C2d->Value( 0.5 * ( f + l ))); - - BRepTopAdaptor_FClass2d classif(newFace,Precision::PConfusion()); - return (classif.Perform(pt2d) == TopAbs_IN); -} - -//======================================================================= -//function : NewWires -//purpose : Returns the list of wires performed. -// can be an empty list. -//======================================================================= - -const TopTools_ListOfShape& Partition_Loop2d::NewWires() const -{ - return myNewWires; -} - -//======================================================================= -//function : NewFaces -//purpose : Returns the list of faces. -//Warning : The method as to be called before. -// can be an empty list. -//======================================================================= - -const TopTools_ListOfShape& Partition_Loop2d::NewFaces() const -{ - return myNewFaces; -} - -//======================================================================= -//function : findEqual -//purpose : move wires form to pairs of wires build of the same edges -//======================================================================= - -static void findEqual (TopTools_ListOfShape& WL, - TopTools_DataMapOfShapeShape& EqWM, - const TopoDS_Face& F) -{ - TopTools_ListIteratorOfListOfShape it1, it2; - Standard_Integer i,j; - TColStd_MapOfInteger IndMap; - for (it1.Initialize(WL), i=1; it1.More(); it1.Next(), i++) { - - if (IndMap.Contains(i)) continue; - const TopoDS_Wire& Wire1 = TopoDS::Wire( it1.Value()); - - for (it2.Initialize(WL), j=1; it2.More(); it2.Next(), j++) { - - if (j <= i || IndMap.Contains(j)) continue; - - TopTools_IndexedMapOfShape EdgesMap; - TopExp::MapShapes (Wire1, TopAbs_EDGE, EdgesMap); - - const TopoDS_Shape& Wire2 = it2.Value(); - TopoDS_Iterator itE ( Wire2); - for (; itE.More(); itE.Next()) { - if ( !EdgesMap.Contains( itE.Value()) ) - break; - } - if (!itE.More()) { // all edges are same - if (isHole( Wire1, F)) { - EqWM.Bind ( Wire1, Wire2 ); - } - else { - EqWM.Bind ( Wire2, Wire1 ); - } - IndMap.Add(i); - IndMap.Add(j); - break; - } - } - } - // clear WL - it1.Initialize(WL); - i=1; - while (it1.More()) { - if (IndMap.Contains(i)) - WL.Remove(it1); // next node becomes current and with Next() we would miss it - else - it1.Next(); - i++; - } -} - -//======================================================================= -//function : classify -//purpose : bind to a wire a list of internal wires -//======================================================================= - -static void classify(const TopTools_DataMapOfShapeShape& EqWM, - BRepAlgo_AsDes& OuterInner, - const TopoDS_Face& F) -{ - TopTools_DataMapIteratorOfDataMapOfShapeShape it1, it2; - - for (it1.Initialize(EqWM); it1.More(); it1.Next()) { - // find next after it1.Value() - for (it2.Initialize(EqWM); it2.More(); it2.Next()) - if (it1.Value().IsSame( it2.Value() )) - { - it2.Next(); - break; - } - for ( ; it2.More(); it2.Next()) { - const TopoDS_Wire& Wire1 = TopoDS::Wire( it1.Value() ); - const TopoDS_Wire& Wire2 = TopoDS::Wire( it2.Value() ); - if (isInside(F, Wire1, Wire2)) - OuterInner.Add (Wire2, Wire1); - else if (isInside(F, Wire2, Wire1)) - OuterInner.Add (Wire1, Wire2); - } - } -} -//======================================================================= -//function : WiresToFaces -//purpose : Build faces from the wires result. -// serves to find original edge by new -// one.
contains edges resulting from face -// intersections -//======================================================================= - -void Partition_Loop2d::WiresToFaces(const BRepAlgo_Image& ) -{ - Standard_Integer nbW = myNewWires.Extent() + myInternalWL.Extent(); - if (nbW==0) - return; - - BRepAlgo_FaceRestrictor FR; - FR.Init (myFace,Standard_False); - - // FaceRestrictor is instable in rather simple cases - // (ex. a single face of bellecoque.brep splited by 10 planes: - // sometimes 1-2 faces are missing ). - // So we use it as less as possible: no holes -> make faces by hands - - - // are there holes in myFace ? - Standard_Boolean hasOldHoles = Standard_False; - TopoDS_Iterator itOldW (myFace); - if ( itOldW.More()) { - const TopoDS_Wire& FirstOldWire = TopoDS::Wire( itOldW.Value() ); - itOldW.Next(); - hasOldHoles = itOldW.More() || isHole( FirstOldWire, myFace); - } - if (myInternalWL.IsEmpty() && !hasOldHoles) { - // each wire bounds one face - BRep_Builder B; - TopTools_ListIteratorOfListOfShape itNW (myNewWires); - for (; itNW.More(); itNW.Next()) { - TopoDS_Face NF = TopoDS::Face ( myFace.EmptyCopied() ); - B.Add ( NF, itNW.Value() ); - NF.Orientation( myFaceOri); - myNewFaces.Append ( NF ); - } - return; - } - - // FaceRestrictor can't classify wires build on all the same edges - // and gives incorrect result in such cases (ex. a plane cut into 2 parts by cylinder) - // We must make faces of equal wires separately. One of equal wires makes a - // hole in a face and should come together with outer wires of face. - // The other of a wires pair bounds a face that may have holes in turn. - - // Find equal wires among internal wires - TopTools_DataMapOfShapeShape EqWM; // key is a hole part of a pair of equal wires - findEqual (myInternalWL, EqWM, myFace); - - if (!EqWM.IsEmpty()) { // there are equal wires - - if (hasOldHoles) - myInternalWL.Append( myNewWires ); // an old wire can be inside an equal wire - - // classify equal wire pairs - BRepAlgo_AsDes OuterInner; - classify (EqWM,OuterInner,myFace); - - // make face of most internal of equal wires and its inner wires - while ( !EqWM.IsEmpty()) { - - TopTools_ListOfShape prevHolesL; // list of hole-part of previous most internal equal wires - - // find most internal wires among pairs (key - hole, value - outer part) - TopTools_DataMapIteratorOfDataMapOfShapeShape it(EqWM); - Standard_Integer nbEqW = EqWM.Extent(); // protection against infinite loop - for ( ; it.More(); it.Next()) { - - TopoDS_Wire outerW = TopoDS::Wire ( it.Value() ); - if ( OuterInner.HasDescendant( outerW ) && // has internal - ! OuterInner.Descendant( outerW ).IsEmpty() ) - continue; - - FR.Add( outerW ); - - // add internal wires that are inside of outerW - TopTools_ListIteratorOfListOfShape itIW (myInternalWL); - while ( itIW.More()) { - TopoDS_Wire IW = TopoDS::Wire ( itIW.Value() ); - if ( isInside (myFace, IW, outerW)) { - FR.Add (IW); - myInternalWL.Remove( itIW ); // == itIW.Next() !!! - } - else - itIW.Next(); - } - - // the hole-part of current pair of equal wires will be in the next new face - prevHolesL.Append ( it.Key() ); - - } // Loop on map of equal pairs searching for innermost wires - - // make faces - FR.Perform(); - if (FR.IsDone()) { - for (; FR.More(); FR.Next()) - myNewFaces.Append(FR.Current()); - } - - FR.Clear(); - - // add hole-parts to FaceRestrictor, - // remove them from the EqWM, - // remove found wires as internal of resting classified wires - Standard_Boolean clearOuterInner = ( prevHolesL.Extent() < EqWM.Extent() ); - TopTools_ListIteratorOfListOfShape itPrev (prevHolesL); - for (; itPrev.More(); itPrev.Next()) { - TopoDS_Wire& Hole = TopoDS::Wire ( itPrev.Value() ); - FR.Add ( Hole ); - if (clearOuterInner) { - const TopoDS_Wire& outerW = TopoDS::Wire ( EqWM.Find( Hole ) ); - // Loop on wires including outerW - TopTools_ListIteratorOfListOfShape itO( OuterInner.Ascendant( outerW )); - for (; itO.More(); itO.Next()) { - TopTools_ListOfShape& innerL = OuterInner.ChangeDescendant( itO.Value() ); - TopTools_ListIteratorOfListOfShape itI (innerL); - // Loop on internal wires of current including wire - for (; itI.More(); itI.Next()) - if ( outerW.IsSame( itI.Value() )) { - innerL.Remove( itI ); break; - } - } - } - EqWM.UnBind ( Hole ); - } - - if (nbEqW == EqWM.Extent()) - { - // error: pb with wires classification -#ifdef DEB - MESSAGE("Partition_Loop2d::WiresToFaces(), pb with wires classification"); -#endif - break; - } - - } // while (!EqWM.IsEmpty) - - } // if !EqWM.IsEmpty() - - myNewWires.Append ( myInternalWL ); - - TopTools_ListIteratorOfListOfShape itW (myNewWires); - for (; itW.More(); itW.Next()) { - TopoDS_Wire& W = TopoDS::Wire ( itW.Value() ); - FR.Add(W); - } - FR.Perform(); - for (; FR.IsDone() && FR.More(); FR.Next()) - myNewFaces.Append(FR.Current()); - - - TopTools_ListIteratorOfListOfShape itNF (myNewFaces); - for (; itNF.More(); itNF.Next()) - itNF.Value().Orientation( myFaceOri ); -} diff --git a/src/PARTITION/Partition_Loop2d.hxx b/src/PARTITION/Partition_Loop2d.hxx deleted file mode 100644 index e60b515a1..000000000 --- a/src/PARTITION/Partition_Loop2d.hxx +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop2d.hxx -// Module : GEOM -// -#ifndef _Partition_Loop2d_HeaderFile -#define _Partition_Loop2d_HeaderFile - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopAbs_Orientation_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -class TopoDS_Face; -class TopoDS_Edge; -class TopTools_ListOfShape; -class BRepAlgo_Image; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Loop2d { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT Partition_Loop2d(); -Standard_EXPORT void Init(const TopoDS_Face& F) ; -Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ; -Standard_EXPORT void AddSectionEdge(const TopoDS_Edge& E) ; -Standard_EXPORT void Perform() ; -Standard_EXPORT const TopTools_ListOfShape& NewWires() const; -Standard_EXPORT void WiresToFaces(const BRepAlgo_Image& EdgeImage) ; -Standard_EXPORT const TopTools_ListOfShape& NewFaces() const; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -TopoDS_Face myFace; -TopAbs_Orientation myFaceOri; -TopTools_ListOfShape myConstEdges; -TopTools_ListOfShape myNewWires; -TopTools_ListOfShape myNewFaces; -TopTools_ListOfShape myInternalWL; -TopTools_MapOfShape mySectionEdges; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Loop2d.ixx b/src/PARTITION/Partition_Loop2d.ixx deleted file mode 100644 index 18b728c33..000000000 --- a/src/PARTITION/Partition_Loop2d.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "Partition_Loop2d.jxx" - - - - diff --git a/src/PARTITION/Partition_Loop2d.jxx b/src/PARTITION/Partition_Loop2d.jxx deleted file mode 100644 index 0118ee22e..000000000 --- a/src/PARTITION/Partition_Loop2d.jxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _BRepAlgo_Image_HeaderFile -#include -#endif -#ifndef _Partition_Loop2d_HeaderFile -#include "Partition_Loop2d.hxx" -#endif diff --git a/src/PARTITION/Partition_Loop3d.cdl b/src/PARTITION/Partition_Loop3d.cdl deleted file mode 100644 index 33e90df74..000000000 --- a/src/PARTITION/Partition_Loop3d.cdl +++ /dev/null @@ -1,84 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Loop3d.cdl --- Module : GEOM - -class Loop3d from Partition - - ---Purpose: Builds the shells from a set of faces. - -- Provides methods for comparing faces mutual - -- location. - -uses - Vec from gp, - MapOfOrientedShape from TopTools, - IndexedDataMapOfShapeListOfShape from TopTools, - Face from TopoDS, - Edge from TopoDS, - ListOfShape from TopTools, - Shape from TopoDS - -is - - Create; - - AddConstFaces (me : in out; S : Shape from TopoDS) - ---Purpose: Add faces of as unique faces in the result. - is static; - - AddSectionFaces (me : in out; S : Shape from TopoDS) - ---Purpose: Add faces of as double faces in the result. - is static; - - MakeShells (me : in out; AvoidFacesMap : MapOfOrientedShape from TopTools) - returns ListOfShape from TopTools is static; - ---Purpose: Make and return shells. - -- can contain faces that must not be - -- added to result shells. - ---C++: return const & - - - ---Category: class methods - - IsInside (myclass; E : Edge from TopoDS; - F1, F2 : Face from TopoDS; - CountDot : Boolean from Standard; - Dot : in out Real from Standard; - GoodOri : in out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: check if is inside by edge . - -- if , compute : scalar production of - -- normalized vectors pointing inside faces, and - -- check if faces are oriented well for sewing - - Normal (myclass; E : Edge from TopoDS; - F : Face from TopoDS) returns Vec from gp; - - -fields - - myNewShells : ListOfShape from TopTools; -- result - - myFaces : ListOfShape from TopTools; - myEFMap : IndexedDataMapOfShapeListOfShape from TopTools; - -end Loop3d; diff --git a/src/PARTITION/Partition_Loop3d.cxx b/src/PARTITION/Partition_Loop3d.cxx deleted file mode 100644 index 798cc2d7b..000000000 --- a/src/PARTITION/Partition_Loop3d.cxx +++ /dev/null @@ -1,368 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop3d.cxx -// Module : GEOM -// -#include "Partition_Loop3d.ixx" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -//======================================================================= -//function : Partition_Loop3d -//purpose : -//======================================================================= - -Partition_Loop3d::Partition_Loop3d() -{ -} - -//======================================================================= -//function : AddConstFaces -//purpose : Add faces of as unique faces in the result. -//======================================================================= - -void Partition_Loop3d::AddConstFaces(const TopoDS_Shape& S) -{ - TopExp_Explorer FaceExp(S, TopAbs_FACE); - for (; FaceExp.More(); FaceExp.Next()) - myFaces.Append( FaceExp.Current() ); - - TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap); -} - -//======================================================================= -//function : AddSectionFaces -//purpose : Add faces of as double faces in the result. -//======================================================================= - -void Partition_Loop3d::AddSectionFaces(const TopoDS_Shape& S) -{ - AddConstFaces( S ); - AddConstFaces( S.Reversed() ); -} - -//======================================================================= -//function : MakeShells -//purpose : Make and return shells. -// can contain faces that must not be -// added to result shells. -//======================================================================= - -const TopTools_ListOfShape& - Partition_Loop3d::MakeShells (const TopTools_MapOfOrientedShape& AvoidFacesMap) -{ - myNewShells.Clear(); - - BRep_Builder Builder; - TopTools_MapOfShape CheckedEdgesMap; - TopTools_MapOfOrientedShape AddedFacesMap; - - TopTools_ListIteratorOfListOfShape itF (myFaces); - for (; itF.More(); itF.Next()) - { - const TopoDS_Shape& FF = itF.Value(); - if (AvoidFacesMap.Contains( FF ) || - ! AddedFacesMap.Add( FF ) ) - continue; - - // make a new shell - TopoDS_Shell Shell; - Builder.MakeShell(Shell); - Builder.Add(Shell,FF); - - // clear the maps from shapes added to previous Shell - TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap); - for (; itEM.More(); itEM.Next()) { - TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key()); - TopTools_ListIteratorOfListOfShape it (FL); - while ( it.More()) { - if (AddedFacesMap.Contains( it.Value())) - FL.Remove( it ); - else - it.Next(); - } - } - CheckedEdgesMap.Clear(); - - - // loop on faces added to Shell; add their neighbor faces to Shell and so on - TopoDS_Iterator itAddedF (Shell); - for (; itAddedF.More(); itAddedF.Next()) - { - const TopoDS_Face& F = TopoDS::Face (itAddedF.Value()); - - // loop on edges of F; find a good neighbor face of F by E - TopExp_Explorer EdgeExp(F, TopAbs_EDGE); - for (; EdgeExp.More(); EdgeExp.Next()) - { - const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current()); - if (! CheckedEdgesMap.Add( E )) - continue; - - // candidate faces list - const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E); - if (FL.IsEmpty()) - continue; - // select one of neighbors - TopoDS_Face SelF; - if (FL.Extent() == 2) { - if (! F.IsSame( FL.First() )) - SelF = TopoDS::Face( FL.First() ); - else if (!F.IsSame( FL.Last() )) - SelF = TopoDS::Face( FL.Last() ); - } - else { - // check if a face already added to Shell shares E - TopTools_ListIteratorOfListOfShape it (FL); - Standard_Boolean found = Standard_False; - for (; !found && it.More(); it.Next()) - if (F != it.Value()) - found = AddedFacesMap.Contains( it.Value() ); - if (found) - continue; - // select basing on geometrical check - Standard_Boolean GoodOri, inside; - Standard_Real dot, MaxDot = -100; - TopTools_ListOfShape TangFL; // tangent faces - for ( it.Initialize( FL ) ; it.More(); it.Next()) { - const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); - if (NeighborF.IsSame( F )) - continue; - inside = Partition_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri); - if (!GoodOri) - continue; - if (!inside) - dot = -dot - 3; - if (dot < MaxDot) - continue; - if ( IsEqual( dot, MaxDot)) - TangFL.Append(SelF); - else - TangFL.Clear(); - MaxDot = dot; - SelF = NeighborF; - } - if (!TangFL.IsEmpty()) { - for (it.Initialize( TangFL ); it.More(); it.Next()) { - const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); - if (Partition_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri)) - SelF = NeighborF; - } - } - } - if (!SelF.IsNull() && - AddedFacesMap.Add( SelF ) && - !AvoidFacesMap.Contains( SelF )) - Builder.Add( Shell, SelF); - - } // loop on edges of F - - } // loop on the faces added to Shell - - // Shell is complete - myNewShells.Append( Shell ); - - } // loop on myFaces - - - // prepare to the next call - myFaces.Clear(); - myEFMap.Clear(); - - return myNewShells; -} - - - -//======================================================================= -//function : Normal -//purpose : -//======================================================================= - -gp_Vec Partition_Loop3d::Normal(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - gp_Vec Norm, V1, V2; - Standard_Real First, Last; - gp_Pnt Ps; - - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); - Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); - - gp_Pnt2d p = C2d->Value( 0.5*(First+Last) ); - Sf->D1(p.X(), p.Y(), Ps, V1, V2); - Norm = V1.Crossed(V2); - - if (F.Orientation() == TopAbs_REVERSED ) - Norm.Reverse(); - - return Norm; -} - -//======================================================================= -//function : NextNormal -//purpose : find normal to F at point a little inside F near the middle of E -//warning : E must be properly oriented in F. -//======================================================================= - -static gp_Vec NextNormal(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - Standard_Real First, Last; - - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); - Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); - - gp_Pnt2d p; - gp_Vec2d v; - C2d->D1( 0.5*(First+Last), p, v); - if (E.Orientation() != F.Orientation()) - v.Reverse(); - gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F - - Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if - // resolutionUV of compared faces is very different. To have a good result, - //it is necessary to get normal to faces at points equidistant from E in 3D - - p.SetX( p.X() + dir.X()*duv ); - p.SetY( p.Y() + dir.Y()*duv ); - - gp_Pnt Ps; - gp_Vec Norm, V1, V2, VV1, VV2; - Sf->D1( p.X(), p.Y(), Ps, V1, V2); - Norm = V1.Crossed(V2); - - if (F.Orientation() == TopAbs_REVERSED ) - Norm.Reverse(); - - return Norm; -} - - -//======================================================================= -//function : FindEinF -//purpose : find E in F -//======================================================================= - -static TopoDS_Edge FindEinF(const TopoDS_Edge& E, - const TopoDS_Face& F) -{ - TopExp_Explorer expl (F, TopAbs_EDGE); - for (; expl.More(); expl.Next()) - if( E.IsSame( expl.Current() )) - return TopoDS::Edge(expl.Current()); - TopoDS_Edge nullE; - return nullE; -} - -//======================================================================= -//function : IsInside -//purpose : check if is inside by edge . -// if , compute : scalar production of -// normalized vectors pointing inside faces, and -// check if faces are oriented well for sewing -//======================================================================= - -Standard_Boolean Partition_Loop3d::IsInside(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const Standard_Boolean CountDot, - Standard_Real& Dot, - Standard_Boolean& GoodOri) -{ - Standard_Real f, l; - gp_Pnt P; - gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2; - Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); - Curve->D1( 0.5*(f + l), P, Vc2); - TopoDS_Edge E1, E2 = FindEinF (E, F2); - if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse(); - - Nf1 = Normal(E,F1); - Nf2 = Normal(E,F2); - - Standard_Real sin = - Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude(); - Standard_Boolean tangent = sin < 0.001; - - Standard_Boolean inside = 0; - if (tangent) { - E1 = FindEinF (E, F1); - gp_Vec NNf1 = NextNormal(E1,F1); - gp_Vec NNf2 = NextNormal(E2,F2); - Vin2 = NNf2.Crossed(Vc2); - inside = Vin2 * NNf1 < 0; - } - else { - Vin2 = Nf2.Crossed(Vc2); - inside = Vin2 * Nf1 < 0; - } - - if (!CountDot) return inside; - - if (tangent) - Vin2 = Nf2.Crossed(Vc2); - else - E1 = FindEinF (E, F1); - - Vc1 = Vc2; - if (E1.Orientation() != E2.Orientation()) - Vc1.Reverse(); - Vin1 = Nf1.Crossed(Vc1); - - if (tangent) { - Standard_Real N1N2 = Nf1 * Nf2; - GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0; - } - else { - Standard_Real V1N2 = Vin1 * Nf2; - GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0); - } - - Vin1.Normalize(); - Vin2.Normalize(); - - Dot = Vin2 * Vin1; - - return inside; -} - diff --git a/src/PARTITION/Partition_Loop3d.hxx b/src/PARTITION/Partition_Loop3d.hxx deleted file mode 100644 index cf7a2f209..000000000 --- a/src/PARTITION/Partition_Loop3d.hxx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Loop3d.hxx -// Module : GEOM -// -#ifndef _Partition_Loop3d_HeaderFile -#define _Partition_Loop3d_HeaderFile - -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -class TopoDS_Shape; -class TopTools_ListOfShape; -class TopTools_MapOfOrientedShape; -class TopoDS_Edge; -class TopoDS_Face; -class gp_Vec; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Loop3d { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT Partition_Loop3d(); -Standard_EXPORT void AddConstFaces(const TopoDS_Shape& S) ; -Standard_EXPORT void AddSectionFaces(const TopoDS_Shape& S) ; -Standard_EXPORT const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ; -Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ; -Standard_EXPORT static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -TopTools_ListOfShape myNewShells; -TopTools_ListOfShape myFaces; -TopTools_IndexedDataMapOfShapeListOfShape myEFMap; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Loop3d.ixx b/src/PARTITION/Partition_Loop3d.ixx deleted file mode 100644 index 83205eb5e..000000000 --- a/src/PARTITION/Partition_Loop3d.ixx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "Partition_Loop3d.jxx" - - - - diff --git a/src/PARTITION/Partition_Loop3d.jxx b/src/PARTITION/Partition_Loop3d.jxx deleted file mode 100644 index 7b8e1f45f..000000000 --- a/src/PARTITION/Partition_Loop3d.jxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfOrientedShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _gp_Vec_HeaderFile -#include -#endif -#ifndef _Partition_Loop3d_HeaderFile -#include "Partition_Loop3d.hxx" -#endif diff --git a/src/PARTITION/Partition_Spliter.cdl b/src/PARTITION/Partition_Spliter.cdl deleted file mode 100644 index 1954b9748..000000000 --- a/src/PARTITION/Partition_Spliter.cdl +++ /dev/null @@ -1,183 +0,0 @@ --- Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, --- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS --- --- This library is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License. --- --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public --- License along with this library; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com --- --- File : Partition_Spliter.cdl --- Author : Benedicte MARTIN --- Module : GEOM - -class Spliter from Partition - - ---Purpose: Split solids, shells and faces into parts of the - -- same topology if reconstruction level is not - -- limited. - -uses - Inter3d from Partition, - Loop2d from Partition, - Builder from BRep, - ShapeEnum from TopAbs, - Compound from TopoDS, - Face from TopoDS, - Edge from TopoDS, - Shape from TopoDS, - MapOfOrientedShape from TopTools, - IndexedMapOfShape from TopTools, - DataMapOfShapeShape from TopTools, - ListOfShape from TopTools, - MapOfShape from TopTools, - AsDes from BRepAlgo, - Image from BRepAlgo - -is - Create returns Spliter from Partition; - ---Purpose: constructor - - AddShape ( me : in out; S : Shape from TopoDS); - ---Purpose: add object Shape to be splitted. - -- If S is a COMPOUND or COMPSOLID, it will be - -- exploded in order to get more simple object - -- shapes. - -- Object shapes that are vertices, edges or wires - -- won't be splitted and won't be in a result. - - AddTool ( me : in out; S : Shape from TopoDS); - ---Purpose: add cutting tool - - Compute (me : in out; Limit : ShapeEnum from TopAbs - = TopAbs_SHAPE); - ---Purpose: produce a result which is a compound of parts of - -- object shapes. A part can be either a vertex, - -- edge, wire, face, shell or solid. - -- By default, a part is of the same topology as an - -- object shape, else restricts parts - -- reconstruction. - -- If == TopAbs_VERTEX, only new vertices are - -- returned in the result - - KeepShapesInside (me : in out; S : Shape from TopoDS); - ---Purpose: remove shapes that are outside of S from result. - -- S should be an object shape. - ---Warning: call it after Compute() - - RemoveShapesInside (me : in out; S : Shape from TopoDS); - ---Purpose: remove shapes that are inside S from result. - -- S should be an object shape. - ---Warning: call it after Compute() - - Shape ( me ) returns Shape from TopoDS; - ---Purpose: return resulting compound - - Clear ( me : in out); - ---Purpose: clear fields - - - ---Category: private methods - - - MakeSolids (me: in out; Solid : Shape from TopoDS; - Shells: in out ListOfShape from TopTools) - is private; - ---Purpose: make solids out of Shells - - MakeShells (me: in out; S : Shape from TopoDS; - NS: in out ListOfShape from TopTools) is private; - ---Purpose: split S into shells - - MakeFaces (me: in out; S : Shape from TopoDS) - returns Shape from TopoDS is private; - ---Purpose: split faces of S, return compound of new faces - - MakeEdges (me; - E : Edge from TopoDS; - VOnE : ListOfShape from TopTools; - NE : in out ListOfShape from TopTools) - is private; - ---Purpose: cut E by vertices VOnE, return list of new edges - -- NE - - FindFacesInside (me: in out; S : Shape from TopoDS; - CheckClosed : Boolean = Standard_False; - All : Boolean = Standard_False) - returns Shape from TopoDS is private; - ---Purpose: return compound of faces of other shapes that are - -- inside . must have image in myImageShape. - -- makes avoid faces that do not form a - -- closed shell - -- makes return already added faces - - CheckTool ( me: in out; S : Shape from TopoDS) - returns Boolean from Standard is private; - ---Purpose: Return True if is a tool shape. Prepare tool - -- faces of for the search of internal faces. - - MergeEqualEdges (me: in out; LE : ListOfShape from TopTools) is private; - ---Purpose: among LE, find equal edges, choose ones to keep - -- and make them have pcurves on all faces they are - -- shared by - -- contains edge splits - - IsInside (myclass; S1,S2 : Shape from TopoDS) - returns Boolean from Standard is private; - ---Purpose: Return True if the first vertex of S1 inside S2. - -- If S1.IsNull(), check infinite point against S2. - - GetOriginalShape(me; aShape : Shape from TopoDS) - returns Shape from TopoDS is private; - ---Purpose: Return the shape aShape originates from. aShape - -- should be a face or more complex result shape - - FindToolsToReconstruct(me: in out) is private; - ---Purpose: find and store as objects tools which interfere - -- with solids or are inside solids without - -- an interference - -fields - - myDoneStep : ShapeEnum from TopAbs; -- rebuilt level - myShape : Compound from TopoDS; -- result - myBuilder : Builder from BRep; - - myListShapes : ListOfShape from TopTools; -- object shapes - myMapFaces : MapOfShape from TopTools; -- object faces - myMapTools : MapOfShape from TopTools; -- tool faces - myEqualEdges : MapOfShape from TopTools; -- equal splits - myNewSection : MapOfShape from TopTools; -- new secton edges - myClosedShapes : MapOfShape from TopTools; - mySharedFaces : MapOfShape from TopTools; -- faces shared by several shapes - myWrappingSolid: MapOfShape from TopTools; -- solids having other shapes inside - myFaceShapeMap : DataMapOfShapeShape from TopTools; -- to find a shape by face - - myInternalFaces: DataMapOfShapeShape from TopTools; -- shape and its internal faces - myIntNotClFaces: DataMapOfShapeShape from TopTools; -- internal but not closed - - - myAsDes : AsDes from BRepAlgo; - myImagesFaces : Image from BRepAlgo; - myImagesEdges : Image from BRepAlgo; - myImageShape : Image from BRepAlgo; - - -- contains info of same domain shapes and section edges - myInter3d : Inter3d from Partition; - - -- avoid rebuilding twice commont part of solids - myAddedFacesMap: MapOfOrientedShape from TopTools; - -end Spliter; diff --git a/src/PARTITION/Partition_Spliter.cxx b/src/PARTITION/Partition_Spliter.cxx deleted file mode 100644 index 7dcb3d85a..000000000 --- a/src/PARTITION/Partition_Spliter.cxx +++ /dev/null @@ -1,2160 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Spliter.cxx -// Author : Benedicte MARTIN -// Module : GEOM -// $Header$ -// -#include "Partition_Inter2d.hxx" -#include "Partition_Inter3d.hxx" -#include "Partition_Loop2d.hxx" -#include "Partition_Loop3d.hxx" -#include "Partition_Spliter.ixx" - -#include "utilities.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef DEB -//# define PART_PERF -#endif - -#ifdef PART_PERF -# include -#endif - -using namespace std; - -//======================================================================= -//function : isClosed -//purpose : check id a shape is closed, ie is a solid or a closed shell -//======================================================================= - -static Standard_Boolean isClosed(const TopoDS_Shape& theShape) -{ - Standard_Boolean isClosed = (theShape.ShapeType() == TopAbs_SOLID); - - if (!isClosed && theShape.ShapeType() == TopAbs_SHELL) { - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, MEF); - for (Standard_Integer i=1; isClosed && i<=MEF.Extent(); ++i) - isClosed = ( MEF(i).Extent() != 1 ); - } - - return isClosed; -} - -//======================================================================= -//function : Partition_Spliter -//purpose : constructor -//======================================================================= - -Partition_Spliter::Partition_Spliter() -{ - myAsDes = new BRepAlgo_AsDes; - Clear(); -} - -//======================================================================= -//function : AddTool -//purpose : add cutting tool that will _NOT_ be in result -//======================================================================= - -void Partition_Spliter::AddTool(const TopoDS_Shape& S) -{ - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - TopoDS_Iterator it (S); - for (; it.More(); it.Next()) - { - AddTool( it.Value()); - myFaceShapeMap.Bind( it.Value(), S ); // to know compound by shape - } - return; - } - - for (TopExp_Explorer exp(S,TopAbs_FACE); exp.More(); exp.Next()) - { - myMapTools.Add(exp.Current()); - myFaceShapeMap.Bind( exp.Current(), S ); - } - if (isClosed( S )) - myClosedShapes.Add( S ); -} - -//======================================================================= -//function : AddShape -//purpose : add object Shape to be splited -//======================================================================= - -void Partition_Spliter::AddShape(const TopoDS_Shape& S) -{ - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - TopoDS_Iterator it (S); - for (; it.More(); it.Next()) - { - AddShape( it.Value()); - myFaceShapeMap.Bind( it.Value(), S ); // to know compound by shape - } - return; - } - - TopExp_Explorer exp(S,TopAbs_FACE); - if (!exp.More()) { // do not split edges and vertices - //myBuilder.Add( myShape, S ); - return; - } - - Standard_Integer nbFacesBefore = myMapFaces.Extent(); // not to add twice the same S - for (; exp.More(); exp.Next()) { - const TopoDS_Shape & aFace = exp.Current(); - if ( ! myFaceShapeMap.IsBound( aFace )) // keep shape of tool face added as object - myFaceShapeMap.Bind( aFace, S ); - if (myMapFaces.Add( aFace )) - myImagesFaces.SetRoot( aFace ); - } - - if (nbFacesBefore == myMapFaces.Extent()) - return; - - // solids must be processed before all - if (S.ShapeType() == TopAbs_SOLID) - myListShapes.Prepend(S); - else - myListShapes.Append(S); - - if (isClosed( S )) - myClosedShapes.Add( S ); - -} - -//======================================================================= -//function : Shape -//purpose : return resulting compound -//======================================================================= - -TopoDS_Shape Partition_Spliter::Shape() const -{ - return myShape; -} - -//======================================================================= -//function : Clear -//purpose : clear fields -//======================================================================= - -void Partition_Spliter::Clear() -{ - myDoneStep = TopAbs_SHAPE; - - myListShapes.Clear(); - myMapFaces.Clear(); - myMapTools.Clear(); - myEqualEdges.Clear(); - myNewSection.Clear(); - myClosedShapes.Clear(); - mySharedFaces.Clear(); - myWrappingSolid.Clear(); - myFaceShapeMap.Clear(); - - myInternalFaces.Clear(); - myIntNotClFaces.Clear(); - - myAsDes->Clear(); - myImagesFaces.Clear(); - myImagesEdges.Clear(); - myImageShape.Clear(); - - myInter3d = Partition_Inter3d(myAsDes); - - myAddedFacesMap.Clear(); - -} - -//======================================================================= -//function : Compute -//purpose : produce a result -//======================================================================= - -void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) -{ - if ((Limit != TopAbs_SHAPE && myDoneStep == Limit) || - (Limit == TopAbs_SHAPE && myDoneStep == TopAbs_SOLID)) - return; - - myBuilder.MakeCompound( myShape ); - - TopTools_MapIteratorOfMapOfShape it; - TopTools_ListIteratorOfListOfShape itl; - TopExp_Explorer exp; - -#ifdef PART_PERF - OSD_Chronometer aCron; -#endif - - if (myDoneStep > TopAbs_VERTEX) { - - TopTools_ListOfShape aListFaces; - aListFaces = myImagesFaces.Roots(); - for (it.Initialize(myMapTools); it.More(); it.Next()) - aListFaces.Append(it.Key()); - -#ifdef PART_PERF - aCron.Start(); -#endif - - //----------------------------------------------- - // Intersection between faces - //----------------------------------------------- - // result is in myAsDes as a map Face - list of new edges; - // special care is done for section edges, same domain faces and vertices: - // data about them is inside myInter3d - myInter3d.CompletPart3d(aListFaces, myFaceShapeMap); - -#ifdef PART_PERF - MESSAGE("+++ CompletPart3d()"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - //----------------------------------------------- - // Intersection of edges - //----------------------------------------------- - - // add tool faces which must be reconstructed to myMapFaces too - FindToolsToReconstruct(); - -#ifdef PART_PERF - MESSAGE("+++ FindToolsToReconstruct()"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - - // add existing vertices to edges of object faces in myAsDes - TopTools_MapOfShape DoneEM; - for ( it.Initialize(myMapFaces); it.More(); it.Next()) { - const TopoDS_Shape& F = it.Key(); - TopoDS_Face FForward = TopoDS::Face(F.Oriented(TopAbs_FORWARD)); - for (exp.Init(FForward,TopAbs_EDGE); exp.More(); exp.Next()) { - const TopoDS_Edge& E = TopoDS::Edge( exp.Current() ); - myAsDes->Add(FForward,E); - if (DoneEM.Add(E)) { - TopoDS_Iterator itV(E); - for (; itV.More(); itV.Next()) { - const TopoDS_Vertex& V = TopoDS::Vertex( itV.Value()); - myAsDes->Add(E, myInter3d.ReplaceSameDomainV( V, E )); - } - } - } - } - - // intersect edges that are descendants of a face in myAsDes - TopTools_MapOfShape& Modif = myInter3d.TouchedFaces(); - for ( it.Initialize(Modif); it.More(); it.Next()) { - const TopoDS_Face& F = TopoDS::Face(it.Key()); - Partition_Inter2d::CompletPart2d (myAsDes, F, myInter3d.NewEdges()); - } - // now myAsDes contains also new vertices made at edge intersection as - // descendant of edges both new and old - - myDoneStep = TopAbs_VERTEX; - -#ifdef PART_PERF - MESSAGE("+++ CompletPart2d()"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - } // if (myDoneStep > TopAbs_VERTEX) - - if (Limit == TopAbs_VERTEX) { - // add new vertices to myShape - for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) { - if (! myAsDes->HasDescendant( it.Key() )) - continue; - itl.Initialize( myAsDes->Descendant( it.Key() )); - for (; itl.More(); itl.Next()) - myBuilder.Add ( myShape, itl.Value() ); - } - return; - } - - - if (myDoneStep > TopAbs_EDGE) { - - //----------------------------------------------- - //----------------------------------------------- - // ------- Reconstruction of all the edges.------ - //----------------------------------------------- - //----------------------------------------------- - - // ============== - // cut new edges - // ============== - TopTools_ListOfShape LSE; // all edge splits - for ( it.Initialize(myInter3d.NewEdges()); it.More(); it.Next()) { - - TopoDS_Vertex V1,V2; - TopoDS_Edge EE = TopoDS::Edge(it.Key()); - - TopTools_ListOfShape aListV, aListF; - aListV = myAsDes->Descendant(EE); // intersection vertices - aListF = myAsDes->Ascendant(EE); // intersected faces - - if (aListV.IsEmpty()) - continue; // new edge does not intersect any other edge - - // Add end vertices to new edges only if - // one face is Tool and the other is Shape - Standard_Boolean isTool1 = ! myMapFaces.Contains( aListF.First() ); - Standard_Boolean isTool2 = ! myMapFaces.Contains( aListF.Last() ); - if (isTool1 || isTool2) - { - TopExp::Vertices(EE,V1,V2); - Standard_Real Tol = Max (BRep_Tool::Tolerance( V1 ), - BRep_Tool::Tolerance( V2 )); - - gp_Pnt P1 = BRep_Tool::Pnt(V1); - gp_Pnt P2 = BRep_Tool::Pnt(V2); - Standard_Boolean AddV1 = Standard_True; - Standard_Boolean AddV2 = Standard_True; - - // add only if there is no intersection at end vertex - for (itl.Initialize(aListV); itl.More(); itl.Next()) { - const TopoDS_Vertex& Ve = TopoDS::Vertex(itl.Value()) ; - Standard_Real Tol2 = Max ( Tol, BRep_Tool::Tolerance( Ve )); - Tol2 *= Tol2; - gp_Pnt P = BRep_Tool::Pnt(Ve); - if (AddV1 && P.SquareDistance(P1) <= Tol2) - AddV1 = Standard_False; - - if (AddV2 && P.SquareDistance(P2) <= Tol2) - AddV2 = Standard_False; - } - - if (AddV1) { - aListV.Append(V1); - myAsDes->Add(EE,V1); - } - - if (AddV2) { - aListV.Append(V2); - myAsDes->Add(EE,V2); - } - } - - // cut new edges - Standard_Integer NbV=aListV.Extent() ; - if (NbV>1 || (NbV==1 && V1.IsSame(V2)) ) { - TopTools_ListOfShape LNE; - MakeEdges (EE,aListV, LNE); - myImagesEdges.Bind(EE,LNE); - LSE.Append( LNE ); - } - } - - // ============== - // cut old edges - // ============== - for ( it.Initialize(myMapFaces); it.More(); it.Next()) { - for (exp.Init( it.Key(), TopAbs_EDGE); exp.More(); exp.Next()) { - const TopoDS_Edge& EE = TopoDS::Edge( exp.Current() ); - if ( myImagesEdges.HasImage( EE )) - continue; - TopTools_ListOfShape LNE; - const TopTools_ListOfShape& aListVV = myAsDes->Descendant(EE); - MakeEdges (EE, aListVV, LNE); - myImagesEdges.Bind(EE,LNE); - LSE.Append( LNE ); - } - } -#ifdef PART_PERF - MESSAGE("+++ Cut Edges"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - - // process same domain section edges - MergeEqualEdges( LSE ); - - myDoneStep = TopAbs_EDGE; - -#ifdef PART_PERF - MESSAGE("+++ MergeEqualEdges()"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - } // if (myDoneStep > TopAbs_EDGE) - - if (Limit == TopAbs_EDGE) { - // add splits of old edges - TopTools_ListIteratorOfListOfShape itNE; - for (itl.Initialize( myListShapes );itl.More();itl.Next()) { - if (myMapTools.Contains( itl.Value() )) - continue; // skip tool faces - for ( exp.Init( itl.Value(), TopAbs_EDGE ); exp.More(); exp.Next()) { - itNE.Initialize( myImagesEdges.Image( exp.Current() )); - for ( ; itNE.More(); itNE.Next()) - myBuilder.Add ( myShape, itNE.Value() ); - } - } - // add splits of new edges - for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) { - itNE.Initialize( myImagesEdges.Image( it.Key() )); - for (; itNE.More(); itNE.Next()) - myBuilder.Add ( myShape, itNE.Value() ); - } - return; - } - - - //----------------------------------------------- - // split faces - //----------------------------------------------- - - if (myDoneStep > TopAbs_FACE) { - - for (itl.Initialize(myListShapes);itl.More();itl.Next()) { - TopoDS_Shape FacesComp = MakeFaces ( itl.Value()); - // there is a cunning here: myImagesFaces keeps faces made by Loop2d - // but some of them may be replaced with splits of same domain face - // and myImageShape keeps ultimate result - myImageShape.Bind( itl.Value(), FacesComp ); - } - - myDoneStep = TopAbs_FACE; -#ifdef PART_PERF - MESSAGE("+++ MakeFaces()"); - aCron.Show( cout ); - aCron.Reset(); - aCron.Start(); -#endif - } - - if (Limit == TopAbs_WIRE || - Limit == TopAbs_FACE) { - for (itl.Initialize(myListShapes);itl.More();itl.Next()) { - if ( myMapTools.Contains( itl.Value() )) - continue; // no result needed for a tool face - const TopoDS_Shape& FacesComp = myImageShape.Image( itl.Value() ).First(); - for ( exp.Init( FacesComp, Limit); exp.More(); exp.Next()) - myBuilder.Add ( myShape, exp.Current()); - } - return; - } - - - //----------------------------------------------- - // split and add solids and shells - //----------------------------------------------- - - Standard_Boolean makeSolids = (Limit == TopAbs_SHAPE || - Limit < TopAbs_SHELL); - for (itl.Initialize(myListShapes);itl.More();itl.Next()) - { - const TopoDS_Shape & S = itl.Value(); - if (S.ShapeType() > TopAbs_SHELL) - continue; - - TopTools_ListOfShape NSL; // new shape list - MakeShells (S , NSL); - if (makeSolids && S.ShapeType() == TopAbs_SOLID ) - MakeSolids( S, NSL ); - - // store new shells or solids - TopTools_ListIteratorOfListOfShape itNSL (NSL); - for ( ; itNSL.More(); itNSL.Next()) - myBuilder.Add (myShape, itNSL.Value()); - } -#ifdef PART_PERF - MESSAGE("+++ MakeShells()"); - aCron.Show( cout ); -#endif - - //----------------------------------------------- - // add split faces - //----------------------------------------------- - - for (itl.Initialize(myListShapes);itl.More();itl.Next()) - { - const TopoDS_Shape & S = itl.Value(); - if (S.ShapeType() != TopAbs_FACE || - myMapTools.Contains( S )) - continue; - TopoDS_Iterator itS( myImageShape.Image(S).First() ); - for (; itS.More(); itS.Next()) - if (! myAddedFacesMap.Contains( itS.Value() )) - myBuilder.Add (myShape, itS.Value()); - } - - myDoneStep = makeSolids ? TopAbs_SOLID : TopAbs_SHELL; - -} - -//======================================================================= -//function : MakeSolids -//purpose : make solids out of Shells -//======================================================================= - -void Partition_Spliter::MakeSolids(const TopoDS_Shape & theSolid, - TopTools_ListOfShape & theShellList) -{ - // for a solid wrapping other shells or solids without intersection, - // it is necessary to find shells making holes in it - - TopTools_ListOfShape aNewSolids; // result - TopTools_ListOfShape aHoleShells; - TopoDS_Shape anInfinitePointShape; - - Standard_Boolean isWrapping = myWrappingSolid.Contains( theSolid ); - if (!isWrapping && !theShellList.IsEmpty()) - { - // check if theSolid initially has internal shells - TopoDS_Iterator aShellExp (theSolid); - aShellExp.Next(); - isWrapping = aShellExp.More(); - } - - TopTools_ListIteratorOfListOfShape aShellIt(theShellList); - for ( ; aShellIt.More(); aShellIt.Next()) - { - const TopoDS_Shape & aShell = aShellIt.Value(); - - // check if a shell is a hole - if (isWrapping && IsInside (anInfinitePointShape, aShell)) - aHoleShells.Append( aShell ); - else - { - // make a solid from a shell - TopoDS_Solid Solid; - myBuilder.MakeSolid( Solid ); - myBuilder.Add (Solid, aShell); - - aNewSolids.Append (Solid); - } - } - - // find an outer shell most close to each hole shell - TopTools_DataMapOfShapeShape aInOutMap; - for (aShellIt.Initialize( aHoleShells ); aShellIt.More(); aShellIt.Next()) - { - const TopoDS_Shape & aHole = aShellIt.Value(); - TopTools_ListIteratorOfListOfShape aSolisIt (aNewSolids); - for ( ; aSolisIt.More(); aSolisIt.Next()) - { - const TopoDS_Shape & aSolid = aSolisIt.Value(); - if (! IsInside( aHole, aSolid )) - continue; - - if ( aInOutMap.IsBound (aHole)) - { - const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); - if ( IsInside( aSolid, aSolid2 )) - { - aInOutMap.UnBind( aHole ); - aInOutMap.Bind ( aHole, aSolid ); - } - } - else - aInOutMap.Bind ( aHole, aSolid ); - } - - // add aHole to a solid - if (aInOutMap.IsBound( aHole )) - myBuilder.Add ( aInOutMap( aHole ), aHole ); - } - - theShellList.Clear(); - theShellList.Append( aNewSolids ); -} - -//======================================================================= -//function : FindFacesInside -//purpose : return compound of faces of other shapes that are -// inside . -// is an object shape. -// makes avoid faces that do not form a -// closed shell -// makes return already added faces -//======================================================================= - -TopoDS_Shape Partition_Spliter::FindFacesInside(const TopoDS_Shape& theShape, - const Standard_Boolean CheckClosed, - const Standard_Boolean All) -{ - // ================================================ - // check if internal faces have been already found - // ================================================ - TopExp_Explorer expl; - if (myInternalFaces.IsBound( theShape )) - { - TopoDS_Shape aIntFComp = myInternalFaces.Find ( theShape ); - TopoDS_Shape aIntRemFComp = myIntNotClFaces.Find ( theShape ); - - expl.Init( aIntRemFComp, TopAbs_FACE); - if (CheckClosed || !expl.More()) - return aIntFComp; - - TopoDS_Compound C; - myBuilder.MakeCompound( C ); - // add removed faces - for (; expl.More(); expl.Next()) - myBuilder.Add( C, expl.Current() ); - // add good internal faces - for (expl.Init( aIntFComp, TopAbs_FACE); expl.More(); expl.Next()) - myBuilder.Add( C, expl.Current() ); - return C; - } - - // =================================== - // get data for internal faces search - // =================================== - - // compound of split faces of theShape - const TopoDS_Shape& CSF = myImageShape.Image(theShape).First(); - - TopTools_MapOfShape MSE, MFP; - TopTools_DataMapOfShapeListOfShape DMSEFP; - TopTools_MapIteratorOfMapOfShape itm; - TopTools_ListOfShape EmptyL; - - // MSE filling: map of new section edges of CSF - for (expl.Init(CSF,TopAbs_EDGE); expl.More(); expl.Next()) { - const TopoDS_Shape & resE = expl.Current() ; - if (myNewSection.Contains( resE )) // only new edges - MSE.Add(resE); - } - - // DMEF: map edge of CSF - faces of CSF - TopTools_IndexedDataMapOfShapeListOfShape DMEF; - TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); - - // Fill - // 1. MFP - a map of faces to process: map of resulting faces except - // those of theShape; we`ll add to C those of them which are inside CSF - // 2. DMSEFP - edge of MSE => faces of MFP - TopTools_ListIteratorOfListOfShape itl; - for (itl.Initialize(myListShapes);itl.More();itl.Next()) { - const TopoDS_Shape& aShape = itl.Value(); - if ( theShape.IsSame( aShape )) continue; - // fill maps - // iterate on split faces of aShape - TopoDS_Iterator itF ( myImageShape.Image(aShape).First() ); - for ( ; itF.More(); itF.Next()) { - const TopoDS_Shape& sf = itF.Value(); - MFP.Add(sf); - // iterate on edges of split faces of aShape, - // add to DMSEFP edges that are new - for (expl.Init( sf, TopAbs_EDGE ); expl.More(); expl.Next()) { - TopoDS_Shape se = expl.Current(); - if ( MSE.Contains(se)) {// section edge - if (!DMSEFP.IsBound(se)) - DMSEFP.Bind(se,EmptyL); - DMSEFP(se).Append(sf); - } - } - } - } - - // add tool faces having section edges on faces of theShape to MFP and DMSEFP; - // such tool faces need not to be reconstructed and so they are not in myListShapes - for (itm.Initialize(myMapTools); itm.More(); itm.Next()) - { - const TopoDS_Shape & aToolFace = itm.Key(); - if (myMapFaces.Contains( aToolFace )) - continue; - MFP.Add(aToolFace); - for (expl.Init( aToolFace, TopAbs_EDGE ); expl.More(); expl.Next()) { - TopoDS_Shape se = expl.Current(); - if ( MSE.Contains( se )) {// section edge - if (!DMSEFP.IsBound( se )) - DMSEFP.Bind( se, EmptyL ); - DMSEFP( se ).Append( aToolFace ); - } - } - } - - - // =========================== - // find faces inside theShape - // =========================== - - Standard_Boolean skipAlreadyAdded = Standard_False; - Standard_Boolean GoodOri, inside; - Standard_Real dot; - TopTools_ListOfShape KeepFaces; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; - - // iterate on section edges, check faces of other shapes - // sharing section edges and put internal faces to KeepFaces - for (Mapit.Initialize(DMSEFP); Mapit.More() ; Mapit.Next() ) { - // a new edge of theShape - const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key()); - // an original edge of which E is a split - const TopoDS_Edge& OrigE = TopoDS::Edge ( myImagesEdges.Root( E )); - // does OrigE itself splits a face - Standard_Boolean isSectionE = myInter3d.IsSectionEdge ( OrigE ); - - // split faces of other shapes sharing E - TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E); - itl.Initialize( LSF ); - while (itl.More()) { - // a split faces of other shape - TopoDS_Face aFace1 = TopoDS::Face(itl.Value()); - // remove aFace1 form DMSEFP and MFP - LSF.Remove( itl ); // == itl.Next(); - if (!MFP.Remove( aFace1 )) - continue; // was not is MFP ( i.e already checked) - // check if aFace1 was already added to 2 shells - if (!All && - myAddedFacesMap.Contains( aFace1 ) && - myAddedFacesMap.Contains( aFace1.Reversed() )) { - skipAlreadyAdded = Standard_True; - continue; - } - - // find another face which originates from the same face as aFace1: - // usually aFace2 is internal if aFace1 is not and vice versa - - TopoDS_Shape anOrigFace = aFace1; - if (myImagesFaces.IsImage(aFace1)) - anOrigFace = myImagesFaces.Root(aFace1); - TopoDS_Shape aFace2; - if ( !isSectionE ) { - while (itl.More()) { - aFace2 = itl.Value(); - if (!MFP.Contains( aFace2 )) { - LSF.Remove( itl ); - continue; - } - if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) - break; - itl.Next(); - } - if (itl.More()) { // aFace2 found, remove it from maps - LSF.Remove( itl ); - MFP.Remove(aFace2); - } - else - aFace2.Nullify(); - itl.Initialize( LSF ); - } - - // check that anOrigFace is not same domain with CSF faces it intersects - - const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E - const TopoDS_Shape& origF1 = myImagesFaces.Root(FL.First()); - const TopoDS_Shape& origF2 = myImagesFaces.Root(FL.Last()); - Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 ); - Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 ); - if (!(sameDom1 || sameDom2) && myInter3d.HasSameDomainF( anOrigFace )) { - sameDom1 = myInter3d.IsSameDomainF( anOrigFace, origF1); - if (origF1 == origF2) - sameDom2 = sameDom1; - else - myInter3d.IsSameDomainF( anOrigFace, origF2); - } - if (sameDom1 && sameDom2) - continue; - if ((sameDom1 || sameDom2)) { - inside = Partition_Loop3d::IsInside (E, - TopoDS::Face(FL.First()), - TopoDS::Face(FL.Last()), - 1, dot, GoodOri); - if (inside || (dot + Precision::Angular() >= 1.0)) - continue; // E is convex between origF1 and origF2 or they are tangent - } - - - // keep one of found faces - - //face of CSF sharing E - const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First(); - // analyse aFace1 state - inside = Partition_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1, - 1, dot, GoodOri); - if (inside && isSectionE) - { - // aFace1 must be tested with both adjacent faces of CSF - const TopoDS_Shape& aShapeFace2 = sameDom1 ? FL.First() : FL.Last(); - if (aShapeFace2 != aShapeFace) - inside = Partition_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1, - 1, dot, GoodOri); - } - - // store internal face - if (inside) - KeepFaces.Append(aFace1); - - else if (!aFace2.IsNull()) - { - if (dot + Precision::Angular() >= 1.0) - { - // aFace2 state is not clear, it will be analysed alone, - // put it back to the maps - MFP.Add( aFace2 ); - LSF.Append( aFace2 ); - } - else - KeepFaces.Append(aFace2); - } - } - } - - // =================================================== - // add not distributed faces connected with KeepFaces - // =================================================== - - // ultimate list of internal faces - TopTools_ListOfShape KeptFaces; - - // add to MFP not split tool faces as well, they may be connected with - // tool faces interfering with theShape - for ( itm.Initialize(myMapTools); itm.More(); itm.Next() ) { - const TopoDS_Shape& aToolFace = itm.Key(); - if (!myImageShape.HasImage(aToolFace)) - MFP.Add (aToolFace); - } - - if (MFP.IsEmpty()) - KeptFaces.Append (KeepFaces); - - while (!KeepFaces.IsEmpty()) - { - // KeepEdges : map of edges of faces kept last time - TopTools_IndexedMapOfShape KeepEdges; - for ( itl.Initialize(KeepFaces); itl.More(); itl.Next() ) { - TopExp::MapShapes( itl.Value(), TopAbs_EDGE, KeepEdges); - KeptFaces.Append( itl.Value() ); - } - - KeepFaces.Clear(); - - // keep faces connected with already kept faces by KeepEdges - for ( itm.Initialize(MFP); itm.More(); itm.Next() ) { - const TopoDS_Shape& FP = itm.Key(); - for (expl.Init(FP,TopAbs_EDGE); expl.More(); expl.Next()) { - const TopoDS_Shape& se = expl.Current(); - if (!MSE.Contains(se) && KeepEdges.Contains(se) ) { - KeepFaces.Append(FP); - MFP.Remove(FP); - break; - } - } - } - } - - // =============================================================== - // here MFP contains faces outer of theShape and those of shapes - // which do not interfere with theShape at all and between which - // there may be those wrapped by theShape and whose faces may be - // needed to be returned as well - // =============================================================== - - Standard_Boolean isSolid = (theShape.ShapeType() == TopAbs_SOLID); - if (All || isSolid) // All is for sub-result removal - { - // loop on not used faces; checked faces will be removed from MFP - // during the loop - for ( itm.Initialize( MFP ); itm.More(); itm.Next() ) { - const TopoDS_Shape & aFace = itm.Key(); - - // a shape which aFace originates from - TopoDS_Shape anOrigShape = GetOriginalShape( aFace ); - - // find out if all split faces of anOrigShape are not in MFP - // and by the way remove them from MFP - Standard_Boolean isAllOut = Standard_True; - TopoDS_Shape aSplitFaces = anOrigShape; - if (myImageShape.HasImage(anOrigShape)) - aSplitFaces = myImageShape.Image(anOrigShape).First(); - - TopTools_ListOfShape aSplitFaceL; // faces candidate to be kept - for (expl.Init( aSplitFaces, TopAbs_FACE ); expl.More(); expl.Next()) - { - const TopoDS_Shape & aSpFace = expl.Current(); - // a tool face which became object has image but the whole tool shape has not - if (myImageShape.HasImage( aSpFace )) - { - TopExp_Explorer exF (myImageShape.Image( aSpFace ).First(), TopAbs_FACE ); - for ( ; exF.More(); exF.Next() ) - { - aSplitFaceL.Append( exF.Current() ); - if ( ! MFP.Remove( exF.Current() ) && isAllOut ) - // a shared face might be removed from MFP during a prev loop - isAllOut = mySharedFaces.Contains( exF.Current() ); - } - } - else - { - aSplitFaceL.Append( aSpFace ); - if ( ! MFP.Remove( aSpFace ) && isAllOut) - // a shared face might be removed from MFP during a prev loop - isAllOut = mySharedFaces.Contains( aSpFace ); - } - } - itm.Initialize( MFP ); // iterate remaining faces - if ( !isAllOut ) - continue; - - // classify anOrigShape against theShape - if (IsInside (anOrigShape, theShape)) - { - if (isSolid && myClosedShapes.Contains( anOrigShape )) - // to make a special care at solid reconstruction - myWrappingSolid.Add ( theShape ); - - // keep faces of an internal shape anOrigShape - KeptFaces.Append( aSplitFaceL ); - } - } - } - - // ==================================================== - // check if kept faces form a shell without free edges - // ==================================================== - - DMEF.Clear(); // edge - kept faces - MFP.Clear(); // reuse it for wrong faces - if (CheckClosed) { - for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) - TopExp::MapShapesAndAncestors(itl.Value(), TopAbs_EDGE, TopAbs_FACE, DMEF); - - Standard_Integer i, nb = DMEF.Extent(); - Standard_Boolean isClosed = Standard_False; - while (!isClosed) { - isClosed = Standard_True; - for (i=1; isClosed && i<=nb; ++i) { - const TopoDS_Shape& E = DMEF.FindKey( i ); - if (! BRep_Tool::Degenerated( TopoDS::Edge( E )) && - ! MSE.Contains( E )) - isClosed = ( DMEF(i).Extent() != 1 ); - } - if (!isClosed) { - const TopoDS_Shape& F = DMEF.FindFromIndex( i-1 ).First(); // bad face - MFP.Add( F ); - // remove bad face from DMEF - for (expl.Init( F, TopAbs_EDGE); expl.More(); expl.Next()) { - const TopoDS_Shape& E = expl.Current(); - TopTools_ListOfShape& FL = DMEF.ChangeFromKey( E ); - for (itl.Initialize( FL ); itl.More(); itl.Next() ) { - if ( F.IsSame( itl.Value() )) { - FL.Remove( itl ); - break; - } - } - } - } - } - } - - // ============== - // make a result - // ============== - - TopoDS_Compound C; - // compound of removed internal faces - TopoDS_Compound CNotCl; - - myBuilder.MakeCompound(C); - myBuilder.MakeCompound(CNotCl); - - // add to compounds - for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) - { - TopoDS_Shape & aIntFace = itl.Value(); - if (! MFP.Contains( aIntFace )) - myBuilder.Add( C, aIntFace); - else - myBuilder.Add( CNotCl, aIntFace); - } - - if (!skipAlreadyAdded && CheckClosed) - { - myInternalFaces.Bind( theShape, C ); - myIntNotClFaces.Bind( theShape, CNotCl ); - } - - return C; -} - -//======================================================================= -//function : MakeShell -//purpose : split S into compound of shells -//======================================================================= - -void Partition_Spliter::MakeShells(const TopoDS_Shape& S, - TopTools_ListOfShape& NS) -{ - Partition_Loop3d ShellMaker; - // get compound of split faces of S - const TopoDS_Shape& FacesComp = myImageShape.Image(S).First(); - ShellMaker.AddConstFaces( FacesComp ); - // add split faces inside S - if (myClosedShapes.Contains( S )) { - TopoDS_Shape InternalFacesComp = FindFacesInside(S, Standard_True); - ShellMaker.AddSectionFaces( InternalFacesComp ); - } - - NS = ShellMaker.MakeShells( myAddedFacesMap ); - - // Add faces added to new shell to myAddedFacesMap: - // avoid rebuilding twice commont part of 2 solids. - TopTools_ListIteratorOfListOfShape itS(NS); - while ( itS.More()) { - TopExp_Explorer expF (itS.Value(), TopAbs_FACE); - for (; expF.More(); expF.Next()) - myAddedFacesMap.Add (expF.Current()); - - itS.Next(); - } -} - -//======================================================================= -//function : findEqual -//purpose : compare edges of EL1 against edges of EL2, -// Result is in EMM binding EL1 edges to list of equal edges. -// Edges are considered equall only if they have same vertices. -// ==True makes consider same edges as equal -// Put in all equal edges -//======================================================================= - -static void findEqual (const TopTools_ListOfShape& EL1, - const TopTools_ListOfShape& EL2, - const Standard_Boolean addSame, - TopTools_DataMapOfShapeListOfShape& EEM, - TopTools_MapOfShape& AllEqMap) -{ - // map vertices to edges for EL2 - TopTools_DataMapOfShapeListOfShape VEM; - TopTools_ListIteratorOfListOfShape itE1, itE2(EL2); - TopoDS_Iterator itV; - TopTools_ListOfShape emptyL; - for (; itE2.More(); itE2.Next()) { - for (itV.Initialize( itE2.Value() ); itV.More(); itV.Next()) { - const TopoDS_Shape& V = itV.Value(); - if (! VEM.IsBound( V ) ) - VEM.Bind( V, emptyL); - VEM( V ).Append( itE2.Value()); - } - } - - gp_Vec D1, D2; - gp_Pnt P; - Standard_Real f,l,u,tol; - Handle(Geom_Curve) C1, C2; - Extrema_ExtPC Extrema; - TopoDS_Vertex V1, V2, V3, V4; - - AllEqMap.Clear(); - - for (itE1.Initialize(EL1); itE1.More(); itE1.Next()) { - const TopoDS_Edge& E1 = TopoDS::Edge( itE1.Value()); - if (BRep_Tool::Degenerated( E1 ) || AllEqMap.Contains (E1)) - continue; - TopExp::Vertices( E1, V1, V2 ); - - if (VEM.IsBound(V1)) - itE2.Initialize( VEM(V1) ); - for (; itE2.More(); itE2.Next()) { - const TopoDS_Edge& E2 = TopoDS::Edge( itE2.Value()); - if (BRep_Tool::Degenerated( E2 ) || AllEqMap.Contains (E2)) - continue; - - if (E1.IsSame(E2)) { - if (!addSame) - continue; - } - else { - TopExp::Vertices( E2, V3, V4); - if (!V2.IsSame(V4) && !V2.IsSame(V3)) - continue; - // E1 and E2 have same vertices - // check D1 at end points. - C2 = BRep_Tool::Curve( E2, f,l); - C1 = BRep_Tool::Curve( E1, f,l); - u = BRep_Tool::Parameter(V1,E1); - C1->D1(u, P, D1); - u = BRep_Tool::Parameter(V1.IsSame(V3) ? V3 : V4, E2); - C2->D1(u, P, D2); - D1.Normalize(); D2.Normalize(); - if (Abs(D1*D2) + Precision::Angular() < 1.0) - continue; - if (! V1.IsSame(V2)) { - u = BRep_Tool::Parameter(V2,E1); - C1->D1(u, P, D1); - u = BRep_Tool::Parameter(V2.IsSame(V3) ? V3 : V4, E2); - C2->D1(u, P, D2); - D1.Normalize(); D2.Normalize(); - if (Abs(D1*D2) + Precision::Angular() < 1.0) - continue; - } - // check distance at a couple of internal points - tol = Max(BRep_Tool::Tolerance(E1), - BRep_Tool::Tolerance(E2)); - GeomAdaptor_Curve AC1(C1); - Extrema.Initialize(AC1,f,l); - Standard_Boolean ok = Standard_True, hasMin = Standard_False; - BRep_Tool::Range( E2, f, l); - Standard_Integer i=1, nbi=3; - for (; iValue( f+(l-f)*i/nbi )); - Standard_Integer j=1, nbj=Extrema.NbExt(); - for (; j<=nbj && ok; ++j) { - if (Extrema.IsMin(j)) { - hasMin = Standard_True; - ok = Extrema.Value(j) <= tol; - } - } - } - if ( !hasMin || !ok) - continue; - } - // bind E2 to E1 in EEM - if (!EEM.IsBound(E1)) { - EEM.Bind (E1, emptyL); - AllEqMap.Add (E1); - } - EEM(E1).Append(E2); - AllEqMap.Add (E2); - } - } -} - -//======================================================================= -//function : MakeFaces -//purpose : split faces of S, return compound of new faces -//======================================================================= - -TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) -{ - TopoDS_Compound C; - myBuilder.MakeCompound(C); - - TopTools_ListIteratorOfListOfShape itl, itNE; - - TopExp_Explorer exp(S,TopAbs_FACE); - for (; exp.More(); exp.Next()) { - - const TopoDS_Face& F = TopoDS::Face(exp.Current()); - - TopTools_ListOfShape LNF; - - if (myImagesFaces.HasImage( F )) { - myImagesFaces.LastImage( F, LNF ); - TopAbs_Orientation oriF = F.Orientation(); - for ( itl.Initialize( LNF ); itl.More(); itl.Next()) - itl.Value().Orientation( oriF ); - } - else { - - Partition_Loop2d loops; - loops.Init(F); - - TopTools_IndexedMapOfShape EM; - TopExp::MapShapes( F, TopAbs_EDGE, EM); - - TopTools_MapOfShape AddedEqualM, EqualSeamM; - Standard_Boolean needRebuild = Standard_False; - - // add splits to loops - - // LE: old edges + new not splitted edges - const TopTools_ListOfShape& LE = myAsDes->Descendant(F); - for (itl.Initialize(LE); itl.More(); itl.Next()) { - const TopoDS_Edge& E = TopoDS::Edge( itl.Value() ); - - Standard_Boolean isSectionE = myInter3d.IsSectionEdge(E); - Standard_Boolean isNewE = !EM.Contains( E ); - - // LSE: list of split edges - TopTools_ListOfShape LSE; - myImagesEdges.LastImage(E,LSE); // splits of E or E itself - - for (itNE.Initialize(LSE); itNE.More(); itNE.Next()) { - - TopoDS_Edge NE = TopoDS::Edge( itNE.Value() ); - Standard_Boolean isSameE = NE.IsSame ( E ); - - if ( isNewE || isSectionE || !isSameE) { - if (AddedEqualM.Contains( NE )) { - // a seam must be twice in a loop - if (!BRep_Tool::IsClosed( E, F ) || !EqualSeamM.Add( NE )) - continue; - } - - if (isNewE) { - if (isSectionE) { - if ( ! myInter3d.IsSplitOn( NE, E, F) ) - continue; - } - else { - TopoDS_Vertex V1,V2; - TopExp::Vertices(NE,V1,V2); - const TopTools_ListOfShape& EL1 = myAsDes->Ascendant(V1); - const TopTools_ListOfShape& EL2 = myAsDes->Ascendant(V2); - if ( EL1.Extent() < 2 && EL2.Extent() < 2 ) - continue; - } - } - else { - NE.Orientation( E.Orientation()); - if (!isSameE) { - // orient NE because it may be a split of other edge - Standard_Real f,l,u; - Handle(Geom_Curve) C3d = BRep_Tool::Curve( E,f,l ); - Handle(Geom_Curve) NC3d = BRep_Tool::Curve( NE,f,l); - if ( C3d != NC3d) { - gp_Vec D1, ND1; gp_Pnt P; - TopoDS_Vertex V = TopExp::FirstVertex(NE); - u = BRep_Tool::Parameter(V,NE); - NC3d->D1 (u, P, ND1); - u = BRep_Tool::Parameter(V,E); - C3d ->D1 (u, P, D1); - if (ND1.Dot(D1) < 0) - NE.Reverse(); - } - } - } - if (myEqualEdges.Contains( NE )) - AddedEqualM.Add( NE ); - - needRebuild = Standard_True; - } - - if (isNewE || isSectionE) - myNewSection.Add( NE ); - - if (isNewE) - loops.AddSectionEdge(NE); - else - loops.AddConstEdge(NE); - } - } - - //------------------- - // Build the faces. - //------------------- - - if (needRebuild) { - - loops.Perform(); - loops.WiresToFaces(myImagesEdges); - - LNF = loops.NewFaces(); - - myImagesFaces.Bind(F,LNF); - - // replace the result faces that have already been built - // during same domain faces reconstruction done earlier - if (myInter3d.HasSameDomainF( F )) - { - // build map edge to same domain faces: EFM - TopTools_IndexedDataMapOfShapeListOfShape EFM; - TopTools_MapOfShape SDFM; // avoid doubling - itl.Initialize( myInter3d.SameDomain( F )); - for (; itl.More(); itl.Next()) { - if ( !myImagesFaces.HasImage( itl.Value() )) - continue; - // loop on splits of a SD face - TopTools_ListIteratorOfListOfShape itNF; - itNF.Initialize (myImagesFaces.Image( itl.Value() )); - for ( ; itNF.More(); itNF.Next()) { - TopoDS_Shape SDF = itNF.Value(); - if (myImagesFaces.HasImage( SDF )) // already replaced - SDF = myImagesFaces.Image( SDF ).First(); - if (SDFM.Add (SDF)) - TopExp::MapShapesAndAncestors(SDF, TopAbs_EDGE, TopAbs_FACE, EFM); - } - } - // do replace faces in the LNF - TopTools_ListOfShape LOF; - if ( !EFM.IsEmpty() ) - itl.Initialize( LNF ); - while (itl.More()) { - const TopoDS_Shape& NF = itl.Value(); - TopExp_Explorer expE ( NF, TopAbs_EDGE ); - const TopoDS_Edge& E = TopoDS::Edge (expE.Current()); - if (EFM.Contains( E )) { - const TopTools_ListOfShape& SDFL = EFM.FindFromKey( E ); - TopoDS_Shape SDF = SDFL.First(); - Standard_Boolean GoodOri; - Standard_Real dot; - Partition_Loop3d::IsInside (E, TopoDS::Face(NF), TopoDS::Face(SDF), - 1, dot, GoodOri); - if (dot < 0) - { - // NF and SDF are on different side of E - if (SDFL.Extent() == 1) { - itl.Next(); - continue; - } - else - SDF = SDFL.Last(); // next face must be on the same side - } - gp_Vec V1 = Partition_Loop3d::Normal( E, TopoDS::Face( NF )); - gp_Vec V2 = Partition_Loop3d::Normal( E, TopoDS::Face( SDF )); - if (V1*V2 < 0) - SDF.Reverse(); - - if (!myImagesFaces.HasImage( NF )) - myImagesFaces.Bind( NF, SDF ); - - // mySharedFaces is used in FindFacesInside() - mySharedFaces.Add( SDF ); - - LOF.Prepend ( SDF ); - LNF.Remove (itl); - } - else - itl.Next(); - } - - LNF.Append (LOF); - } - } // if (needRebuild) - - else { - LNF.Append( F ); - myImagesFaces.Bind(F,LNF); - } - } // if (myImagesFaces.HasImage( F )) - - // fill the resulting compound - for (itl.Initialize(LNF); itl.More(); itl.Next()) - myBuilder.Add ( C, itl.Value()); - - } // loop on faces of S - - return C; -} - - -//======================================================================= -//function : Tri -//purpose : -//======================================================================= - -static void Tri(const TopoDS_Edge& E, - TopTools_SequenceOfShape& Seq, - const Partition_Inter3d & theInter3d) -{ - Standard_Boolean Invert = Standard_True; - Standard_Real U1,U2; - TopoDS_Vertex V1,V2; - - while (Invert) { - Invert = Standard_False; - for ( Standard_Integer i = 1; i < Seq.Length(); i++) { - - V1 = TopoDS::Vertex(Seq.Value(i)); - V2 = TopoDS::Vertex(Seq.Value(i+1)); - - V1.Orientation(TopAbs_INTERNAL); - V2.Orientation(TopAbs_INTERNAL); - - U1 = BRep_Tool::Parameter(V1,E); - U2 = BRep_Tool::Parameter(V2,E); - - if (IsEqual(U1,U2)) { - if (theInter3d.ReplaceSameDomainV( V1, E ).IsSame( V1 )) - Seq.Remove(i+1); // remove V2 - else - Seq.Remove(i); - i--; - continue; - } - if (U2 < U1) { - Seq.Exchange(i,i+1); - Invert = Standard_True; - } - } - } -} - -//======================================================================= -//function : MakeEdges -//purpose : cut E by vertices VOnE, return list of new edges NE -//======================================================================= - -void Partition_Spliter::MakeEdges (const TopoDS_Edge& E, - const TopTools_ListOfShape& VOnE, - TopTools_ListOfShape& NE ) const -{ - TopoDS_Edge WE = E; - WE.Orientation(TopAbs_FORWARD); - - Standard_Real U1,U2, f, l; - TopoDS_Vertex V1,V2,VF,VL; - - BRep_Tool::Range(WE,f,l); - TopExp::Vertices(WE,VF,VL); - - if (VOnE.Extent() < 3) { // do not rebuild not cut edge - if (( VF.IsSame( VOnE.First() ) && VL.IsSame( VOnE.Last() )) || - VL.IsSame( VOnE.First() ) && VF.IsSame( VOnE.Last() ) ) { - NE.Append( E ); - return; - } - } - - TopTools_SequenceOfShape SV; - TopTools_ListIteratorOfListOfShape itv(VOnE); - TopTools_MapOfOrientedShape VM( VOnE.Extent() ); - for (; itv.More(); itv.Next()) - if ( VM.Add( itv.Value() )) - SV.Append(itv.Value()); - - Tri( WE, SV, myInter3d ); - - if (SV.Length() < 3) { // do not rebuild not cut edge - if (( VF.IsSame( SV.First() ) && VL.IsSame( SV.Last() )) || - VL.IsSame( SV.First() ) && VF.IsSame( SV.Last() ) ) { - NE.Append( E ); - return; - } - } - - Standard_Integer iVer, NbVer = SV.Length(); - - - //---------------------------------------------------------------- - // Construction of the new edges . - //---------------------------------------------------------------- - - if (VF.IsSame(VL)) { // closed edge - if (NbVer==1) - SV.Append( SV.First() ); - else if (!SV.First().IsSame(SV.Last())) { - Standard_Boolean isFirst=0; - Standard_Real minDU = 1.e10; - TopoDS_Vertex endV = Partition_Inter2d::FindEndVertex(VOnE, f,l, E, isFirst,minDU); - if (endV.IsSame(SV.First())) - SV.Append(endV); - else if (endV.IsSame(SV.Last())) - SV.Prepend(endV); - else - MESSAGE ("END VERTEX IS IN SEQUNCE MIDDLE"); - } - NbVer = SV.Length(); - } - - for (iVer=1; iVer < NbVer; iVer++) { - V1 = TopoDS::Vertex(SV(iVer)); - V2 = TopoDS::Vertex(SV(iVer+1)); - - TopoDS_Shape NewEdge = WE.EmptyCopied(); - V1.Orientation(TopAbs_FORWARD); - myBuilder.Add (NewEdge,V1); - V2.Orientation(TopAbs_REVERSED); - myBuilder.Add (NewEdge,V2); - - if (iVer==1) - U1 = f; - else { - V1.Orientation(TopAbs_INTERNAL); - U1=BRep_Tool::Parameter(V1,WE); - } - if (iVer+1 == NbVer) - U2 = l; - else { - V2.Orientation(TopAbs_INTERNAL); - U2=BRep_Tool::Parameter(V2,WE); - } - if (Abs(U1-U2) <= Precision::PConfusion()) { - MESSAGE( "MakeEdges(), EQUAL PARAMETERS OF DIFFERENT VERTICES"); - continue; - } - TopoDS_Edge EE=TopoDS::Edge(NewEdge); - myBuilder.Range (EE,U1,U2); - - TopoDS_Edge NEdge = TopoDS::Edge(NewEdge); - myBuilder.SameParameter(NEdge,Standard_False); - - Standard_Real tol = 1.0e-2; - Standard_Boolean flag = BRep_Tool::SameParameter(NEdge); - if (!flag) { - BRepLib::SameParameter(NEdge,tol); - } - NE.Append(NEdge.Oriented(E.Orientation())); - } -} - -//======================================================================= -//function : MergeEqualEdges -//purpose : find equal edges, choose ones to keep and make -// them have pcurves on all faces they are shared by -//======================================================================= - -void Partition_Spliter::MergeEqualEdges (const TopTools_ListOfShape& LSE) -{ - // find equal edges - // map: edge - equal edges - TopTools_DataMapOfShapeListOfShape EEM( LSE.Extent() ); - findEqual (LSE, LSE, 0, EEM, myEqualEdges); - - TopTools_ListOfShape EEL; // list of equal edges - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itM (EEM); - for ( ; itM.More(); itM.Next()) { - EEL = itM.Value(); - EEL.Append( itM.Key() ); - - // choose an edge to keep, section edges have priority - TopoDS_Edge EKeep; - TopTools_ListIteratorOfListOfShape itEE (EEL); - for (; itEE.More(); itEE.Next()) { - EKeep = TopoDS::Edge( itEE.Value() ); - const TopoDS_Edge& EKeepOrig = TopoDS::Edge( myImagesEdges.Root( EKeep )); - if (myInter3d.IsSectionEdge( EKeepOrig )) - break; - } - - // update edge images and build pcurves - Standard_Real f,l, tol; - for (itEE.Initialize (EEL); itEE.More(); itEE.Next()) { - const TopoDS_Edge& E = TopoDS::Edge( itEE.Value() ); - if ( E.IsSame( EKeep )) - continue; - - // 1. build pcurves of the kept edge on faces where replaced edges exist - const TopoDS_Edge& EReplOrig = TopoDS::Edge( myImagesEdges.Root( E )); - TopTools_ListOfShape FL; - FL = myAsDes->Ascendant( EReplOrig ); - Standard_Integer iFace, iFirstSectionFace = FL.Extent() + 1; - // add faces where the replaced edge is a section edge - if (myInter3d.IsSectionEdge( EReplOrig )) { - TopTools_ListIteratorOfListOfShape seIt; - seIt.Initialize( myInter3d.SectionEdgeFaces ( EReplOrig )); - for ( ; seIt.More(); seIt.Next()) - FL.Append( seIt.Value() ); - } - // loop on faces - TopTools_ListIteratorOfListOfShape itF (FL); - for ( iFace = 1 ; itF.More(); itF.Next(), ++iFace ) { - const TopoDS_Face& F = TopoDS::Face( itF.Value()); - - Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( EKeep, F, f,l); - if (pc.IsNull()) { - Handle(Geom_Curve) C3d = BRep_Tool::Curve( EKeep, f, l); - C3d = new Geom_TrimmedCurve( C3d, f,l); - pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol); - if (pc.IsNull()) { - MESSAGE (" CANT BUILD PCURVE "); - } - myBuilder.UpdateEdge( EKeep, pc, F, tol); - } - - if (iFace >= iFirstSectionFace || - !BRep_Tool::IsClosed( EReplOrig, F )) - continue; - - // build the second pcurve for a seam - TopoDS_Vertex V = TopExp::FirstVertex( EKeep ); - Standard_Real Ukeep = BRep_Tool::Parameter( V, EKeep ); - Standard_Real Urepl = BRep_Tool::Parameter( V, E ); - - TopoDS_Edge EReplRev = E; - EReplRev.Reverse(); - Handle(Geom2d_Curve) pcRepl1 = BRep_Tool::CurveOnSurface( E, F, f,l); - Handle(Geom2d_Curve) pcRepl2 = BRep_Tool::CurveOnSurface( EReplRev, F, f,l); - - gp_Pnt2d p1r, p2r, pk; - p1r = pcRepl1->Value( Urepl ); - p2r = pcRepl2->Value( Urepl ); - pk = pc->Value( Ukeep ); - - // suppose that pk is equal to either p1r or p2r - Standard_Boolean isUPeriod = - ( Abs( p1r.X() - p2r.X() ) > Abs( p1r.Y() - p2r.Y() )); - Standard_Boolean is1Equal; - if (isUPeriod) - is1Equal = ( Abs( p1r.X() - pk.X() ) < Abs( p2r.X() - pk.X() )); - else - is1Equal = ( Abs( p1r.Y() - pk.Y() ) < Abs( p2r.Y() - pk.Y() )); - - Handle(Geom2d_Curve) pc2 = Handle(Geom2d_Curve)::DownCast - ( pc->Translated( pk, is1Equal ? p2r : p1r ) ); - - if (E.Orientation() == TopAbs_REVERSED) - is1Equal = !is1Equal; - - if (is1Equal) - myBuilder.UpdateEdge( EKeep, pc, pc2, F, tol); - else - myBuilder.UpdateEdge( EKeep, pc2, pc, F, tol); - - } // loop on a Faces where a replaced edge exists - - - // 2. update edge images according to replacement - if (myImagesEdges.HasImage( E )) - myImagesEdges.Remove( E ); - myImagesEdges.Bind( E, EKeep ); - - } // loop on a list of equal edges EEL - } // loop on a map of equal edges EEM -} - -//======================================================================= -//function : KeepShapesInside -//purpose : remove shapes that are outside of S from resul -//======================================================================= - -void Partition_Spliter::KeepShapesInside (const TopoDS_Shape& S) -{ - TopoDS_Iterator it; - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - for (it.Initialize( S ); it.More(); it.Next()) - KeepShapesInside( it.Value()); - return; - } - - Standard_Boolean isTool = Standard_False; - if (!myImageShape.HasImage( S )) { - isTool = CheckTool( S ); - if (!isTool) return; - } - - // build map of internal faces - TopTools_IndexedMapOfShape MIF; - TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); - TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF ); - - TopoDS_Compound C; - myBuilder.MakeCompound(C); - - TopAbs_ShapeEnum anInternalShapeType = TopAbs_SHAPE; - if (!MIF.IsEmpty()) - { - // leave in the result only those shapes having a face in MIF - for (it.Initialize( myShape ); it.More(); it.Next()) { - const TopoDS_Shape & aResShape = it.Value(); - TopExp_Explorer expResF( aResShape, TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) { - if ( MIF.Contains( expResF.Current())) { - myBuilder.Add( C, aResShape ); - if (aResShape.ShapeType() < anInternalShapeType) - anInternalShapeType = aResShape.ShapeType(); - break; - } - } - } - } - - // may be S was not split by internal faces then it is missing - // in myShape, add it - if (!isTool && - (anInternalShapeType > TopAbs_SOLID || S.ShapeType() > TopAbs_SOLID)) - { - TopTools_IndexedMapOfShape MSF; // map of split faces of S - TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MSF); - - // find a shape having all faces in MSF - for (it.Initialize( myShape ); it.More(); it.Next()) { - TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) { - if (! MSF.Contains( expResF.Current())) - break; - } - if (! expResF.More()) { - myBuilder.Add( C, it.Value() ); - break; - } - } - } - - myShape = C; -} - -//======================================================================= -//function : RemoveShapesInside -//purpose : remove shapes that are inside S from resul -//======================================================================= - -void Partition_Spliter::RemoveShapesInside (const TopoDS_Shape& S) -{ - TopoDS_Iterator it; - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - for (it.Initialize( S ); it.More(); it.Next()) - RemoveShapesInside( it.Value()); - return; - } - Standard_Boolean isTool = Standard_False; - if (!myImageShape.HasImage( S )) { - isTool = CheckTool( S ); - if (!isTool) return; - } - - TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); - TopTools_IndexedMapOfShape MIF; // map of internal faces - TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF); - - if (MIF.IsEmpty()) return; - - // add to MIF split faces of S - if (myImageShape.HasImage(S)) - TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF); - - // leave in the result only those shapes not having all face in MIF - - TopoDS_Compound C; - myBuilder.MakeCompound(C); - - // RMF : faces of removed shapes that encounter once - TopTools_MapOfShape RFM; - - for (it.Initialize( myShape ); it.More(); it.Next()) { - - TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) - if (!MIF.Contains( expResF.Current())) - break; - - if (expResF.More()) - // add shape to result - myBuilder.Add( C, it.Value() ); - else - // add faces of a removed shape to RFM - for (expResF.ReInit(); expResF.More(); expResF.Next()) { - const TopoDS_Shape& F = expResF.Current(); - if ( ! RFM.Remove ( F )) - RFM.Add( F ); - } - } - - if (!isTool) { - - // rebuild S, it must remain in the result - - Standard_Boolean isClosed = Standard_False; - switch (S.ShapeType()) { - case TopAbs_SOLID : - isClosed = Standard_True; break; - case TopAbs_SHELL: { - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF); - Standard_Integer i; - for (i=1; isClosed && i<=MEF.Extent(); ++i) - isClosed = ( MEF(i).Extent() != 1 ); - break; - } - default: - isClosed = Standard_False; - } - if (isClosed) { - - // add to a new shape external faces of removed shapes, ie those in RFM - - TopoDS_Shell Shell; - myBuilder.MakeShell( Shell ); - - // exclude redundant internal face with edges encounterd only once - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopTools_MapIteratorOfMapOfShape itF (RFM); - for ( ; itF.More(); itF.Next()) - TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF); - - // add only faces forming a closed shell - for (itF.Reset() ; itF.More(); itF.Next()) - { - TopExp_Explorer expE (itF.Key(), TopAbs_EDGE); - for (; expE.More(); expE.Next()) - if (MEF.FindFromKey(expE.Current()).Extent() == 1) - break; - if (!expE.More()) - myBuilder.Add( Shell, itF.Key()); - } - - if (S.ShapeType() == TopAbs_SOLID) { - TopoDS_Solid Solid; - myBuilder.MakeSolid( Solid ); - myBuilder.Add (Solid, Shell); - myBuilder.Add (C, Solid); - } - else - myBuilder.Add (C, Shell); - } - else { - if (myImageShape.HasImage( S )) { - for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next()) - myBuilder.Add (C, it.Value()); - } - } - } - - myShape = C; -} - -//======================================================================= -//function : CheckTool -//purpose : Return True if is a tool shape. Prepare tool -// faces of for the search of internal faces. -//======================================================================= - -Standard_Boolean Partition_Spliter::CheckTool(const TopoDS_Shape& S) -{ - // suppose S has not an image - - Standard_Boolean isTool = Standard_False; - TopoDS_Compound C; - myBuilder.MakeCompound( C ); - - TopExp_Explorer expF( S, TopAbs_FACE); - for (; expF.More(); expF.Next()) { - - const TopoDS_Face& F = TopoDS::Face( expF.Current() ); - if (myMapTools.Contains( F )) - isTool = Standard_True; - else - continue; - - if (myImagesFaces.HasImage( F )) { - // F has been reconstructed - TopAbs_Orientation Fori = F.Orientation(); - TopTools_ListOfShape LNF; - myImagesFaces.LastImage( F, LNF); - TopTools_ListIteratorOfListOfShape itF (LNF); - for ( ; itF.More(); itF.Next()) - myBuilder.Add( C, itF.Value().Oriented(Fori) ); - continue; - } - - Standard_Boolean hasSectionE = myInter3d.HasSectionEdge( F ); - Standard_Boolean hasNewE = myAsDes->HasDescendant( F ); - if (!hasSectionE && !hasNewE) - { - // F intersects nothing - myBuilder.Add( C, F ); - continue; - } - - // make an image for F - - TopoDS_Face NF = F; - NF.Orientation(TopAbs_FORWARD); - NF = TopoDS::Face( NF.EmptyCopied() ); // make a copy - TopoDS_Wire NW; - myBuilder.MakeWire( NW ); - - // add edges, as less as possible - TopTools_ListOfShape NEL; - TopTools_ListIteratorOfListOfShape itNE; - if (hasSectionE) { - // add section edges - TopExp_Explorer expE; - for ( ; expE.More(); expE.Next()) { - if (! myImagesEdges.HasImage( expE.Current() )) - continue; - myImagesEdges.LastImage( expE.Current(), NEL ); - for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next()) - myBuilder.Add ( NW, itNE.Value()); - } - } - if (hasNewE) { - // add new adges - NEL = myAsDes->Descendant( F ); - for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next()) { - TopTools_ListOfShape SEL; // splits - myImagesEdges.LastImage( itNE.Value(), SEL ); - TopTools_ListIteratorOfListOfShape itSE (SEL); - for ( ; itSE.More(); itSE.Next()) - myBuilder.Add ( NW, itSE.Value()); - } - } - myBuilder.Add( NF, NW ); - myBuilder.Add (C, NF); - - NF.Orientation( F.Orientation() ); // NF is most probably invalid - myImagesFaces.Bind (F, NF); - } - if (isTool) - myImageShape.Bind (S, C); - - return isTool; -} - -//======================================================================= -//function : IsInside -//purpose : Return True if the first vertex of S1 inside S2. -// If S1.IsNull(), check infinite point against S2. -//======================================================================= - -Standard_Boolean Partition_Spliter::IsInside (const TopoDS_Shape& theS1, - const TopoDS_Shape& theS2) -{ - BRepClass3d_SolidClassifier aClassifier( theS2 ); - - TopExp_Explorer expl( theS1, TopAbs_VERTEX ); - if (!expl.More()) - aClassifier.PerformInfinitePoint( ::RealSmall()); - else - { - const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); - aClassifier.Perform (BRep_Tool::Pnt( aVertex ), - BRep_Tool::Tolerance( aVertex )); - } - - return ( aClassifier.State() == TopAbs_IN ); -} - -//======================================================================= -//function : GetOriginalShape -//purpose : Return the shape aShape originates from. aShape -// should be a face or more complex result shape -//======================================================================= - -TopoDS_Shape Partition_Spliter::GetOriginalShape(const TopoDS_Shape& theShape) const -{ - TopoDS_Shape anOrigShape; - - TopExp_Explorer expl( theShape, TopAbs_FACE); - if (expl.More()) - { - - TopoDS_Shape aFace = expl.Current(); - if (myImagesFaces.IsImage( aFace )) - aFace = myImagesFaces.Root( aFace ); - anOrigShape = myFaceShapeMap.Find( aFace ); - } - return anOrigShape; -} - -//======================================================================= -//function : FindToolsToReconstruct -//purpose : find and store as objects tools which interfere -// with solids or are inside solids without -// an interference -//======================================================================= - -void Partition_Spliter::FindToolsToReconstruct() -{ - if (myMapTools.IsEmpty()) - return; - - Standard_Integer nbFoundTools = 0; - - // build edge - face map in order to detect interference with section edges - TopTools_IndexedDataMapOfShapeListOfShape EFM; - TopTools_MapIteratorOfMapOfShape aMapIt; - for (aMapIt.Initialize(myMapTools); aMapIt.More(); aMapIt.Next()) - TopExp::MapShapesAndAncestors( aMapIt.Key(), TopAbs_EDGE, TopAbs_FACE, EFM); - for (aMapIt.Initialize(myMapFaces); aMapIt.More(); aMapIt.Next()) - TopExp::MapShapesAndAncestors( aMapIt.Key(), TopAbs_EDGE, TopAbs_FACE, EFM); - - TopTools_MapOfShape aCurrentSolids, aCheckedShapes; - - // faces cut by new edges - TopTools_MapOfShape & aSectionFaces = myInter3d.TouchedFaces(); - - // keep solids interfering with each other in aCurrentSolids map - // and add tool faces intersecting solids as object shapes - - TopTools_ListIteratorOfListOfShape itS, itF, itCF, itE; - for (itS.Initialize( myListShapes ); itS.More(); itS.Next()) { - TopExp_Explorer expSo (itS.Value(), TopAbs_SOLID); - for (; expSo.More(); expSo.Next()) { - - // check if a solid has been already processed - const TopoDS_Shape & aSo = expSo.Current(); - if (!aCheckedShapes.Add( aSo )) - continue; - aCurrentSolids.Add( aSo ); - - // faces to check - TopTools_ListOfShape aFacesToCheck; - TopExp_Explorer exp( aSo, TopAbs_FACE ); - for ( ; exp.More(); exp.Next()) - aFacesToCheck.Append ( exp.Current()); - - // add other shapes interefering with a solid. - // iterate faces to check while appending new ones - for (itCF.Initialize (aFacesToCheck) ; itCF.More(); itCF.Next()) - { - const TopoDS_Shape& aCheckFace = itCF.Value(); -// if (!aCheckedShapes.Add( aCheckFace )) -// continue; - - // find faces interfering with aCheckFace - TopTools_ListOfShape anIntFaces; - - // ** 1. faces intersecting aCheckFace with creation of new edges on it - if ( myAsDes->HasDescendant( aCheckFace )) - { - // new edges on aCheckFace - const TopTools_ListOfShape& NEL = myAsDes->Descendant( aCheckFace ); - for (itE.Initialize( NEL); itE.More(); itE.Next()) - { - const TopoDS_Shape & aNewEdge = itE.Value(); - if (!aCheckedShapes.Add( aNewEdge )) - continue; - - // faces interfering by aNewEdge - itF.Initialize (myAsDes->Ascendant( aNewEdge )); - for (; itF.More(); itF.Next()) - if (aCheckFace != itF.Value()) - anIntFaces.Append( itF.Value() ); - - // ** 2. faces having section edge aNewEdge on aFacesToCheck - if (EFM.Contains( aNewEdge)) - { - itF.Initialize ( EFM.FindFromKey (itE.Value())); - for (; itF.More(); itF.Next()) - if (aCheckFace != itF.Value()) - anIntFaces.Append( itF.Value() ); - } - } - } - - // ** 3. faces cut by edges of aCheckFace - TopExp_Explorer expE (aCheckFace, TopAbs_EDGE); - for ( ; expE.More(); expE.Next()) - { - const TopoDS_Shape & aCheckEdge = expE.Current(); - if (aCheckedShapes.Add( aCheckEdge ) && - myInter3d.IsSectionEdge( TopoDS::Edge( aCheckEdge ))) - { - itF.Initialize( myInter3d.SectionEdgeFaces( TopoDS::Edge( aCheckEdge ))); - for (; itF.More(); itF.Next()) - if (aCheckFace != itF.Value()) - anIntFaces.Append( itF.Value() ); - } - } - - // process faces interfering with aCheckFace and shapes they - // belong to - for (itF.Initialize (anIntFaces); itF.More(); itF.Next()) - { - const TopoDS_Shape & F = itF.Value(); - if (! aCheckedShapes.Add( F )) - continue; - - Standard_Boolean isTool = myMapTools.Contains( F ); - if (isTool && - myFaceShapeMap( aCheckFace ).ShapeType() == TopAbs_SOLID ) - { - // a tool interfering with a solid - if (aSectionFaces.Contains( F )) - AddShape( F ); - ++ nbFoundTools; - if (nbFoundTools == myMapTools.Extent()) - return; - } - - const TopoDS_Shape & S = myFaceShapeMap( F ); - if (aCheckedShapes.Add( S )) - { - // a new shape interefering with aCurrentSolids is found - if (!isTool && S.ShapeType() == TopAbs_SOLID) - aCurrentSolids.Add ( S ); - // add faces to aFacesToCheck list - for ( exp.Init( S, TopAbs_FACE ); exp.More(); exp.Next()) - aFacesToCheck.Append ( exp.Current() ); - } - } - } // loop on aFacesToCheck - - // Here aCurrentSolids contains all solids interfering with each other. - // aCheckedShapes contains all faces belonging to shapes included - // in or interfering with aCurrentSolids or previously checked solids. - // Test if tool faces that do not interefere with other shapes are - // wrapped by any of aCurrentSolids - - TopTools_MapIteratorOfMapOfShape aSolidIt (aCurrentSolids); - for ( ; aSolidIt.More(); aSolidIt.Next()) - { - const TopoDS_Shape & aSolid = aSolidIt.Key(); - TopTools_MapOfShape aCheckedTools( myMapTools.Extent() ); - - TopTools_MapIteratorOfMapOfShape aToolIt (myMapTools); - for ( ; aToolIt.More(); aToolIt.Next()) - { - const TopoDS_Shape & aToolFace = aToolIt.Key(); - if (aCheckedShapes.Contains( aToolFace ) || // already found - aCheckedTools.Contains( aToolFace )) // checked against aSolid - continue; - - const TopoDS_Shape & aToolShape = myFaceShapeMap( aToolFace ); - TopExp_Explorer aToolFaceIt( aToolShape, TopAbs_FACE ); - - Standard_Boolean isInside = IsInside( aToolShape, aSolid ); - for ( ; aToolFaceIt.More(); aToolFaceIt.Next() ) - { - const TopoDS_Shape & aTool = aToolFaceIt.Current(); - aCheckedTools.Add( aTool ); - if (isInside) - { - if (aSectionFaces.Contains( aTool )) - AddShape( aTool ); - ++ nbFoundTools; - if (nbFoundTools == myMapTools.Extent()) - return; - aCheckedShapes.Add( aTool ); - } - } - } - } - - } // loop on solid shapes - } -} diff --git a/src/PARTITION/Partition_Spliter.hxx b/src/PARTITION/Partition_Spliter.hxx deleted file mode 100644 index 1b71e20b1..000000000 --- a/src/PARTITION/Partition_Spliter.hxx +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Spliter.hxx -// Module : GEOM -// -#ifndef _Partition_Spliter_HeaderFile -#define _Partition_Spliter_HeaderFile - -#ifndef _TopAbs_ShapeEnum_HeaderFile -#include -#endif -#ifndef _TopoDS_Compound_HeaderFile -#include -#endif -#ifndef _BRep_Builder_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_MapOfShape_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeShape_HeaderFile -#include -#endif -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _BRepAlgo_Image_HeaderFile -#include -#endif -#ifndef _Partition_Inter3d_HeaderFile -#include "Partition_Inter3d.hxx" -#endif -#ifndef _TopTools_MapOfOrientedShape_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class BRepAlgo_AsDes; -class TopoDS_Shape; -class TopTools_ListOfShape; -class TopoDS_Edge; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class Partition_Spliter { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT Partition_Spliter(); -Standard_EXPORT void AddShape(const TopoDS_Shape& S) ; -Standard_EXPORT void AddTool(const TopoDS_Shape& S) ; -Standard_EXPORT void Compute(const TopAbs_ShapeEnum Limit = TopAbs_SHAPE) ; -Standard_EXPORT void KeepShapesInside(const TopoDS_Shape& S) ; -Standard_EXPORT void RemoveShapesInside(const TopoDS_Shape& S) ; -Standard_EXPORT TopoDS_Shape Shape() const; -Standard_EXPORT void Clear() ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void MakeSolids(const TopoDS_Shape& Solid,TopTools_ListOfShape& Shells) ; -Standard_EXPORT void MakeShells(const TopoDS_Shape& S,TopTools_ListOfShape& NS) ; -Standard_EXPORT TopoDS_Shape MakeFaces(const TopoDS_Shape& S) ; -Standard_EXPORT void MakeEdges(const TopoDS_Edge& E,const TopTools_ListOfShape& VOnE,TopTools_ListOfShape& NE) const; -Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ; -Standard_EXPORT Standard_Boolean CheckTool(const TopoDS_Shape& S) ; -Standard_EXPORT void MergeEqualEdges(const TopTools_ListOfShape& LE) ; -Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& S1,const TopoDS_Shape& S2) ; -Standard_EXPORT TopoDS_Shape GetOriginalShape(const TopoDS_Shape& aShape) const; -Standard_EXPORT void FindToolsToReconstruct() ; - - - // Fields PRIVATE - // -TopAbs_ShapeEnum myDoneStep; -TopoDS_Compound myShape; -BRep_Builder myBuilder; -TopTools_ListOfShape myListShapes; -TopTools_MapOfShape myMapFaces; -TopTools_MapOfShape myMapTools; -TopTools_MapOfShape myEqualEdges; -TopTools_MapOfShape myNewSection; -TopTools_MapOfShape myClosedShapes; -TopTools_MapOfShape mySharedFaces; -TopTools_MapOfShape myWrappingSolid; -TopTools_DataMapOfShapeShape myFaceShapeMap; -TopTools_DataMapOfShapeShape myInternalFaces; -TopTools_DataMapOfShapeShape myIntNotClFaces; -Handle_BRepAlgo_AsDes myAsDes; -BRepAlgo_Image myImagesFaces; -BRepAlgo_Image myImagesEdges; -BRepAlgo_Image myImageShape; -Partition_Inter3d myInter3d; -TopTools_MapOfOrientedShape myAddedFacesMap; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/PARTITION/Partition_Spliter.ixx b/src/PARTITION/Partition_Spliter.ixx deleted file mode 100644 index 3443f3150..000000000 --- a/src/PARTITION/Partition_Spliter.ixx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Spliter.ixx -// Module : GEOM -// -#include "Partition_Spliter.jxx" - - - - diff --git a/src/PARTITION/Partition_Spliter.jxx b/src/PARTITION/Partition_Spliter.jxx deleted file mode 100644 index 79d17ddb4..000000000 --- a/src/PARTITION/Partition_Spliter.jxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// GEOM PARTITION : partition algorithm -// File : Partition_Spliter.jxx -// Module : GEOM -// -#ifndef _BRepAlgo_AsDes_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopTools_ListOfShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Partition_Spliter_HeaderFile -#include "Partition_Spliter.hxx" -#endif