mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 18:18:35 +05:00
Internal issue 0022865: Restructurization of Partition packages.
This commit is contained in:
parent
f33f73b435
commit
35bb93a206
16
configure.ac
16
configure.ac
@ -316,6 +316,19 @@ echo
|
|||||||
|
|
||||||
CHECK_CAS
|
CHECK_CAS
|
||||||
|
|
||||||
|
echo "OCC_VERSION_DEVELOPMENT = ${OCC_VERSION_DEVELOPMENT}"
|
||||||
|
NMTDS_VAR=NMTDS
|
||||||
|
NMTTools_VAR=NMTTools
|
||||||
|
GEOMAlgo_VAR=GEOMAlgo
|
||||||
|
if test "${OCC_VERSION_DEVELOPMENT}" == "1"; then
|
||||||
|
NMTDS_VAR=NMTDS_NEW
|
||||||
|
NMTTools_VAR=NMTTools_NEW
|
||||||
|
GEOMAlgo_VAR=GEOMAlgo_NEW
|
||||||
|
fi
|
||||||
|
AC_SUBST(NMTDS_VAR)
|
||||||
|
AC_SUBST(NMTTools_VAR)
|
||||||
|
AC_SUBST(GEOMAlgo_VAR)
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo ---------------------------------------------
|
echo ---------------------------------------------
|
||||||
echo Testing html generators
|
echo Testing html generators
|
||||||
@ -445,6 +458,7 @@ AC_OUTPUT([ \
|
|||||||
src/EntityGUI/Makefile \
|
src/EntityGUI/Makefile \
|
||||||
src/GEOM/Makefile \
|
src/GEOM/Makefile \
|
||||||
src/GEOMAlgo/Makefile \
|
src/GEOMAlgo/Makefile \
|
||||||
|
src/GEOMAlgo_NEW/Makefile \
|
||||||
src/GEOMBase/Makefile \
|
src/GEOMBase/Makefile \
|
||||||
src/GEOMClient/Makefile \
|
src/GEOMClient/Makefile \
|
||||||
src/GEOMFiltersSelection/Makefile \
|
src/GEOMFiltersSelection/Makefile \
|
||||||
@ -464,7 +478,9 @@ AC_OUTPUT([ \
|
|||||||
src/IGESImport/Makefile \
|
src/IGESImport/Makefile \
|
||||||
src/MeasureGUI/Makefile \
|
src/MeasureGUI/Makefile \
|
||||||
src/NMTDS/Makefile \
|
src/NMTDS/Makefile \
|
||||||
|
src/NMTDS_NEW/Makefile \
|
||||||
src/NMTTools/Makefile \
|
src/NMTTools/Makefile \
|
||||||
|
src/NMTTools_NEW/Makefile \
|
||||||
src/OBJECT/Makefile \
|
src/OBJECT/Makefile \
|
||||||
src/OCC2VTK/Makefile \
|
src/OCC2VTK/Makefile \
|
||||||
src/OperationGUI/Makefile \
|
src/OperationGUI/Makefile \
|
||||||
|
67
src/GEOMAlgo_NEW/BlockFix.cdl
Normal file
67
src/GEOMAlgo_NEW/BlockFix.cdl
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix.cdl
|
||||||
|
-- Created: Tue Dec 7 11:59:05 2004
|
||||||
|
-- Author: Pavel Durandin
|
||||||
|
--
|
||||||
|
package BlockFix
|
||||||
|
|
||||||
|
uses
|
||||||
|
|
||||||
|
TColStd,
|
||||||
|
gp,
|
||||||
|
Geom,
|
||||||
|
Geom2d,
|
||||||
|
GeomAbs,
|
||||||
|
TopLoc,
|
||||||
|
TopoDS,
|
||||||
|
BRepTools,
|
||||||
|
TopTools,
|
||||||
|
ShapeBuild
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
class SphereSpaceModifier;
|
||||||
|
|
||||||
|
class UnionFaces;
|
||||||
|
|
||||||
|
class UnionEdges;
|
||||||
|
|
||||||
|
class BlockFixAPI;
|
||||||
|
---Purpose: API class to perform the fixing of the
|
||||||
|
-- block
|
||||||
|
|
||||||
|
class PeriodicSurfaceModifier;
|
||||||
|
|
||||||
|
class CheckTool;
|
||||||
|
|
||||||
|
RotateSphereSpace (S: Shape from TopoDS; Tol: Real)
|
||||||
|
returns Shape from TopoDS;
|
||||||
|
|
||||||
|
FixRanges (S: Shape from TopoDS; Tol: Real)
|
||||||
|
returns Shape from TopoDS;
|
||||||
|
---Purpose: checking and fixing cases where parametric
|
||||||
|
-- boundaries of face based on periodic surface are not
|
||||||
|
-- contained in the range of this surface.
|
||||||
|
|
||||||
|
end BlockFix;
|
216
src/GEOMAlgo_NEW/BlockFix.cxx
Normal file
216
src/GEOMAlgo_NEW/BlockFix.cxx
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix.cxx
|
||||||
|
// Created: Tue Dec 7 11:59:05 2004
|
||||||
|
// Author: Pavel DURANDIN
|
||||||
|
//
|
||||||
|
#include <BlockFix.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
#include <ShapeCustom.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <ShapeBuild_ReShape.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom_CylindricalSurface.hxx>
|
||||||
|
#include <Geom_ConicalSurface.hxx>
|
||||||
|
#include <ShapeFix_Wire.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <BRepTools_Modifier.hxx>
|
||||||
|
#include <Geom_SphericalSurface.hxx>
|
||||||
|
#include <Geom_ToroidalSurface.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <ShapeAnalysis_Edge.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
#include <ShapeFix.hxx>
|
||||||
|
#include <ShapeFix_Face.hxx>
|
||||||
|
#include <ShapeAnalysis.hxx>
|
||||||
|
|
||||||
|
#include <TColgp_SequenceOfPnt2d.hxx>
|
||||||
|
#include <ShapeAnalysis_Curve.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <ShapeBuild_Edge.hxx>
|
||||||
|
|
||||||
|
#include <BlockFix_SphereSpaceModifier.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <BlockFix_PeriodicSurfaceModifier.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FixResult
|
||||||
|
//purpose : auxilary
|
||||||
|
//=======================================================================
|
||||||
|
static void FixResult(const TopoDS_Shape& result,
|
||||||
|
Handle(ShapeBuild_ReShape)& Context,
|
||||||
|
const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) {
|
||||||
|
TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
// face coud not be dropped or splitted on this step
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(aShape);
|
||||||
|
TopLoc_Location L;
|
||||||
|
Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L);
|
||||||
|
|
||||||
|
if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ||
|
||||||
|
Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) {
|
||||||
|
|
||||||
|
Standard_Integer nbWires = 0;
|
||||||
|
for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) {
|
||||||
|
nbWires++;
|
||||||
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()),
|
||||||
|
aFace,
|
||||||
|
Precision::Confusion());
|
||||||
|
sfw->FixReorder();
|
||||||
|
if(sfw->StatusReorder ( ShapeExtend_FAIL ))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sfw->SetPrecision(2.*Tol);
|
||||||
|
sfw->FixShifted();
|
||||||
|
|
||||||
|
Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE );
|
||||||
|
isDone |= sfw->FixDegenerated();
|
||||||
|
|
||||||
|
// remove degenerated edges from not degenerated points
|
||||||
|
ShapeAnalysis_Edge sae;
|
||||||
|
Handle(ShapeExtend_WireData) sewd = sfw->WireData();
|
||||||
|
Standard_Integer i;
|
||||||
|
for( i = 1; i<=sewd->NbEdges();i++) {
|
||||||
|
TopoDS_Edge E = sewd->Edge(i);
|
||||||
|
if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) {
|
||||||
|
sewd->Remove(i);
|
||||||
|
isDone = Standard_True;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395)
|
||||||
|
|
||||||
|
// remove neighbour seam edges
|
||||||
|
if(isDone) {
|
||||||
|
for( i = 1; i<sewd->NbEdges();i++) {
|
||||||
|
if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) {
|
||||||
|
isDone = Standard_True;
|
||||||
|
sewd->Remove(i);
|
||||||
|
sewd->Remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) {
|
||||||
|
sewd->Remove(1);
|
||||||
|
sewd->Remove(sewd->NbEdges());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(isDone) {
|
||||||
|
TopoDS_Wire ResWire = sfw->Wire();
|
||||||
|
Context->Replace(ex_w.Current(), ResWire);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Implement fix orientation in case of several wires
|
||||||
|
if(nbWires > 1) {
|
||||||
|
TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace));
|
||||||
|
Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace);
|
||||||
|
if(sff->FixOrientation())
|
||||||
|
Context->Replace(aFixedFace,sff->Face());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ConvertToAnalytical
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S,
|
||||||
|
const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Create a modification description
|
||||||
|
Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier;
|
||||||
|
SR->SetTolerance(Tol);
|
||||||
|
|
||||||
|
TopTools_DataMapOfShapeShape context;
|
||||||
|
BRepTools_Modifier MD;
|
||||||
|
TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD );
|
||||||
|
|
||||||
|
Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape;
|
||||||
|
FixResult(result,RS,Tol);
|
||||||
|
result = RS->Apply(result);
|
||||||
|
|
||||||
|
ShapeFix_Edge sfe;
|
||||||
|
for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Edge E = TopoDS::Edge(exp.Current());
|
||||||
|
sfe.FixVertexTolerance (E);
|
||||||
|
}
|
||||||
|
|
||||||
|
ShapeFix::SameParameter(result,Standard_False);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FixRanges
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S,
|
||||||
|
const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
// Create a modification description
|
||||||
|
Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier;
|
||||||
|
SR->SetTolerance(Tol);
|
||||||
|
|
||||||
|
TopTools_DataMapOfShapeShape context;
|
||||||
|
BRepTools_Modifier MD;
|
||||||
|
TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD );
|
||||||
|
|
||||||
|
Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape;
|
||||||
|
FixResult(result,RS,Tol);
|
||||||
|
result = RS->Apply(result);
|
||||||
|
|
||||||
|
ShapeFix_Edge sfe;
|
||||||
|
for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Edge E = TopoDS::Edge(exp.Current());
|
||||||
|
sfe.FixVertexTolerance (E);
|
||||||
|
}
|
||||||
|
|
||||||
|
ShapeFix::SameParameter(result,Standard_False);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
106
src/GEOMAlgo_NEW/BlockFix.hxx
Normal file
106
src/GEOMAlgo_NEW/BlockFix.hxx
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_HeaderFile
|
||||||
|
#define _BlockFix_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
class TopoDS_Shape;
|
||||||
|
class BlockFix_SphereSpaceModifier;
|
||||||
|
class BlockFix_UnionFaces;
|
||||||
|
class BlockFix_UnionEdges;
|
||||||
|
class BlockFix_BlockFixAPI;
|
||||||
|
class BlockFix_PeriodicSurfaceModifier;
|
||||||
|
class BlockFix_CheckTool;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Macro_HeaderFile
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class BlockFix {
|
||||||
|
|
||||||
|
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 TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol) ;
|
||||||
|
Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Methods PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Methods PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
friend class BlockFix_SphereSpaceModifier;
|
||||||
|
friend class BlockFix_UnionFaces;
|
||||||
|
friend class BlockFix_UnionEdges;
|
||||||
|
friend class BlockFix_BlockFixAPI;
|
||||||
|
friend class BlockFix_PeriodicSurfaceModifier;
|
||||||
|
friend class BlockFix_CheckTool;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
27
src/GEOMAlgo_NEW/BlockFix.ixx
Normal file
27
src/GEOMAlgo_NEW/BlockFix.ixx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix.jxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
28
src/GEOMAlgo_NEW/BlockFix.jxx
Normal file
28
src/GEOMAlgo_NEW/BlockFix.jxx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_HeaderFile
|
||||||
|
#include <BlockFix.hxx>
|
||||||
|
#endif
|
68
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cdl
Normal file
68
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cdl
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_BlockFixAPI.cdl
|
||||||
|
-- Created: Tue Dec 7 17:56:09 2004
|
||||||
|
-- Author: Pavel Durandin
|
||||||
|
--
|
||||||
|
class BlockFixAPI from BlockFix inherits TShared from MMgt
|
||||||
|
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
uses
|
||||||
|
|
||||||
|
Shape from TopoDS,
|
||||||
|
ReShape from ShapeBuild
|
||||||
|
|
||||||
|
is
|
||||||
|
Create returns BlockFixAPI from BlockFix;
|
||||||
|
---Purpose: Empty constructor
|
||||||
|
|
||||||
|
SetShape(me: mutable; Shape: Shape from TopoDS);
|
||||||
|
---Purpose: Sets the shape to be operated on
|
||||||
|
---C++: inline
|
||||||
|
|
||||||
|
Perform(me: mutable);
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
Shape(me) returns Shape from TopoDS;
|
||||||
|
---Purpose: Returns resulting shape.
|
||||||
|
---C++: inline
|
||||||
|
|
||||||
|
Context(me:mutable) returns ReShape from ShapeBuild;
|
||||||
|
---Purpose: Returns modifiable context for storing the
|
||||||
|
-- mofifications
|
||||||
|
---C++: inline
|
||||||
|
---C++: return &
|
||||||
|
|
||||||
|
Tolerance (me:mutable) returns Real;
|
||||||
|
---Purpose: Returns modifiable tolerance of recognition
|
||||||
|
---C++: inline
|
||||||
|
---C++: return &
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myContext : ReShape from ShapeBuild;
|
||||||
|
myShape : Shape from TopoDS;
|
||||||
|
myTolerance : Real from Standard;
|
||||||
|
|
||||||
|
end BlockFixAPI from BlockFix;
|
66
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cxx
Normal file
66
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cxx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix_BlockFixAPI.cxx
|
||||||
|
// Created: Tue Dec 7 11:59:05 2004
|
||||||
|
// Author: Pavel DURANDIN
|
||||||
|
//
|
||||||
|
#include <BlockFix_BlockFixAPI.ixx>
|
||||||
|
#include <BlockFix.hxx>
|
||||||
|
#include <BlockFix_UnionFaces.hxx>
|
||||||
|
#include <BlockFix_UnionEdges.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShapeConvert_CanonicAPI
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_BlockFixAPI::BlockFix_BlockFixAPI()
|
||||||
|
{
|
||||||
|
myTolerance = Precision::Confusion();
|
||||||
|
myOptimumNbFaces = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_BlockFixAPI::Perform()
|
||||||
|
{
|
||||||
|
// processing spheres with degenerativities
|
||||||
|
TopoDS_Shape aShape = Shape();
|
||||||
|
myShape = BlockFix::RotateSphereSpace(aShape,myTolerance);
|
||||||
|
|
||||||
|
// faces unification
|
||||||
|
BlockFix_UnionFaces aFaceUnifier;
|
||||||
|
aFaceUnifier.GetTolerance() = myTolerance;
|
||||||
|
aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
|
||||||
|
TopoDS_Shape aResult = aFaceUnifier.Perform(myShape);
|
||||||
|
|
||||||
|
BlockFix_UnionEdges anEdgeUnifier;
|
||||||
|
myShape = anEdgeUnifier.Perform(aResult,myTolerance);
|
||||||
|
|
||||||
|
TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
|
||||||
|
myShape = aRes;
|
||||||
|
}
|
94
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.hxx
Normal file
94
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.hxx
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_BlockFixAPI_HeaderFile
|
||||||
|
#define _BlockFix_BlockFixAPI_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile
|
||||||
|
#include <Handle_BlockFix_BlockFixAPI.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
|
||||||
|
#include <Handle_ShapeBuild_ReShape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Shape_HeaderFile
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _MMgt_TShared_HeaderFile
|
||||||
|
#include <MMgt_TShared.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class ShapeBuild_ReShape;
|
||||||
|
class TopoDS_Shape;
|
||||||
|
|
||||||
|
|
||||||
|
class BlockFix_BlockFixAPI : public MMgt_TShared
|
||||||
|
{
|
||||||
|
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 BlockFix_BlockFixAPI();
|
||||||
|
void SetShape(const TopoDS_Shape& Shape);
|
||||||
|
Standard_EXPORT void Perform();
|
||||||
|
TopoDS_Shape Shape() const;
|
||||||
|
Handle_ShapeBuild_ReShape& Context();
|
||||||
|
Standard_Real& Tolerance();
|
||||||
|
Standard_Integer& OptimumNbFaces();
|
||||||
|
Standard_EXPORT ~BlockFix_BlockFixAPI();
|
||||||
|
|
||||||
|
// Type management
|
||||||
|
//
|
||||||
|
Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_();
|
||||||
|
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
|
||||||
|
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
Handle_ShapeBuild_ReShape myContext;
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
Standard_Integer myOptimumNbFaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include <BlockFix_BlockFixAPI.lxx>
|
||||||
|
|
||||||
|
#endif
|
77
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.ixx
Normal file
77
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.ixx
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_BlockFixAPI.jxx>
|
||||||
|
|
||||||
|
#ifndef _Standard_TypeMismatch_HeaderFile
|
||||||
|
#include <Standard_TypeMismatch.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Standard_EXPORT Handle_Standard_Type& BlockFix_BlockFixAPI_Type_()
|
||||||
|
{
|
||||||
|
|
||||||
|
static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
|
||||||
|
|
||||||
|
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL};
|
||||||
|
static Handle_Standard_Type _aType = new Standard_Type("BlockFix_BlockFixAPI",
|
||||||
|
sizeof(BlockFix_BlockFixAPI),
|
||||||
|
1,
|
||||||
|
(Standard_Address)_Ancestors,
|
||||||
|
(Standard_Address)NULL);
|
||||||
|
|
||||||
|
return _aType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DownCast method
|
||||||
|
// allow safe downcasting
|
||||||
|
//
|
||||||
|
const Handle(BlockFix_BlockFixAPI) Handle(BlockFix_BlockFixAPI)::DownCast(const Handle(Standard_Transient)& AnObject)
|
||||||
|
{
|
||||||
|
Handle(BlockFix_BlockFixAPI) _anOtherObject;
|
||||||
|
|
||||||
|
if (!AnObject.IsNull()) {
|
||||||
|
if (AnObject->IsKind(STANDARD_TYPE(BlockFix_BlockFixAPI))) {
|
||||||
|
_anOtherObject = Handle(BlockFix_BlockFixAPI)((Handle(BlockFix_BlockFixAPI)&)AnObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _anOtherObject ;
|
||||||
|
}
|
||||||
|
const Handle(Standard_Type)& BlockFix_BlockFixAPI::DynamicType() const
|
||||||
|
{
|
||||||
|
return STANDARD_TYPE(BlockFix_BlockFixAPI) ;
|
||||||
|
}
|
||||||
|
Standard_Boolean BlockFix_BlockFixAPI::IsKind(const Handle(Standard_Type)& AType) const
|
||||||
|
{
|
||||||
|
return (STANDARD_TYPE(BlockFix_BlockFixAPI) == AType || MMgt_TShared::IsKind(AType));
|
||||||
|
}
|
||||||
|
Handle_BlockFix_BlockFixAPI::~Handle_BlockFix_BlockFixAPI() {}
|
||||||
|
|
31
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.jxx
Normal file
31
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.jxx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _ShapeBuild_ReShape_HeaderFile
|
||||||
|
#include <ShapeBuild_ReShape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Shape_HeaderFile
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_BlockFixAPI_HeaderFile
|
||||||
|
#include <BlockFix_BlockFixAPI.hxx>
|
||||||
|
#endif
|
73
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.lxx
Normal file
73
src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.lxx
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_BlockFixAPI.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape)
|
||||||
|
{
|
||||||
|
myShape = Shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const
|
||||||
|
{
|
||||||
|
return myShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Context
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context()
|
||||||
|
{
|
||||||
|
return myContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Tolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
inline Standard_Real& BlockFix_BlockFixAPI::Tolerance()
|
||||||
|
{
|
||||||
|
return myTolerance;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : OptimumNbFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces()
|
||||||
|
{
|
||||||
|
return myOptimumNbFaces;
|
||||||
|
}
|
67
src/GEOMAlgo_NEW/BlockFix_CheckTool.cdl
Normal file
67
src/GEOMAlgo_NEW/BlockFix_CheckTool.cdl
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_CheckTool.cdl
|
||||||
|
-- Created: Fri Dec 17 10:36:58 2004
|
||||||
|
-- Author: Sergey KUUL
|
||||||
|
--
|
||||||
|
class CheckTool from BlockFix
|
||||||
|
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
uses
|
||||||
|
|
||||||
|
Shape from TopoDS,
|
||||||
|
SequenceOfShape from TopTools
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
Create returns CheckTool from BlockFix;
|
||||||
|
---Purpose: Empty constructor
|
||||||
|
|
||||||
|
SetShape(me: in out; aShape: Shape from TopoDS);
|
||||||
|
|
||||||
|
Perform(me: in out);
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
NbPossibleBlocks(me) returns Integer;
|
||||||
|
|
||||||
|
PossibleBlock(me; num: Integer) returns Shape from TopoDS;
|
||||||
|
|
||||||
|
DumpCheckResult(me; S : in out OStream);
|
||||||
|
---Purpose: Dumps results of checking
|
||||||
|
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myShape : Shape from TopoDS;
|
||||||
|
myHasCheck : Boolean;
|
||||||
|
myNbSolids : Integer;
|
||||||
|
myNbBlocks : Integer;
|
||||||
|
myPossibleBlocks : SequenceOfShape from TopTools;
|
||||||
|
myNbDegen : Integer;
|
||||||
|
myNbUF : Integer;
|
||||||
|
myNbUE : Integer;
|
||||||
|
myNbUFUE : Integer;
|
||||||
|
myBadRanges : Integer;
|
||||||
|
|
||||||
|
end CheckTool;
|
279
src/GEOMAlgo_NEW/BlockFix_CheckTool.cxx
Normal file
279
src/GEOMAlgo_NEW/BlockFix_CheckTool.cxx
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix_CheckTool.cxx
|
||||||
|
// Created: 17.12.04 11:15:25
|
||||||
|
// Author: Sergey KUUL
|
||||||
|
//
|
||||||
|
#include <BlockFix_CheckTool.ixx>
|
||||||
|
|
||||||
|
//#include <BlockFix_UnionEdges.hxx>
|
||||||
|
//#include <BlockFix_UnionFaces.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BlockFix_CheckTool()
|
||||||
|
//purpose : Constructor
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_CheckTool::BlockFix_CheckTool( )
|
||||||
|
{
|
||||||
|
myHasCheck = Standard_False;
|
||||||
|
myPossibleBlocks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape)
|
||||||
|
{
|
||||||
|
myHasCheck = Standard_False;
|
||||||
|
myShape = aShape;
|
||||||
|
myPossibleBlocks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_CheckTool::Perform()
|
||||||
|
{
|
||||||
|
myNbSolids=0;
|
||||||
|
myNbBlocks=0;
|
||||||
|
myNbDegen=0;
|
||||||
|
myNbUF=0;
|
||||||
|
myNbUE=0;
|
||||||
|
myNbUFUE=0;
|
||||||
|
|
||||||
|
TopExp_Explorer exps (myShape, TopAbs_SOLID);
|
||||||
|
TopTools_MapOfShape mapS;
|
||||||
|
for (; exps.More(); exps.Next()) {
|
||||||
|
TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
|
||||||
|
if (!mapS.Add(aSolid)) continue;
|
||||||
|
myNbSolids++;
|
||||||
|
Standard_Boolean IsBlock=Standard_True;
|
||||||
|
Standard_Boolean MayBeUF=Standard_False;
|
||||||
|
Standard_Boolean MayBeUE=Standard_False;
|
||||||
|
Standard_Integer nf=0;
|
||||||
|
TopExp_Explorer expf (aSolid, TopAbs_FACE);
|
||||||
|
TopTools_MapOfShape mapF;
|
||||||
|
for (; expf.More(); expf.Next()) {
|
||||||
|
if (mapF.Add(expf.Current()))
|
||||||
|
nf++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf < 6) {
|
||||||
|
IsBlock = Standard_False;
|
||||||
|
}
|
||||||
|
else if (nf > 6) {
|
||||||
|
IsBlock = Standard_False;
|
||||||
|
// check faces unification
|
||||||
|
TopTools_SequenceOfShape faces;
|
||||||
|
mapF.Clear();
|
||||||
|
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
||||||
|
if (mapF.Add(expf.Current())) {
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
||||||
|
faces.Append(aFace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Standard_Boolean HasFacesForUnification = Standard_False;
|
||||||
|
for (Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
|
||||||
|
TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
|
||||||
|
TopTools_MapOfShape Edges;
|
||||||
|
for (TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
|
||||||
|
Edges.Add(expe.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
TopLoc_Location L1;
|
||||||
|
Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
|
||||||
|
for(Standard_Integer j=i+1; j<=faces.Length() && !HasFacesForUnification; j++) {
|
||||||
|
TopoDS_Face F2 = TopoDS::Face(faces.Value(j));
|
||||||
|
TopLoc_Location L2;
|
||||||
|
Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
|
||||||
|
if( S1==S2 && L1==L2 ) {
|
||||||
|
// faces have equal based surface
|
||||||
|
// now check common edge
|
||||||
|
for(TopExp_Explorer expe2(F2,TopAbs_EDGE); expe2.More(); expe2.Next()) {
|
||||||
|
if(Edges.Contains(expe2.Current().Oriented(TopAbs_FORWARD))) {
|
||||||
|
HasFacesForUnification = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (HasFacesForUnification) {
|
||||||
|
MayBeUF=Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer nbe=0;
|
||||||
|
TopTools_MapOfShape DegenEdges;
|
||||||
|
TopExp_Explorer expe (aSolid, TopAbs_EDGE);
|
||||||
|
TopTools_MapOfShape mapE;
|
||||||
|
for (; expe.More(); expe.Next()) {
|
||||||
|
TopoDS_Edge E = TopoDS::Edge(expe.Current());
|
||||||
|
if (!mapE.Add(E)) continue;
|
||||||
|
if (BRep_Tool::Degenerated(E)) {
|
||||||
|
DegenEdges.Add(E);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nbe++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nbe == 12 && DegenEdges.Extent() > 0) {
|
||||||
|
IsBlock = Standard_False;
|
||||||
|
myNbDegen++;
|
||||||
|
myPossibleBlocks.Append(aSolid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (nbe < 12)
|
||||||
|
IsBlock = Standard_False;
|
||||||
|
if (nbe > 12) {
|
||||||
|
IsBlock = Standard_False;
|
||||||
|
// check edges unification
|
||||||
|
// creating map of edge faces
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||||
|
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||||
|
|
||||||
|
mapF.Clear();
|
||||||
|
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
||||||
|
if (!mapF.Add(aFace)) continue;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
|
||||||
|
|
||||||
|
TopTools_MapOfShape mapEe;
|
||||||
|
for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
|
||||||
|
if (!mapEe.Add(edge)) continue;
|
||||||
|
if (!aMapEdgeFaces.Contains(edge)) continue;
|
||||||
|
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
||||||
|
TopTools_ListIteratorOfListOfShape anIter (aList);
|
||||||
|
for (; anIter.More(); anIter.Next()) {
|
||||||
|
TopoDS_Face face = TopoDS::Face(anIter.Value());
|
||||||
|
if (face.IsSame(aFace)) continue;
|
||||||
|
if (aMapFacesEdges.Contains(face)) {
|
||||||
|
aMapFacesEdges.ChangeFromKey(face).Append(edge);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape ListEdges;
|
||||||
|
ListEdges.Append(edge);
|
||||||
|
aMapFacesEdges.Add(face,ListEdges);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Standard_Integer i = 1;
|
||||||
|
for (; i <= aMapFacesEdges.Extent(); i++) {
|
||||||
|
const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
|
||||||
|
if (ListEdges.Extent() > 1) break;
|
||||||
|
}
|
||||||
|
if (i <= aMapFacesEdges.Extent()) {
|
||||||
|
MayBeUE = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsBlock)
|
||||||
|
myNbBlocks++;
|
||||||
|
else {
|
||||||
|
if (MayBeUF) {
|
||||||
|
myPossibleBlocks.Append(aSolid);
|
||||||
|
if (MayBeUE)
|
||||||
|
myNbUFUE++;
|
||||||
|
else
|
||||||
|
myNbUF++;
|
||||||
|
}
|
||||||
|
else if (MayBeUE) {
|
||||||
|
myNbUE++;
|
||||||
|
myPossibleBlocks.Append(aSolid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
myHasCheck = Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPossibleBlocks
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const
|
||||||
|
{
|
||||||
|
return myPossibleBlocks.Length();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : PossibleBlock
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const
|
||||||
|
{
|
||||||
|
TopoDS_Shape res;
|
||||||
|
if( num>0 && num<=myPossibleBlocks.Length() )
|
||||||
|
res = myPossibleBlocks.Value(num);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DumpCheckResult
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const
|
||||||
|
{
|
||||||
|
if(!myHasCheck)
|
||||||
|
S<<"Check not performed!"<<endl;
|
||||||
|
else {
|
||||||
|
S<<"dump results of check:"<<endl;
|
||||||
|
S<<" total number of solids = "<<myNbSolids<<endl;
|
||||||
|
S<<" including: number of good blocks = "<<myNbBlocks<<endl;
|
||||||
|
S<<" number of possible blocks = "<<NbPossibleBlocks()<<endl;
|
||||||
|
S<<" including: need remove degenerative = "<<myNbDegen<<endl;
|
||||||
|
S<<" need unionfaces = "<<myNbUF<<endl;
|
||||||
|
S<<" need unionedges = "<<myNbUE<<endl;
|
||||||
|
S<<" need both unionfaces and unionedges = "<<myNbUFUE<<endl;
|
||||||
|
Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
|
||||||
|
S<<" number of impossible blocks = "<<nbtmp<<endl;
|
||||||
|
}
|
||||||
|
}
|
120
src/GEOMAlgo_NEW/BlockFix_CheckTool.hxx
Normal file
120
src/GEOMAlgo_NEW/BlockFix_CheckTool.hxx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_CheckTool_HeaderFile
|
||||||
|
#define _BlockFix_CheckTool_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _TopoDS_Shape_HeaderFile
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Boolean_HeaderFile
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Integer_HeaderFile
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopTools_SequenceOfShape_HeaderFile
|
||||||
|
#include <TopTools_SequenceOfShape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_OStream_HeaderFile
|
||||||
|
#include <Standard_OStream.hxx>
|
||||||
|
#endif
|
||||||
|
class TopoDS_Shape;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Macro_HeaderFile
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class BlockFix_CheckTool {
|
||||||
|
|
||||||
|
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 BlockFix_CheckTool();
|
||||||
|
Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ;
|
||||||
|
Standard_EXPORT void Perform() ;
|
||||||
|
Standard_EXPORT Standard_Integer NbPossibleBlocks() const;
|
||||||
|
Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const;
|
||||||
|
Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Methods PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Methods PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
Standard_Boolean myHasCheck;
|
||||||
|
Standard_Integer myNbSolids;
|
||||||
|
Standard_Integer myNbBlocks;
|
||||||
|
TopTools_SequenceOfShape myPossibleBlocks;
|
||||||
|
Standard_Integer myNbDegen;
|
||||||
|
Standard_Integer myNbUF;
|
||||||
|
Standard_Integer myNbUE;
|
||||||
|
Standard_Integer myNbUFUE;
|
||||||
|
Standard_Integer myBadRanges;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
27
src/GEOMAlgo_NEW/BlockFix_CheckTool.ixx
Normal file
27
src/GEOMAlgo_NEW/BlockFix_CheckTool.ixx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_CheckTool.jxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
28
src/GEOMAlgo_NEW/BlockFix_CheckTool.jxx
Normal file
28
src/GEOMAlgo_NEW/BlockFix_CheckTool.jxx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_CheckTool_HeaderFile
|
||||||
|
#include <BlockFix_CheckTool.hxx>
|
||||||
|
#endif
|
135
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cdl
Normal file
135
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cdl
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_PeriodicSurfaceModifier.cdl
|
||||||
|
-- Created: Wed Dec 15 10:03:50 2004
|
||||||
|
-- Author: Sergey KUUL
|
||||||
|
--
|
||||||
|
class PeriodicSurfaceModifier from BlockFix inherits Modification from BRepTools
|
||||||
|
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
uses
|
||||||
|
Vertex from TopoDS,
|
||||||
|
Edge from TopoDS,
|
||||||
|
Face from TopoDS,
|
||||||
|
Location from TopLoc,
|
||||||
|
Shape from GeomAbs,
|
||||||
|
Pnt from gp,
|
||||||
|
Curve from Geom,
|
||||||
|
Curve from Geom2d,
|
||||||
|
Surface from Geom,
|
||||||
|
IndexedMapOfTransient from TColStd,
|
||||||
|
DataMapOfShapeInteger from TopTools
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
Create returns mutable PeriodicSurfaceModifier from BlockFix;
|
||||||
|
|
||||||
|
SetTolerance(me: mutable; Toler: Real);
|
||||||
|
---Purpose: Sets the tolerance for recognition of geometry
|
||||||
|
|
||||||
|
NewSurface(me: mutable; F : Face from TopoDS;
|
||||||
|
S : out Surface from Geom;
|
||||||
|
L : out Location from TopLoc;
|
||||||
|
Tol: out Real from Standard;
|
||||||
|
RevWires : out Boolean from Standard;
|
||||||
|
RevFace : out Boolean from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the face <F> has been
|
||||||
|
-- modified. In this case, <S> is the new geometric
|
||||||
|
-- support of the face, <L> the new location, <Tol>
|
||||||
|
-- the new tolerance. Otherwise, returns
|
||||||
|
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||||
|
-- significant.
|
||||||
|
|
||||||
|
NewCurve(me: mutable; E : Edge from TopoDS;
|
||||||
|
C : out Curve from Geom;
|
||||||
|
L : out Location from TopLoc;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the edge <E> has been
|
||||||
|
-- modified. In this case, <C> is the new geometric
|
||||||
|
-- support of the edge, <L> the new location, <Tol>
|
||||||
|
-- the new tolerance. Otherwise, returns
|
||||||
|
-- Standard_False, and <C>, <L>, <Tol> are not
|
||||||
|
-- significant.
|
||||||
|
|
||||||
|
NewPoint(me: mutable; V : Vertex from TopoDS;
|
||||||
|
P : out Pnt from gp;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the vertex <V> has been
|
||||||
|
-- modified. In this case, <P> is the new geometric
|
||||||
|
-- support of the vertex, <Tol> the new tolerance.
|
||||||
|
-- Otherwise, returns Standard_False, and <P>, <Tol>
|
||||||
|
-- are not significant.
|
||||||
|
|
||||||
|
NewCurve2d(me: mutable; E : Edge from TopoDS;
|
||||||
|
F : Face from TopoDS;
|
||||||
|
NewE : Edge from TopoDS;
|
||||||
|
NewF : Face from TopoDS;
|
||||||
|
C : out Curve from Geom2d;
|
||||||
|
Tol : out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the edge <E> has a new
|
||||||
|
-- curve on surface on the face <F>.In this case, <C>
|
||||||
|
-- is the new geometric support of the edge, <L> the
|
||||||
|
-- new location, <Tol> the new tolerance.
|
||||||
|
--
|
||||||
|
-- Otherwise, returns Standard_False, and <C>, <L>,
|
||||||
|
-- <Tol> are not significant.
|
||||||
|
--
|
||||||
|
-- <NewE> is the new edge created from <E>. <NewF>
|
||||||
|
-- is the new face created from <F>. They may be usefull.
|
||||||
|
|
||||||
|
NewParameter(me: mutable; V : Vertex from TopoDS;
|
||||||
|
E : Edge from TopoDS;
|
||||||
|
P : out Real from Standard;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the Vertex <V> has a new
|
||||||
|
-- parameter on the edge <E>. In this case, <P> is
|
||||||
|
-- the parameter, <Tol> the new tolerance.
|
||||||
|
-- Otherwise, returns Standard_False, and <P>, <Tol>
|
||||||
|
-- are not significant.
|
||||||
|
|
||||||
|
Continuity(me: mutable; E : Edge from TopoDS;
|
||||||
|
F1,F2 : Face from TopoDS;
|
||||||
|
NewE : Edge from TopoDS;
|
||||||
|
NewF1,NewF2: Face from TopoDS)
|
||||||
|
returns Shape from GeomAbs;
|
||||||
|
---Purpose: Returns the continuity of <NewE> between <NewF1>
|
||||||
|
-- and <NewF2>.
|
||||||
|
--
|
||||||
|
-- <NewE> is the new edge created from <E>. <NewF1>
|
||||||
|
-- (resp. <NewF2>) is the new face created from <F1>
|
||||||
|
-- (resp. <F2>).
|
||||||
|
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myTolerance : Real;
|
||||||
|
myMapOfFaces : DataMapOfShapeInteger from TopTools;
|
||||||
|
myMapOfSurfaces: IndexedMapOfTransient from TColStd;
|
||||||
|
|
||||||
|
end PeriodicSurfaceModifier;
|
250
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cxx
Normal file
250
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cxx
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix_PeriodicSurfaceModifier.cxx
|
||||||
|
// Created: 15.12.04 10:08:50
|
||||||
|
// Author: Sergey KUUL
|
||||||
|
|
||||||
|
#include <BlockFix_PeriodicSurfaceModifier.ixx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <Geom_CylindricalSurface.hxx>
|
||||||
|
#include <Geom_SphericalSurface.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BlockFix_PeriodicSurfaceModifier()
|
||||||
|
//purpose : Constructor
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier ( )
|
||||||
|
{
|
||||||
|
myMapOfFaces.Clear();
|
||||||
|
myMapOfSurfaces.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetTolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_PeriodicSurfaceModifier::SetTolerance(const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
myTolerance = Tol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ModifySurface
|
||||||
|
//purpose : auxilary
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
static Standard_Boolean ModifySurface(const TopoDS_Face& aFace,
|
||||||
|
const Handle(Geom_Surface)& aSurface,
|
||||||
|
Handle(Geom_Surface)& aNewSurface)
|
||||||
|
{
|
||||||
|
Handle(Geom_Surface) S = aSurface;
|
||||||
|
|
||||||
|
if(S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
|
||||||
|
Handle(Geom_CylindricalSurface) aCyl =
|
||||||
|
Handle(Geom_CylindricalSurface)::DownCast(S);
|
||||||
|
Standard_Real Umin, Umax, Vmin, Vmax;
|
||||||
|
BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax);
|
||||||
|
if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) {
|
||||||
|
gp_Ax3 ax3 = aCyl->Position();
|
||||||
|
gp_Ax1 NDir = ax3.Axis();
|
||||||
|
gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion());
|
||||||
|
Handle(Geom_CylindricalSurface) aNewCyl =
|
||||||
|
new Geom_CylindricalSurface(newax3,aCyl->Radius());
|
||||||
|
aNewSurface = aNewCyl;
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
|
||||||
|
Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S);
|
||||||
|
Standard_Real Umin, Umax, Vmin, Vmax;
|
||||||
|
BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax);
|
||||||
|
if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) {
|
||||||
|
gp_Ax3 ax3 = aSphere->Position();
|
||||||
|
gp_Ax1 NDir = ax3.Axis();
|
||||||
|
gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion());
|
||||||
|
Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(newax3,aSphere->Radius());
|
||||||
|
aNewSurface = aNewSphere;
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewSurface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewSurface(const TopoDS_Face& F,
|
||||||
|
Handle(Geom_Surface)& S,
|
||||||
|
TopLoc_Location& L,Standard_Real& Tol,
|
||||||
|
Standard_Boolean& RevWires,
|
||||||
|
Standard_Boolean& RevFace)
|
||||||
|
{
|
||||||
|
TopLoc_Location LS;
|
||||||
|
Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS);
|
||||||
|
|
||||||
|
if(ModifySurface(F, SIni, S)) {
|
||||||
|
|
||||||
|
RevWires = Standard_False;
|
||||||
|
RevFace = Standard_False;
|
||||||
|
|
||||||
|
L = LS;
|
||||||
|
Tol = BRep_Tool::Tolerance(F);
|
||||||
|
|
||||||
|
Standard_Integer anIndex = myMapOfSurfaces.Add(S);
|
||||||
|
myMapOfFaces.Bind(F,anIndex);
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewCurve
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve(const TopoDS_Edge& /*E*/,
|
||||||
|
Handle(Geom_Curve)& /*C*/,
|
||||||
|
TopLoc_Location& /*L*/,
|
||||||
|
Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewPoint
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewPoint(const TopoDS_Vertex& /*V*/,
|
||||||
|
gp_Pnt& /*P*/,
|
||||||
|
Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewCurve2d
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve2d(const TopoDS_Edge& E,
|
||||||
|
const TopoDS_Face& F,
|
||||||
|
const TopoDS_Edge& /*NewE*/,
|
||||||
|
const TopoDS_Face& /*NewF*/,
|
||||||
|
Handle(Geom2d_Curve)& C,
|
||||||
|
Standard_Real& Tol)
|
||||||
|
{
|
||||||
|
//check if undelying surface of the face was modified
|
||||||
|
if(myMapOfFaces.IsBound(F)) {
|
||||||
|
Standard_Integer anIndex = myMapOfFaces.Find(F);
|
||||||
|
|
||||||
|
Handle(Geom_Surface) aNewSurf = Handle(Geom_Surface)::DownCast(myMapOfSurfaces.FindKey(anIndex));
|
||||||
|
|
||||||
|
Standard_Real f,l;
|
||||||
|
TopLoc_Location LC, LS;
|
||||||
|
Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l );
|
||||||
|
Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS);
|
||||||
|
|
||||||
|
//taking into accound the orientation of the seam
|
||||||
|
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||||
|
Tol = BRep_Tool::Tolerance(E);
|
||||||
|
|
||||||
|
BRep_Builder B;
|
||||||
|
TopoDS_Edge TempE;
|
||||||
|
B.MakeEdge(TempE);
|
||||||
|
B.Add(TempE, TopExp::FirstVertex(E));
|
||||||
|
B.Add(TempE, TopExp::LastVertex(E));
|
||||||
|
|
||||||
|
if(!C3d.IsNull())
|
||||||
|
B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion());
|
||||||
|
B.Range(TempE, f, l);
|
||||||
|
|
||||||
|
Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge;
|
||||||
|
Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(LS.Transformation()));
|
||||||
|
TopLoc_Location LTemp;
|
||||||
|
LTemp.Identity();
|
||||||
|
|
||||||
|
Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F);
|
||||||
|
Standard_Real aWorkTol = 2*myTolerance+Tol;
|
||||||
|
sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol));
|
||||||
|
sfe->FixSameParameter(TempE);
|
||||||
|
|
||||||
|
//keep the orientation of original edge
|
||||||
|
TempE.Orientation(E.Orientation());
|
||||||
|
C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l);
|
||||||
|
|
||||||
|
//surface was modified
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewParameter
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,
|
||||||
|
const TopoDS_Edge& /*E*/,
|
||||||
|
Standard_Real& /*P*/,
|
||||||
|
Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Continuity
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
GeomAbs_Shape BlockFix_PeriodicSurfaceModifier::Continuity(const TopoDS_Edge& E,
|
||||||
|
const TopoDS_Face& F1,
|
||||||
|
const TopoDS_Face& F2,
|
||||||
|
const TopoDS_Edge& /*NewE*/,
|
||||||
|
const TopoDS_Face& /*NewF1*/,
|
||||||
|
const TopoDS_Face& /*NewF2*/)
|
||||||
|
{
|
||||||
|
return BRep_Tool::Continuity(E,F1,F2);
|
||||||
|
}
|
||||||
|
|
140
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.hxx
Normal file
140
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.hxx
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_PeriodicSurfaceModifier_HeaderFile
|
||||||
|
#define _BlockFix_PeriodicSurfaceModifier_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile
|
||||||
|
#include <Handle_BlockFix_PeriodicSurfaceModifier.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
|
||||||
|
#include <TopTools_DataMapOfShapeInteger.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
|
||||||
|
#include <TColStd_IndexedMapOfTransient.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BRepTools_Modification_HeaderFile
|
||||||
|
#include <BRepTools_Modification.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Boolean_HeaderFile
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom_Surface_HeaderFile
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom_Curve_HeaderFile
|
||||||
|
#include <Handle_Geom_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom2d_Curve_HeaderFile
|
||||||
|
#include <Handle_Geom2d_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _GeomAbs_Shape_HeaderFile
|
||||||
|
#include <GeomAbs_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
class TopoDS_Face;
|
||||||
|
class Geom_Surface;
|
||||||
|
class TopLoc_Location;
|
||||||
|
class TopoDS_Edge;
|
||||||
|
class Geom_Curve;
|
||||||
|
class TopoDS_Vertex;
|
||||||
|
class gp_Pnt;
|
||||||
|
class Geom2d_Curve;
|
||||||
|
|
||||||
|
|
||||||
|
class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification {
|
||||||
|
|
||||||
|
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 BlockFix_PeriodicSurfaceModifier();
|
||||||
|
Standard_EXPORT void SetTolerance(const Standard_Real Toler) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ;
|
||||||
|
Standard_EXPORT ~BlockFix_PeriodicSurfaceModifier();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Type management
|
||||||
|
//
|
||||||
|
Standard_EXPORT friend Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_();
|
||||||
|
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
|
||||||
|
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Methods PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Methods PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
TopTools_DataMapOfShapeInteger myMapOfFaces;
|
||||||
|
TColStd_IndexedMapOfTransient myMapOfSurfaces;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
79
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.ixx
Normal file
79
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.ixx
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_PeriodicSurfaceModifier.jxx>
|
||||||
|
|
||||||
|
#ifndef _Standard_TypeMismatch_HeaderFile
|
||||||
|
#include <Standard_TypeMismatch.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Standard_EXPORT Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_()
|
||||||
|
{
|
||||||
|
|
||||||
|
static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification);
|
||||||
|
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification);
|
||||||
|
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
|
||||||
|
|
||||||
|
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
|
||||||
|
static Handle_Standard_Type _aType = new Standard_Type("BlockFix_PeriodicSurfaceModifier",
|
||||||
|
sizeof(BlockFix_PeriodicSurfaceModifier),
|
||||||
|
1,
|
||||||
|
(Standard_Address)_Ancestors,
|
||||||
|
(Standard_Address)NULL);
|
||||||
|
|
||||||
|
return _aType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DownCast method
|
||||||
|
// allow safe downcasting
|
||||||
|
//
|
||||||
|
const Handle(BlockFix_PeriodicSurfaceModifier) Handle(BlockFix_PeriodicSurfaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject)
|
||||||
|
{
|
||||||
|
Handle(BlockFix_PeriodicSurfaceModifier) _anOtherObject;
|
||||||
|
|
||||||
|
if (!AnObject.IsNull()) {
|
||||||
|
if (AnObject->IsKind(STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier))) {
|
||||||
|
_anOtherObject = Handle(BlockFix_PeriodicSurfaceModifier)((Handle(BlockFix_PeriodicSurfaceModifier)&)AnObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _anOtherObject ;
|
||||||
|
}
|
||||||
|
const Handle(Standard_Type)& BlockFix_PeriodicSurfaceModifier::DynamicType() const
|
||||||
|
{
|
||||||
|
return STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) ;
|
||||||
|
}
|
||||||
|
Standard_Boolean BlockFix_PeriodicSurfaceModifier::IsKind(const Handle(Standard_Type)& AType) const
|
||||||
|
{
|
||||||
|
return (STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) == AType || BRepTools_Modification::IsKind(AType));
|
||||||
|
}
|
||||||
|
Handle_BlockFix_PeriodicSurfaceModifier::~Handle_BlockFix_PeriodicSurfaceModifier() {}
|
||||||
|
|
49
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.jxx
Normal file
49
src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.jxx
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <TopoDS_Face.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom_Surface_HeaderFile
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopLoc_Location_HeaderFile
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Edge_HeaderFile
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom_Curve_HeaderFile
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Vertex_HeaderFile
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _gp_Pnt_HeaderFile
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom2d_Curve_HeaderFile
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile
|
||||||
|
#include <BlockFix_PeriodicSurfaceModifier.hxx>
|
||||||
|
#endif
|
139
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cdl
Normal file
139
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cdl
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_SphereSpaceModifier.cdl
|
||||||
|
-- Created: Tue Dec 7 12:01:49 2004
|
||||||
|
-- Author: Pavel Durandin
|
||||||
|
--
|
||||||
|
class SphereSpaceModifier from BlockFix inherits Modification from BRepTools
|
||||||
|
|
||||||
|
---Purpose: Rotation of the parametric space of the sphere in order
|
||||||
|
-- to avoid the seam and degenerared edge within it
|
||||||
|
|
||||||
|
uses
|
||||||
|
Vertex from TopoDS,
|
||||||
|
Edge from TopoDS,
|
||||||
|
Face from TopoDS,
|
||||||
|
Location from TopLoc,
|
||||||
|
Shape from GeomAbs,
|
||||||
|
Pnt from gp,
|
||||||
|
Curve from Geom,
|
||||||
|
Curve from Geom2d,
|
||||||
|
Surface from Geom,
|
||||||
|
IndexedMapOfTransient from TColStd,
|
||||||
|
DataMapOfShapeInteger from TopTools
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
Create returns mutable SphereSpaceModifier from BlockFix;
|
||||||
|
|
||||||
|
SetTolerance(me: mutable; Toler: Real);
|
||||||
|
---Purpose: Sets the tolerance for recognition of geometry
|
||||||
|
|
||||||
|
NewSurface(me: mutable; F : Face from TopoDS;
|
||||||
|
S : out Surface from Geom;
|
||||||
|
L : out Location from TopLoc;
|
||||||
|
Tol: out Real from Standard;
|
||||||
|
RevWires : out Boolean from Standard;
|
||||||
|
RevFace : out Boolean from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the face <F> has been
|
||||||
|
-- modified. In this case, <S> is the new geometric
|
||||||
|
-- support of the face, <L> the new location, <Tol>
|
||||||
|
-- the new tolerance. Otherwise, returns
|
||||||
|
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||||
|
-- significant.
|
||||||
|
|
||||||
|
NewCurve(me: mutable; E : Edge from TopoDS;
|
||||||
|
C : out Curve from Geom;
|
||||||
|
L : out Location from TopLoc;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the edge <E> has been
|
||||||
|
-- modified. In this case, <C> is the new geometric
|
||||||
|
-- support of the edge, <L> the new location, <Tol>
|
||||||
|
-- the new tolerance. Otherwise, returns
|
||||||
|
-- Standard_False, and <C>, <L>, <Tol> are not
|
||||||
|
-- significant.
|
||||||
|
|
||||||
|
NewPoint(me: mutable; V : Vertex from TopoDS;
|
||||||
|
P : out Pnt from gp;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the vertex <V> has been
|
||||||
|
-- modified. In this case, <P> is the new geometric
|
||||||
|
-- support of the vertex, <Tol> the new tolerance.
|
||||||
|
-- Otherwise, returns Standard_False, and <P>, <Tol>
|
||||||
|
-- are not significant.
|
||||||
|
|
||||||
|
NewCurve2d(me: mutable; E : Edge from TopoDS;
|
||||||
|
F : Face from TopoDS;
|
||||||
|
NewE : Edge from TopoDS;
|
||||||
|
NewF : Face from TopoDS;
|
||||||
|
C : out Curve from Geom2d;
|
||||||
|
Tol : out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the edge <E> has a new
|
||||||
|
-- curve on surface on the face <F>.In this case, <C>
|
||||||
|
-- is the new geometric support of the edge, <L> the
|
||||||
|
-- new location, <Tol> the new tolerance.
|
||||||
|
--
|
||||||
|
-- Otherwise, returns Standard_False, and <C>, <L>,
|
||||||
|
-- <Tol> are not significant.
|
||||||
|
--
|
||||||
|
-- <NewE> is the new edge created from <E>. <NewF>
|
||||||
|
-- is the new face created from <F>. They may be usefull.
|
||||||
|
|
||||||
|
NewParameter(me: mutable; V : Vertex from TopoDS;
|
||||||
|
E : Edge from TopoDS;
|
||||||
|
P : out Real from Standard;
|
||||||
|
Tol: out Real from Standard)
|
||||||
|
returns Boolean from Standard;
|
||||||
|
---Purpose: Returns Standard_True if the Vertex <V> has a new
|
||||||
|
-- parameter on the edge <E>. In this case, <P> is
|
||||||
|
-- the parameter, <Tol> the new tolerance.
|
||||||
|
-- Otherwise, returns Standard_False, and <P>, <Tol>
|
||||||
|
-- are not significant.
|
||||||
|
|
||||||
|
Continuity(me: mutable; E : Edge from TopoDS;
|
||||||
|
F1,F2 : Face from TopoDS;
|
||||||
|
NewE : Edge from TopoDS;
|
||||||
|
NewF1,NewF2: Face from TopoDS)
|
||||||
|
returns Shape from GeomAbs;
|
||||||
|
---Purpose: Returns the continuity of <NewE> between <NewF1>
|
||||||
|
-- and <NewF2>.
|
||||||
|
--
|
||||||
|
-- <NewE> is the new edge created from <E>. <NewF1>
|
||||||
|
-- (resp. <NewF2>) is the new face created from <F1>
|
||||||
|
-- (resp. <F2>).
|
||||||
|
|
||||||
|
ForRotation(me: mutable; F: Face from TopoDS) returns Boolean;
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myTolerance : Real;
|
||||||
|
myMapOfFaces : DataMapOfShapeInteger from TopTools;
|
||||||
|
myMapOfSpheres: IndexedMapOfTransient from TColStd;
|
||||||
|
--myMapOfGeom: MapOfShapeTransient from TColStd;
|
||||||
|
|
||||||
|
end SphereSpaceModifier;
|
||||||
|
|
262
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cxx
Normal file
262
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cxx
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix.cxx
|
||||||
|
// Created: Tue Dec 7 11:59:05 2004
|
||||||
|
// Author: Pavel DURANDIN
|
||||||
|
|
||||||
|
#include <BlockFix_SphereSpaceModifier.ixx>
|
||||||
|
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <Geom_SphericalSurface.hxx>
|
||||||
|
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||||
|
#include <ShapeAnalysis.hxx>
|
||||||
|
#include <gp_Sphere.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BlockFix_SphereSpaceModifier
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier()
|
||||||
|
{
|
||||||
|
myMapOfFaces.Clear();
|
||||||
|
myMapOfSpheres.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetTolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_SphereSpaceModifier::SetTolerance(const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
myTolerance = Tol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewSurface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
|
||||||
|
static Standard_Boolean ModifySurface(const TopoDS_Face& aFace,
|
||||||
|
const Handle(Geom_Surface)& aSurface,
|
||||||
|
Handle(Geom_Surface)& aNewSurface)
|
||||||
|
{
|
||||||
|
Handle(Geom_Surface) S = aSurface;
|
||||||
|
if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
|
||||||
|
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||||
|
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
|
||||||
|
S = RTS->BasisSurface();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
|
||||||
|
Standard_Real Umin, Umax, Vmin, Vmax;
|
||||||
|
ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax);
|
||||||
|
Standard_Real PI2 = M_PI/2.;
|
||||||
|
if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) {
|
||||||
|
Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S);
|
||||||
|
gp_Sphere sp = aSphere->Sphere();
|
||||||
|
gp_Ax3 ax3 = sp.Position();
|
||||||
|
if(Abs(Vmax-Vmin) < PI2) {
|
||||||
|
gp_Ax3 axnew3(ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(),ax3.XDirection());
|
||||||
|
sp.SetPosition(axnew3);
|
||||||
|
Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp);
|
||||||
|
aNewSurface = aNewSphere;
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gp_Pnt PC = ax3.Location();
|
||||||
|
Standard_Real Vpar;
|
||||||
|
if(fabs(PI2-Vmax)>fabs(-PI2-Vmin))
|
||||||
|
Vpar = (PI2+Vmax)/2.;
|
||||||
|
else
|
||||||
|
Vpar = (-PI2+Vmin)/2.;
|
||||||
|
Standard_Real Upar = (Umin+Umax)/2.;;
|
||||||
|
gp_Pnt PN,PX;
|
||||||
|
S->D0(Upar,Vpar,PN);
|
||||||
|
S->D0(Upar+PI2,0.,PX);
|
||||||
|
gp_Dir newNorm(gp_Vec(PC,PN));
|
||||||
|
gp_Dir newDirX(gp_Vec(PC,PX));
|
||||||
|
gp_Ax3 axnew3(ax3.Axis().Location(), newNorm, newDirX);
|
||||||
|
sp.SetPosition(axnew3);
|
||||||
|
Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp);
|
||||||
|
aNewSurface = aNewSphere;
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::NewSurface(const TopoDS_Face& F,
|
||||||
|
Handle(Geom_Surface)& S,
|
||||||
|
TopLoc_Location& L,Standard_Real& Tol,
|
||||||
|
Standard_Boolean& RevWires,
|
||||||
|
Standard_Boolean& RevFace)
|
||||||
|
{
|
||||||
|
TopLoc_Location LS;
|
||||||
|
Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS);
|
||||||
|
|
||||||
|
//check if pole of the sphere in the parametric space
|
||||||
|
if(ModifySurface(F, SIni, S)) {
|
||||||
|
|
||||||
|
RevWires = Standard_False;
|
||||||
|
RevFace = Standard_False;
|
||||||
|
|
||||||
|
L = LS;
|
||||||
|
Tol = BRep_Tool::Tolerance(F);
|
||||||
|
|
||||||
|
Standard_Integer anIndex = myMapOfSpheres.Add(S);
|
||||||
|
myMapOfFaces.Bind(F,anIndex);
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewCurve
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve(const TopoDS_Edge& /*E*/,Handle(Geom_Curve)& /*C*/,
|
||||||
|
TopLoc_Location& /*L*/,Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewPoint
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::NewPoint(const TopoDS_Vertex& /*V*/,
|
||||||
|
gp_Pnt& /*P*/,
|
||||||
|
Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewCurve2d
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,
|
||||||
|
const TopoDS_Edge& /*NewE*/,const TopoDS_Face& /*NewF*/,
|
||||||
|
Handle(Geom2d_Curve)& C,Standard_Real& Tol)
|
||||||
|
{
|
||||||
|
//check if undelying surface of the face was modified
|
||||||
|
if(myMapOfFaces.IsBound(F)) {
|
||||||
|
Standard_Integer anIndex = myMapOfFaces.Find(F);
|
||||||
|
|
||||||
|
Handle(Geom_Surface) aNewSphere = Handle(Geom_Surface)::DownCast(myMapOfSpheres.FindKey(anIndex));
|
||||||
|
|
||||||
|
Standard_Real f,l;
|
||||||
|
TopLoc_Location LC, LS;
|
||||||
|
Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l );
|
||||||
|
Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS);
|
||||||
|
|
||||||
|
//taking into accound the orientation of the seam
|
||||||
|
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||||
|
Tol = BRep_Tool::Tolerance(E);
|
||||||
|
|
||||||
|
BRep_Builder B;
|
||||||
|
TopoDS_Edge TempE;
|
||||||
|
B.MakeEdge(TempE);
|
||||||
|
B.Add(TempE, TopExp::FirstVertex(E));
|
||||||
|
B.Add(TempE, TopExp::LastVertex(E));
|
||||||
|
|
||||||
|
if(!C3d.IsNull())
|
||||||
|
B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion());
|
||||||
|
B.Range(TempE, f, l);
|
||||||
|
|
||||||
|
Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge;
|
||||||
|
Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSphere->Transformed(LS.Transformation()));
|
||||||
|
TopLoc_Location LTemp;
|
||||||
|
LTemp.Identity();
|
||||||
|
|
||||||
|
Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F);
|
||||||
|
Standard_Real aWorkTol = 2*myTolerance+Tol;
|
||||||
|
sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol));
|
||||||
|
sfe->FixSameParameter(TempE);
|
||||||
|
|
||||||
|
//keep the orientation of original edge
|
||||||
|
TempE.Orientation(E.Orientation());
|
||||||
|
C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l);
|
||||||
|
|
||||||
|
// shifting seam of sphere
|
||||||
|
if(isClosed && !C.IsNull()) {
|
||||||
|
Standard_Real f2,l2;
|
||||||
|
Handle(Geom2d_Curve) c22 =
|
||||||
|
BRep_Tool::CurveOnSurface(TopoDS::Edge(TempE.Reversed()),STemp, LTemp,f2,l2);
|
||||||
|
Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion();
|
||||||
|
if((C->Value(f).SquareDistance(c22->Value(f2)) < dPreci)
|
||||||
|
||(C->Value(l).SquareDistance(c22->Value(l2)) < dPreci)) {
|
||||||
|
gp_Vec2d shift(S->UPeriod(),0.);
|
||||||
|
C->Translate(shift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sphere was modified
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NewParameter
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,const TopoDS_Edge& /*E*/,
|
||||||
|
Standard_Real& /*P*/,Standard_Real& /*Tol*/)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Continuity
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
GeomAbs_Shape BlockFix_SphereSpaceModifier::Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,
|
||||||
|
const TopoDS_Face& F2,const TopoDS_Edge& /*NewE*/,
|
||||||
|
const TopoDS_Face& /*NewF1*/,const TopoDS_Face& /*NewF2*/)
|
||||||
|
{
|
||||||
|
return BRep_Tool::Continuity(E,F1,F2);
|
||||||
|
}
|
141
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.hxx
Normal file
141
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.hxx
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_SphereSpaceModifier_HeaderFile
|
||||||
|
#define _BlockFix_SphereSpaceModifier_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile
|
||||||
|
#include <Handle_BlockFix_SphereSpaceModifier.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
|
||||||
|
#include <TopTools_DataMapOfShapeInteger.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
|
||||||
|
#include <TColStd_IndexedMapOfTransient.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BRepTools_Modification_HeaderFile
|
||||||
|
#include <BRepTools_Modification.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Boolean_HeaderFile
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom_Surface_HeaderFile
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom_Curve_HeaderFile
|
||||||
|
#include <Handle_Geom_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_Geom2d_Curve_HeaderFile
|
||||||
|
#include <Handle_Geom2d_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _GeomAbs_Shape_HeaderFile
|
||||||
|
#include <GeomAbs_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
class TopoDS_Face;
|
||||||
|
class Geom_Surface;
|
||||||
|
class TopLoc_Location;
|
||||||
|
class TopoDS_Edge;
|
||||||
|
class Geom_Curve;
|
||||||
|
class TopoDS_Vertex;
|
||||||
|
class gp_Pnt;
|
||||||
|
class Geom2d_Curve;
|
||||||
|
|
||||||
|
|
||||||
|
class BlockFix_SphereSpaceModifier : public BRepTools_Modification {
|
||||||
|
|
||||||
|
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 BlockFix_SphereSpaceModifier();
|
||||||
|
Standard_EXPORT void SetTolerance(const Standard_Real Toler) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ;
|
||||||
|
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ;
|
||||||
|
Standard_EXPORT Standard_Boolean ForRotation(const TopoDS_Face& F) ;
|
||||||
|
Standard_EXPORT ~BlockFix_SphereSpaceModifier();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Type management
|
||||||
|
//
|
||||||
|
Standard_EXPORT friend Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_();
|
||||||
|
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
|
||||||
|
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Methods PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Methods PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
TopTools_DataMapOfShapeInteger myMapOfFaces;
|
||||||
|
TColStd_IndexedMapOfTransient myMapOfSpheres;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
79
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.ixx
Normal file
79
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.ixx
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_SphereSpaceModifier.jxx>
|
||||||
|
|
||||||
|
#ifndef _Standard_TypeMismatch_HeaderFile
|
||||||
|
#include <Standard_TypeMismatch.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Standard_EXPORT Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_()
|
||||||
|
{
|
||||||
|
|
||||||
|
static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification);
|
||||||
|
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification);
|
||||||
|
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
|
||||||
|
|
||||||
|
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
|
||||||
|
static Handle_Standard_Type _aType = new Standard_Type("BlockFix_SphereSpaceModifier",
|
||||||
|
sizeof(BlockFix_SphereSpaceModifier),
|
||||||
|
1,
|
||||||
|
(Standard_Address)_Ancestors,
|
||||||
|
(Standard_Address)NULL);
|
||||||
|
|
||||||
|
return _aType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DownCast method
|
||||||
|
// allow safe downcasting
|
||||||
|
//
|
||||||
|
const Handle(BlockFix_SphereSpaceModifier) Handle(BlockFix_SphereSpaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject)
|
||||||
|
{
|
||||||
|
Handle(BlockFix_SphereSpaceModifier) _anOtherObject;
|
||||||
|
|
||||||
|
if (!AnObject.IsNull()) {
|
||||||
|
if (AnObject->IsKind(STANDARD_TYPE(BlockFix_SphereSpaceModifier))) {
|
||||||
|
_anOtherObject = Handle(BlockFix_SphereSpaceModifier)((Handle(BlockFix_SphereSpaceModifier)&)AnObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _anOtherObject ;
|
||||||
|
}
|
||||||
|
const Handle(Standard_Type)& BlockFix_SphereSpaceModifier::DynamicType() const
|
||||||
|
{
|
||||||
|
return STANDARD_TYPE(BlockFix_SphereSpaceModifier) ;
|
||||||
|
}
|
||||||
|
Standard_Boolean BlockFix_SphereSpaceModifier::IsKind(const Handle(Standard_Type)& AType) const
|
||||||
|
{
|
||||||
|
return (STANDARD_TYPE(BlockFix_SphereSpaceModifier) == AType || BRepTools_Modification::IsKind(AType));
|
||||||
|
}
|
||||||
|
Handle_BlockFix_SphereSpaceModifier::~Handle_BlockFix_SphereSpaceModifier() {}
|
||||||
|
|
49
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.jxx
Normal file
49
src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.jxx
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <TopoDS_Face.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom_Surface_HeaderFile
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopLoc_Location_HeaderFile
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Edge_HeaderFile
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom_Curve_HeaderFile
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Vertex_HeaderFile
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _gp_Pnt_HeaderFile
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Geom2d_Curve_HeaderFile
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_SphereSpaceModifier_HeaderFile
|
||||||
|
#include <BlockFix_SphereSpaceModifier.hxx>
|
||||||
|
#endif
|
49
src/GEOMAlgo_NEW/BlockFix_UnionEdges.cdl
Normal file
49
src/GEOMAlgo_NEW/BlockFix_UnionEdges.cdl
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_UnionEdges.cdl
|
||||||
|
-- Created: Tue Dec 7 15:24:51 2004
|
||||||
|
-- Author: Sergey KUUL
|
||||||
|
--
|
||||||
|
class UnionEdges from BlockFix
|
||||||
|
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
uses
|
||||||
|
|
||||||
|
Shape from TopoDS,
|
||||||
|
ReShape from ShapeBuild
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
Create returns UnionEdges from BlockFix;
|
||||||
|
|
||||||
|
Perform(me: in out; Shape: Shape from TopoDS;
|
||||||
|
Tol : Real)
|
||||||
|
returns Shape from TopoDS;
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myTolerance : Real;
|
||||||
|
myContext : ReShape from ShapeBuild;
|
||||||
|
|
||||||
|
end UnionEdges;
|
398
src/GEOMAlgo_NEW/BlockFix_UnionEdges.cxx
Normal file
398
src/GEOMAlgo_NEW/BlockFix_UnionEdges.cxx
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix_UnionEdges.cxx
|
||||||
|
// Created: 07.12.04 15:27:30
|
||||||
|
// Author: Sergey KUUL
|
||||||
|
|
||||||
|
#include <BlockFix_UnionEdges.ixx>
|
||||||
|
|
||||||
|
#include <Approx_Curve3d.hxx>
|
||||||
|
#include <BRepAdaptor_HCompCurve.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <GC_MakeCircle.hxx>
|
||||||
|
#include <Geom_BSplineCurve.hxx>
|
||||||
|
#include <Geom_Circle.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Line.hxx>
|
||||||
|
#include <Geom_TrimmedCurve.hxx>
|
||||||
|
#include <ShapeAnalysis_Edge.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
#include <ShapeFix_Face.hxx>
|
||||||
|
#include <ShapeFix_Shell.hxx>
|
||||||
|
#include <TColgp_SequenceOfPnt.hxx>
|
||||||
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_SequenceOfShape.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BlockFix_UnionEdges()
|
||||||
|
//purpose : Constructor
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_UnionEdges::BlockFix_UnionEdges ( )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : MergeEdges
|
||||||
|
//purpose : auxilary
|
||||||
|
//=======================================================================
|
||||||
|
static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||||
|
const TopoDS_Face& aFace,
|
||||||
|
const Standard_Real Tol,
|
||||||
|
TopoDS_Edge& anEdge)
|
||||||
|
{
|
||||||
|
// make chain for union
|
||||||
|
BRep_Builder B;
|
||||||
|
ShapeAnalysis_Edge sae;
|
||||||
|
TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1));
|
||||||
|
TopoDS_Edge LastE = FirstE;
|
||||||
|
TopoDS_Vertex VF = sae.FirstVertex(FirstE);
|
||||||
|
TopoDS_Vertex VL = sae.LastVertex(LastE);
|
||||||
|
TopTools_SequenceOfShape aChain;
|
||||||
|
aChain.Append(FirstE);
|
||||||
|
TColStd_MapOfInteger IndUsedEdges;
|
||||||
|
IndUsedEdges.Add(1);
|
||||||
|
Standard_Integer j;
|
||||||
|
for(j=2; j<=SeqEdges.Length(); j++) {
|
||||||
|
for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) {
|
||||||
|
if(IndUsedEdges.Contains(k)) continue;
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k));
|
||||||
|
TopoDS_Vertex VF2 = sae.FirstVertex(edge);
|
||||||
|
TopoDS_Vertex VL2 = sae.LastVertex(edge);
|
||||||
|
if(sae.FirstVertex(edge).IsSame(VL)) {
|
||||||
|
aChain.Append(edge);
|
||||||
|
LastE = edge;
|
||||||
|
VL = sae.LastVertex(LastE);
|
||||||
|
IndUsedEdges.Add(k);
|
||||||
|
}
|
||||||
|
else if(sae.LastVertex(edge).IsSame(VF)) {
|
||||||
|
aChain.Prepend(edge);
|
||||||
|
FirstE = edge;
|
||||||
|
VF = sae.FirstVertex(FirstE);
|
||||||
|
IndUsedEdges.Add(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(aChain.Length()<SeqEdges.Length()) {
|
||||||
|
MESSAGE ("can not create correct chain...");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
// union edges in chain
|
||||||
|
// first step: union lines and circles
|
||||||
|
TopLoc_Location Loc;
|
||||||
|
Standard_Real fp1,lp1,fp2,lp2;
|
||||||
|
for(j=1; j<aChain.Length(); j++) {
|
||||||
|
TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j));
|
||||||
|
Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1);
|
||||||
|
if(c3d1.IsNull()) break;
|
||||||
|
while(c3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||||
|
Handle(Geom_TrimmedCurve) tc =
|
||||||
|
Handle(Geom_TrimmedCurve)::DownCast(c3d1);
|
||||||
|
c3d1 = tc->BasisCurve();
|
||||||
|
}
|
||||||
|
TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1));
|
||||||
|
Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2);
|
||||||
|
if(c3d2.IsNull()) break;
|
||||||
|
while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||||
|
Handle(Geom_TrimmedCurve) tc =
|
||||||
|
Handle(Geom_TrimmedCurve)::DownCast(c3d2);
|
||||||
|
c3d2 = tc->BasisCurve();
|
||||||
|
}
|
||||||
|
if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) {
|
||||||
|
// union lines
|
||||||
|
Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1);
|
||||||
|
Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2);
|
||||||
|
gp_Dir Dir1 = L1->Position().Direction();
|
||||||
|
gp_Dir Dir2 = L2->Position().Direction();
|
||||||
|
//if(!Dir1.IsEqual(Dir2,Precision::Angular())) {
|
||||||
|
//if(!Dir1.IsParallel(Dir2,Precision::Angular())) {
|
||||||
|
if(!Dir1.IsParallel(Dir2,Tol)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// can union lines => create new edge
|
||||||
|
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
|
||||||
|
gp_Pnt PV1 = BRep_Tool::Pnt(V1);
|
||||||
|
TopoDS_Vertex V2 = sae.LastVertex(edge2);
|
||||||
|
gp_Pnt PV2 = BRep_Tool::Pnt(V2);
|
||||||
|
gp_Vec Vec(PV1,PV2);
|
||||||
|
Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec));
|
||||||
|
Standard_Real dist = PV1.Distance(PV2);
|
||||||
|
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist);
|
||||||
|
TopoDS_Edge E;
|
||||||
|
B.MakeEdge (E,tc,Precision::Confusion());
|
||||||
|
B.Add (E,V1); B.Add (E,V2);
|
||||||
|
B.UpdateVertex(V1, 0., E, 0.);
|
||||||
|
B.UpdateVertex(V2, dist, E, 0.);
|
||||||
|
//ShapeFix_Edge sfe;
|
||||||
|
//sfe.FixAddPCurve(E,aFace,Standard_False);
|
||||||
|
//sfe.FixSameParameter(E);
|
||||||
|
aChain.Remove(j);
|
||||||
|
aChain.SetValue(j,E);
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) {
|
||||||
|
// union circles
|
||||||
|
Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1);
|
||||||
|
Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2);
|
||||||
|
gp_Pnt P01 = C1->Location();
|
||||||
|
gp_Pnt P02 = C2->Location();
|
||||||
|
if (P01.Distance(P02) > Precision::Confusion()) continue;
|
||||||
|
// can union circles => create new edge
|
||||||
|
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
|
||||||
|
gp_Pnt PV1 = BRep_Tool::Pnt(V1);
|
||||||
|
TopoDS_Vertex V2 = sae.LastVertex(edge2);
|
||||||
|
gp_Pnt PV2 = BRep_Tool::Pnt(V2);
|
||||||
|
TopoDS_Vertex VM = sae.LastVertex(edge1);
|
||||||
|
gp_Pnt PVM = BRep_Tool::Pnt(VM);
|
||||||
|
GC_MakeCircle MC (PV1,PVM,PV2);
|
||||||
|
Handle(Geom_Circle) C = MC.Value();
|
||||||
|
TopoDS_Edge E;
|
||||||
|
if (!MC.IsDone() || C.IsNull()) {
|
||||||
|
// jfa for Mantis issue 0020228
|
||||||
|
if (PV1.Distance(PV2) > Precision::Confusion()) continue;
|
||||||
|
// closed chain
|
||||||
|
C = C1;
|
||||||
|
B.MakeEdge (E,C,Precision::Confusion());
|
||||||
|
B.Add(E,V1);
|
||||||
|
B.Add(E,V2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gp_Pnt P0 = C->Location();
|
||||||
|
gp_Dir D1(gp_Vec(P0,PV1));
|
||||||
|
gp_Dir D2(gp_Vec(P0,PV2));
|
||||||
|
Standard_Real fpar = C->XAxis().Direction().Angle(D1);
|
||||||
|
if(fabs(fpar)>Precision::Confusion()) {
|
||||||
|
// check orientation
|
||||||
|
gp_Dir ND = C->XAxis().Direction().Crossed(D1);
|
||||||
|
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
|
||||||
|
fpar = -fpar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Standard_Real lpar = C->XAxis().Direction().Angle(D2);
|
||||||
|
if(fabs(lpar)>Precision::Confusion()) {
|
||||||
|
// check orientation
|
||||||
|
gp_Dir ND = C->XAxis().Direction().Crossed(D2);
|
||||||
|
if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) {
|
||||||
|
lpar = -lpar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lpar < fpar) lpar += 2*M_PI;
|
||||||
|
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
|
||||||
|
B.MakeEdge (E,tc,Precision::Confusion());
|
||||||
|
B.Add(E,V1);
|
||||||
|
B.Add(E,V2);
|
||||||
|
B.UpdateVertex(V1, fpar, E, 0.);
|
||||||
|
B.UpdateVertex(V2, lpar, E, 0.);
|
||||||
|
}
|
||||||
|
aChain.Remove(j);
|
||||||
|
aChain.SetValue(j,E);
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j < aChain.Length()) {
|
||||||
|
MESSAGE ("null curve3d in edge...");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
if (aChain.Length() > 1) {
|
||||||
|
// second step: union edges with various curves
|
||||||
|
// skl for bug 0020052 from Mantis: perform such unions
|
||||||
|
// only if curves are bspline or bezier
|
||||||
|
bool NeedUnion = true;
|
||||||
|
for(j=1; j<=aChain.Length(); j++) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j));
|
||||||
|
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1);
|
||||||
|
if(c3d.IsNull()) continue;
|
||||||
|
while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||||
|
Handle(Geom_TrimmedCurve) tc =
|
||||||
|
Handle(Geom_TrimmedCurve)::DownCast(c3d);
|
||||||
|
c3d = tc->BasisCurve();
|
||||||
|
}
|
||||||
|
if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) ||
|
||||||
|
c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue;
|
||||||
|
NeedUnion = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(NeedUnion) {
|
||||||
|
MESSAGE ("can not make analitical union => make approximation");
|
||||||
|
TopoDS_Wire W;
|
||||||
|
B.MakeWire(W);
|
||||||
|
for(j=1; j<=aChain.Length(); j++) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j));
|
||||||
|
B.Add(W,edge);
|
||||||
|
}
|
||||||
|
Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W);
|
||||||
|
Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000);
|
||||||
|
Handle(Geom_BSplineCurve) bc = Conv.Curve();
|
||||||
|
TopoDS_Edge E;
|
||||||
|
B.MakeEdge (E,bc,Precision::Confusion());
|
||||||
|
B.Add (E,VF);
|
||||||
|
B.Add (E,VL);
|
||||||
|
aChain.SetValue(1,E);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MESSAGE ("can not make approximation for such types of curves");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
anEdge = TopoDS::Edge(aChain.Value(1));
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape,
|
||||||
|
const Standard_Real Tol)
|
||||||
|
{
|
||||||
|
myContext = new ShapeBuild_ReShape;
|
||||||
|
myTolerance = Tol;
|
||||||
|
TopoDS_Shape aResult = myContext->Apply(Shape);
|
||||||
|
|
||||||
|
// processing each solid
|
||||||
|
TopAbs_ShapeEnum aType = TopAbs_SOLID;
|
||||||
|
TopExp_Explorer exps (Shape, aType);
|
||||||
|
if (!exps.More()) {
|
||||||
|
aType = TopAbs_SHELL;
|
||||||
|
exps.Init(Shape, aType);
|
||||||
|
}
|
||||||
|
for (; exps.More(); exps.Next()) {
|
||||||
|
//TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
|
||||||
|
TopoDS_Shape aSolid = exps.Current();
|
||||||
|
|
||||||
|
TopTools_IndexedMapOfShape ChangedFaces;
|
||||||
|
|
||||||
|
// creating map of edge faces
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||||
|
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||||
|
|
||||||
|
Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
|
||||||
|
TopoDS_Shape aRes = aSolid;
|
||||||
|
aRes = aContext->Apply(aSolid);
|
||||||
|
|
||||||
|
// processing each face
|
||||||
|
TopExp_Explorer exp;
|
||||||
|
for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Face aFace =
|
||||||
|
TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD)));
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
|
||||||
|
|
||||||
|
for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
|
||||||
|
if (!aMapEdgeFaces.Contains(edge)) continue;
|
||||||
|
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
||||||
|
TopTools_ListIteratorOfListOfShape anIter(aList);
|
||||||
|
for ( ; anIter.More(); anIter.Next()) {
|
||||||
|
TopoDS_Face face = TopoDS::Face(anIter.Value());
|
||||||
|
TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value()));
|
||||||
|
if (face1.IsSame(aFace)) continue;
|
||||||
|
if (aMapFacesEdges.Contains(face)) {
|
||||||
|
aMapFacesEdges.ChangeFromKey(face).Append(edge);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape ListEdges;
|
||||||
|
ListEdges.Append(edge);
|
||||||
|
aMapFacesEdges.Add(face,ListEdges);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) {
|
||||||
|
const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
|
||||||
|
TopTools_SequenceOfShape SeqEdges;
|
||||||
|
TopTools_ListIteratorOfListOfShape anIter(ListEdges);
|
||||||
|
for ( ; anIter.More(); anIter.Next()) {
|
||||||
|
SeqEdges.Append(anIter.Value());
|
||||||
|
}
|
||||||
|
if (SeqEdges.Length()==1) continue;
|
||||||
|
TopoDS_Edge E;
|
||||||
|
if ( MergeEdges(SeqEdges,aFace,Tol,E) ) {
|
||||||
|
// now we have only one edge - aChain.Value(1)
|
||||||
|
// we have to replace old ListEdges with this new edge
|
||||||
|
aContext->Replace(SeqEdges(1),E);
|
||||||
|
for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) {
|
||||||
|
aContext->Remove(SeqEdges(j));
|
||||||
|
}
|
||||||
|
TopoDS_Face tmpF = TopoDS::Face(exp.Current());
|
||||||
|
if ( !ChangedFaces.Contains(tmpF) )
|
||||||
|
ChangedFaces.Add(tmpF);
|
||||||
|
tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i));
|
||||||
|
if ( !ChangedFaces.Contains(tmpF) )
|
||||||
|
ChangedFaces.Add(tmpF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end processing each face
|
||||||
|
|
||||||
|
// fix changed faces and replace them in the local context
|
||||||
|
for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) {
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i)));
|
||||||
|
Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace);
|
||||||
|
sff->SetContext(myContext);
|
||||||
|
sff->SetPrecision(myTolerance);
|
||||||
|
sff->SetMinTolerance(myTolerance);
|
||||||
|
sff->SetMaxTolerance(Max(1.,myTolerance*1000.));
|
||||||
|
sff->Perform();
|
||||||
|
aContext->Replace(aFace,sff->Face());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedFaces.Extent() > 0) {
|
||||||
|
// fix changed shell and replace it in the local context
|
||||||
|
TopoDS_Shape aRes1 = aContext->Apply(aRes);
|
||||||
|
TopExp_Explorer expsh;
|
||||||
|
for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) {
|
||||||
|
TopoDS_Shell aShell = TopoDS::Shell(expsh.Current());
|
||||||
|
Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell;
|
||||||
|
sfsh->FixFaceOrientation(aShell);
|
||||||
|
aContext->Replace(aShell,sfsh->Shell());
|
||||||
|
}
|
||||||
|
TopoDS_Shape aRes2 = aContext->Apply(aRes1);
|
||||||
|
// put new solid into global context
|
||||||
|
myContext->Replace(aSolid,aRes2);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end processing each solid
|
||||||
|
|
||||||
|
aResult = myContext->Apply(Shape);
|
||||||
|
return aResult;
|
||||||
|
}
|
100
src/GEOMAlgo_NEW/BlockFix_UnionEdges.hxx
Normal file
100
src/GEOMAlgo_NEW/BlockFix_UnionEdges.hxx
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_UnionEdges_HeaderFile
|
||||||
|
#define _BlockFix_UnionEdges_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
|
||||||
|
#include <Handle_ShapeBuild_ReShape.hxx>
|
||||||
|
#endif
|
||||||
|
class ShapeBuild_ReShape;
|
||||||
|
class TopoDS_Shape;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Macro_HeaderFile
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class BlockFix_UnionEdges {
|
||||||
|
|
||||||
|
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 BlockFix_UnionEdges();
|
||||||
|
Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape,const Standard_Real Tol) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Methods PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PROTECTED
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Methods PRIVATE
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
Handle_ShapeBuild_ReShape myContext;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
27
src/GEOMAlgo_NEW/BlockFix_UnionEdges.ixx
Normal file
27
src/GEOMAlgo_NEW/BlockFix_UnionEdges.ixx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_UnionEdges.jxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
31
src/GEOMAlgo_NEW/BlockFix_UnionEdges.jxx
Normal file
31
src/GEOMAlgo_NEW/BlockFix_UnionEdges.jxx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _ShapeBuild_ReShape_HeaderFile
|
||||||
|
#include <ShapeBuild_ReShape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Shape_HeaderFile
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_UnionEdges_HeaderFile
|
||||||
|
#include <BlockFix_UnionEdges.hxx>
|
||||||
|
#endif
|
65
src/GEOMAlgo_NEW/BlockFix_UnionFaces.cdl
Normal file
65
src/GEOMAlgo_NEW/BlockFix_UnionFaces.cdl
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: BlockFix_UnionFaces.cdl
|
||||||
|
-- Created: Tue Dec 7 17:15:42 2004
|
||||||
|
-- Author: Pavel Durandin
|
||||||
|
--
|
||||||
|
class UnionFaces from BlockFix
|
||||||
|
|
||||||
|
uses
|
||||||
|
|
||||||
|
Face from TopoDS,
|
||||||
|
Shape from TopoDS
|
||||||
|
|
||||||
|
is
|
||||||
|
|
||||||
|
Create returns UnionFaces from BlockFix;
|
||||||
|
---Purpose: Empty constructor
|
||||||
|
|
||||||
|
GetTolerance(me: in out) returns Real;
|
||||||
|
---Purpose: Returns modifiable tolerance
|
||||||
|
---C++: return&
|
||||||
|
|
||||||
|
Perform (me: in out; Shape: Shape from TopoDS) returns Shape from TopoDS;
|
||||||
|
---Purpose: Performs the unification of the fsces
|
||||||
|
-- whith the same geometry
|
||||||
|
|
||||||
|
IsSameDomain(me; aFace : Face from TopoDS;
|
||||||
|
aChekedFace: Face from TopoDS)
|
||||||
|
returns Boolean is virtual;
|
||||||
|
---Purpose: Returns true is surfaces have same geometrically domain
|
||||||
|
-- with given tolerance
|
||||||
|
|
||||||
|
MovePCurves(me; aTarget: in out Face from TopoDS;
|
||||||
|
aSource: Face from TopoDS)
|
||||||
|
is virtual;
|
||||||
|
---Purpose: Creates pcurves on aTarget face for each edge from
|
||||||
|
-- aSource one.
|
||||||
|
|
||||||
|
fields
|
||||||
|
|
||||||
|
myTolerance: Real;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
721
src/GEOMAlgo_NEW/BlockFix_UnionFaces.cxx
Normal file
721
src/GEOMAlgo_NEW/BlockFix_UnionFaces.cxx
Normal file
@ -0,0 +1,721 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: BlockFix_UnionFaces.cxx
|
||||||
|
// Created: Tue Dec 7 17:15:42 2004
|
||||||
|
// Author: Pavel DURANDIN
|
||||||
|
|
||||||
|
#include <BlockFix_UnionFaces.ixx>
|
||||||
|
|
||||||
|
#include <Basics_OCCTVersion.hxx>
|
||||||
|
|
||||||
|
#include <ShapeAnalysis_WireOrder.hxx>
|
||||||
|
#include <ShapeAnalysis_Edge.hxx>
|
||||||
|
|
||||||
|
#include <ShapeBuild_Edge.hxx>
|
||||||
|
#include <ShapeBuild_ReShape.hxx>
|
||||||
|
|
||||||
|
#include <ShapeExtend_WireData.hxx>
|
||||||
|
#include <ShapeExtend_CompositeSurface.hxx>
|
||||||
|
|
||||||
|
#include <ShapeFix_Face.hxx>
|
||||||
|
#include <ShapeFix_ComposeShell.hxx>
|
||||||
|
#include <ShapeFix_SequenceOfWireSegment.hxx>
|
||||||
|
#include <ShapeFix_WireSegment.hxx>
|
||||||
|
#include <ShapeFix_Wire.hxx>
|
||||||
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
|
||||||
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
||||||
|
#include <IntPatch_ImpImpIntersection.hxx>
|
||||||
|
#else
|
||||||
|
#include <IntPatch_TheIIIntOfIntersection.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRepTopAdaptor_TopolTool.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_SequenceOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include <TColGeom_HArray2OfSurface.hxx>
|
||||||
|
|
||||||
|
#include <GeomAdaptor_HSurface.hxx>
|
||||||
|
#include <GeomLib_IsPlanarSurface.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
#include <Geom_OffsetSurface.hxx>
|
||||||
|
#include <Geom_SphericalSurface.hxx>
|
||||||
|
#include <Geom_CylindricalSurface.hxx>
|
||||||
|
#include <Geom_SurfaceOfRevolution.hxx>
|
||||||
|
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||||
|
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Line.hxx>
|
||||||
|
#include <Geom_Circle.hxx>
|
||||||
|
|
||||||
|
#include <Geom2d_Line.hxx>
|
||||||
|
|
||||||
|
#include <gp_XY.hxx>
|
||||||
|
#include <gp_Pnt2d.hxx>
|
||||||
|
|
||||||
|
#include <Standard_Failure.hxx>
|
||||||
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BlockFix_UnionFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
BlockFix_UnionFaces::BlockFix_UnionFaces()
|
||||||
|
: myTolerance(Precision::Confusion()),
|
||||||
|
myOptimumNbFaces(6)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetTolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Real& BlockFix_UnionFaces::GetTolerance()
|
||||||
|
{
|
||||||
|
return myTolerance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetOptimumNbFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces()
|
||||||
|
{
|
||||||
|
return myOptimumNbFaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddOrdinaryEdges
|
||||||
|
//purpose : auxilary
|
||||||
|
//=======================================================================
|
||||||
|
// adds edges from the shape to the sequence
|
||||||
|
// seams and equal edges are dropped
|
||||||
|
// Returns true if one of original edges dropped
|
||||||
|
static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
|
||||||
|
const TopoDS_Shape aShape,
|
||||||
|
Standard_Integer& anIndex)
|
||||||
|
{
|
||||||
|
//map of edges
|
||||||
|
TopTools_MapOfShape aNewEdges;
|
||||||
|
//add edges without seams
|
||||||
|
for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Shape edge = exp.Current();
|
||||||
|
if(aNewEdges.Contains(edge))
|
||||||
|
aNewEdges.Remove(edge);
|
||||||
|
else
|
||||||
|
aNewEdges.Add(edge);
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Boolean isDropped = Standard_False;
|
||||||
|
//merge edges and drop seams
|
||||||
|
for(Standard_Integer i = 1; i <= edges.Length(); i++) {
|
||||||
|
TopoDS_Shape current = edges(i);
|
||||||
|
if(aNewEdges.Contains(current)) {
|
||||||
|
|
||||||
|
aNewEdges.Remove(current);
|
||||||
|
edges.Remove(i);
|
||||||
|
i--;
|
||||||
|
|
||||||
|
if(!isDropped) {
|
||||||
|
isDropped = Standard_True;
|
||||||
|
anIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//add edges to the sequemce
|
||||||
|
for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next())
|
||||||
|
edges.Append(anIter.Key());
|
||||||
|
|
||||||
|
return isDropped;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ClearRts
|
||||||
|
//purpose : auxilary
|
||||||
|
//=======================================================================
|
||||||
|
static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
|
||||||
|
{
|
||||||
|
if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
|
||||||
|
Handle(Geom_RectangularTrimmedSurface) rts =
|
||||||
|
Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
|
||||||
|
return rts->BasisSurface();
|
||||||
|
}
|
||||||
|
return aSurface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
||||||
|
{
|
||||||
|
Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape;
|
||||||
|
TopoDS_Shape aResShape = myContext->Apply(Shape);
|
||||||
|
|
||||||
|
// processing each solid
|
||||||
|
TopExp_Explorer exps;
|
||||||
|
for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
|
||||||
|
TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
|
||||||
|
|
||||||
|
// creating map of edge faces
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||||
|
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||||
|
|
||||||
|
// map of processed shapes
|
||||||
|
TopTools_MapOfShape aProcessed;
|
||||||
|
|
||||||
|
Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
|
||||||
|
|
||||||
|
Standard_Integer NbModif = 0;
|
||||||
|
Standard_Boolean hasFailed = Standard_False;
|
||||||
|
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
|
||||||
|
|
||||||
|
// count faces
|
||||||
|
int nbf = 0;
|
||||||
|
TopExp_Explorer exp;
|
||||||
|
TopTools_MapOfShape mapF;
|
||||||
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
|
if (mapF.Add(exp.Current()))
|
||||||
|
nbf++;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool doUnion = ((myOptimumNbFaces == 0) ||
|
||||||
|
((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces)));
|
||||||
|
|
||||||
|
// processing each face
|
||||||
|
mapF.Clear();
|
||||||
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
|
||||||
|
if (aProcessed.Contains(aFace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Standard_Integer dummy;
|
||||||
|
TopTools_SequenceOfShape edges;
|
||||||
|
AddOrdinaryEdges(edges,aFace,dummy);
|
||||||
|
|
||||||
|
TopTools_SequenceOfShape faces;
|
||||||
|
faces.Append(aFace);
|
||||||
|
|
||||||
|
//surface and location to construct result
|
||||||
|
TopLoc_Location aBaseLocation;
|
||||||
|
Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
|
||||||
|
aBaseSurface = ClearRts(aBaseSurface);
|
||||||
|
|
||||||
|
// find adjacent faces to union
|
||||||
|
Standard_Integer i;
|
||||||
|
for (i = 1; i <= edges.Length(); i++) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(edges(i));
|
||||||
|
if (BRep_Tool::Degenerated(edge))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
||||||
|
TopTools_ListIteratorOfListOfShape anIter(aList);
|
||||||
|
for (; anIter.More(); anIter.Next()) {
|
||||||
|
TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD));
|
||||||
|
if (anCheckedFace.IsSame(aFace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (aProcessed.Contains(anCheckedFace))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (IsSameDomain(aFace,anCheckedFace)) {
|
||||||
|
|
||||||
|
if (aList.Extent() != 2) {
|
||||||
|
// non mainfold case is not processed
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// replacing pcurves
|
||||||
|
TopoDS_Face aMockUpFace;
|
||||||
|
BRep_Builder B;
|
||||||
|
B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
|
||||||
|
MovePCurves(aMockUpFace,anCheckedFace);
|
||||||
|
|
||||||
|
if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
|
||||||
|
// sequence edges is modified
|
||||||
|
i = dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
faces.Append(anCheckedFace);
|
||||||
|
aProcessed.Add(anCheckedFace);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// all faces collected in the sequence. Perform union of faces
|
||||||
|
if (faces.Length() > 1) {
|
||||||
|
NbModif++;
|
||||||
|
TopoDS_Face aResult;
|
||||||
|
BRep_Builder B;
|
||||||
|
B.MakeFace(aResult,aBaseSurface,aBaseLocation,0);
|
||||||
|
Standard_Integer nbWires = 0;
|
||||||
|
|
||||||
|
// connecting wires
|
||||||
|
while (edges.Length()>0) {
|
||||||
|
|
||||||
|
Standard_Boolean isEdge3d = Standard_False;
|
||||||
|
nbWires++;
|
||||||
|
TopTools_MapOfShape aVertices;
|
||||||
|
TopoDS_Wire aWire;
|
||||||
|
B.MakeWire(aWire);
|
||||||
|
|
||||||
|
TopoDS_Edge anEdge = TopoDS::Edge(edges(1));
|
||||||
|
edges.Remove(1);
|
||||||
|
|
||||||
|
isEdge3d |= !BRep_Tool::Degenerated(anEdge);
|
||||||
|
B.Add(aWire,anEdge);
|
||||||
|
TopoDS_Vertex V1,V2;
|
||||||
|
TopExp::Vertices(anEdge,V1,V2);
|
||||||
|
aVertices.Add(V1);
|
||||||
|
aVertices.Add(V2);
|
||||||
|
|
||||||
|
Standard_Boolean isNewFound = Standard_False;
|
||||||
|
do {
|
||||||
|
isNewFound = Standard_False;
|
||||||
|
for(Standard_Integer j = 1; j <= edges.Length(); j++) {
|
||||||
|
anEdge = TopoDS::Edge(edges(j));
|
||||||
|
TopExp::Vertices(anEdge,V1,V2);
|
||||||
|
if(aVertices.Contains(V1) || aVertices.Contains(V2)) {
|
||||||
|
isEdge3d |= !BRep_Tool::Degenerated(anEdge);
|
||||||
|
aVertices.Add(V1);
|
||||||
|
aVertices.Add(V2);
|
||||||
|
B.Add(aWire,anEdge);
|
||||||
|
edges.Remove(j);
|
||||||
|
j--;
|
||||||
|
isNewFound = Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (isNewFound);
|
||||||
|
|
||||||
|
// sorting any type of edges
|
||||||
|
aWire = TopoDS::Wire(aContext->Apply(aWire));
|
||||||
|
|
||||||
|
TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
|
||||||
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
|
||||||
|
sfw->FixReorder();
|
||||||
|
Standard_Boolean isDegRemoved = Standard_False;
|
||||||
|
if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
|
||||||
|
// clear degenerated edges if at least one with 3d curve exist
|
||||||
|
if(isEdge3d) {
|
||||||
|
Handle(ShapeExtend_WireData) sewd = sfw->WireData();
|
||||||
|
for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) {
|
||||||
|
TopoDS_Edge E = sewd->Edge(j);
|
||||||
|
if(BRep_Tool::Degenerated(E)) {
|
||||||
|
sewd->Remove(j);
|
||||||
|
isDegRemoved = Standard_True;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sfw->FixShifted();
|
||||||
|
if(isDegRemoved)
|
||||||
|
sfw->FixDegenerated();
|
||||||
|
}
|
||||||
|
TopoDS_Wire aWireFixed = sfw->Wire();
|
||||||
|
aContext->Replace(aWire,aWireFixed);
|
||||||
|
// add resulting wire
|
||||||
|
if(isEdge3d) {
|
||||||
|
B.Add(aResult,aWireFixed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// sorting edges
|
||||||
|
Handle(ShapeExtend_WireData) sbwd = sfw->WireData();
|
||||||
|
Standard_Integer nbEdges = sbwd->NbEdges();
|
||||||
|
// sort degenerated edges and create one edge instead of several ones
|
||||||
|
ShapeAnalysis_WireOrder sawo(Standard_False, 0);
|
||||||
|
ShapeAnalysis_Edge sae;
|
||||||
|
Standard_Integer aLastEdge = nbEdges;
|
||||||
|
for(Standard_Integer j = 1; j <= nbEdges; j++) {
|
||||||
|
Standard_Real f,l;
|
||||||
|
//smh protection on NULL pcurve
|
||||||
|
Handle(Geom2d_Curve) c2d;
|
||||||
|
if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) {
|
||||||
|
aLastEdge--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
|
||||||
|
}
|
||||||
|
sawo.Perform();
|
||||||
|
|
||||||
|
// constructind one degenerative edge
|
||||||
|
gp_XY aStart, anEnd, tmp;
|
||||||
|
Standard_Integer nbFirst = sawo.Ordered(1);
|
||||||
|
TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD));
|
||||||
|
ShapeBuild_Edge sbe;
|
||||||
|
TopoDS_Vertex aDummyV;
|
||||||
|
TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV);
|
||||||
|
sawo.XY(nbFirst,aStart,tmp);
|
||||||
|
sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd);
|
||||||
|
|
||||||
|
gp_XY aVec = anEnd-aStart;
|
||||||
|
Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
|
||||||
|
|
||||||
|
B.UpdateEdge(E,aLine,tmpF,0.);
|
||||||
|
B.Range(E,tmpF,0.,aVec.Modulus());
|
||||||
|
Handle(Geom_Curve) C3d;
|
||||||
|
B.UpdateEdge(E,C3d,0.);
|
||||||
|
B.Degenerated(E,Standard_True);
|
||||||
|
TopoDS_Wire aW;
|
||||||
|
B.MakeWire(aW);
|
||||||
|
B.Add(aW,E);
|
||||||
|
B.Add(aResult,aW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// perform substitution of face
|
||||||
|
aContext->Replace(aContext->Apply(aFace),aResult);
|
||||||
|
|
||||||
|
ShapeFix_Face sff (aResult);
|
||||||
|
//Intializing by tolerances
|
||||||
|
sff.SetPrecision(myTolerance);
|
||||||
|
sff.SetMinTolerance(tol);
|
||||||
|
sff.SetMaxTolerance(Max(1.,myTolerance*1000.));
|
||||||
|
//Setting modes
|
||||||
|
sff.FixOrientationMode() = 0;
|
||||||
|
//sff.FixWireMode() = 0;
|
||||||
|
sff.SetContext(aContext);
|
||||||
|
// Applying the fixes
|
||||||
|
sff.Perform();
|
||||||
|
if(sff.Status(ShapeExtend_FAIL))
|
||||||
|
hasFailed = Standard_True;
|
||||||
|
|
||||||
|
// breaking down to several faces
|
||||||
|
TopoDS_Shape theResult = aContext->Apply(aResult);
|
||||||
|
for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) {
|
||||||
|
TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 );
|
||||||
|
grid->SetValue ( 1, 1, aBaseSurface );
|
||||||
|
Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
|
||||||
|
ShapeFix_ComposeShell CompShell;
|
||||||
|
CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
|
||||||
|
CompShell.SetContext( aContext );
|
||||||
|
|
||||||
|
TopTools_SequenceOfShape parts;
|
||||||
|
ShapeFix_SequenceOfWireSegment wires;
|
||||||
|
for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) {
|
||||||
|
Handle(ShapeExtend_WireData) sbwd =
|
||||||
|
new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() ));
|
||||||
|
ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
|
||||||
|
wires.Append(seg);
|
||||||
|
}
|
||||||
|
|
||||||
|
CompShell.DispatchWires ( parts,wires );
|
||||||
|
for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
|
||||||
|
ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
|
||||||
|
aFixOrient.SetContext(aContext);
|
||||||
|
aFixOrient.FixOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape CompRes;
|
||||||
|
if ( faces.Length() !=1 ) {
|
||||||
|
TopoDS_Shell S;
|
||||||
|
B.MakeShell ( S );
|
||||||
|
for ( i=1; i <= parts.Length(); i++ )
|
||||||
|
B.Add ( S, parts(i) );
|
||||||
|
CompRes = S;
|
||||||
|
}
|
||||||
|
else CompRes = parts(1);
|
||||||
|
|
||||||
|
aContext->Replace(aCurrent,CompRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove the remaining faces
|
||||||
|
for(i = 2; i <= faces.Length(); i++)
|
||||||
|
aContext->Remove(faces(i));
|
||||||
|
}
|
||||||
|
} // end processing each face
|
||||||
|
|
||||||
|
//TopoDS_Shape aResult = Shape;
|
||||||
|
if (NbModif > 0 && !hasFailed) {
|
||||||
|
TopoDS_Shape aResult = aContext->Apply(aSolid);
|
||||||
|
|
||||||
|
ShapeFix_Edge sfe;
|
||||||
|
for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Edge E = TopoDS::Edge(exp.Current());
|
||||||
|
sfe.FixVertexTolerance (E);
|
||||||
|
// ptv add fix same parameter
|
||||||
|
sfe.FixSameParameter(E, myTolerance);
|
||||||
|
}
|
||||||
|
|
||||||
|
myContext->Replace(aSolid, aResult);
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
{
|
||||||
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
||||||
|
sfw->SetContext(myContext);
|
||||||
|
sfw->SetPrecision(myTolerance);
|
||||||
|
sfw->SetMinTolerance(myTolerance);
|
||||||
|
sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
|
||||||
|
sfw->SetFace(aFace);
|
||||||
|
for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
|
||||||
|
TopoDS_Wire wire = TopoDS::Wire(iter.Value());
|
||||||
|
sfw->Load(wire);
|
||||||
|
sfw->FixReorder();
|
||||||
|
sfw->FixShifted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end processing each solid
|
||||||
|
|
||||||
|
aResShape = myContext->Apply(Shape);
|
||||||
|
return aResShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsSameDomain
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder)
|
||||||
|
{
|
||||||
|
bool isCylinder = false;
|
||||||
|
|
||||||
|
if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
|
||||||
|
Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface);
|
||||||
|
|
||||||
|
theOutCylinder = aGC->Cylinder();
|
||||||
|
isCylinder = true;
|
||||||
|
}
|
||||||
|
else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
|
||||||
|
Handle(Geom_SurfaceOfRevolution) aRS =
|
||||||
|
Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface);
|
||||||
|
Handle(Geom_Curve) aBasis = aRS->BasisCurve();
|
||||||
|
if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||||
|
Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis);
|
||||||
|
gp_Dir aDir = aRS->Direction();
|
||||||
|
gp_Dir aBasisDir = aBasisLine->Position().Direction();
|
||||||
|
if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
|
||||||
|
// basis line is parallel to the revolution axis: it is a cylinder
|
||||||
|
gp_Pnt aLoc = aRS->Location();
|
||||||
|
Standard_Real aR = aBasisLine->Lin().Distance(aLoc);
|
||||||
|
gp_Ax3 aCylAx (aLoc, aDir);
|
||||||
|
|
||||||
|
theOutCylinder = gp_Cylinder(aCylAx, aR);
|
||||||
|
isCylinder = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
|
||||||
|
Handle(Geom_SurfaceOfLinearExtrusion) aLES =
|
||||||
|
Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface);
|
||||||
|
Handle(Geom_Curve) aBasis = aLES->BasisCurve();
|
||||||
|
if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) {
|
||||||
|
Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis);
|
||||||
|
gp_Dir aDir = aLES->Direction();
|
||||||
|
gp_Dir aBasisDir = aBasisCircle->Position().Direction();
|
||||||
|
if (aBasisDir.IsParallel(aDir, Precision::Confusion())) {
|
||||||
|
// basis circle is normal to the extrusion axis: it is a cylinder
|
||||||
|
gp_Pnt aLoc = aBasisCircle->Location();
|
||||||
|
Standard_Real aR = aBasisCircle->Radius();
|
||||||
|
gp_Ax3 aCylAx (aLoc, aDir);
|
||||||
|
|
||||||
|
theOutCylinder = gp_Cylinder(aCylAx, aR);
|
||||||
|
isCylinder = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
|
||||||
|
return isCylinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
|
||||||
|
const TopoDS_Face& aCheckedFace) const
|
||||||
|
{
|
||||||
|
//checking the same handles
|
||||||
|
TopLoc_Location L1, L2;
|
||||||
|
Handle(Geom_Surface) S1, S2;
|
||||||
|
|
||||||
|
S1 = BRep_Tool::Surface(aFace,L1);
|
||||||
|
S2 = BRep_Tool::Surface(aCheckedFace,L2);
|
||||||
|
|
||||||
|
if (S1 == S2 && L1 == L2)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// planar and cylindrical cases (IMP 20052)
|
||||||
|
Standard_Real aPrec = Precision::Confusion();
|
||||||
|
|
||||||
|
S1 = BRep_Tool::Surface(aFace);
|
||||||
|
S2 = BRep_Tool::Surface(aCheckedFace);
|
||||||
|
|
||||||
|
S1 = ClearRts(S1);
|
||||||
|
S2 = ClearRts(S2);
|
||||||
|
|
||||||
|
//Handle(Geom_OffsetSurface) aGOFS1, aGOFS2;
|
||||||
|
//aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1);
|
||||||
|
//aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2);
|
||||||
|
//if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface();
|
||||||
|
//if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface();
|
||||||
|
|
||||||
|
// case of two elementary surfaces: use OCCT tool
|
||||||
|
// elementary surfaces: ConicalSurface, CylindricalSurface,
|
||||||
|
// Plane, SphericalSurface and ToroidalSurface
|
||||||
|
if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) &&
|
||||||
|
S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface)))
|
||||||
|
{
|
||||||
|
Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1);
|
||||||
|
Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2);
|
||||||
|
|
||||||
|
Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool();
|
||||||
|
Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool();
|
||||||
|
|
||||||
|
try {
|
||||||
|
#if OCC_VERSION_LARGE > 0x06010000
|
||||||
|
OCC_CATCH_SIGNALS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
|
||||||
|
IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
|
||||||
|
#else
|
||||||
|
IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec);
|
||||||
|
#endif
|
||||||
|
if (!anIIInt.IsDone() || anIIInt.IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return anIIInt.TangentFaces();
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// case of two planar surfaces:
|
||||||
|
// all kinds of surfaces checked, including b-spline and bezier
|
||||||
|
GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec);
|
||||||
|
if (aPlanarityChecker1.IsPlanar()) {
|
||||||
|
GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec);
|
||||||
|
if (aPlanarityChecker2.IsPlanar()) {
|
||||||
|
gp_Pln aPln1 = aPlanarityChecker1.Plan();
|
||||||
|
gp_Pln aPln2 = aPlanarityChecker2.Plan();
|
||||||
|
|
||||||
|
if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) &&
|
||||||
|
aPln1.Distance(aPln2) < aPrec) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// case of two cylindrical surfaces, at least one of which is a swept surface
|
||||||
|
// swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution
|
||||||
|
if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
|
||||||
|
S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) &&
|
||||||
|
(S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
|
||||||
|
S2->IsKind(STANDARD_TYPE(Geom_SweptSurface))))
|
||||||
|
{
|
||||||
|
gp_Cylinder aCyl1, aCyl2;
|
||||||
|
if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) {
|
||||||
|
if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) {
|
||||||
|
gp_Dir aDir1 = aCyl1.Position().Direction();
|
||||||
|
gp_Dir aDir2 = aCyl2.Position().Direction();
|
||||||
|
if (aDir1.IsParallel(aDir2, aPrec)) {
|
||||||
|
gp_Pnt aLoc1 = aCyl1.Location();
|
||||||
|
gp_Pnt aLoc2 = aCyl2.Location();
|
||||||
|
gp_Vec aVec12 (aLoc1, aLoc2);
|
||||||
|
if (aVec12.SquareMagnitude() < aPrec*aPrec ||
|
||||||
|
aVec12.IsParallel(aDir1, aPrec)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : MovePCurves
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
|
||||||
|
const TopoDS_Face& aSource) const
|
||||||
|
{
|
||||||
|
BRep_Builder B;
|
||||||
|
for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) {
|
||||||
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()),
|
||||||
|
aTarget, Precision::Confusion());
|
||||||
|
sfw->FixReorder();
|
||||||
|
Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
|
||||||
|
sfw->FixEdgeCurves();
|
||||||
|
if(isReoredFailed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sfw->FixShifted();
|
||||||
|
sfw->FixDegenerated();
|
||||||
|
|
||||||
|
// remove degenerated edges from not degenerated points
|
||||||
|
ShapeAnalysis_Edge sae;
|
||||||
|
Handle(ShapeExtend_WireData) sewd = sfw->WireData();
|
||||||
|
for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) {
|
||||||
|
TopoDS_Edge E = sewd->Edge(i);
|
||||||
|
if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) {
|
||||||
|
sewd->Remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Wire ResWire = sfw->Wire();
|
||||||
|
B.Add(aTarget,ResWire);
|
||||||
|
}
|
||||||
|
}
|
90
src/GEOMAlgo_NEW/BlockFix_UnionFaces.hxx
Normal file
90
src/GEOMAlgo_NEW/BlockFix_UnionFaces.hxx
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 _BlockFix_UnionFaces_HeaderFile
|
||||||
|
#define _BlockFix_UnionFaces_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _Standard_Real_HeaderFile
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Boolean_HeaderFile
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_Macro_HeaderFile
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TopoDS_Shape;
|
||||||
|
class TopoDS_Face;
|
||||||
|
|
||||||
|
class BlockFix_UnionFaces
|
||||||
|
{
|
||||||
|
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 BlockFix_UnionFaces();
|
||||||
|
|
||||||
|
Standard_EXPORT Standard_Real& GetTolerance();
|
||||||
|
|
||||||
|
/* \brief To get/set the OptimumNbFaces parameter
|
||||||
|
*
|
||||||
|
* If a being processed solid has less than OptimumNbFaces
|
||||||
|
* faces, no union will be performed.
|
||||||
|
* By default this parameter is set to 6 (to correctly
|
||||||
|
* process blocks - hexahedral solids)
|
||||||
|
* Special values: 0 - do all possible unions, regardless the faces quantity,
|
||||||
|
* negative - do not perform any unions, regardless the faces quantity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Standard_EXPORT Standard_Integer& GetOptimumNbFaces();
|
||||||
|
|
||||||
|
Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape);
|
||||||
|
|
||||||
|
Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,
|
||||||
|
const TopoDS_Face& aChekedFace) const;
|
||||||
|
Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget,
|
||||||
|
const TopoDS_Face& aSource) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Fields PRIVATE
|
||||||
|
//
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
Standard_Integer myOptimumNbFaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
27
src/GEOMAlgo_NEW/BlockFix_UnionFaces.ixx
Normal file
27
src/GEOMAlgo_NEW/BlockFix_UnionFaces.ixx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <BlockFix_UnionFaces.jxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
31
src/GEOMAlgo_NEW/BlockFix_UnionFaces.jxx
Normal file
31
src/GEOMAlgo_NEW/BlockFix_UnionFaces.jxx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <TopoDS_Shape.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TopoDS_Face_HeaderFile
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _BlockFix_UnionFaces_HeaderFile
|
||||||
|
#include <BlockFix_UnionFaces.hxx>
|
||||||
|
#endif
|
169
src/GEOMAlgo_NEW/FILES
Normal file
169
src/GEOMAlgo_NEW/FILES
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
GEOMAlgo_Builder_0.cxx
|
||||||
|
GEOMAlgo_Builder_1.cxx
|
||||||
|
GEOMAlgo_Builder_2.cxx
|
||||||
|
GEOMAlgo_Builder_3.cxx
|
||||||
|
GEOMAlgo_Builder_4.cxx
|
||||||
|
GEOMAlgo_ShapeInfoFiller_1.cxx
|
||||||
|
GEOMAlgo_Tools_1.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_Gluer2.hxx
|
||||||
|
GEOMAlgo_Gluer2.cxx
|
||||||
|
GEOMAlgo_Gluer2_1.cxx
|
||||||
|
GEOMAlgo_Gluer2_2.cxx
|
||||||
|
GEOMAlgo_Gluer2_3.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_GluerAlgo.hxx
|
||||||
|
GEOMAlgo_GluerAlgo.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_GlueDetector.hxx
|
||||||
|
GEOMAlgo_GlueDetector.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_GetInPlace.hxx
|
||||||
|
GEOMAlgo_GetInPlace.cxx
|
||||||
|
GEOMAlgo_GetInPlace_1.cxx
|
||||||
|
GEOMAlgo_GetInPlace_2.cxx
|
||||||
|
GEOMAlgo_GetInPlace_3.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_FinderShapeOnQuad.hxx
|
||||||
|
GEOMAlgo_FinderShapeOnQuad.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_WireSplitter.hxx
|
||||||
|
GEOMAlgo_WireSplitter.cxx
|
||||||
|
GEOMAlgo_WESScaler.hxx
|
||||||
|
GEOMAlgo_WESScaler.cxx
|
||||||
|
GEOMAlgo_WESCorrector.hxx
|
||||||
|
GEOMAlgo_WESCorrector.cxx
|
||||||
|
GEOMAlgo_WireEdgeSet.hxx
|
||||||
|
GEOMAlgo_WireEdgeSet.cxx
|
||||||
|
GEOMAlgo_GlueAnalyser.hxx
|
||||||
|
GEOMAlgo_GlueAnalyser.cxx
|
||||||
|
GEOMAlgo_Gluer.hxx
|
||||||
|
GEOMAlgo_Gluer.cxx
|
||||||
|
GEOMAlgo_FinderShapeOn2.hxx
|
||||||
|
GEOMAlgo_FinderShapeOn2.cxx
|
||||||
|
GEOMAlgo_FinderShapeOn1.hxx
|
||||||
|
GEOMAlgo_FinderShapeOn1.cxx
|
||||||
|
GEOMAlgo_FinderShapeOn.hxx
|
||||||
|
GEOMAlgo_FinderShapeOn.cxx
|
||||||
|
GEOMAlgo_ShapeAlgo.hxx
|
||||||
|
GEOMAlgo_ShapeAlgo.cxx
|
||||||
|
GEOMAlgo_SolidSolid.hxx
|
||||||
|
GEOMAlgo_SolidSolid.cxx
|
||||||
|
GEOMAlgo_ShellSolid.hxx
|
||||||
|
GEOMAlgo_ShellSolid.cxx
|
||||||
|
GEOMAlgo_VertexSolid.hxx
|
||||||
|
GEOMAlgo_VertexSolid.cxx
|
||||||
|
GEOMAlgo_WireSolid.hxx
|
||||||
|
GEOMAlgo_WireSolid.cxx
|
||||||
|
GEOMAlgo_ShapeSolid.hxx
|
||||||
|
GEOMAlgo_ShapeSolid.cxx
|
||||||
|
GEOMAlgo_Splitter.hxx
|
||||||
|
GEOMAlgo_Splitter.cxx
|
||||||
|
GEOMAlgo_Builder.hxx
|
||||||
|
GEOMAlgo_Builder.cxx
|
||||||
|
GEOMAlgo_BuilderShape.hxx
|
||||||
|
GEOMAlgo_BuilderShape.cxx
|
||||||
|
GEOMAlgo_BuilderArea.hxx
|
||||||
|
GEOMAlgo_BuilderArea.cxx
|
||||||
|
GEOMAlgo_BuilderFace.hxx
|
||||||
|
GEOMAlgo_BuilderFace.cxx
|
||||||
|
GEOMAlgo_BuilderSolid.hxx
|
||||||
|
GEOMAlgo_BuilderSolid.cxx
|
||||||
|
GEOMAlgo_ShapeInfoFiller.hxx
|
||||||
|
GEOMAlgo_ShapeInfoFiller.cxx
|
||||||
|
GEOMAlgo_Algo.hxx
|
||||||
|
GEOMAlgo_Algo.cxx
|
||||||
|
GEOMAlgo_ShapeSet.hxx
|
||||||
|
GEOMAlgo_ShapeSet.cxx
|
||||||
|
GEOMAlgo_SurfaceTools.hxx
|
||||||
|
GEOMAlgo_SurfaceTools.cxx
|
||||||
|
GEOMAlgo_State.hxx
|
||||||
|
GEOMAlgo_KindOfBounds.hxx
|
||||||
|
GEOMAlgo_KindOfClosed.hxx
|
||||||
|
GEOMAlgo_KindOfName.hxx
|
||||||
|
GEOMAlgo_KindOfShape.hxx
|
||||||
|
GEOMAlgo_ShapeInfo.hxx
|
||||||
|
GEOMAlgo_ShapeInfo.cxx
|
||||||
|
GEOMAlgo_CoupleOfShapes.hxx
|
||||||
|
GEOMAlgo_CoupleOfShapes.cxx
|
||||||
|
GEOMAlgo_BuilderTools.hxx
|
||||||
|
GEOMAlgo_BuilderTools.cxx
|
||||||
|
GEOMAlgo_Tools3D.hxx
|
||||||
|
GEOMAlgo_Tools3D.cxx
|
||||||
|
GEOMAlgo_Tools.hxx
|
||||||
|
GEOMAlgo_Tools.cxx
|
||||||
|
GEOMAlgo_PWireEdgeSet.hxx
|
||||||
|
GEOMAlgo_StateCollector.cxx
|
||||||
|
GEOMAlgo_StateCollector.hxx
|
||||||
|
GEOMAlgo_PassKey.hxx
|
||||||
|
GEOMAlgo_PassKey.cxx
|
||||||
|
GEOMAlgo_PassKeyMapHasher.hxx
|
||||||
|
GEOMAlgo_PassKeyMapHasher.cxx
|
||||||
|
GEOMAlgo_PassKeyShape.hxx
|
||||||
|
GEOMAlgo_PassKeyShape.cxx
|
||||||
|
GEOMAlgo_PassKeyShapeMapHasher.hxx
|
||||||
|
GEOMAlgo_PassKeyShapeMapHasher.cxx
|
||||||
|
GEOMAlgo_ClsfBox.hxx
|
||||||
|
GEOMAlgo_ClsfBox.cxx
|
||||||
|
GEOMAlgo_ClsfSolid.hxx
|
||||||
|
GEOMAlgo_ClsfSolid.cxx
|
||||||
|
GEOMAlgo_ClsfSurf.hxx
|
||||||
|
GEOMAlgo_ClsfSurf.cxx
|
||||||
|
GEOMAlgo_Clsf.hxx
|
||||||
|
GEOMAlgo_Clsf.cxx
|
||||||
|
GEOMAlgo_HAlgo.hxx
|
||||||
|
GEOMAlgo_HAlgo.cxx
|
||||||
|
|
||||||
|
GEOMAlgo_ListOfCoupleOfShapes.hxx
|
||||||
|
GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx
|
||||||
|
GEOMAlgo_ListOfPnt.hxx
|
||||||
|
GEOMAlgo_ListIteratorOfListOfPnt.hxx
|
||||||
|
GEOMAlgo_DataMapOfShapeShapeSet.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx
|
||||||
|
GEOMAlgo_DataMapOfShapeReal.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx
|
||||||
|
GEOMAlgo_DataMapOfRealListOfShape.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx
|
||||||
|
GEOMAlgo_DataMapOfPassKeyInteger.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx
|
||||||
|
GEOMAlgo_DataMapOfPassKeyShapeShape.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx
|
||||||
|
GEOMAlgo_DataMapOfOrientedShapeShape.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx
|
||||||
|
GEOMAlgo_DataMapOfShapeMapOfShape.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx
|
||||||
|
GEOMAlgo_DataMapOfShapePnt.hxx
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeBox.hxx
|
||||||
|
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeState.hxx
|
||||||
|
GEOMAlgo_IndexedDataMapOfIntegerShape.hxx
|
||||||
|
GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
342
src/GEOMAlgo_NEW/GEOMAlgo.cdl
Normal file
342
src/GEOMAlgo_NEW/GEOMAlgo.cdl
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
-- Copyright (C) 2007-2011 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: GEOMAlgo.cdl
|
||||||
|
-- Created: Sat Dec 04 12:36:22 2004
|
||||||
|
-- Author: Peter KURNEV
|
||||||
|
|
||||||
|
package GEOMAlgo
|
||||||
|
|
||||||
|
---Purpose:
|
||||||
|
|
||||||
|
uses
|
||||||
|
TCollection,
|
||||||
|
|
||||||
|
TColgp,
|
||||||
|
Geom,
|
||||||
|
Bnd,
|
||||||
|
gp,
|
||||||
|
GeomAdaptor,
|
||||||
|
TopAbs,
|
||||||
|
TopoDS,
|
||||||
|
TopTools,
|
||||||
|
IntTools,
|
||||||
|
BOPTools,
|
||||||
|
BOP,
|
||||||
|
|
||||||
|
TColStd,
|
||||||
|
BOPTColStd,
|
||||||
|
BRepAlgo,
|
||||||
|
NMTDS,
|
||||||
|
NMTTools
|
||||||
|
|
||||||
|
is
|
||||||
|
-- Enumerations
|
||||||
|
imported State from GEOMAlgo;
|
||||||
|
imported KindOfShape from GEOMAlgo;
|
||||||
|
imported KindOfName from GEOMAlgo;
|
||||||
|
imported KindOfBounds from GEOMAlgo;
|
||||||
|
imported KindOfClosed from GEOMAlgo;
|
||||||
|
--
|
||||||
|
-- Gluer / GetInPlace
|
||||||
|
imported Gluer2 from GEOMAlgo;
|
||||||
|
imported GlueDetector from GEOMAlgo;
|
||||||
|
imported GluerAlgo from GEOMAlgo;
|
||||||
|
imported GetInPlace from GEOMAlgo;
|
||||||
|
-- Algos
|
||||||
|
imported WireSplitter from GEOMAlgo;
|
||||||
|
imported WESScaler from GEOMAlgo;
|
||||||
|
imported WESCorrector from GEOMAlgo;
|
||||||
|
imported WireEdgeSet from GEOMAlgo;
|
||||||
|
imported GlueAnalyser from GEOMAlgo;
|
||||||
|
imported Gluer from GEOMAlgo;
|
||||||
|
imported FinderShapeOn2 from GEOMAlgo;
|
||||||
|
imported FinderShapeOn1 from GEOMAlgo;
|
||||||
|
imported FinderShapeOn from GEOMAlgo;
|
||||||
|
imported ShapeAlgo from GEOMAlgo;
|
||||||
|
imported SolidSolid from GEOMAlgo;
|
||||||
|
imported ShellSolid from GEOMAlgo;
|
||||||
|
imported VertexSolid from GEOMAlgo;
|
||||||
|
imported WireSolid from GEOMAlgo;
|
||||||
|
imported ShapeSolid from GEOMAlgo;
|
||||||
|
imported Splitter from GEOMAlgo;
|
||||||
|
imported Builder from GEOMAlgo;
|
||||||
|
imported BuilderShape from GEOMAlgo;
|
||||||
|
imported BuilderSolid from GEOMAlgo;
|
||||||
|
imported BuilderFace from GEOMAlgo;
|
||||||
|
imported BuilderArea from GEOMAlgo;
|
||||||
|
imported ShapeInfoFiller from GEOMAlgo;
|
||||||
|
imported Algo from GEOMAlgo;
|
||||||
|
-- Data / Tools
|
||||||
|
imported ShapeSet from GEOMAlgo;
|
||||||
|
imported SurfaceTools from GEOMAlgo;
|
||||||
|
imported ShapeInfo from GEOMAlgo;
|
||||||
|
imported CoupleOfShapes from GEOMAlgo;
|
||||||
|
imported BuilderTools from GEOMAlgo;
|
||||||
|
imported Tools3D from GEOMAlgo;
|
||||||
|
imported Tools from GEOMAlgo;
|
||||||
|
imported PWireEdgeSet from GEOMAlgo;
|
||||||
|
imported StateCollector from GEOMAlgo;
|
||||||
|
imported PassKey from GEOMAlgo;
|
||||||
|
imported PassKeyMapHasher from GEOMAlgo;
|
||||||
|
imported PassKeyShape from GEOMAlgo;
|
||||||
|
imported PassKeyShapeMapHasher from GEOMAlgo;
|
||||||
|
imported ClsfBox from GEOMAlgo;
|
||||||
|
imported ClsfSurf from GEOMAlgo;
|
||||||
|
imported ClsfSolid from GEOMAlgo;
|
||||||
|
imported Clsf from GEOMAlgo;
|
||||||
|
imported HAlgo from GEOMAlgo;
|
||||||
|
|
||||||
|
imported ListOfCoupleOfShapes from GEOMAlgo;
|
||||||
|
imported ListIteratorOfListOfCoupleOfShapes from GEOMAlgo;
|
||||||
|
imported ListOfPnt from GEOMAlgo;
|
||||||
|
imported ListIteratorOfListOfPnt from GEOMAlgo;
|
||||||
|
imported DataMapOfShapeShapeSet from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfShapeShapeSet from GEOMAlgo;
|
||||||
|
imported DataMapOfShapeReal from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfShapeReal from GEOMAlgo;
|
||||||
|
imported DataMapOfRealListOfShape from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfRealListOfShape from GEOMAlgo;
|
||||||
|
imported DataMapOfPassKeyInteger from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfPassKeyInteger from GEOMAlgo;
|
||||||
|
imported DataMapOfPassKeyShapeShape from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfPassKeyShapeShape from GEOMAlgo;
|
||||||
|
imported DataMapOfOrientedShapeShape from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfOrientedShapeShape from GEOMAlgo;
|
||||||
|
imported DataMapOfShapeMapOfShape from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfShapeMapOfShape from GEOMAlgo;
|
||||||
|
imported DataMapOfShapePnt from GEOMAlgo;
|
||||||
|
imported DataMapIteratorOfDataMapOfShapePnt from GEOMAlgo;
|
||||||
|
imported IndexedDataMapOfShapeBox from GEOMAlgo;
|
||||||
|
imported IndexedDataMapOfShapeShapeInfo from GEOMAlgo;
|
||||||
|
imported IndexedDataMapOfShapeState from GEOMAlgo;
|
||||||
|
imported IndexedDataMapOfIntegerShape from GEOMAlgo;
|
||||||
|
imported IndexedDataMapOfPassKeyShapeListOfShape from GEOMAlgo;
|
||||||
|
|
||||||
|
|
||||||
|
-- Instantiations
|
||||||
|
|
||||||
|
--class ListOfCoupleOfShapes
|
||||||
|
-- instantiates List from TCollection (CoupleOfShapes from GEOMAlgo);
|
||||||
|
|
||||||
|
--class ListOfPnt
|
||||||
|
-- instantiates List from TCollection (Pnt from gp);
|
||||||
|
--
|
||||||
|
|
||||||
|
--class DataMapOfShapeShapeSet instantiates
|
||||||
|
-- DataMap from TCollection(Shape from TopoDS,
|
||||||
|
-- ShapeSet from GEOMAlgo,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
--class DataMapOfShapeReal instantiates
|
||||||
|
-- DataMap from TCollection(Shape from TopoDS,
|
||||||
|
-- Real from Standard,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
|
||||||
|
--class DataMapOfRealListOfShape instantiates
|
||||||
|
-- DataMap from TCollection(Real from Standard,
|
||||||
|
-- ListOfShape from TopTools,
|
||||||
|
-- MapRealHasher from TColStd);
|
||||||
|
|
||||||
|
|
||||||
|
--class DataMapOfPassKeyInteger
|
||||||
|
-- instantiates DataMap from TCollection (PassKey from GEOMAlgo,
|
||||||
|
-- Integer from Standard,
|
||||||
|
-- PassKeyMapHasher from GEOMAlgo);
|
||||||
|
|
||||||
|
--class DataMapOfPassKeyShapeShape
|
||||||
|
-- instantiates DataMap from TCollection (PassKeyShape from GEOMAlgo,
|
||||||
|
-- Shape from TopoDS,
|
||||||
|
-- PassKeyShapeMapHasher from GEOMAlgo);
|
||||||
|
|
||||||
|
--class DataMapOfOrientedShapeShape instantiates
|
||||||
|
-- DataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- Shape from TopoDS,
|
||||||
|
-- OrientedShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
|
||||||
|
--class DataMapOfShapeMapOfShape instantiates
|
||||||
|
-- DataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- MapOfShape from TopTools,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
--class DataMapOfShapePnt instantiates
|
||||||
|
-- DataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- Pnt from gp,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
--
|
||||||
|
--class IndexedDataMapOfShapeBox
|
||||||
|
-- instantiates IndexedDataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- Box from Bnd,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
-- class IndexedDataMapOfShapeShapeInfo
|
||||||
|
-- instantiates IndexedDataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- ShapeInfo from GEOMAlgo,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
-- class IndexedDataMapOfShapeState
|
||||||
|
-- instantiates IndexedDataMap from TCollection (Shape from TopoDS,
|
||||||
|
-- State from TopAbs,
|
||||||
|
-- ShapeMapHasher from TopTools);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- class IndexedDataMapOfIntegerShape
|
||||||
|
-- instantiates IndexedDataMap from TCollection (Integer from Standard,
|
||||||
|
-- Shape from TopoDS,
|
||||||
|
-- MapIntegerHasher from TColStd);
|
||||||
|
|
||||||
|
|
||||||
|
-- class IndexedDataMapOfPassKeyShapeListOfShape
|
||||||
|
-- instantiates IndexedDataMap from TCollection (PassKeyShape from GEOMAlgo,
|
||||||
|
-- ListOfShape from TopTools,
|
||||||
|
-- PassKeyShapeMapHasher from GEOMAlgo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end GEOMAlgo;
|
||||||
|
--
|
||||||
|
-- enumerations
|
||||||
|
--
|
||||||
|
--enumeration State is
|
||||||
|
-- ST_UNKNOWN,
|
||||||
|
-- ST_IN,
|
||||||
|
-- ST_OUT,
|
||||||
|
-- ST_ON,
|
||||||
|
-- ST_ONIN,
|
||||||
|
-- ST_ONOUT,
|
||||||
|
-- ST_INOUT
|
||||||
|
-- end State;
|
||||||
|
--
|
||||||
|
-- enumeration KindOfShape is
|
||||||
|
-- KS_UNKNOWN,
|
||||||
|
-- KS_SPHERE,
|
||||||
|
-- KS_CYLINDER,
|
||||||
|
-- KS_BOX,
|
||||||
|
-- KS_TORUS,
|
||||||
|
-- KS_CONE,
|
||||||
|
-- KS_ELLIPSE,
|
||||||
|
-- KS_PLANE,
|
||||||
|
-- KS_CIRCLE,
|
||||||
|
-- KS_LINE,
|
||||||
|
-- KS_DEGENERATED
|
||||||
|
-- end KindOfShape;
|
||||||
|
--
|
||||||
|
-- enumeration KindOfName is
|
||||||
|
-- KN_UNKNOWN,
|
||||||
|
-- KN_SPHERE,
|
||||||
|
-- KN_CYLINDER,
|
||||||
|
-- KN_TORUS,
|
||||||
|
-- KN_CONE,
|
||||||
|
-- KN_ELLIPSE,
|
||||||
|
-- KN_CIRCLE,
|
||||||
|
-- KN_PLANE,
|
||||||
|
-- KN_LINE,
|
||||||
|
-- KN_BOX,
|
||||||
|
-- KN_SEGMENT,
|
||||||
|
-- KN_ARCCIRCLE,
|
||||||
|
-- KN_POLYGON,
|
||||||
|
-- KN_POLYHEDRON,
|
||||||
|
-- KN_DISKCIRCLE,
|
||||||
|
-- KN_DISKELLIPSE,
|
||||||
|
-- KN_RECTANGLE,
|
||||||
|
-- KN_TRIANGLE,
|
||||||
|
-- KN_QUADRANGLE,
|
||||||
|
-- KN_ARCELLIPSE
|
||||||
|
-- end KindOfName;
|
||||||
|
--
|
||||||
|
-- enumeration KindOfBounds is
|
||||||
|
-- KB_UNKNOWN,
|
||||||
|
-- KB_TRIMMED,
|
||||||
|
-- KB_INFINITE
|
||||||
|
-- end KindOfBounds;
|
||||||
|
--
|
||||||
|
-- enumeration KindOfClosed is
|
||||||
|
-- KC_UNKNOWN,
|
||||||
|
-- KC_CLOSED,
|
||||||
|
-- KC_NOTCLOSED
|
||||||
|
-- end KindOfClosed;
|
||||||
|
--
|
||||||
|
|
||||||
|
--deferred class HAlgo;
|
||||||
|
--deferred class Clsf;
|
||||||
|
--class ClsfSurf;
|
||||||
|
--class ClsfBox;
|
||||||
|
--class ClsfSolid;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- classes
|
||||||
|
--
|
||||||
|
--deferred class Algo;
|
||||||
|
--deferred class ShapeAlgo;
|
||||||
|
--
|
||||||
|
--class ShapeInfo;
|
||||||
|
--class ShapeInfoFiller;
|
||||||
|
--class CoupleOfShapes;
|
||||||
|
--class SurfaceTools;
|
||||||
|
--class Tools;
|
||||||
|
--class PassKey;
|
||||||
|
--class PassKeyMapHasher;
|
||||||
|
--class PassKeyShape;
|
||||||
|
--class PassKeyShapeMapHasher;
|
||||||
|
--
|
||||||
|
-- finder on
|
||||||
|
--deferred class ShapeSolid;
|
||||||
|
--class WireSolid;
|
||||||
|
--class ShellSolid;
|
||||||
|
--class VertexSolid;
|
||||||
|
--class SolidSolid;
|
||||||
|
--class StateCollector;
|
||||||
|
|
||||||
|
--
|
||||||
|
--class Gluer;
|
||||||
|
--class GlueAnalyser;
|
||||||
|
--class FinderShapeOn;
|
||||||
|
--class FinderShapeOn1;
|
||||||
|
--class FinderShapeOn2;
|
||||||
|
--
|
||||||
|
-- Builder/Splitter
|
||||||
|
--deferred class BuilderShape;
|
||||||
|
--class Builder;
|
||||||
|
--class Splitter;
|
||||||
|
--class Tools3D;
|
||||||
|
--class BuilderTools;
|
||||||
|
--class ShapeSet;
|
||||||
|
|
||||||
|
--deferred class BuilderArea;
|
||||||
|
--class BuilderFace;
|
||||||
|
--class BuilderSolid;
|
||||||
|
|
||||||
|
--class WireSplitter;
|
||||||
|
--class WireEdgeSet;
|
||||||
|
--class WESCorrector;
|
||||||
|
--class WESScaler;
|
||||||
|
--
|
||||||
|
-- Pointers
|
||||||
|
--
|
||||||
|
--pointer PWireEdgeSet to WireEdgeSet from GEOMAlgo;
|
||||||
|
--
|
||||||
|
--
|
90
src/GEOMAlgo_NEW/GEOMAlgo_Algo.cxx
Normal file
90
src/GEOMAlgo_NEW/GEOMAlgo_Algo.cxx
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Algo.cxx
|
||||||
|
// Created: Sat Dec 04 12:39:47 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <peter@PREFEX>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Algo.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function:
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Algo::GEOMAlgo_Algo()
|
||||||
|
:
|
||||||
|
myErrorStatus(1),
|
||||||
|
myWarningStatus(0),
|
||||||
|
myComputeInternalShapes(Standard_True)
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
// function: ~
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Algo::~GEOMAlgo_Algo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: CheckData
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Algo::CheckData()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: CheckResult
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Algo::CheckResult()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: ErrorStatus
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_Algo::ErrorStatus()const
|
||||||
|
{
|
||||||
|
return myErrorStatus;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: WarningStatus
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_Algo::WarningStatus()const
|
||||||
|
{
|
||||||
|
return myWarningStatus;
|
||||||
|
}
|
||||||
|
// myErrorStatus
|
||||||
|
//
|
||||||
|
// 1 - object is just initialized
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ComputeInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Algo::ComputeInternalShapes(const Standard_Boolean theFlag)
|
||||||
|
{
|
||||||
|
myComputeInternalShapes = theFlag;
|
||||||
|
}
|
75
src/GEOMAlgo_NEW/GEOMAlgo_Algo.hxx
Normal file
75
src/GEOMAlgo_NEW/GEOMAlgo_Algo.hxx
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Algo.hxx
|
||||||
|
// Created: Sat Dec 04 12:39:47 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <peter@PREFEX>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_Algo_HeaderFile
|
||||||
|
#define _GEOMAlgo_Algo_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_Algo
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_Algo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() = 0;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer ErrorStatus() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer WarningStatus() const;
|
||||||
|
|
||||||
|
//! Allows to omit of creation of internal shapes (manifold topology). <br>
|
||||||
|
//! Needed for the SALOME/TRIPOLI module. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void ComputeInternalShapes(const Standard_Boolean theFlag) ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_Algo();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_Algo();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckResult() ;
|
||||||
|
|
||||||
|
|
||||||
|
Standard_Integer myErrorStatus;
|
||||||
|
Standard_Integer myWarningStatus;
|
||||||
|
Standard_Boolean myComputeInternalShapes;
|
||||||
|
};
|
||||||
|
#endif
|
416
src/GEOMAlgo_NEW/GEOMAlgo_Builder.cxx
Normal file
416
src/GEOMAlgo_NEW/GEOMAlgo_Builder.cxx
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Builder.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <BOP_CorrectTolerances.hxx>
|
||||||
|
|
||||||
|
#include <BRepLib.hxx>
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
#include <GEOMAlgo_Tools.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Builder::GEOMAlgo_Builder()
|
||||||
|
:
|
||||||
|
GEOMAlgo_BuilderShape()
|
||||||
|
{
|
||||||
|
myNbTypes=9;
|
||||||
|
myPaveFiller=NULL;
|
||||||
|
myEntryPoint=0; // Entry point through PerformWithFiller ()
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Builder::~GEOMAlgo_Builder()
|
||||||
|
{
|
||||||
|
if (myEntryPoint==1) {
|
||||||
|
if (myPaveFiller) {
|
||||||
|
delete myPaveFiller;
|
||||||
|
myPaveFiller=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddCompound
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::AddCompound(const TopoDS_Shape& theShape)
|
||||||
|
{
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
aIt.Initialize(theShape);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
AddShape(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddShape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::AddShape(const TopoDS_Shape& theShape)
|
||||||
|
{
|
||||||
|
if (myMapFence.Add(theShape)) {
|
||||||
|
myShapes.Append(theShape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes()const
|
||||||
|
{
|
||||||
|
return myShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Clear
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::Clear()
|
||||||
|
{
|
||||||
|
myShapes.Clear();
|
||||||
|
ClearInternals();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ClearInternals
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::ClearInternals()
|
||||||
|
{
|
||||||
|
Standard_Integer i;
|
||||||
|
//
|
||||||
|
for (i=0; i<myNbTypes; ++i){
|
||||||
|
myShapes1[i].Clear();
|
||||||
|
}
|
||||||
|
myImages.Clear();
|
||||||
|
//
|
||||||
|
myInParts.Clear();
|
||||||
|
mySplitFaces.Clear();
|
||||||
|
mySameDomainShapes.Clear();
|
||||||
|
myDraftSolids.Clear();
|
||||||
|
myMapFence.Clear();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Prepare
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::Prepare()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer aNb;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Compound aC;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
aNb=myShapes.Extent();
|
||||||
|
if (aNb<2) {
|
||||||
|
myErrorStatus=10; // No shapes to process
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 1. myShape is empty compound
|
||||||
|
aBB.MakeCompound(aC);
|
||||||
|
myShape=aC;
|
||||||
|
//
|
||||||
|
// 2. myShapes1
|
||||||
|
aIt.Initialize(myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
AddShape1(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddShape1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::AddShape1(const TopoDS_Shape& theShape)
|
||||||
|
{
|
||||||
|
Standard_Integer iType;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_MapOfShape aM;
|
||||||
|
//
|
||||||
|
aType=theShape.ShapeType();
|
||||||
|
if (aType==TopAbs_COMPOUND) {
|
||||||
|
aIt.Initialize(theShape);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
AddShape1(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
iType=(Standard_Integer)aType;
|
||||||
|
if (aM.Add(theShape)) {
|
||||||
|
myShapes1[iType].Append(theShape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : BuildResult
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_MapOfShape aM;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt, aItIm;
|
||||||
|
//
|
||||||
|
aIt.Initialize(myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
aType=aS.ShapeType();
|
||||||
|
if (aType==theType) {
|
||||||
|
if (myImages.HasImage(aS)){
|
||||||
|
const TopTools_ListOfShape& aLSIm=myImages.Image(aS);
|
||||||
|
aItIm.Initialize(aLSIm);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
const TopoDS_Shape& aSIm=aItIm.Value();
|
||||||
|
if (aM.Add(aSIm)) {
|
||||||
|
aBB.Add(myShape, aSIm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (aM.Add(aS)) {
|
||||||
|
aBB.Add(myShape, aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Compound aCS;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
aBB.MakeCompound(aCS);
|
||||||
|
//
|
||||||
|
aIt.Initialize(myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
aBB.Add(aCS, aS);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
NMTTools_PaveFiller* pPF=new NMTTools_PaveFiller;
|
||||||
|
//
|
||||||
|
pPF->SetCompositeShape(aCS);
|
||||||
|
pPF->Perform();
|
||||||
|
//
|
||||||
|
myEntryPoint=1;
|
||||||
|
PerformInternal(*pPF);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformWithFiller
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::PerformWithFiller(const NMTTools_PaveFiller& theDSF)
|
||||||
|
{
|
||||||
|
myEntryPoint=0;
|
||||||
|
//
|
||||||
|
PerformInternal(theDSF);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformInternal
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::PerformInternal(const NMTTools_PaveFiller& pPF)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsDone;
|
||||||
|
//
|
||||||
|
// 0. myPaveFiller
|
||||||
|
myPaveFiller=(NMTTools_PaveFiller *)&pPF;
|
||||||
|
//
|
||||||
|
bIsDone=myPaveFiller->IsDone();
|
||||||
|
if (!bIsDone) {
|
||||||
|
myErrorStatus=2; // PaveFiller is failed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 1. Clear Internal fields
|
||||||
|
ClearInternals();
|
||||||
|
//
|
||||||
|
// 2. Prepare
|
||||||
|
Prepare();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 3. Fill Images
|
||||||
|
//
|
||||||
|
// 3.1 Vertices
|
||||||
|
FillImagesVertices();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BuildResult(TopAbs_VERTEX);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.2 Edges
|
||||||
|
FillImagesEdges();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_EDGE);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.3 Wires
|
||||||
|
FillImagesContainers(TopAbs_WIRE);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_WIRE);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.4 Faces
|
||||||
|
FillImagesFaces();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_FACE);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.5 Shells
|
||||||
|
|
||||||
|
FillImagesContainers(TopAbs_SHELL);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_SHELL);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.6 Solids
|
||||||
|
FillImagesSolids();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_SOLID);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.7 CompSolids
|
||||||
|
FillImagesContainers(TopAbs_COMPSOLID);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_COMPSOLID);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 3.8 Compounds
|
||||||
|
FillImagesContainers(TopAbs_COMPOUND);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildResult(TopAbs_COMPOUND);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4.History
|
||||||
|
PrepareHistory();
|
||||||
|
//
|
||||||
|
// 5 Post-treatment
|
||||||
|
PostTreat();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// static
|
||||||
|
// void CorrectWires(const TopoDS_Shape& aS);
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : PostTreat
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::PostTreat()
|
||||||
|
{
|
||||||
|
Standard_Integer aNbS;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_ListOfShape aLS;
|
||||||
|
//
|
||||||
|
aIt.Initialize(myShape);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
aLS.Append(aS);
|
||||||
|
}
|
||||||
|
aNbS=aLS.Extent();
|
||||||
|
if (aNbS==1) {
|
||||||
|
myShape=aLS.First();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
|
||||||
|
//
|
||||||
|
GEOMAlgo_Tools::CorrectWires(myShape);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// myErrorStatus
|
||||||
|
//
|
||||||
|
// 0 - Ok
|
||||||
|
// 1 - The object is just initialized
|
||||||
|
// 2 - PaveFiller is failed
|
||||||
|
// 10 - No shapes to process
|
||||||
|
// 30 - SolidBuilder failed
|
||||||
|
|
224
src/GEOMAlgo_NEW/GEOMAlgo_Builder.hxx
Normal file
224
src/GEOMAlgo_NEW/GEOMAlgo_Builder.hxx
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Builder.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_Builder_HeaderFile
|
||||||
|
#define _GEOMAlgo_Builder_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <NMTTools_PPaveFiller.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <BRepAlgo_Image.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderShape.hxx>
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <BRepAlgo_Image.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_Builder
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_Builder : public GEOMAlgo_BuilderShape
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Empty constructor <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_Builder();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_Builder();
|
||||||
|
|
||||||
|
//! Performs calculations <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
//! Performs calculations using prepared PaveFiller <br>
|
||||||
|
//! object theDSF <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformWithFiller(const NMTTools_PaveFiller& theDSF) ;
|
||||||
|
|
||||||
|
//! Adds argument theShape of the operation <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void AddShape(const TopoDS_Shape& theShape) ;
|
||||||
|
|
||||||
|
//! Clears internal fields and arguments <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Clear() ;
|
||||||
|
|
||||||
|
//! Returns the arguments of the operation <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes() const;
|
||||||
|
|
||||||
|
//! Returns the list of shapes generated from the <br>
|
||||||
|
//! shape theS. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Returns the list of shapes modified from the shape <br>
|
||||||
|
//! theS. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Returns true if the shape theS has been deleted. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Adds arguments of the operation as <br>
|
||||||
|
//! shapes of upper level of container shape theShape <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void AddCompound(const TopoDS_Shape& theShape) ;
|
||||||
|
|
||||||
|
//! Returns list of arguments of type theType <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes1(const Standard_Integer theType) const;
|
||||||
|
|
||||||
|
//! Returns image shapes <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const BRepAlgo_Image& Images() const;
|
||||||
|
|
||||||
|
//! Returns split-parts of shapes that have <br>
|
||||||
|
//! state IN for the domain of shape theShape <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& InParts(const TopoDS_Shape& theShape) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Performs calculations using prepared DSFiller <br>
|
||||||
|
//! object theDSF <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformInternal(const NMTTools_PaveFiller& theDSF) ;
|
||||||
|
|
||||||
|
//! Prepare information for history support <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PrepareHistory() ;
|
||||||
|
|
||||||
|
//! Clears internal fields <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void ClearInternals() ;
|
||||||
|
|
||||||
|
//! Provides preparing actions <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Prepare() ;
|
||||||
|
|
||||||
|
//! Provides post-tratment actions <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PostTreat() ;
|
||||||
|
|
||||||
|
//! Append the argument theShape to <br>
|
||||||
|
//! typified lists of arguments myShapes1 <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void AddShape1(const TopoDS_Shape& theShape) ;
|
||||||
|
|
||||||
|
//! Build the resulting shapes of type theType <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void BuildResult(const TopAbs_ShapeEnum theType) ;
|
||||||
|
|
||||||
|
//! Fill Images for vertices <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesVertices() ;
|
||||||
|
|
||||||
|
//! Fill Images for edges <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesEdges() ;
|
||||||
|
|
||||||
|
//! Fill Images for faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesFaces() ;
|
||||||
|
|
||||||
|
//! For each interferred face find split edges <br>
|
||||||
|
//! that are in 2-D domain of the face <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillIn2DParts() ;
|
||||||
|
|
||||||
|
//! Build draft faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void BuildSplitFaces() ;
|
||||||
|
|
||||||
|
//! Among draft faces find same domain faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillSameDomainFaces() ;
|
||||||
|
|
||||||
|
//! Fill Images for faces <br>
|
||||||
|
//! taking into account same domain faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesFaces1() ;
|
||||||
|
|
||||||
|
//! Update Images for faces by <br>
|
||||||
|
//! internal vertices <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillInternalVertices() ;
|
||||||
|
|
||||||
|
//! Fill Images for Wires, Shells, Compsolids, Compounds <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesContainers(const TopAbs_ShapeEnum theType) ;
|
||||||
|
|
||||||
|
//! Fill Images for solids <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesSolids() ;
|
||||||
|
|
||||||
|
//! For each interferred solid find split faces <br>
|
||||||
|
//! that are in 3-D domain of the solid <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillIn3DParts() ;
|
||||||
|
|
||||||
|
//! Build draft solids <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void BuildSplitSolids() ;
|
||||||
|
|
||||||
|
//! Update draft solids by <br>
|
||||||
|
//! internal shells, edges, vertices <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillInternalShapes() ;
|
||||||
|
|
||||||
|
//! Build solid theDraftSolid that consists of <br>
|
||||||
|
//! non-internal split faces of the solid <br>
|
||||||
|
//! theSolid. <br>
|
||||||
|
//! All splits of internal faces of <br>
|
||||||
|
//! theSolid are in the list: theInternalFaces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void BuildDraftSolid(const TopoDS_Shape& theSolid,
|
||||||
|
TopoDS_Shape& theDraftSolid,
|
||||||
|
TopTools_ListOfShape& theInternalFaces) ;
|
||||||
|
|
||||||
|
|
||||||
|
NMTTools_PPaveFiller myPaveFiller;
|
||||||
|
TopTools_ListOfShape myShapes;
|
||||||
|
Standard_Integer myNbTypes;
|
||||||
|
TopTools_MapOfShape myMapFence;
|
||||||
|
TopTools_ListOfShape myShapes1[9];
|
||||||
|
BRepAlgo_Image myImages;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape myInParts;
|
||||||
|
BRepAlgo_Image mySplitFaces;
|
||||||
|
TopTools_IndexedDataMapOfShapeShape mySameDomainShapes;
|
||||||
|
TopTools_IndexedDataMapOfShapeShape myDraftSolids;
|
||||||
|
Standard_Integer myEntryPoint;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
142
src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.cxx
Normal file
142
src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.cxx
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderArea.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_BuilderArea.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderArea::GEOMAlgo_BuilderArea()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Algo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderArea::~GEOMAlgo_BuilderArea()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetContext
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::SetContext(const Handle(IntTools_Context)& theContext)
|
||||||
|
{
|
||||||
|
myContext=theContext;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Context
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Handle(IntTools_Context)& GEOMAlgo_BuilderArea::Context()const
|
||||||
|
{
|
||||||
|
return myContext;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::Perform()
|
||||||
|
{
|
||||||
|
if (myContext.IsNull()) {
|
||||||
|
myContext=new IntTools_Context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::SetShapes(const TopTools_ListOfShape& theLF)
|
||||||
|
{
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
myShapes.Clear();
|
||||||
|
aIt.Initialize(theLF);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
myShapes.Append(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Shapes()const
|
||||||
|
{
|
||||||
|
return myShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Loops
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Loops()const
|
||||||
|
{
|
||||||
|
return myLoops;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Areas
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Areas()const
|
||||||
|
{
|
||||||
|
return myAreas;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function :PerformShapesToAvoid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::PerformShapesToAvoid()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformLoops
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::PerformLoops()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformAreas
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::PerformAreas()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderArea::PerformInternalShapes()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
112
src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.hxx
Normal file
112
src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.hxx
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderArea.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_BuilderArea_HeaderFile
|
||||||
|
#define _GEOMAlgo_BuilderArea_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfOrientedShape.hxx>
|
||||||
|
#include <Handle_IntTools_Context.hxx>
|
||||||
|
#include <GEOMAlgo_Algo.hxx>
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
//! The root class for algorithms to build <br>
|
||||||
|
//! faces/solids from set of edges/faces <br>
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_BuilderArea
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_BuilderArea : public GEOMAlgo_Algo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Sets cashed geometrical tools <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetContext(const Handle(IntTools_Context)& theContext) ;
|
||||||
|
|
||||||
|
//! Returns cashed geometrical tools <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const Handle_IntTools_Context& Context() const;
|
||||||
|
|
||||||
|
//! Sets edges/faces to process <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShapes(const TopTools_ListOfShape& theLS) ;
|
||||||
|
|
||||||
|
//! Returns edges/faces to process <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes() const;
|
||||||
|
|
||||||
|
//! Returns wires/shells that have been built <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Loops() const;
|
||||||
|
|
||||||
|
//! Returns faces/solids that have been built <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Areas() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Empty constructor <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_BuilderArea();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_BuilderArea();
|
||||||
|
//! Collect the edges/faces that <br>
|
||||||
|
//! a) are internal <br>
|
||||||
|
//! b) are the same and have different orientation <br>
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformShapesToAvoid() ;
|
||||||
|
|
||||||
|
//! Build draft faces/shells <br>
|
||||||
|
//! a)myLoops - draft faces/shells that consist of <br>
|
||||||
|
//! boundary edges/faces <br>
|
||||||
|
//! b)myLoopsInternal - draft faces/shells that contains <br>
|
||||||
|
//! inner edges/faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformLoops() ;
|
||||||
|
//! Build draft faces/solids that contains boundary faces <br>
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformAreas() ;
|
||||||
|
|
||||||
|
//! Build finalized faces/solids with internal wires/shells <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformInternalShapes() ;
|
||||||
|
|
||||||
|
TopTools_ListOfShape myShapes;
|
||||||
|
TopTools_ListOfShape myLoops;
|
||||||
|
TopTools_ListOfShape myLoopsInternal;
|
||||||
|
TopTools_MapOfOrientedShape myShapesToAvoid;
|
||||||
|
TopTools_ListOfShape myAreas;
|
||||||
|
Handle_IntTools_Context myContext;
|
||||||
|
};
|
||||||
|
#endif
|
711
src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.cxx
Normal file
711
src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.cxx
Normal file
@ -0,0 +1,711 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderFace.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_BuilderFace.hxx>
|
||||||
|
|
||||||
|
#include <gp_Pnt2d.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
#include <gp_Dir.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs.hxx>
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfOrientedShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_FClass2d.hxx>
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
#include <BOPTools_Tools2D.hxx>
|
||||||
|
#include <BOP_WireEdgeSet.hxx>
|
||||||
|
#include <BOP_WESCorrector.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_ListOfCoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_CoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderTools.hxx>
|
||||||
|
#include <GEOMAlgo_WireEdgeSet.hxx>
|
||||||
|
#include <GEOMAlgo_WESCorrector.hxx>
|
||||||
|
|
||||||
|
//
|
||||||
|
static
|
||||||
|
Standard_Boolean IsGrowthWire(const TopoDS_Shape& ,
|
||||||
|
|
||||||
|
const TopTools_IndexedMapOfShape& );
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Boolean IsInside(const TopoDS_Shape& ,
|
||||||
|
const TopoDS_Shape& ,
|
||||||
|
const Handle(IntTools_Context)& );
|
||||||
|
static
|
||||||
|
void MakeInternalWires(const TopTools_MapOfShape& ,
|
||||||
|
TopTools_ListOfShape& );
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderFace::GEOMAlgo_BuilderFace()
|
||||||
|
:
|
||||||
|
GEOMAlgo_BuilderArea()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderFace::~GEOMAlgo_BuilderFace()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetFace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace)
|
||||||
|
{
|
||||||
|
myFace=theFace;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Face
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Face& GEOMAlgo_BuilderFace::Face()const
|
||||||
|
{
|
||||||
|
return myFace;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if (myFace.IsNull()) {
|
||||||
|
myErrorStatus=12;// Null face generix
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_BuilderArea::Perform();
|
||||||
|
//
|
||||||
|
PerformShapesToAvoid();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PerformLoops();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PerformAreas();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PerformInternalShapes();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function :PerformShapesToAvoid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::PerformShapesToAvoid()
|
||||||
|
{
|
||||||
|
Standard_Boolean bFound;
|
||||||
|
Standard_Integer i, iCnt, aNbV, aNbE;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
myShapesToAvoid.Clear();
|
||||||
|
//
|
||||||
|
iCnt=0;
|
||||||
|
while (1) {
|
||||||
|
++iCnt;
|
||||||
|
bFound=Standard_False;
|
||||||
|
//
|
||||||
|
// 1. MEF
|
||||||
|
aMVE.Clear();
|
||||||
|
aIt.Initialize (myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aIt.Value();
|
||||||
|
if (!myShapesToAvoid.Contains(aE)) {
|
||||||
|
TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
|
||||||
|
}
|
||||||
|
// else {
|
||||||
|
// int a=0;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
aNbV=aMVE.Extent();
|
||||||
|
//
|
||||||
|
// 2. myEdgesToAvoid
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i));
|
||||||
|
//
|
||||||
|
TopTools_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
|
||||||
|
aNbE=aLE.Extent();
|
||||||
|
if (!aNbE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Edge& aE1=TopoDS::Edge(aLE.First());
|
||||||
|
if (aNbE==1) {
|
||||||
|
if (BRep_Tool::Degenerated(aE1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aV.Orientation()==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bFound=Standard_True;
|
||||||
|
myShapesToAvoid.Add(aE1);
|
||||||
|
}
|
||||||
|
else if (aNbE==2) {
|
||||||
|
const TopoDS_Edge& aE2=TopoDS::Edge(aLE.Last());
|
||||||
|
if (aE2.IsSame(aE1)) {
|
||||||
|
TopoDS_Vertex aV1x, aV2x;
|
||||||
|
//
|
||||||
|
TopExp::Vertices(aE1, aV1x, aV2x);
|
||||||
|
if (aV1x.IsSame(aV2x)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bFound=Standard_True;
|
||||||
|
myShapesToAvoid.Add(aE1);
|
||||||
|
myShapesToAvoid.Add(aE2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}// for (i=1; i<=aNbE; ++i) {
|
||||||
|
//
|
||||||
|
if (!bFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
}//while (1)
|
||||||
|
//printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformLoops
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::PerformLoops()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bFlag;
|
||||||
|
Standard_Integer aNbEA;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
TopTools_MapIteratorOfMapOfOrientedShape aItM;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aVEMap;
|
||||||
|
TopTools_MapOfOrientedShape aMAdded;
|
||||||
|
TopoDS_Iterator aItW;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
GEOMAlgo_WireEdgeSet aWES;
|
||||||
|
GEOMAlgo_WESCorrector aWESCor;
|
||||||
|
//
|
||||||
|
// 1. Usual Wires
|
||||||
|
myLoops.Clear();
|
||||||
|
aWES.SetFace(myFace);
|
||||||
|
//
|
||||||
|
aIt.Initialize (myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aIt.Value();
|
||||||
|
if (!myShapesToAvoid.Contains(aE)) {
|
||||||
|
aWES.AddStartElement(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aWESCor.SetWES(aWES);
|
||||||
|
aWESCor.Perform();
|
||||||
|
//
|
||||||
|
GEOMAlgo_WireEdgeSet& aWESN=aWESCor.NewWES();
|
||||||
|
const TopTools_ListOfShape& aLW=aWESN.Shapes();
|
||||||
|
//
|
||||||
|
aIt.Initialize (aLW);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aW=aIt.Value();
|
||||||
|
myLoops.Append(aW);
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Aug 5 15:09:29 2008f
|
||||||
|
// Post Treatment
|
||||||
|
TopTools_MapOfOrientedShape aMEP;
|
||||||
|
//
|
||||||
|
// a. collect all edges that are in loops
|
||||||
|
aIt.Initialize (myLoops);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aW=aIt.Value();
|
||||||
|
aItW.Initialize(aW);
|
||||||
|
for (; aItW.More(); aItW.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItW.Value();
|
||||||
|
aMEP.Add(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// b. collect all edges that are to avoid
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItM.Key();
|
||||||
|
aMEP.Add(aE);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// c. add all edges that are not processed to myShapesToAvoid
|
||||||
|
aIt.Initialize (myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aIt.Value();
|
||||||
|
if (!aMEP.Contains(aE)) {
|
||||||
|
myShapesToAvoid.Add(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Aug 5 15:09:35 2008t
|
||||||
|
//
|
||||||
|
// 2. Internal Wires
|
||||||
|
myLoopsInternal.Clear();
|
||||||
|
//
|
||||||
|
aNbEA=myShapesToAvoid.Extent();
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aEE=aItM.Key();
|
||||||
|
TopExp::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bFlag=Standard_True;
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More()&&bFlag; aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aEE=aItM.Key();
|
||||||
|
if (!aMAdded.Add(aEE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make new wire
|
||||||
|
TopoDS_Wire aW;
|
||||||
|
aBB.MakeWire(aW);
|
||||||
|
aBB.Add(aW, aEE);
|
||||||
|
//
|
||||||
|
aItW.Initialize(aW);
|
||||||
|
for (; aItW.More()&&bFlag; aItW.Next()) {
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value());
|
||||||
|
//
|
||||||
|
TopoDS_Iterator aItE(aE);
|
||||||
|
for (; aItE.More()&&bFlag; aItE.Next()) {
|
||||||
|
const TopoDS_Vertex& aV = TopoDS::Vertex(aItE.Value());
|
||||||
|
const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV);
|
||||||
|
aIt.Initialize(aLE);
|
||||||
|
for (; aIt.More()&&bFlag; aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aEx=aIt.Value();
|
||||||
|
if (aMAdded.Add(aEx)) {
|
||||||
|
aBB.Add(aW, aEx);
|
||||||
|
if(aMAdded.Extent()==aNbEA) {
|
||||||
|
bFlag=!bFlag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//for (; aIt.More(); aIt.Next()) {
|
||||||
|
}//for (; aItE.More(); aItE.Next()) {
|
||||||
|
}//for (; aItW.More(); aItW.Next()) {
|
||||||
|
myLoopsInternal.Append(aW);
|
||||||
|
}//for (; aItM.More(); aItM.Next()) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformAreas
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::PerformAreas()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsGrowth, bIsHole;
|
||||||
|
Standard_Real aTol;
|
||||||
|
TopTools_ListOfShape aNewFaces, aHoleWires;
|
||||||
|
TopoDS_Shape anInfinitePointShape;
|
||||||
|
TopTools_DataMapOfShapeShape aInOutMap;
|
||||||
|
TopTools_DataMapOfShapeListOfShape aMSH;
|
||||||
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt1, aIt2;
|
||||||
|
TopTools_IndexedMapOfShape aMHE;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
//
|
||||||
|
aTol=BRep_Tool::Tolerance(myFace);
|
||||||
|
aS=BRep_Tool::Surface(myFace, aLoc);
|
||||||
|
//
|
||||||
|
myAreas.Clear();
|
||||||
|
//
|
||||||
|
// Draft faces [aNewFaces]
|
||||||
|
aIt1.Initialize(myLoops);
|
||||||
|
for ( ; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aWire=aIt1.Value();
|
||||||
|
//
|
||||||
|
bIsGrowth=IsGrowthWire(aWire, aMHE);
|
||||||
|
if (bIsGrowth) {
|
||||||
|
// make a growth face from a wire
|
||||||
|
TopoDS_Face aFace;
|
||||||
|
aBB.MakeFace(aFace, aS, aLoc, aTol);
|
||||||
|
aBB.Add (aFace, aWire);
|
||||||
|
//
|
||||||
|
aNewFaces.Append (aFace);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// check if a wire is a hole
|
||||||
|
//XX
|
||||||
|
//bIsHole=IsHole(aWire, myFace, myContext);
|
||||||
|
bIsHole=GEOMAlgo_BuilderTools::IsHole(aWire, myFace);
|
||||||
|
//XX
|
||||||
|
if (bIsHole) {
|
||||||
|
aHoleWires.Append(aWire);
|
||||||
|
TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// make a growth face from a wire
|
||||||
|
TopoDS_Face aFace;
|
||||||
|
aBB.MakeFace(aFace, aS, aLoc, aTol);
|
||||||
|
aBB.Add (aFace, aWire);
|
||||||
|
//
|
||||||
|
aNewFaces.Append (aFace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Find outer growth shell that is most close to each hole shell
|
||||||
|
aIt2.Initialize(aHoleWires);
|
||||||
|
for (; aIt2.More(); aIt2.Next()) {
|
||||||
|
const TopoDS_Shape& aHole = aIt2.Value();
|
||||||
|
//
|
||||||
|
aIt1.Initialize(aNewFaces);
|
||||||
|
for ( ; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt1.Value();
|
||||||
|
//
|
||||||
|
if (!IsInside(aHole, aF, myContext)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if ( aInOutMap.IsBound (aHole)){
|
||||||
|
const TopoDS_Shape& aF2=aInOutMap(aHole);
|
||||||
|
if (IsInside(aF, aF2, myContext)) {
|
||||||
|
aInOutMap.UnBind(aHole);
|
||||||
|
aInOutMap.Bind (aHole, aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
aInOutMap.Bind (aHole, aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Add aHole to a map Face/ListOfHoles [aMSH]
|
||||||
|
if (aInOutMap.IsBound(aHole)){
|
||||||
|
const TopoDS_Shape& aF=aInOutMap(aHole);
|
||||||
|
if (aMSH.IsBound(aF)) {
|
||||||
|
TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF);
|
||||||
|
aLH.Append(aHole);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape aLH;
|
||||||
|
aLH.Append(aHole);
|
||||||
|
aMSH.Bind(aF, aLH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}// for (; aIt2.More(); aIt2.Next())
|
||||||
|
//
|
||||||
|
// 3. Add aHoles to Faces
|
||||||
|
aItMSH.Initialize(aMSH);
|
||||||
|
for (; aItMSH.More(); aItMSH.Next()) {
|
||||||
|
TopoDS_Face aF=TopoDS::Face(aItMSH.Key());
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLH=aItMSH.Value();
|
||||||
|
aIt2.Initialize(aLH);
|
||||||
|
for (; aIt2.More(); aIt2.Next()) {
|
||||||
|
const TopoDS_Shape& aHole = aIt2.Value();
|
||||||
|
aBB.Add (aF, aHole);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// update classifier
|
||||||
|
aTol=BRep_Tool::Tolerance(aF);
|
||||||
|
IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
|
||||||
|
aClsf.Init(aF, aTol);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// These aNewFaces are draft faces that
|
||||||
|
// do not contain any internal shapes
|
||||||
|
//
|
||||||
|
myAreas.Append(aNewFaces);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderFace::PerformInternalShapes()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer aNbWI=myLoopsInternal.Extent();
|
||||||
|
if (!aNbWI) {// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//Standard_Real aTol;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt1, aIt2;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_MapOfShape aME, aMEP;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItME;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
|
||||||
|
TopTools_ListOfShape aLSI;
|
||||||
|
//
|
||||||
|
// 1. All internal edges
|
||||||
|
aIt1.Initialize(myLoopsInternal);
|
||||||
|
for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aWire=aIt1.Value();
|
||||||
|
aIt.Initialize(aWire);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aIt.Value();
|
||||||
|
aME.Add(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aNbWI=aME.Extent();
|
||||||
|
//
|
||||||
|
// 2 Process faces
|
||||||
|
aIt2.Initialize(myAreas);
|
||||||
|
for ( ; aIt2.More(); aIt2.Next()) {
|
||||||
|
TopoDS_Face& aF=TopoDS::Face(aIt2.Value());
|
||||||
|
//
|
||||||
|
aMVE.Clear();
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
|
||||||
|
//
|
||||||
|
// 2.1 Separate faces to process aMEP
|
||||||
|
aMEP.Clear();
|
||||||
|
aItME.Initialize(aME);
|
||||||
|
for (; aItME.More(); aItME.Next()) {
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aItME.Key());
|
||||||
|
if (IsInside(aE, aF, myContext)) {
|
||||||
|
aMEP.Add(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2.2 Make Internal Wires
|
||||||
|
aLSI.Clear();
|
||||||
|
MakeInternalWires(aMEP, aLSI);
|
||||||
|
//
|
||||||
|
// 2.3 Add them to aF
|
||||||
|
aIt1.Initialize(aLSI);
|
||||||
|
for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aSI=aIt1.Value();
|
||||||
|
aBB.Add (aF, aSI);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2.4 Remove faces aMFP from aMF
|
||||||
|
aItME.Initialize(aMEP);
|
||||||
|
for (; aItME.More(); aItME.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItME.Key();
|
||||||
|
aME.Remove(aE);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbWI=aME.Extent();
|
||||||
|
if (!aNbWI) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} //for ( ; aIt2.More(); aIt2.Next()) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : MakeInternalWires
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void MakeInternalWires(const TopTools_MapOfShape& theME,
|
||||||
|
TopTools_ListOfShape& theWires)
|
||||||
|
{
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItM;
|
||||||
|
TopTools_MapOfShape aAddedMap;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItE;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
aItM.Initialize(theME);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItM.Key();
|
||||||
|
TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItM.Initialize(theME);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
TopoDS_Shape aEE=aItM.Key();
|
||||||
|
if (!aAddedMap.Add(aEE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make a new shell
|
||||||
|
TopoDS_Wire aW;
|
||||||
|
aBB.MakeWire(aW);
|
||||||
|
aEE.Orientation(TopAbs_INTERNAL);
|
||||||
|
aBB.Add(aW, aEE);
|
||||||
|
//
|
||||||
|
TopoDS_Iterator aItAdded (aW);
|
||||||
|
for (; aItAdded.More(); aItAdded.Next()) {
|
||||||
|
const TopoDS_Shape& aE =aItAdded.Value();
|
||||||
|
//
|
||||||
|
TopExp_Explorer aExp(aE, TopAbs_VERTEX);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aV =aExp.Current();
|
||||||
|
const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
|
||||||
|
aItE.Initialize(aLE);
|
||||||
|
for (; aItE.More(); aItE.Next()) {
|
||||||
|
TopoDS_Shape aEL=aItE.Value();
|
||||||
|
if (aAddedMap.Add(aEL)){
|
||||||
|
aEL.Orientation(TopAbs_INTERNAL);
|
||||||
|
aBB.Add(aW, aEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theWires.Append(aW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsInside
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsInside(const TopoDS_Shape& theHole,
|
||||||
|
const TopoDS_Shape& theF2,
|
||||||
|
const Handle(IntTools_Context)& theContext)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
Standard_Real aT, aU, aV;
|
||||||
|
|
||||||
|
TopAbs_State aState;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
TopTools_IndexedMapOfShape aME2;
|
||||||
|
gp_Pnt2d aP2D;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
aState=TopAbs_UNKNOWN;
|
||||||
|
const TopoDS_Face& aF2=TopoDS::Face(theF2);
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(aF2, TopAbs_EDGE, aME2);
|
||||||
|
//
|
||||||
|
aExp.Init(theHole, TopAbs_EDGE);
|
||||||
|
if (aExp.More()) {
|
||||||
|
const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current());
|
||||||
|
if (aME2.Contains(aE)) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aT=BOPTools_Tools2D::IntermediatePoint(aE);
|
||||||
|
BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV);
|
||||||
|
aP2D.SetCoord(aU, aV);
|
||||||
|
//
|
||||||
|
IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
|
||||||
|
aState=aClsf.Perform(aP2D);
|
||||||
|
bRet=(aState==TopAbs_IN);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsGrowthWire
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire,
|
||||||
|
const TopTools_IndexedMapOfShape& theMHE)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
if (theMHE.Extent()) {
|
||||||
|
aIt.Initialize(theWire);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aIt.Value();
|
||||||
|
if (theMHE.Contains(aE)) {
|
||||||
|
return !bRet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
//BRepTools::Write(aFF, "ff");
|
||||||
|
//
|
||||||
|
// ErrorStatus :
|
||||||
|
// 11 - Null Context
|
||||||
|
// 12 - Null face generix
|
||||||
|
|
||||||
|
/*
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsInside
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsInside(const TopoDS_Shape& theHole,
|
||||||
|
const TopoDS_Shape& theF2,
|
||||||
|
IntTools_PContext& theContext)
|
||||||
|
{
|
||||||
|
Standard_Real aT, aU, aV;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
TopAbs_State aState=TopAbs_UNKNOWN;
|
||||||
|
gp_Pnt2d aP2D;
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF2=TopoDS::Face(theF2);
|
||||||
|
//
|
||||||
|
aExp.Init(theHole, TopAbs_EDGE);
|
||||||
|
if (aExp.More()){
|
||||||
|
const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current());
|
||||||
|
aT=BOPTools_Tools2D::IntermediatePoint(aE);
|
||||||
|
BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV);
|
||||||
|
aP2D.SetCoord(aU, aV);
|
||||||
|
//
|
||||||
|
IntTools_FClass2d& aClsf=theContext->FClass2d(aF2);
|
||||||
|
aState=aClsf.Perform(aP2D);
|
||||||
|
}
|
||||||
|
return (aState==TopAbs_IN);
|
||||||
|
}
|
||||||
|
*/
|
91
src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.hxx
Normal file
91
src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.hxx
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderFace.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_BuilderFace_HeaderFile
|
||||||
|
#define _GEOMAlgo_BuilderFace_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderArea.hxx>
|
||||||
|
|
||||||
|
//! The algorithm to build faces from set of edges <br>
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_BuilderFace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_BuilderFace : public GEOMAlgo_BuilderArea
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Empty constructor <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_BuilderFace();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_BuilderFace();
|
||||||
|
|
||||||
|
//! Sets the face generatix <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetFace(const TopoDS_Face& theFace) ;
|
||||||
|
|
||||||
|
//! Returns the face generatix <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Face& Face() const;
|
||||||
|
|
||||||
|
//! Performs the algorithm <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Collect the edges that <br>
|
||||||
|
//! a) are internal <br>
|
||||||
|
//! b) are the same and have different orientation <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformShapesToAvoid() ;
|
||||||
|
|
||||||
|
//! Build draft wires <br>
|
||||||
|
//! a)myLoops - draft wires that consist of <br>
|
||||||
|
//! boundary edges <br>
|
||||||
|
//! b)myLoopsInternal - draft wires that contains <br>
|
||||||
|
//! inner edges <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformLoops() ;
|
||||||
|
|
||||||
|
//! Build draft faces that contains boundary edges <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformAreas() ;
|
||||||
|
|
||||||
|
//! Build finalized faces with internals <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformInternalShapes() ;
|
||||||
|
|
||||||
|
|
||||||
|
TopoDS_Face myFace;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
133
src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.cxx
Normal file
133
src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.cxx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderShape.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_BuilderShape.hxx>
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderShape::GEOMAlgo_BuilderShape()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Algo()
|
||||||
|
{
|
||||||
|
myHasDeleted=Standard_False;
|
||||||
|
myHasGenerated=Standard_False;
|
||||||
|
myHasModified=Standard_False;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderShape::~GEOMAlgo_BuilderShape()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Shape& GEOMAlgo_BuilderShape::Shape() const
|
||||||
|
{
|
||||||
|
return myShape;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : Generated
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_BuilderShape::Generated(const TopoDS_Shape& )
|
||||||
|
{
|
||||||
|
myHistShapes.Clear();
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Modified
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_BuilderShape::Modified(const TopoDS_Shape& )
|
||||||
|
{
|
||||||
|
myHistShapes.Clear();
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsDeleted
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderShape::IsDeleted(const TopoDS_Shape& theS)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
//
|
||||||
|
bRet=!myMapShape.Contains(theS);
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasDeleted
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderShape::HasDeleted()const
|
||||||
|
{
|
||||||
|
return myHasDeleted;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasGenerated
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderShape::HasGenerated()const
|
||||||
|
{
|
||||||
|
return myHasGenerated;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasModified
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderShape::HasModified()const
|
||||||
|
{
|
||||||
|
return myHasModified;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PrepareHistory
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderShape::PrepareHistory()
|
||||||
|
{
|
||||||
|
myHistShapes.Clear();
|
||||||
|
myMapShape.Clear();
|
||||||
|
myHasDeleted=Standard_False;
|
||||||
|
myHasGenerated=Standard_False;
|
||||||
|
myHasModified=Standard_False;
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:14:15 2006
|
||||||
|
myImagesResult.Clear();
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:14:17 2006t
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:57:00 2006f
|
||||||
|
//=======================================================================
|
||||||
|
//function : ImagesResult
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_IndexedDataMapOfShapeListOfShape& GEOMAlgo_BuilderShape::ImagesResult()const
|
||||||
|
{
|
||||||
|
return myImagesResult;
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:57:04 2006t
|
105
src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.hxx
Normal file
105
src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.hxx
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderShape.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_BuilderShape_HeaderFile
|
||||||
|
#define _GEOMAlgo_BuilderShape_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_Algo.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//! Root class for algorithms that has shape as result <br>
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_BuilderShape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_BuilderShape : public GEOMAlgo_Algo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Returns the result of algorithm <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& Shape() const;
|
||||||
|
|
||||||
|
//! Returns the list of shapes generated from the <br>
|
||||||
|
//! shape theS. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Returns the list of shapes modified from the <br>
|
||||||
|
//! shape theS. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Returns true if the shape theS has been deleted. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
//! Returns true if the at least one shape(or sub-shape) <br>
|
||||||
|
//! of arguments has been deleted. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean HasDeleted() const;
|
||||||
|
|
||||||
|
//! Returns true if the at least one shape(or sub-shape) <br>
|
||||||
|
//! of arguments has generated shapes. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean HasGenerated() const;
|
||||||
|
|
||||||
|
//! Returns true if the at least one shape(or sub-shape) <br>
|
||||||
|
//! of arguments has modified shapes. <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean HasModified() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_IndexedDataMapOfShapeListOfShape& ImagesResult() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Empty constructor <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_BuilderShape();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_BuilderShape();
|
||||||
|
|
||||||
|
//! Prepare information for history support <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PrepareHistory() ;
|
||||||
|
|
||||||
|
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
TopTools_ListOfShape myHistShapes;
|
||||||
|
TopTools_MapOfShape myMapShape;
|
||||||
|
Standard_Boolean myHasDeleted;
|
||||||
|
Standard_Boolean myHasGenerated;
|
||||||
|
Standard_Boolean myHasModified;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape myImagesResult;
|
||||||
|
};
|
||||||
|
#endif
|
914
src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.cxx
Normal file
914
src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.cxx
Normal file
@ -0,0 +1,914 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderSolid.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_BuilderSolid.hxx>
|
||||||
|
|
||||||
|
#include <gp_Pnt2d.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
#include <gp_Dir.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfOrientedShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
#include <BOPTools_Tools2D.hxx>
|
||||||
|
#include <BOPTools_Tools3D.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_ListOfCoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_CoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderTools.hxx>
|
||||||
|
|
||||||
|
//
|
||||||
|
static
|
||||||
|
Standard_Boolean IsGrowthShell(const TopoDS_Shape& ,
|
||||||
|
const TopTools_IndexedMapOfShape& );
|
||||||
|
static
|
||||||
|
Standard_Boolean IsHole(const TopoDS_Shape& ,
|
||||||
|
const Handle(IntTools_Context)& );
|
||||||
|
static
|
||||||
|
Standard_Boolean IsInside(const TopoDS_Shape& ,
|
||||||
|
const TopoDS_Shape& ,
|
||||||
|
const Handle(IntTools_Context)& );
|
||||||
|
static
|
||||||
|
void MakeInternalShells(const TopTools_MapOfShape& ,
|
||||||
|
TopTools_ListOfShape& );
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Boolean IsClosedShell(const TopoDS_Shell& );
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Boolean RefineShell(const TopoDS_Shell& ,
|
||||||
|
TopoDS_Shell& );
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderSolid::GEOMAlgo_BuilderSolid()
|
||||||
|
:
|
||||||
|
GEOMAlgo_BuilderArea()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_BuilderSolid::~GEOMAlgo_BuilderSolid()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderSolid::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_BuilderArea::Perform();
|
||||||
|
//
|
||||||
|
TopoDS_Compound aC;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
|
||||||
|
aBB.MakeCompound(aC);
|
||||||
|
aIt.Initialize(myShapes);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
aBB.Add(aC, aF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PerformShapesToAvoid();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PerformLoops();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PerformAreas();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myComputeInternalShapes) {
|
||||||
|
PerformInternalShapes();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function :PerformShapesToAvoid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderSolid::PerformShapesToAvoid()
|
||||||
|
{
|
||||||
|
Standard_Boolean bFound;
|
||||||
|
Standard_Integer i, iCnt, aNbE, aNbF;
|
||||||
|
TopAbs_Orientation aOrE;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
myShapesToAvoid.Clear();
|
||||||
|
//
|
||||||
|
iCnt=0;
|
||||||
|
while (1) {
|
||||||
|
++iCnt;
|
||||||
|
bFound=Standard_False;
|
||||||
|
//
|
||||||
|
// 1. MEF
|
||||||
|
aMEF.Clear();
|
||||||
|
aIt.Initialize (myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (!myShapesToAvoid.Contains(aF)) {
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else {
|
||||||
|
int a=0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
aNbE=aMEF.Extent();
|
||||||
|
//
|
||||||
|
// 2. myFacesToAvoid
|
||||||
|
for (i=1; i<=aNbE; ++i) {
|
||||||
|
const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopTools_ListOfShape& aLF=aMEF.ChangeFromKey(aE);
|
||||||
|
//
|
||||||
|
aNbF=aLF.Extent();
|
||||||
|
if (!aNbF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aOrE=aE.Orientation();
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
|
||||||
|
if (aNbF==1) {
|
||||||
|
if (aOrE==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bFound=Standard_True;
|
||||||
|
myShapesToAvoid.Add(aF1);
|
||||||
|
}
|
||||||
|
else if (aNbF==2) {
|
||||||
|
const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
|
||||||
|
if (aF2.IsSame(aF1)) {
|
||||||
|
if (BRep_Tool::IsClosed(aE, aF1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aOrE==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bFound=Standard_True;
|
||||||
|
myShapesToAvoid.Add(aF1);
|
||||||
|
myShapesToAvoid.Add(aF2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*//DEB
|
||||||
|
else {
|
||||||
|
TopTools_ListIteratorOfListOfShape aItLF;
|
||||||
|
//
|
||||||
|
aItLF.Initialize (aLF);
|
||||||
|
for (; aItLF.More(); aItLF.Next()) {
|
||||||
|
const TopoDS_Shape& aFx=aItLF.Value();
|
||||||
|
int a=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*///DEB
|
||||||
|
}// for (i=1; i<=aNbE; ++i) {
|
||||||
|
//
|
||||||
|
if (!bFound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
}//while (1)
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformLoops
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderSolid::PerformLoops()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
myLoops.Clear();
|
||||||
|
//
|
||||||
|
Standard_Integer aNbLF, aNbOff, aNbFP;
|
||||||
|
TopAbs_Orientation anOr;
|
||||||
|
TopoDS_Edge aEL;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
NMTTools_CoupleOfShape aCSOff;
|
||||||
|
TopTools_MapOfOrientedShape AddedFacesMap;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItF, aIt;
|
||||||
|
TopTools_MapIteratorOfMapOfOrientedShape aItM;
|
||||||
|
TopoDS_Iterator aItS;
|
||||||
|
//
|
||||||
|
//=================================================
|
||||||
|
//
|
||||||
|
// 1. Shells Usual
|
||||||
|
//
|
||||||
|
aItF.Initialize (myShapes);
|
||||||
|
for (; aItF.More(); aItF.Next()) {
|
||||||
|
const TopoDS_Shape& aFF = aItF.Value();
|
||||||
|
TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItF.Initialize (myShapes);
|
||||||
|
for (; aItF.More(); aItF.Next()) {
|
||||||
|
const TopoDS_Shape& aFF = aItF.Value();
|
||||||
|
if (myShapesToAvoid.Contains(aFF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!AddedFacesMap.Add(aFF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make a new shell
|
||||||
|
TopoDS_Shell aShell;
|
||||||
|
aBB.MakeShell(aShell);
|
||||||
|
aBB.Add(aShell, aFF);
|
||||||
|
//
|
||||||
|
aMEFP.Clear();
|
||||||
|
TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
|
||||||
|
//
|
||||||
|
// loop on faces added to Shell; add their neighbor faces to Shell and so on
|
||||||
|
TopoDS_Iterator aItAddedF (aShell);
|
||||||
|
for (; aItAddedF.More(); aItAddedF.Next()) {
|
||||||
|
const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
|
||||||
|
//
|
||||||
|
// loop on edges of aF; find a good neighbor face of aF by aE
|
||||||
|
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
|
||||||
|
for (; aEdgeExp.More(); aEdgeExp.Next()) {
|
||||||
|
const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aEdgeExp.Current()));
|
||||||
|
//
|
||||||
|
//1
|
||||||
|
if (aMEFP.Contains(aE)) {
|
||||||
|
const TopTools_ListOfShape& aLFP=aMEFP.FindFromKey(aE);
|
||||||
|
aNbFP=aLFP.Extent();
|
||||||
|
if (aNbFP>1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//2
|
||||||
|
anOr=aE.Orientation();
|
||||||
|
if (anOr==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//3
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// candidate faces list
|
||||||
|
const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
|
||||||
|
aNbLF=aLF.Extent();
|
||||||
|
if (!aNbLF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// try to select one of neighbors
|
||||||
|
// check if a face already added to Shell shares E
|
||||||
|
Standard_Boolean bFound;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItLF;
|
||||||
|
NMTTools_ListOfCoupleOfShape aLCSOff;
|
||||||
|
//
|
||||||
|
aItLF.Initialize(aLF);
|
||||||
|
for (; aItLF.More(); aItLF.Next()) {
|
||||||
|
const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItLF.Value()));
|
||||||
|
if (myShapesToAvoid.Contains(aFL)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aF.IsSame(aFL)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (AddedFacesMap.Contains(aFL)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bFound=GEOMAlgo_Tools3D::GetEdgeOff(aE, aFL, aEL);
|
||||||
|
if (!bFound) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aCSOff.SetShape1(aEL);
|
||||||
|
aCSOff.SetShape2(aFL);
|
||||||
|
aLCSOff.Append(aCSOff);
|
||||||
|
}//for (; aItLF.More(); aItLF.Next()) {
|
||||||
|
//
|
||||||
|
aNbOff=aLCSOff.Extent();
|
||||||
|
if (!aNbOff){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopoDS_Face aSelF;
|
||||||
|
if (aNbOff==1) {
|
||||||
|
aSelF=*((TopoDS_Face*)(&aLCSOff.First().Shape2()));
|
||||||
|
}
|
||||||
|
else if (aNbOff>1){
|
||||||
|
GEOMAlgo_Tools3D::GetFaceOff(aE, aF, aLCSOff, aSelF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
|
||||||
|
aBB.Add(aShell, aSelF);
|
||||||
|
TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
|
||||||
|
}
|
||||||
|
} // for (; aEdgeExp.More(); aEdgeExp.Next()) {
|
||||||
|
} //for (; aItAddedF.More(); aItAddedF.Next()) {
|
||||||
|
//
|
||||||
|
if (IsClosedShell(aShell)) {
|
||||||
|
myLoops.Append(aShell);
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 07:10:41 2010f
|
||||||
|
else {
|
||||||
|
Standard_Boolean bRefine;
|
||||||
|
TopoDS_Shell aShx;
|
||||||
|
//
|
||||||
|
bRefine=RefineShell(aShell, aShx);
|
||||||
|
if (bRefine) {
|
||||||
|
myLoops.Append(aShx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 07:10:44 2010t
|
||||||
|
} // for (; aItF.More(); aItF.Next()) {
|
||||||
|
//
|
||||||
|
// Post Treatment
|
||||||
|
TopTools_MapOfOrientedShape aMP;
|
||||||
|
//
|
||||||
|
// a. collect all edges that are in loops
|
||||||
|
aIt.Initialize (myLoops);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
aItS.Initialize(aS);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItS.Value();
|
||||||
|
aMP.Add(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// b. collect all faces that are to avoid
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItM.Key();
|
||||||
|
aMP.Add(aF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// c. add all faces that are not processed to myShapesToAvoid
|
||||||
|
aIt.Initialize (myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (!aMP.Contains(aF)) {
|
||||||
|
myShapesToAvoid.Add(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=================================================
|
||||||
|
//
|
||||||
|
// 2.Internal Shells
|
||||||
|
//
|
||||||
|
myLoopsInternal.Clear();
|
||||||
|
//
|
||||||
|
aEFMap.Clear();
|
||||||
|
AddedFacesMap.Clear();
|
||||||
|
//
|
||||||
|
if (myComputeInternalShapes) {
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aFF=aItM.Key();
|
||||||
|
TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItM.Initialize(myShapesToAvoid);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aFF=aItM.Key();
|
||||||
|
if (!AddedFacesMap.Add(aFF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make a new shell
|
||||||
|
TopoDS_Shell aShell;
|
||||||
|
aBB.MakeShell(aShell);
|
||||||
|
aBB.Add(aShell, aFF);
|
||||||
|
//
|
||||||
|
TopoDS_Iterator aItAddedF (aShell);
|
||||||
|
for (; aItAddedF.More(); aItAddedF.Next()) {
|
||||||
|
const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value()));
|
||||||
|
//
|
||||||
|
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
|
||||||
|
for (; aEdgeExp.More(); aEdgeExp.Next()) {
|
||||||
|
const TopoDS_Edge& aE = *((TopoDS_Edge*)(&aEdgeExp.Current()));
|
||||||
|
const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE);
|
||||||
|
aItF.Initialize(aLF);
|
||||||
|
for (; aItF.More(); aItF.Next()) {
|
||||||
|
const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItF.Value()));
|
||||||
|
if (AddedFacesMap.Add(aFL)){
|
||||||
|
aBB.Add(aShell, aFL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myLoopsInternal.Append(aShell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformAreas
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderSolid::PerformAreas()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsGrowthShell, bIsHole;
|
||||||
|
TopTools_ListOfShape aNewSolids, aHoleShells;
|
||||||
|
TopoDS_Shape anInfinitePointShape;
|
||||||
|
TopTools_DataMapOfShapeShape aInOutMap;
|
||||||
|
TopTools_DataMapOfShapeListOfShape aMSH;
|
||||||
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
|
||||||
|
TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
|
||||||
|
TopTools_IndexedMapOfShape aMHF;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
myAreas.Clear();
|
||||||
|
//
|
||||||
|
// Draft solids [aNewSolids]
|
||||||
|
aShellIt.Initialize(myLoops);
|
||||||
|
for ( ; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
const TopoDS_Shape& aShell = aShellIt.Value();
|
||||||
|
//
|
||||||
|
bIsGrowthShell=IsGrowthShell(aShell, aMHF);
|
||||||
|
if (bIsGrowthShell) {
|
||||||
|
// make a growth solid from a shell
|
||||||
|
TopoDS_Solid Solid;
|
||||||
|
aBB.MakeSolid(Solid);
|
||||||
|
aBB.Add (Solid, aShell);
|
||||||
|
//
|
||||||
|
aNewSolids.Append (Solid);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// check if a shell is a hole
|
||||||
|
bIsHole=IsHole(aShell, myContext);
|
||||||
|
//
|
||||||
|
if (bIsHole) {
|
||||||
|
aHoleShells.Append(aShell);
|
||||||
|
TopExp::MapShapes(aShell, TopAbs_FACE, aMHF);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// make a growth solid from a shell
|
||||||
|
TopoDS_Solid Solid;
|
||||||
|
aBB.MakeSolid(Solid);
|
||||||
|
aBB.Add (Solid, aShell);
|
||||||
|
//
|
||||||
|
aNewSolids.Append (Solid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Find outer growth shell that is most close to each hole shell
|
||||||
|
aShellIt.Initialize(aHoleShells);
|
||||||
|
for (; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
const TopoDS_Shape& aHole = aShellIt.Value();
|
||||||
|
//
|
||||||
|
aSolidIt.Initialize(aNewSolids);
|
||||||
|
for ( ; aSolidIt.More(); aSolidIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSolid = aSolidIt.Value();
|
||||||
|
//
|
||||||
|
if (!IsInside(aHole, aSolid, myContext)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if ( aInOutMap.IsBound (aHole)){
|
||||||
|
const TopoDS_Shape& aSolid2 = aInOutMap(aHole);
|
||||||
|
if (IsInside(aSolid, aSolid2, myContext)) {
|
||||||
|
aInOutMap.UnBind(aHole);
|
||||||
|
aInOutMap.Bind (aHole, aSolid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
aInOutMap.Bind (aHole, aSolid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Add aHole to a map Solid/ListOfHoles [aMSH]
|
||||||
|
if (aInOutMap.IsBound(aHole)){
|
||||||
|
const TopoDS_Shape& aSolid=aInOutMap(aHole);
|
||||||
|
if (aMSH.IsBound(aSolid)) {
|
||||||
|
TopTools_ListOfShape& aLH=aMSH.ChangeFind(aSolid);
|
||||||
|
aLH.Append(aHole);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape aLH;
|
||||||
|
aLH.Append(aHole);
|
||||||
|
aMSH.Bind(aSolid, aLH);
|
||||||
|
}
|
||||||
|
//aBB.Add (aSolid, aHole);
|
||||||
|
}
|
||||||
|
}// for (; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
//
|
||||||
|
// 3. Add aHoles to Solids
|
||||||
|
aItMSH.Initialize(aMSH);
|
||||||
|
for (; aItMSH.More(); aItMSH.Next()) {
|
||||||
|
TopoDS_Solid aSolid=*((TopoDS_Solid*)(&aItMSH.Key()));
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLH=aItMSH.Value();
|
||||||
|
aShellIt.Initialize(aLH);
|
||||||
|
for (; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
const TopoDS_Shape& aHole = aShellIt.Value();
|
||||||
|
aBB.Add (aSolid, aHole);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// update classifier
|
||||||
|
BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid);
|
||||||
|
aSC.Load(aSolid);
|
||||||
|
//
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// These aNewSolids are draft solids that
|
||||||
|
// do not contain any internal shapes
|
||||||
|
//
|
||||||
|
myAreas.Append(aNewSolids);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PerformInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_BuilderSolid::PerformInternalShapes()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer aNbFI=myLoopsInternal.Extent();
|
||||||
|
if (!aNbFI) {// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_MapOfShape aMF, aMFP;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItMF;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
TopTools_ListOfShape aLSI;
|
||||||
|
//
|
||||||
|
// 1. All internal faces
|
||||||
|
aShellIt.Initialize(myLoopsInternal);
|
||||||
|
for (; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
const TopoDS_Shape& aShell=aShellIt.Value();
|
||||||
|
aIt.Initialize(aShell);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
aMF.Add(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aNbFI=aMF.Extent();
|
||||||
|
//
|
||||||
|
// 2 Process solids
|
||||||
|
aSolidIt.Initialize(myAreas);
|
||||||
|
for ( ; aSolidIt.More(); aSolidIt.Next()) {
|
||||||
|
TopoDS_Solid& aSolid=*((TopoDS_Solid*)(&aSolidIt.Value()));
|
||||||
|
//
|
||||||
|
aMEF.Clear();
|
||||||
|
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
//
|
||||||
|
// 2.1 Separate faces to process aMFP
|
||||||
|
aMFP.Clear();
|
||||||
|
aItMF.Initialize(aMF);
|
||||||
|
for (; aItMF.More(); aItMF.Next()) {
|
||||||
|
const TopoDS_Face& aF=*((TopoDS_Face*)(&aItMF.Key()));
|
||||||
|
if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) {
|
||||||
|
aMFP.Add(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2.2 Make Internal Shells
|
||||||
|
aLSI.Clear();
|
||||||
|
MakeInternalShells(aMFP, aLSI);
|
||||||
|
//
|
||||||
|
// 2.3 Add them to aSolid
|
||||||
|
aShellIt.Initialize(aLSI);
|
||||||
|
for (; aShellIt.More(); aShellIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSI=aShellIt.Value();
|
||||||
|
aBB.Add (aSolid, aSI);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2.4 Remove faces aMFP from aMF
|
||||||
|
aItMF.Initialize(aMFP);
|
||||||
|
for (; aItMF.More(); aItMF.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItMF.Key();
|
||||||
|
aMF.Remove(aF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbFI=aMF.Extent();
|
||||||
|
if (!aNbFI) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} //for ( ; aSolidIt.More(); aSolidIt.Next()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : MakeInternalShells
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void MakeInternalShells(const TopTools_MapOfShape& theMF,
|
||||||
|
TopTools_ListOfShape& theShells)
|
||||||
|
{
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItM;
|
||||||
|
TopTools_MapOfShape aAddedFacesMap;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItF;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
aItM.Initialize(theMF);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItM.Key();
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItM.Initialize(theMF);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
TopoDS_Shape aFF=aItM.Key();
|
||||||
|
if (!aAddedFacesMap.Add(aFF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make a new shell
|
||||||
|
TopoDS_Shell aShell;
|
||||||
|
aBB.MakeShell(aShell);
|
||||||
|
aFF.Orientation(TopAbs_INTERNAL);
|
||||||
|
aBB.Add(aShell, aFF);
|
||||||
|
//
|
||||||
|
TopoDS_Iterator aItAddedF (aShell);
|
||||||
|
for (; aItAddedF.More(); aItAddedF.Next()) {
|
||||||
|
const TopoDS_Shape& aF =aItAddedF.Value();
|
||||||
|
//
|
||||||
|
TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
|
||||||
|
for (; aEdgeExp.More(); aEdgeExp.Next()) {
|
||||||
|
const TopoDS_Shape& aE =aEdgeExp.Current();
|
||||||
|
const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
|
||||||
|
aItF.Initialize(aLF);
|
||||||
|
for (; aItF.More(); aItF.Next()) {
|
||||||
|
TopoDS_Shape aFL=aItF.Value();
|
||||||
|
if (aAddedFacesMap.Add(aFL)){
|
||||||
|
aFL.Orientation(TopAbs_INTERNAL);
|
||||||
|
aBB.Add(aShell, aFL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theShells.Append(aShell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsHole
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsHole(const TopoDS_Shape& theS2,
|
||||||
|
const Handle(IntTools_Context)& theContext)
|
||||||
|
{
|
||||||
|
TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
|
||||||
|
BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
|
||||||
|
//
|
||||||
|
aClsf.PerformInfinitePoint(::RealSmall());
|
||||||
|
//
|
||||||
|
return (aClsf.State()==TopAbs_IN);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsInside
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsInside(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2,
|
||||||
|
const Handle(IntTools_Context)& theContext)
|
||||||
|
{
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
TopAbs_State aState;
|
||||||
|
//
|
||||||
|
TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
|
||||||
|
//
|
||||||
|
aExp.Init(theS1, TopAbs_FACE);
|
||||||
|
if (!aExp.More()){
|
||||||
|
BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
|
||||||
|
aClsf.PerformInfinitePoint(::RealSmall());
|
||||||
|
aState=aClsf.State();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_IndexedMapOfShape aBounds;
|
||||||
|
const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
|
||||||
|
aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext);
|
||||||
|
}
|
||||||
|
return (aState==TopAbs_IN);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsGrowthShell
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell,
|
||||||
|
const TopTools_IndexedMapOfShape& theMHF)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
if (theMHF.Extent()) {
|
||||||
|
aIt.Initialize(theShell);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (theMHF.Contains(aF)) {
|
||||||
|
return !bRet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsClosedShell
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell)
|
||||||
|
{
|
||||||
|
Standard_Integer aNbE;
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
TopTools_MapOfShape aM;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
aIt.Initialize(theShell);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aIt.Value());
|
||||||
|
aExp.Init(aF, TopAbs_EDGE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current()));
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aE.Orientation()==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!aM.Add(aE)) {
|
||||||
|
aM.Remove(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbE=aM.Extent();
|
||||||
|
if (!aNbE) {
|
||||||
|
bRet=!bRet;
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : RefineShell
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean RefineShell(const TopoDS_Shell& aShell,
|
||||||
|
TopoDS_Shell& aShx)
|
||||||
|
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
Standard_Integer i, aNbE, aNbF;
|
||||||
|
TopAbs_Orientation aOrE;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
TopTools_MapOfOrientedShape aMFx;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
//
|
||||||
|
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
aNbE=aMEF.Extent();
|
||||||
|
for (i=1; i<=aNbE; ++i) {
|
||||||
|
const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
|
||||||
|
//
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aOrE=aE.Orientation();
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLF=aMEF(i);
|
||||||
|
aNbF=aLF.Extent();
|
||||||
|
if (!aNbF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
|
||||||
|
if (aNbF==1) {
|
||||||
|
if (aOrE==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
aMFx.Add(aF1);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else if (aNbF==2) {
|
||||||
|
const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
|
||||||
|
if (aF2.IsSame(aF1)) {
|
||||||
|
if (BRep_Tool::IsClosed(aE, aF1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aOrE==TopAbs_INTERNAL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
aMFx.Add(aF1);
|
||||||
|
aMFx.Add(aF2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbF=aMFx.Extent();
|
||||||
|
if (!aNbF) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
aNbF=0;
|
||||||
|
aBB.MakeShell(aShx);
|
||||||
|
aIt.Initialize(aShell);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (!aMFx.Contains(aF)) {
|
||||||
|
aBB.Add(aShx, aF);
|
||||||
|
++aNbF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aNbF) {
|
||||||
|
bRet=IsClosedShell(aShx);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// ErrorStatus :
|
||||||
|
// 11 - Null Context
|
77
src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.hxx
Normal file
77
src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.hxx
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderSolid.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_BuilderSolid_HeaderFile
|
||||||
|
#define _GEOMAlgo_BuilderSolid_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderArea.hxx>
|
||||||
|
|
||||||
|
//! The algorithm to build solids from set of faces <br>
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_BuilderSolid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_BuilderSolid : public GEOMAlgo_BuilderArea
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Empty constructor <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_BuilderSolid();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_BuilderSolid();
|
||||||
|
|
||||||
|
//! Performs the algorithm <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Collect the faces that <br>
|
||||||
|
//! a) are internal <br>
|
||||||
|
//! b) are the same and have different orientation <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformShapesToAvoid() ;
|
||||||
|
|
||||||
|
//! Build draft shells <br>
|
||||||
|
//! a)myLoops - draft shells that consist of <br>
|
||||||
|
//! boundary faces <br>
|
||||||
|
//! b)myLoopsInternal - draft shells that contains <br>
|
||||||
|
//! inner faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformLoops() ;
|
||||||
|
|
||||||
|
//! Build draft solids that contains boundary faces <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformAreas() ;
|
||||||
|
|
||||||
|
//! Build finalized solids with internal shells <br>
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void PerformInternalShapes() ;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
291
src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.cxx
Normal file
291
src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.cxx
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderTools.cxx
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_BuilderTools.hxx>
|
||||||
|
|
||||||
|
#include <Basics_OCCTVersion.hxx>
|
||||||
|
|
||||||
|
#include <TColStd_Array1OfReal.hxx>
|
||||||
|
|
||||||
|
#include <gp_Pnt2d.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
#include <gp_Dir.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
|
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
|
#include <Poly_Array1OfTriangle.hxx>
|
||||||
|
#include <Poly_Triangle.hxx>
|
||||||
|
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#include <Geom2dInt_Geom2dCurveTool.hxx>
|
||||||
|
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#include <TopAbs_Orientation.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <BRepMesh_FastDiscret.hxx>
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRepAdaptor_Curve2d.hxx>
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Integer ComputeProps(const TopoDS_Face& aF,
|
||||||
|
Standard_Real& aA,
|
||||||
|
Standard_Real& aV);
|
||||||
|
static
|
||||||
|
void BuildTriangulation(const TopoDS_Face& aF);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsHole
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderTools::IsHole(const TopoDS_Shape& aW,
|
||||||
|
const TopoDS_Shape& aFace)
|
||||||
|
{
|
||||||
|
Standard_Boolean bIsHole;
|
||||||
|
Standard_Integer i, aNbS;
|
||||||
|
Standard_Real aT1, aT2, aS;
|
||||||
|
Standard_Real aU1, aU2, aU, dU;
|
||||||
|
Standard_Real aX1, aY1, aX0, aY0;
|
||||||
|
TopAbs_Orientation aOr;
|
||||||
|
|
||||||
|
gp_Pnt2d aP2D0, aP2D1;
|
||||||
|
Handle(Geom2d_Curve) aC2D;
|
||||||
|
TopoDS_Face aF, aFF;
|
||||||
|
TopoDS_Iterator aItW;
|
||||||
|
//
|
||||||
|
bIsHole=Standard_False;
|
||||||
|
//
|
||||||
|
aF=TopoDS::Face(aFace);
|
||||||
|
aFF=aF;
|
||||||
|
aFF.Orientation(TopAbs_FORWARD);
|
||||||
|
//
|
||||||
|
aS=0.;
|
||||||
|
aItW.Initialize(aW);
|
||||||
|
for (; aItW.More(); aItW.Next()) {
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value());
|
||||||
|
aOr=aE.Orientation();
|
||||||
|
if (!(aOr==TopAbs_FORWARD ||
|
||||||
|
aOr==TopAbs_REVERSED)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aC2D=BRep_Tool::CurveOnSurface(aE, aFF, aT1, aT2);
|
||||||
|
if (aC2D.IsNull()) {
|
||||||
|
break; //xx
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRepAdaptor_Curve2d aBAC2D(aE, aFF);
|
||||||
|
aNbS=Geom2dInt_Geom2dCurveTool::NbSamples(aBAC2D);
|
||||||
|
if (aNbS>2) {
|
||||||
|
aNbS*=4;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
dU=(aT2-aT1)/(Standard_Real)(aNbS-1);
|
||||||
|
aU =aT1;
|
||||||
|
aU1=aT1;
|
||||||
|
aU2=aT2;
|
||||||
|
if (aOr==TopAbs_REVERSED) {
|
||||||
|
aU =aT2;
|
||||||
|
aU1=aT2;
|
||||||
|
aU2=aT1;
|
||||||
|
dU=-dU;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aC2D->D0(aU, aP2D0);
|
||||||
|
for(i=2; i<=aNbS; i++) {
|
||||||
|
aU=aU1+(i-1)*dU;
|
||||||
|
aC2D->D0(aU, aP2D1);
|
||||||
|
aP2D0.Coord(aX0, aY0);
|
||||||
|
aP2D1.Coord(aX1, aY1);
|
||||||
|
//
|
||||||
|
aS=aS+(aY0+aY1)*(aX1-aX0);
|
||||||
|
//
|
||||||
|
aP2D0=aP2D1;
|
||||||
|
}
|
||||||
|
}//for (; aItW.More(); aItW.Next()) {
|
||||||
|
bIsHole=(aS>0.);
|
||||||
|
return bIsHole;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsHole
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_BuilderTools::IsHole(const TopoDS_Shape& aShell)
|
||||||
|
{
|
||||||
|
Standard_Boolean bIsHole;
|
||||||
|
Standard_Integer iRet;
|
||||||
|
Standard_Real aAi, aA, aV, aVi;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
//
|
||||||
|
aA=0.;
|
||||||
|
aV=0.;
|
||||||
|
aExp.Init(aShell, TopAbs_FACE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aExp.Current());
|
||||||
|
iRet=ComputeProps(aF, aAi, aVi);
|
||||||
|
if (!iRet) {
|
||||||
|
aA+=aAi;
|
||||||
|
aV+=aVi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsHole=aV<0.;
|
||||||
|
return bIsHole;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ComputeProps
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer ComputeProps(const TopoDS_Face& aF,
|
||||||
|
Standard_Real& aA,
|
||||||
|
Standard_Real& aV)
|
||||||
|
{
|
||||||
|
Standard_Integer j, i, i1, i2, aNbNodes, aNbTrigs, n[3];
|
||||||
|
Standard_Real aAi, aVi;
|
||||||
|
gp_Pnt aP[3], aGC, aGC1;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
TopAbs_Orientation aOr;
|
||||||
|
Handle(Poly_Triangulation) aTri;
|
||||||
|
//
|
||||||
|
aA=0.;
|
||||||
|
aV=0.;
|
||||||
|
//
|
||||||
|
aTri=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
if(aTri.IsNull()) {
|
||||||
|
BuildTriangulation(aF);
|
||||||
|
aTri=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
if(aTri.IsNull()) {
|
||||||
|
return 1;// a face is without triangulation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbNodes=aTri->NbNodes();
|
||||||
|
aNbTrigs=aTri->NbTriangles();
|
||||||
|
if (!aNbTrigs){
|
||||||
|
return 2;//no triangles
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aOr=aF.Orientation();
|
||||||
|
//
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aTri->Nodes();
|
||||||
|
const Poly_Array1OfTriangle& aTriangles=aTri->Triangles();
|
||||||
|
//
|
||||||
|
i1=aTriangles.Lower();
|
||||||
|
i2=aTriangles.Upper();
|
||||||
|
//
|
||||||
|
for (i=i1; i<=i2; ++i){
|
||||||
|
const Poly_Triangle& aTriangle=aTriangles.Value(i);
|
||||||
|
aTriangle.Get(n[0], n[1], n[2]);
|
||||||
|
aGC.SetCoord(0.,0.,0.);
|
||||||
|
for (j=0; j<3; ++j) {
|
||||||
|
aP[j]=aNodes.Value(n[j]);
|
||||||
|
aGC.ChangeCoord()+=aP[j].XYZ();
|
||||||
|
}
|
||||||
|
aGC.ChangeCoord()*=0.333333333333;
|
||||||
|
//
|
||||||
|
// Normal
|
||||||
|
gp_Vec aV01(aP[0], aP[1]);
|
||||||
|
gp_Vec aV12(aP[1], aP[2]);
|
||||||
|
gp_Vec aVN=aV01^aV12;
|
||||||
|
aAi=aVN.Magnitude();
|
||||||
|
aA=aA+aAi;
|
||||||
|
//
|
||||||
|
if (aAi>0.0000001) {
|
||||||
|
Standard_Real aSx, aZx;
|
||||||
|
gp_Dir aDN(aVN);
|
||||||
|
if (aOr==TopAbs_REVERSED) {
|
||||||
|
aDN.Reverse();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSx=aAi*aDN.Z();
|
||||||
|
aZx=aGC.Z();
|
||||||
|
aVi=aZx*aSx;
|
||||||
|
aV=aV+aVi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : BuildTriangulation
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void BuildTriangulation(const TopoDS_Face& aF)
|
||||||
|
{
|
||||||
|
Standard_Boolean bWithShare;
|
||||||
|
Standard_Real aDiscret, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
Standard_Real dX, dY, dZ, dMax, aCoeff, aAngle;
|
||||||
|
Bnd_Box aBox;
|
||||||
|
//
|
||||||
|
bWithShare=Standard_False;
|
||||||
|
aAngle=0.5;
|
||||||
|
//
|
||||||
|
BRepBndLib::Add(aF, aBox);
|
||||||
|
//
|
||||||
|
// aDiscret
|
||||||
|
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
dX=aXmax-aXmin;
|
||||||
|
dY=aYmax-aYmin;
|
||||||
|
dZ=aZmax-aZmin;
|
||||||
|
dMax=dX;
|
||||||
|
if (dY>dMax) {
|
||||||
|
dMax=dY;
|
||||||
|
}
|
||||||
|
if (dZ>dMax) {
|
||||||
|
dMax=dZ;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aCoeff=0.1;
|
||||||
|
aDiscret=aCoeff*dMax;
|
||||||
|
//
|
||||||
|
BRepMesh_FastDiscret aMesher(aDiscret,
|
||||||
|
aAngle,
|
||||||
|
aBox,
|
||||||
|
bWithShare,
|
||||||
|
Standard_True,
|
||||||
|
Standard_False,
|
||||||
|
Standard_True);
|
||||||
|
|
||||||
|
#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape anAncestors;
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, anAncestors);
|
||||||
|
aMesher.Add(aF, anAncestors);
|
||||||
|
#else
|
||||||
|
aMesher.Add(aF);
|
||||||
|
#endif
|
||||||
|
}
|
47
src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.hxx
Normal file
47
src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.hxx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_BuilderTools.hxx
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_BuilderTools_HeaderFile
|
||||||
|
#define _GEOMAlgo_BuilderTools_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_BuilderTools
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_BuilderTools
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
static Standard_Boolean IsHole(const TopoDS_Shape& aW,
|
||||||
|
const TopoDS_Shape& aF) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
static Standard_Boolean IsHole(const TopoDS_Shape& aShell) ;
|
||||||
|
};
|
||||||
|
#endif
|
64
src/GEOMAlgo_NEW/GEOMAlgo_Builder_0.cxx
Normal file
64
src/GEOMAlgo_NEW/GEOMAlgo_Builder_0.cxx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 <GEOMAlgo_Builder.hxx>
|
||||||
|
|
||||||
|
#include <NMTDS_ShapesDataStructure.hxx>
|
||||||
|
//#include <NMTTools_DSFiller.hxx>
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <BOPTools_ListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_PaveBlock.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shapes1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes1(const Standard_Integer theType)const
|
||||||
|
{
|
||||||
|
return myShapes1[theType];
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Images
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const BRepAlgo_Image& GEOMAlgo_Builder::Images()const
|
||||||
|
{
|
||||||
|
return myImages;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : InParts
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_Builder::InParts(const TopoDS_Shape& theS)const
|
||||||
|
{
|
||||||
|
static TopTools_ListOfShape sLS;
|
||||||
|
//
|
||||||
|
if (myInParts.Contains(theS)) {
|
||||||
|
return myInParts.FindFromKey(theS);
|
||||||
|
}
|
||||||
|
return sLS;
|
||||||
|
}
|
360
src/GEOMAlgo_NEW/GEOMAlgo_Builder_1.cxx
Normal file
360
src/GEOMAlgo_NEW/GEOMAlgo_Builder_1.cxx
Normal file
@ -0,0 +1,360 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Builder_1.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Builder.hxx>
|
||||||
|
//
|
||||||
|
#include <TColStd_ListOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
//
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
//
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
//
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_ListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_PaveBlock.hxx>
|
||||||
|
//
|
||||||
|
#include <NMTDS_ShapesDataStructure.hxx>
|
||||||
|
//
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
#include <NMTTools_CommonBlockPool.hxx>
|
||||||
|
#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
|
||||||
|
#include <NMTTools_CommonBlock.hxx>
|
||||||
|
#include <NMTTools_CommonBlockPool.hxx>
|
||||||
|
#include <NMTTools_ListOfCommonBlock.hxx>
|
||||||
|
#include <NMTTools_CommonBlockAPI.hxx>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
void FillImagesCompounds(const TopTools_MapOfShape& ,
|
||||||
|
BRepAlgo_Image& );
|
||||||
|
|
||||||
|
static
|
||||||
|
void FillImagesCompound(const TopoDS_Shape& ,
|
||||||
|
BRepAlgo_Image& ,
|
||||||
|
TopTools_MapOfShape& );
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FillImagesVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesVertices()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
//
|
||||||
|
Standard_Integer i, aNb, iV;
|
||||||
|
//
|
||||||
|
aNb=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aV=aDS.Shape(i);
|
||||||
|
if (aV.ShapeType()==TopAbs_VERTEX) {
|
||||||
|
iV=pPF->FindSDVertex(i);
|
||||||
|
if (iV) {
|
||||||
|
const TopoDS_Shape& aVSD=aDS.Shape(iV);
|
||||||
|
if (!myImages.HasImage(aV)) {
|
||||||
|
myImages.Bind(aV, aVSD);
|
||||||
|
//
|
||||||
|
mySameDomainShapes.Add(aV, aVSD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillImagesEdges
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesEdges()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool();
|
||||||
|
const Handle(IntTools_Context)& aCtx=pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bToReverse;
|
||||||
|
Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB, aNbLB;
|
||||||
|
TColStd_ListIteratorOfListOfInteger aItLB;
|
||||||
|
TColStd_ListOfInteger aLB;
|
||||||
|
TopoDS_Edge aEE, aESpR;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListOfShape aLSp;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt1;
|
||||||
|
BOPTools_ListIteratorOfListOfPaveBlock aIt;
|
||||||
|
//
|
||||||
|
aNb=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aE=aDS.Shape(i);
|
||||||
|
if (aE.ShapeType()!=TopAbs_EDGE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!aMFence.Add(aE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(i));
|
||||||
|
aNbSp=aLPB.Extent();
|
||||||
|
if (!aNbSp) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aEE=TopoDS::Edge(aE);
|
||||||
|
aLSp.Clear();
|
||||||
|
//
|
||||||
|
if (aNbSp==1) {
|
||||||
|
const BOPTools_PaveBlock& aPB=aLPB.First();
|
||||||
|
nSp=aPB.Edge();
|
||||||
|
const TopoDS_Shape& aSp=aDS.Shape(nSp);
|
||||||
|
//
|
||||||
|
const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB);
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 11:19:30 2010f
|
||||||
|
aNbLB=aLB.Extent();
|
||||||
|
if (aIsCB && aNbLB<2) {
|
||||||
|
aIsCB=0;
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 11:19:34 2010t
|
||||||
|
//
|
||||||
|
nSpR=aPBR.Edge();
|
||||||
|
const TopoDS_Shape& aSpR=aDS.Shape(nSpR);
|
||||||
|
if (aSpR.IsSame(aSp) && aSpR.IsSame(aE) && !aIsCB) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aESpR=TopoDS::Edge(aSpR);
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aESpR.Reverse();
|
||||||
|
}
|
||||||
|
aLSp.Append(aESpR);
|
||||||
|
//
|
||||||
|
aItLB.Initialize(aLB);
|
||||||
|
for (; aItLB.More(); aItLB.Next()) {
|
||||||
|
nSpx=aItLB.Value();
|
||||||
|
const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
|
||||||
|
mySameDomainShapes.Add(aSpx ,aSpR);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
}// if (aNbSp==1) {
|
||||||
|
else {
|
||||||
|
aIt.Initialize(aLPB);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const BOPTools_PaveBlock& aPB=aIt.Value();
|
||||||
|
const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB);
|
||||||
|
nSpR=aPBR.Edge();
|
||||||
|
const TopoDS_Shape& aSpR=aDS.Shape(nSpR);
|
||||||
|
//
|
||||||
|
aESpR=TopoDS::Edge(aSpR);
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aESpR.Reverse();
|
||||||
|
}
|
||||||
|
aLSp.Append(aESpR);
|
||||||
|
//
|
||||||
|
aItLB.Initialize(aLB);
|
||||||
|
for (; aItLB.More(); aItLB.Next()) {
|
||||||
|
nSpx=aItLB.Value();
|
||||||
|
const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
|
||||||
|
mySameDomainShapes.Add(aSpx ,aSpR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myImages.Bind(aE, aLSp);
|
||||||
|
|
||||||
|
}//for (i=1; i<=aNb; ++i)
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillImagesContainers
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesContainers(const TopAbs_ShapeEnum theType)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bInterferred, bToReverse;
|
||||||
|
Standard_Integer i, aNbS;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItIm;
|
||||||
|
TopTools_MapOfShape aMS;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItS;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
const TopoDS_Shape& aC=aDS.Shape(i);
|
||||||
|
aType=aC.ShapeType();
|
||||||
|
if (aType==theType) {
|
||||||
|
aMS.Add(aC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (theType==TopAbs_COMPOUND) {
|
||||||
|
FillImagesCompounds(aMS, myImages);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItS.Initialize(aMS);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aC=aItS.Key();
|
||||||
|
// whether the shape has image
|
||||||
|
bInterferred=Standard_False;
|
||||||
|
aIt.Initialize(aC);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (myImages.HasImage(aF)) {
|
||||||
|
bInterferred=!bInterferred;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bInterferred){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopoDS_Shape aCIm;
|
||||||
|
GEOMAlgo_Tools3D::MakeContainer(theType, aCIm);
|
||||||
|
//
|
||||||
|
aIt.Initialize(aC);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt.Value();
|
||||||
|
if (myImages.HasImage(aF)) {
|
||||||
|
const TopTools_ListOfShape& aLFIm=myImages.Image(aF);
|
||||||
|
aItIm.Initialize(aLFIm);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
TopoDS_Shape aFIm=aItIm.Value();
|
||||||
|
//
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFIm, aF, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aFIm.Reverse();
|
||||||
|
}
|
||||||
|
aBB.Add(aCIm, aFIm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aBB.Add(aCIm, aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myImages.Bind(aC, aCIm);
|
||||||
|
}// for (; aItS.More(); aItS.Next()) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillImagesCompounds
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void FillImagesCompounds(const TopTools_MapOfShape& theMS,
|
||||||
|
BRepAlgo_Image& theImages)
|
||||||
|
{
|
||||||
|
TopTools_MapOfShape aMFP;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItS;
|
||||||
|
//
|
||||||
|
aItS.Initialize(theMS);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aC=aItS.Key();
|
||||||
|
FillImagesCompound(aC, theImages, aMFP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : FillImagesCompound
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void FillImagesCompound(const TopoDS_Shape& theS,
|
||||||
|
BRepAlgo_Image& theImages,
|
||||||
|
TopTools_MapOfShape& theMFP)
|
||||||
|
{
|
||||||
|
Standard_Boolean bInterferred;
|
||||||
|
TopAbs_ShapeEnum aTypeX;
|
||||||
|
TopAbs_Orientation aOrX;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItIm;
|
||||||
|
//
|
||||||
|
if (!theMFP.Add(theS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bInterferred=Standard_False;
|
||||||
|
aIt.Initialize(theS);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSX=aIt.Value();
|
||||||
|
aTypeX=aSX.ShapeType();
|
||||||
|
if (aTypeX==TopAbs_COMPOUND) {
|
||||||
|
FillImagesCompound(aSX, theImages, theMFP);
|
||||||
|
}
|
||||||
|
if (theImages.HasImage(aSX)) {
|
||||||
|
bInterferred=Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bInterferred){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopoDS_Shape aCIm;
|
||||||
|
GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCIm);
|
||||||
|
//
|
||||||
|
aIt.Initialize(theS);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSX=aIt.Value();
|
||||||
|
aOrX=aSX.Orientation();
|
||||||
|
if (theImages.HasImage(aSX)) {
|
||||||
|
const TopTools_ListOfShape& aLFIm=theImages.Image(aSX);
|
||||||
|
aItIm.Initialize(aLFIm);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
TopoDS_Shape aSXIm=aItIm.Value();
|
||||||
|
aSXIm.Orientation(aOrX);
|
||||||
|
aBB.Add(aCIm, aSXIm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aBB.Add(aCIm, aSX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theImages.Bind(theS, aCIm);
|
||||||
|
}
|
947
src/GEOMAlgo_NEW/GEOMAlgo_Builder_2.cxx
Normal file
947
src/GEOMAlgo_NEW/GEOMAlgo_Builder_2.cxx
Normal file
@ -0,0 +1,947 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Builder_2.cxx
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||||
|
#include <TColStd_ListOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_Orientation.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepAlgo_Image.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
#include <IntTools_FClass2d.hxx>
|
||||||
|
|
||||||
|
#include <BooleanOperations_OnceExplorer.hxx>
|
||||||
|
#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
|
||||||
|
#include <BOPTools_ListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_CArray1OfSSInterference.hxx>
|
||||||
|
#include <BOPTools_SSInterference.hxx>
|
||||||
|
#include <BOPTools_SequenceOfCurves.hxx>
|
||||||
|
#include <BOPTools_Curve.hxx>
|
||||||
|
#include <BOPTools_ListOfPaveBlock.hxx>
|
||||||
|
#include <BOPTools_PaveBlock.hxx>
|
||||||
|
#include <BOPTools_Tools3D.hxx>
|
||||||
|
#include <BOPTools_CArray1OfVSInterference.hxx>
|
||||||
|
#include <BOPTools_VSInterference.hxx>
|
||||||
|
#include <BOPTools_ESInterference.hxx>
|
||||||
|
#include <BOPTools_CArray1OfESInterference.hxx>
|
||||||
|
|
||||||
|
#include <NMTDS_ShapesDataStructure.hxx>
|
||||||
|
#include <NMTDS_InterfPool.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
#include <NMTTools_ListOfCoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_Tools.hxx>
|
||||||
|
#include <NMTTools_CoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
|
||||||
|
#include <NMTTools_Tools.hxx>
|
||||||
|
#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
|
||||||
|
#include <NMTTools_ListOfCommonBlock.hxx>
|
||||||
|
#include <NMTTools_CommonBlock.hxx>
|
||||||
|
#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
#include <GEOMAlgo_WireEdgeSet.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderFace.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_ShapeSet.hxx>
|
||||||
|
//
|
||||||
|
#include <NMTDS_BoxBndTree.hxx>
|
||||||
|
#include <NCollection_UBTreeFiller.hxx>
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <TopTools_DataMapOfIntegerShape.hxx>
|
||||||
|
#include <TColStd_ListOfInteger.hxx>
|
||||||
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeInteger.hxx>
|
||||||
|
|
||||||
|
static
|
||||||
|
void UpdateCandidates(const Standard_Integer ,
|
||||||
|
const Standard_Integer ,
|
||||||
|
NMTTools_IndexedDataMapOfIndexedMapOfInteger& );
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FillImagesFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesFaces()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
FillIn2DParts();
|
||||||
|
BuildSplitFaces();
|
||||||
|
FillSameDomainFaces();
|
||||||
|
FillImagesFaces1();
|
||||||
|
FillInternalVertices();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillIn2DParts
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillIn2DParts()
|
||||||
|
{
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
NMTDS_InterfPool* pIP=pPF->IP();
|
||||||
|
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
|
||||||
|
NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool();
|
||||||
|
//
|
||||||
|
Standard_Integer j, nSpIn, nSpSc, aNbCurves;
|
||||||
|
Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListOfShape aLSpIn;
|
||||||
|
TopoDS_Face aF;
|
||||||
|
NMTTools_ListIteratorOfListOfCommonBlock aItCB;
|
||||||
|
BOPTools_ListIteratorOfListOfPaveBlock aItPB;
|
||||||
|
//
|
||||||
|
myInParts.Clear();
|
||||||
|
//
|
||||||
|
aNbFFs=aFFs.Extent();
|
||||||
|
aNbCBP=aCBP.Extent();
|
||||||
|
//
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (nF=1; nF<=aNbS; ++nF) {
|
||||||
|
if (aDS.GetShapeType(nF)!=TopAbs_FACE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aF=TopoDS::Face(aDS.Shape(nF));
|
||||||
|
//
|
||||||
|
aMFence.Clear();
|
||||||
|
aLSpIn.Clear();
|
||||||
|
//
|
||||||
|
// 1. In Parts
|
||||||
|
BOPTools_ListOfPaveBlock aLPBIn;
|
||||||
|
//
|
||||||
|
pPF->RealSplitsInFace(nF, aLPBIn);
|
||||||
|
//
|
||||||
|
aItPB.Initialize(aLPBIn);
|
||||||
|
for (; aItPB.More(); aItPB.Next()) {
|
||||||
|
const BOPTools_PaveBlock& aPB1=aItPB.Value();
|
||||||
|
nSpIn=aPB1.Edge();
|
||||||
|
const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
|
||||||
|
aLSpIn.Append(aSpIn);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Section Parts
|
||||||
|
for (j=1; j<=aNbFFs; ++j) {
|
||||||
|
BOPTools_SSInterference& aFF=aFFs(j);
|
||||||
|
aFF.Indices(n1, n2);
|
||||||
|
if (!(n1==nF || n2==nF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BOPTools_SequenceOfCurves& aSC=aFF.Curves();
|
||||||
|
aNbCurves=aSC.Length();
|
||||||
|
if (!aNbCurves) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const BOPTools_Curve& aBC=aSC(1);
|
||||||
|
const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
|
||||||
|
aItPB.Initialize(aLPB);
|
||||||
|
for (; aItPB.More(); aItPB.Next()) {
|
||||||
|
const BOPTools_PaveBlock& aPBSc=aItPB.Value();
|
||||||
|
nSpSc=aPBSc.Edge();
|
||||||
|
const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
|
||||||
|
if (aMFence.Add(aSpSc)){
|
||||||
|
aLSpIn.Append(aSpSc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aNbSpIn=aLSpIn.Extent();
|
||||||
|
if (aNbSpIn) {
|
||||||
|
myInParts.Add(aF, aLSpIn);
|
||||||
|
}
|
||||||
|
}//for (nF=1; nF<=aNbS; ++nF) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: BuildSplitFaces
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::BuildSplitFaces()
|
||||||
|
{
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
NMTDS_InterfPool* pIP=pPF->IP();
|
||||||
|
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
|
||||||
|
Standard_Integer i, aNb, aNbF, nF;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TColStd_IndexedMapOfInteger aMFP;
|
||||||
|
TopExp_Explorer anExp;
|
||||||
|
TopoDS_Face aFF;
|
||||||
|
TopoDS_Edge aSp, aEE;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
TopAbs_Orientation anOriF, anOriE;
|
||||||
|
//
|
||||||
|
mySplitFaces.Clear();
|
||||||
|
//
|
||||||
|
// 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.Add(aF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myInParts.Contains(aF)) {
|
||||||
|
aMFP.Add(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
anExp.Init(aF, TopAbs_EDGE);
|
||||||
|
for (; anExp.More(); anExp.Next()) {
|
||||||
|
const TopoDS_Shape& aE=anExp.Current();
|
||||||
|
if (myImages.HasImage(aE)) {
|
||||||
|
aMFP.Add(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//===
|
||||||
|
{
|
||||||
|
Standard_Integer aNbFFs, aNbSE, j, n1, n2;
|
||||||
|
//
|
||||||
|
aNbFFs=aFFs.Extent();
|
||||||
|
for (j=1; j<=aNbFFs; ++j) {
|
||||||
|
BOPTools_SSInterference& aFFj=aFFs(j);
|
||||||
|
aFFj.Indices(n1, n2);
|
||||||
|
if (!(n1==i || n2==i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges();
|
||||||
|
aNbSE=aLSE.Extent();
|
||||||
|
if (aNbSE) {
|
||||||
|
aMFP.Add(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//===
|
||||||
|
//
|
||||||
|
}// for (i=1; i<=aNb; ++i)
|
||||||
|
//
|
||||||
|
// 2. ProcessFaces
|
||||||
|
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
|
||||||
|
GEOMAlgo_WireEdgeSet aWES;
|
||||||
|
aWES.SetFace(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());
|
||||||
|
anOriE=aE.Orientation();
|
||||||
|
//
|
||||||
|
if (!myImages.HasImage(aE)) {
|
||||||
|
if (anOriE==TopAbs_INTERNAL) {
|
||||||
|
aEE=aE;
|
||||||
|
aEE.Orientation(TopAbs_FORWARD);
|
||||||
|
aWES.AddStartElement(aEE);
|
||||||
|
aEE.Orientation(TopAbs_REVERSED);
|
||||||
|
aWES.AddStartElement(aEE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aWES.AddStartElement(aE);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsDegenerated=BRep_Tool::Degenerated(aE);
|
||||||
|
bIsClosed=BRep_Tool::IsClosed(aE, aF);
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLIE=myImages.Image(aE);
|
||||||
|
aIt.Initialize(aLIE);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
aSp=TopoDS::Edge(aIt.Value());
|
||||||
|
//
|
||||||
|
if (bIsDegenerated) {
|
||||||
|
aSp.Orientation(anOriE);
|
||||||
|
aWES.AddStartElement(aSp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (anOriE==TopAbs_INTERNAL) {
|
||||||
|
aSp.Orientation(TopAbs_FORWARD);
|
||||||
|
aWES.AddStartElement(aSp);
|
||||||
|
aSp.Orientation(TopAbs_REVERSED);
|
||||||
|
aWES.AddStartElement(aSp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (bIsClosed){
|
||||||
|
if (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;
|
||||||
|
}// if (aMFence.Add(aSp))
|
||||||
|
//
|
||||||
|
aSp.Orientation(anOriE);
|
||||||
|
bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aSp.Reverse();
|
||||||
|
}
|
||||||
|
aWES.AddStartElement(aSp);
|
||||||
|
}// for (; aIt.More(); aIt.Next()) {
|
||||||
|
}// for (; anExp.More(); anExp.Next()) {
|
||||||
|
//
|
||||||
|
// 2.1.2. Add In2D Parts
|
||||||
|
if (myInParts.Contains(aF)) {
|
||||||
|
const TopTools_ListOfShape& aLE=myInParts.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
|
||||||
|
TopTools_ListOfShape aLFR;
|
||||||
|
GEOMAlgo_ShapeSet aS1, aS2;
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aSE=aWES.StartElements();
|
||||||
|
aS1.Add(aSE);
|
||||||
|
aS2.Add(aFF, TopAbs_EDGE);
|
||||||
|
if (aS1.IsEqual(aS2)) {
|
||||||
|
aLFR.Append(aF);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GEOMAlgo_BuilderFace aBF;
|
||||||
|
//
|
||||||
|
aBF.SetFace(aFF);
|
||||||
|
aBF.SetContext(aCtx);
|
||||||
|
aBF.SetShapes(aSE);
|
||||||
|
// <-DEB
|
||||||
|
aBF.Perform();
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLF=aBF.Areas();
|
||||||
|
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 draft images Faces
|
||||||
|
mySplitFaces.Bind(aF, aLFR);
|
||||||
|
}//for (i=1; i<=aNbF; ++i)
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillSameDomainFaces
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillSameDomainFaces()
|
||||||
|
{
|
||||||
|
Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward;
|
||||||
|
Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE;
|
||||||
|
Standard_Integer aNbF1, aNbF2, i2s, aNbSD;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListOfShape aLX1, aLX2;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItF1, aItF2;
|
||||||
|
NMTTools_ListOfCoupleOfShape aLCS;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
NMTDS_InterfPool* pIP=pPF->IP();
|
||||||
|
BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//mySameDomainShapes.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();
|
||||||
|
//
|
||||||
|
//===
|
||||||
|
const TColStd_ListOfInteger& aLSE=aFF.SharedEdges();
|
||||||
|
aNbSE=aLSE.Extent();
|
||||||
|
if (!aNbPBInOn && !aNbSE) {
|
||||||
|
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
|
||||||
|
aMFence.Clear();
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------
|
||||||
|
bHasImage1=mySplitFaces.HasImage(aF1);
|
||||||
|
bHasImage2=mySplitFaces.HasImage(aF2);
|
||||||
|
//
|
||||||
|
aLX1.Clear();
|
||||||
|
if (!bHasImage1) {
|
||||||
|
aLX1.Append(aF1);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aLX2.Clear();
|
||||||
|
if (!bHasImage2) {
|
||||||
|
aLX2.Append(aF2);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1;
|
||||||
|
const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2;
|
||||||
|
//
|
||||||
|
TopTools_DataMapOfIntegerShape aMIS;
|
||||||
|
TColStd_ListIteratorOfListOfInteger aItLI;
|
||||||
|
NMTDS_BoxBndTreeSelector aSelector;
|
||||||
|
NMTDS_BoxBndTree aBBTree;
|
||||||
|
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
||||||
|
//
|
||||||
|
aNbF1=aLF1r.Extent();
|
||||||
|
aNbF2=aLF2r.Extent();
|
||||||
|
bForward=(aNbF1<aNbF2);
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
|
||||||
|
const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
|
||||||
|
//
|
||||||
|
// 1. aTreeFiller
|
||||||
|
aItF2.Initialize(aLF2);
|
||||||
|
for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
|
||||||
|
Bnd_Box aBoxF2s;
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
|
||||||
|
//
|
||||||
|
BRepBndLib::Add(aF2s, aBoxF2s);
|
||||||
|
//
|
||||||
|
aMIS.Bind(i2s, aF2s);
|
||||||
|
//
|
||||||
|
aTreeFiller.Add(i2s, aBoxF2s);
|
||||||
|
}//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
|
||||||
|
//
|
||||||
|
aTreeFiller.Fill();
|
||||||
|
//
|
||||||
|
// 2.
|
||||||
|
aItF1.Initialize(aLF1);
|
||||||
|
for (j=1; aItF1.More(); aItF1.Next(), ++j) {
|
||||||
|
Bnd_Box aBoxF1x;
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
|
||||||
|
//
|
||||||
|
BRepBndLib::Add(aF1x, aBoxF1x);
|
||||||
|
//
|
||||||
|
aSelector.Clear();
|
||||||
|
aSelector.SetBox(aBoxF1x);
|
||||||
|
aNbSD=aBBTree.Select(aSelector);
|
||||||
|
if (!aNbSD) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TColStd_ListOfInteger& aLI=aSelector.Indices();
|
||||||
|
aItLI.Initialize(aLI);
|
||||||
|
for (; aItLI.More(); aItLI.Next()) {
|
||||||
|
i2s=aItLI.Value();
|
||||||
|
const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
|
||||||
|
//
|
||||||
|
bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
|
||||||
|
if (bIsSDF) {
|
||||||
|
if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
aMFence.Add(aF1x);
|
||||||
|
aMFence.Add(aF2y);
|
||||||
|
//
|
||||||
|
NMTTools_CoupleOfShape aCS;
|
||||||
|
//
|
||||||
|
aCS.SetShape1(aF1x);
|
||||||
|
aCS.SetShape2(aF2y);
|
||||||
|
aLCS.Append(aCS);
|
||||||
|
//
|
||||||
|
if (bForward) {
|
||||||
|
if (aF1x==aF1) {
|
||||||
|
if (!mySplitFaces.HasImage(aF1)) {
|
||||||
|
mySplitFaces.Bind(aF1, aF1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aF2y==aF2) {
|
||||||
|
if (!mySplitFaces.HasImage(aF2)) {
|
||||||
|
mySplitFaces.Bind(aF2, aF2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (aF1x==aF2) {
|
||||||
|
if (!mySplitFaces.HasImage(aF2)) {
|
||||||
|
mySplitFaces.Bind(aF2, aF2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aF2y==aF1) {
|
||||||
|
if (!mySplitFaces.HasImage(aF1)) {
|
||||||
|
mySplitFaces.Bind(aF1, aF1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}//if (bIsSDF) {
|
||||||
|
}//for (; aItLI.More(); aItLI.Next()) {
|
||||||
|
}//for (; aItF1.More(); aItF1.Next()) {
|
||||||
|
}//for (i=1; i<=aNbFF; ++i)
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
aNbC=aLCS.Extent();
|
||||||
|
if (!aNbC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Find Chains
|
||||||
|
NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
|
||||||
|
//
|
||||||
|
NMTTools_Tools::FindChains(aLCS, aMC);
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsImage;
|
||||||
|
Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
|
||||||
|
TopoDS_Shape aFOld, aFSDmin;
|
||||||
|
TopTools_IndexedMapOfShape aMFj;
|
||||||
|
TopTools_DataMapOfShapeInteger aDMSI;
|
||||||
|
//
|
||||||
|
aItF1.Initialize(myShapes);
|
||||||
|
for (j=1; aItF1.More(); aItF1.Next(), ++j) {
|
||||||
|
const TopoDS_Shape& aSj=aItF1.Value();
|
||||||
|
aMFj.Clear();
|
||||||
|
TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
|
||||||
|
aNbMFj=aMFj.Extent();
|
||||||
|
for (k=1; k<=aNbMFj; ++k) {
|
||||||
|
const TopoDS_Shape& aFk=aMFj(k);
|
||||||
|
if (!aDMSI.IsBound(aFk)) {
|
||||||
|
aDMSI.Bind(aFk, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 3. Fill the map of SDF mySameDomainFaces
|
||||||
|
aNbC=aMC.Extent();
|
||||||
|
for (i=1; i<=aNbC; ++i) {
|
||||||
|
// const TopoDS_Shape& aF=aMC.FindKey(i);
|
||||||
|
const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
|
||||||
|
//
|
||||||
|
aNbMSDF=aMSDF.Extent();
|
||||||
|
for (j=1; j<=aNbMSDF; ++j) {
|
||||||
|
const TopoDS_Shape& aFSD=aMSDF(j);
|
||||||
|
bIsImage=mySplitFaces.IsImage(aFSD);
|
||||||
|
aFOld=aFSD;
|
||||||
|
if (bIsImage) {
|
||||||
|
aFOld=mySplitFaces.ImageFrom(aFSD);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aIx=aDMSI.Find(aFOld);
|
||||||
|
if (j==1) {
|
||||||
|
aIxMin=aIx;
|
||||||
|
aFSDmin=aFSD;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (aIx<aIxMin) {
|
||||||
|
aIxMin=aIx;
|
||||||
|
aFSDmin=aFSD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (j=1; j<=aNbMSDF; ++j) {
|
||||||
|
const TopoDS_Shape& aFSD=aMSDF(j);
|
||||||
|
mySameDomainShapes.Add(aFSD, aFSDmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillImagesFaces1
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesFaces1()
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNb, iSense, aNbLFx;
|
||||||
|
TopoDS_Face aF, aFSp, aFSD;
|
||||||
|
TopTools_ListOfShape aLFx;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
//
|
||||||
|
aNb=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
||||||
|
if (aS.ShapeType()!=TopAbs_FACE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!mySplitFaces.HasImage(aS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aF=*((TopoDS_Face*)&aS);
|
||||||
|
//
|
||||||
|
aLFx.Clear();
|
||||||
|
const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF);
|
||||||
|
aIt.Initialize(aLF);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
aFSp=*((TopoDS_Face*)(&aIt.Value()));
|
||||||
|
if (!mySameDomainShapes.Contains(aFSp)) {
|
||||||
|
aLFx.Append(aFSp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp);
|
||||||
|
aFSD=*((TopoDS_Face*)(&aSx));
|
||||||
|
iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD);
|
||||||
|
if (iSense<0) {
|
||||||
|
aFSD.Reverse();
|
||||||
|
}
|
||||||
|
aLFx.Append(aFSD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!myImages.HasImage(aF)) {
|
||||||
|
aNbLFx=aLFx.Extent();
|
||||||
|
if (aNbLFx==1) {
|
||||||
|
const TopoDS_Shape& aFx=aLFx.First();
|
||||||
|
if (aF.IsSame(aFx)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myImages.Bind(aF, aLFx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: FillInternalVertices
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillInternalVertices()
|
||||||
|
{
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
NMTDS_InterfPool* pIP=pPF->IP();
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences();
|
||||||
|
BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences();
|
||||||
|
const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices();
|
||||||
|
//
|
||||||
|
Standard_Boolean bHasImage;
|
||||||
|
Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag;
|
||||||
|
Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV;
|
||||||
|
Standard_Real aU1, aU2, aTol;
|
||||||
|
NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt, aItV;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
// 1. Collect face-vertex candidates [aMFMV]
|
||||||
|
//
|
||||||
|
// 1.1. VFs
|
||||||
|
aNbVFs=aVFs.Extent();
|
||||||
|
for (i=1; i<=aNbVFs; ++i) {
|
||||||
|
const BOPTools_VSInterference& aVS=aVFs(i);
|
||||||
|
aVS.Indices(n1, n2);
|
||||||
|
nF=n2;
|
||||||
|
nV=n1;
|
||||||
|
if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) {
|
||||||
|
nF=n1;
|
||||||
|
nV=n2;
|
||||||
|
}
|
||||||
|
nVSD=pPF->FindSDVertex(nV);
|
||||||
|
if (nVSD) {
|
||||||
|
nV=nVSD;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
UpdateCandidates(nF, nV, aMFMV);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 1.2 EFs
|
||||||
|
aNbEFs=aEFs.Extent();
|
||||||
|
for (i=1; i<=aNbEFs; ++i) {
|
||||||
|
const BOPTools_ESInterference& aEF=aEFs(i);
|
||||||
|
aEF.Indices(n1, n2);
|
||||||
|
nV=aEF.NewShape();
|
||||||
|
if (!nV) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const TopoDS_Shape& aSnew=aDS.Shape(nV);
|
||||||
|
if (aSnew.ShapeType()!=TopAbs_VERTEX) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2;
|
||||||
|
nVSD=pPF->FindSDVertex(nV);
|
||||||
|
if (nVSD) {
|
||||||
|
nV=nVSD;
|
||||||
|
}
|
||||||
|
UpdateCandidates(nF, nV, aMFMV);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (nF=1; nF<=aNbS; ++nF) {
|
||||||
|
const TopoDS_Shape& aF=aDS.Shape(nF);
|
||||||
|
//
|
||||||
|
if (aF.ShapeType()!=TopAbs_FACE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!aMFence.Add(aF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aFF=TopoDS::Face(aF);
|
||||||
|
aTol=BRep_Tool::Tolerance(aFF);
|
||||||
|
//
|
||||||
|
// 1.3 FFs
|
||||||
|
if (aMAV.Contains(nF)) {
|
||||||
|
const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF);
|
||||||
|
aNbAVF=aMAVF.Extent();
|
||||||
|
for (j=1; j<=aNbAVF; ++j) {
|
||||||
|
nV=aMAVF(j);
|
||||||
|
nVSD=pPF->FindSDVertex(nV);
|
||||||
|
if (nVSD) {
|
||||||
|
nV=nVSD;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
UpdateCandidates(nF, nV, aMFMV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 1.4 Internal vertices of the face nF
|
||||||
|
BooleanOperations_OnceExplorer aExp(aDS);
|
||||||
|
aExp.Init(nF, TopAbs_VERTEX);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
nV=aExp.Current();
|
||||||
|
const TopoDS_Shape& aV=aDS.Shape(nV);
|
||||||
|
if (aV.Orientation()==TopAbs_INTERNAL) {
|
||||||
|
nVSD=pPF->FindSDVertex(nV);
|
||||||
|
if (nVSD) {
|
||||||
|
nV=nVSD;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
UpdateCandidates(nF, nV, aMFMV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Process face nF
|
||||||
|
if (!aMFMV.Contains(nF)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF);
|
||||||
|
aNbVC=aMVC.Extent();
|
||||||
|
if (!aNbVC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2.1 Refine candidates
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
|
||||||
|
TopTools_ListOfShape aLV;
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(aF);
|
||||||
|
if (bHasImage) {
|
||||||
|
const TopTools_ListOfShape& aLFx=myImages.Image(aF);
|
||||||
|
aIt.Initialize(aLFx);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aFx=aIt.Value();
|
||||||
|
TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Standard_Boolean bFaceToProcess;
|
||||||
|
//
|
||||||
|
TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
|
||||||
|
bFaceToProcess=Standard_False;
|
||||||
|
for (j=1; j<=aNbVC; ++j) {
|
||||||
|
nV=aMVC(j);
|
||||||
|
const TopoDS_Shape& aV=aDS.Shape(nV);
|
||||||
|
if (!aMVE.Contains(aV)) {
|
||||||
|
bFaceToProcess=!bFaceToProcess;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bFaceToProcess) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}// else
|
||||||
|
//
|
||||||
|
for (j=1; j<=aNbVC; ++j) {
|
||||||
|
nV=aMVC(j);
|
||||||
|
const TopoDS_Shape& aV=aDS.Shape(nV);
|
||||||
|
if (aMVE.Contains(aV)) {
|
||||||
|
const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV);
|
||||||
|
aNbE=aLE.Extent();
|
||||||
|
if (aNbE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aLV.Append(aV);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbV=aLV.Extent();
|
||||||
|
if (aNbV) {
|
||||||
|
// 3. Try to put vertices into the face(s)
|
||||||
|
aItV.Initialize(aLV);
|
||||||
|
for (; aItV.More(); aItV.Next()) {
|
||||||
|
TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value());
|
||||||
|
aV.Orientation(TopAbs_INTERNAL);
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(aF);
|
||||||
|
if (bHasImage) {
|
||||||
|
const TopTools_ListOfShape& aLFx=myImages.Image(aF);
|
||||||
|
aIt.Initialize(aLFx);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
TopoDS_Face aFx=TopoDS::Face(aIt.Value());
|
||||||
|
// update classifier
|
||||||
|
IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
|
||||||
|
aClsf.Init(aFx, aTol);
|
||||||
|
//
|
||||||
|
iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
|
||||||
|
if (!iFlag) {
|
||||||
|
aBB.Add(aFx, aV);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const TopoDS_Face& aFx=TopoDS::Face(aF);
|
||||||
|
// update classifier
|
||||||
|
IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx);
|
||||||
|
aClsf.Init(aFx, aTol);
|
||||||
|
//
|
||||||
|
iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2);
|
||||||
|
if (!iFlag) {
|
||||||
|
TopoDS_Face aFz;
|
||||||
|
//
|
||||||
|
GEOMAlgo_Tools3D::CopyFace(aFx, aFz);
|
||||||
|
aBB.Add(aFz, aV);
|
||||||
|
myImages.Bind(aF, aFz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}// for (; aItV.More(); aItV.Next()) {
|
||||||
|
}// if (aNbV) {
|
||||||
|
}// for (nF=1; nF<=aNb; ++nF) {
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function: UpdateCandidates
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void UpdateCandidates(const Standard_Integer theNF,
|
||||||
|
const Standard_Integer theNV,
|
||||||
|
NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV)
|
||||||
|
{
|
||||||
|
if (theMFMV.Contains(theNF)) {
|
||||||
|
TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF);
|
||||||
|
aMV.Add(theNV);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TColStd_IndexedMapOfInteger aMV;
|
||||||
|
aMV.Add(theNV);
|
||||||
|
theMFMV.Add(theNF, aMV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
TopoDS_Compound aCx;
|
||||||
|
BRep_Builder aBBx;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItx;
|
||||||
|
//
|
||||||
|
aBBx.MakeCompound(aCx);
|
||||||
|
aBBx.Add(aCx, aFF);
|
||||||
|
aItx.Initialize(aSE);
|
||||||
|
for (; aItx.More(); aItx.Next()) {
|
||||||
|
TopoDS_Shape& aEx=aItx.Value();
|
||||||
|
aBBx.Add(aCx, aEx);
|
||||||
|
}
|
||||||
|
int a=0;
|
||||||
|
}
|
||||||
|
*/
|
768
src/GEOMAlgo_NEW/GEOMAlgo_Builder_3.cxx
Normal file
768
src/GEOMAlgo_NEW/GEOMAlgo_Builder_3.cxx
Normal file
@ -0,0 +1,768 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 : GEOMAlgo_Builder_3.cxx
|
||||||
|
// Created :
|
||||||
|
// Author : Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeInteger.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
#include <NMTDS_ShapesDataStructure.hxx>
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
#include <GEOMAlgo_BuilderSolid.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeSet.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
void OwnInternalShapes(const TopoDS_Shape& ,
|
||||||
|
TopTools_IndexedMapOfShape& );
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FillImagesSolids
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillImagesSolids()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
FillIn3DParts();
|
||||||
|
BuildSplitSolids();
|
||||||
|
FillInternalShapes();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : BuildDraftSolid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::BuildDraftSolid (const TopoDS_Shape& theSolid,
|
||||||
|
TopoDS_Shape& theDraftSolid,
|
||||||
|
TopTools_ListOfShape& theLIF)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bToReverse;
|
||||||
|
Standard_Integer iFlag;
|
||||||
|
TopAbs_Orientation aOrF, aOrSh, aOrSd;
|
||||||
|
TopoDS_Iterator aIt1, aIt2;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItS;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Shell aShD;
|
||||||
|
TopoDS_Shape aFSDx, aFx;
|
||||||
|
//
|
||||||
|
aOrSd=theSolid.Orientation();
|
||||||
|
theDraftSolid.Orientation(aOrSd);
|
||||||
|
//
|
||||||
|
aIt1.Initialize(theSolid);
|
||||||
|
for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aSh=aIt1.Value();
|
||||||
|
if(aSh.ShapeType()!=TopAbs_SHELL) {
|
||||||
|
continue; // mb internal edges,vertices
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aOrSh=aSh.Orientation();
|
||||||
|
aBB.MakeShell(aShD);
|
||||||
|
aShD.Orientation(aOrSh);
|
||||||
|
iFlag=0;
|
||||||
|
//
|
||||||
|
aIt2.Initialize(aSh);
|
||||||
|
for (; aIt2.More(); aIt2.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aIt2.Value();
|
||||||
|
aOrF=aF.Orientation();
|
||||||
|
//
|
||||||
|
if (myImages.HasImage(aF)) {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(aF);
|
||||||
|
aItS.Initialize(aLSp);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
aFx=aItS.Value();
|
||||||
|
//
|
||||||
|
if (mySameDomainShapes.Contains(aFx)) {
|
||||||
|
aFSDx=mySameDomainShapes.FindFromKey(aFx);
|
||||||
|
//
|
||||||
|
if (aOrF==TopAbs_INTERNAL) {
|
||||||
|
aFSDx.Orientation(aOrF);
|
||||||
|
theLIF.Append(aFSDx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFSDx, aF, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aFSDx.Reverse();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
iFlag=1;
|
||||||
|
aBB.Add(aShD, aFSDx);
|
||||||
|
}
|
||||||
|
}// if (mySameDomainShapes.Contains(aFx)) {
|
||||||
|
else {
|
||||||
|
aFx.Orientation(aOrF);
|
||||||
|
if (aOrF==TopAbs_INTERNAL) {
|
||||||
|
theLIF.Append(aFx);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
iFlag=1;
|
||||||
|
aBB.Add(aShD, aFx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //if (myImages.HasImage(aF)) {
|
||||||
|
//
|
||||||
|
else {
|
||||||
|
if (aOrF==TopAbs_INTERNAL) {
|
||||||
|
theLIF.Append(aF);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
iFlag=1;
|
||||||
|
aBB.Add(aShD, aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //for (; aIt2.More(); aIt2.Next()) {
|
||||||
|
//
|
||||||
|
if (iFlag) {
|
||||||
|
aBB.Add(theDraftSolid, aShD);
|
||||||
|
}
|
||||||
|
} //for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : FillIn3DParts
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillIn3DParts()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsIN, bHasImage;
|
||||||
|
Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopAbs_State aState;
|
||||||
|
TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN;
|
||||||
|
TopTools_MapOfShape aMFDone;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItS;
|
||||||
|
TopoDS_Iterator aIt, aItF;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Solid aSolidSp;
|
||||||
|
TopoDS_Face aFP;
|
||||||
|
//
|
||||||
|
myDraftSolids.Clear();
|
||||||
|
//
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
||||||
|
//
|
||||||
|
aType=aS.ShapeType();
|
||||||
|
if (aType==TopAbs_SOLID) {
|
||||||
|
// all solids from DS
|
||||||
|
aMSolids.Add(aS);
|
||||||
|
}
|
||||||
|
else if (aType==TopAbs_FACE) {
|
||||||
|
// all faces (originals from DS or theirs images)
|
||||||
|
if (myImages.HasImage(aS)) {
|
||||||
|
const TopTools_ListOfShape& aLS=myImages.Image(aS);
|
||||||
|
aItS.Initialize(aLS);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aFx=aItS.Value();
|
||||||
|
//
|
||||||
|
if (mySameDomainShapes.Contains(aFx)) {
|
||||||
|
const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aFx);
|
||||||
|
aMFaces.Add(aFSDx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMFaces.Add(aFx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mySameDomainShapes.Contains(aS)) {
|
||||||
|
const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aS);
|
||||||
|
aMFaces.Add(aFSDx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMFaces.Add(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbFaces=aMFaces.Extent();
|
||||||
|
aNbSolids=aMSolids.Extent();
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbSolids; ++i) {
|
||||||
|
const TopoDS_Solid& aSolid=TopoDS::Solid(aMSolids(i));
|
||||||
|
aMFDone.Clear();
|
||||||
|
aMFIN.Clear();
|
||||||
|
aMEF.Clear();
|
||||||
|
//
|
||||||
|
aBB.MakeSolid(aSolidSp);
|
||||||
|
//
|
||||||
|
TopTools_ListOfShape aLIF;
|
||||||
|
//
|
||||||
|
BuildDraftSolid(aSolid, aSolidSp, aLIF);
|
||||||
|
aNbLIF=aLIF.Extent();
|
||||||
|
//
|
||||||
|
// 1 all faces/edges from aSolid [ aMS ]
|
||||||
|
bHasImage=Standard_False;
|
||||||
|
aMS.Clear();
|
||||||
|
aIt.Initialize(aSolid);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aShell=aIt.Value();
|
||||||
|
//
|
||||||
|
if (myImages.HasImage(aShell)) {
|
||||||
|
bHasImage=Standard_True;
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLS=myImages.Image(aShell);
|
||||||
|
aItS.Initialize(aLS);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=aItS.Value();
|
||||||
|
aMS.Add(aSx);
|
||||||
|
TopExp::MapShapes(aSx, TopAbs_FACE, aMS);
|
||||||
|
TopExp::MapShapes(aSx, TopAbs_EDGE, aMS);
|
||||||
|
TopExp::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//aMS.Add(aShell);
|
||||||
|
TopExp::MapShapes(aShell, TopAbs_FACE, aMS);
|
||||||
|
//modified by NIZNHY-PKV Fri Dec 03 11:18:45 2010f
|
||||||
|
TopExp::MapShapes(aShell, TopAbs_EDGE, aMS);
|
||||||
|
//modified by NIZNHY-PKV Fri Dec 03 11:18:51 2010t
|
||||||
|
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2 all faces that are not from aSolid [ aLFP1 ]
|
||||||
|
Standard_Integer aNbEFP;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMEFP;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItFP, aItEx;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListOfShape aLFP1, aLFP2, aLFP, aLCBF, aLFIN, aLEx;//*pLFP,
|
||||||
|
//
|
||||||
|
// for all non-solid faces build EF map [ aMEFP ]
|
||||||
|
for (j=1; j<=aNbFaces; ++j) {
|
||||||
|
const TopoDS_Shape& aFace=aMFaces(j);
|
||||||
|
if (!aMS.Contains(aFace)) {
|
||||||
|
TopExp::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// among all faces from aMEFP select these that have same edges
|
||||||
|
// with the solid (i.e aMEF). These faces will be treated first
|
||||||
|
// to prevent the usage of 3D classifier.
|
||||||
|
// The full list of faces to process is aLFP1.
|
||||||
|
aNbEFP=aMEFP.Extent();
|
||||||
|
for (j=1; j<=aNbEFP; ++j) {
|
||||||
|
const TopoDS_Shape& aE=aMEFP.FindKey(j);
|
||||||
|
//
|
||||||
|
if (aMEF.Contains(aE)) { // !!
|
||||||
|
const TopTools_ListOfShape& aLF=aMEFP(j);
|
||||||
|
aItFP.Initialize(aLF);
|
||||||
|
for (; aItFP.More(); aItFP.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItFP.Value();
|
||||||
|
if (aMFence.Add(aF)) {
|
||||||
|
aLFP1.Append(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aLEx.Append(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItEx.Initialize(aLEx);
|
||||||
|
for (; aItEx.More(); aItEx.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItEx.Value();
|
||||||
|
const TopTools_ListOfShape& aLF=aMEFP.FindFromKey(aE);
|
||||||
|
aItFP.Initialize(aLF);
|
||||||
|
for (; aItFP.More(); aItFP.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aItFP.Value();
|
||||||
|
if (aMFence.Add(aF)) {
|
||||||
|
aLFP2.Append(aF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aLFP1.Append(aLFP2);
|
||||||
|
//==========
|
||||||
|
//
|
||||||
|
// 3 Process faces aLFP1
|
||||||
|
aNbFP=aLFP1.Extent();
|
||||||
|
aItFP.Initialize(aLFP1);
|
||||||
|
for (; aItFP.More(); aItFP.Next()) {
|
||||||
|
const TopoDS_Shape& aSP=aItFP.Value();
|
||||||
|
if (!aMFDone.Add(aSP)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// first face to process
|
||||||
|
aFP=TopoDS::Face(aSP);
|
||||||
|
bIsIN= GEOMAlgo_Tools3D::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, aCtx);
|
||||||
|
aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
|
||||||
|
//
|
||||||
|
// collect faces to process [ aFP is the first ]
|
||||||
|
aLFP.Clear();
|
||||||
|
aLFP.Append(aFP);
|
||||||
|
aItS.Initialize(aLFP1);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aSk=aItS.Value();
|
||||||
|
if (!aMFDone.Contains(aSk)) {
|
||||||
|
aLFP.Append(aSk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Connexity Block that spreads from aFP the Bound
|
||||||
|
// or till the end of the block itself
|
||||||
|
aLCBF.Clear();
|
||||||
|
GEOMAlgo_Tools3D::MakeConnexityBlock(aLFP, aMS, aLCBF);
|
||||||
|
//
|
||||||
|
// fill states for the Connexity Block
|
||||||
|
aItS.Initialize(aLCBF);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=aItS.Value();
|
||||||
|
aMFDone.Add(aSx);
|
||||||
|
if (aState==TopAbs_IN) {
|
||||||
|
aMFIN.Add(aSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbFPx=aMFDone.Extent();
|
||||||
|
if (aNbFPx==aNbFP) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}//for (; aItFP.More(); aItFP.Next())
|
||||||
|
//
|
||||||
|
// faces Inside aSolid
|
||||||
|
aLFIN.Clear();
|
||||||
|
aNbFIN=aMFIN.Extent();
|
||||||
|
if (aNbFIN || aNbLIF) {
|
||||||
|
for (j=1; j<=aNbFIN; ++j) {
|
||||||
|
const TopoDS_Shape& aFIN=aMFIN(j);
|
||||||
|
aLFIN.Append(aFIN);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aItS.Initialize(aLIF);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aFIN=aItS.Value();
|
||||||
|
aLFIN.Append(aFIN);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myInParts.Add(aSolid, aLFIN);
|
||||||
|
}
|
||||||
|
if (aNbFIN || bHasImage) {
|
||||||
|
myDraftSolids.Add(aSolid, aSolidSp);
|
||||||
|
}
|
||||||
|
}//for (i=1; i<=aNbSolids; ++i) { // next solid
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : BuildSplitSolids
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::BuildSplitSolids()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Integer i, aNbS, iErr;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
TopTools_ListOfShape aSFS, aLSEmpty;
|
||||||
|
TopTools_MapOfShape aMFence;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
GEOMAlgo_BuilderSolid aSB;
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet aItSS;
|
||||||
|
GEOMAlgo_DataMapOfShapeShapeSet aMSS;
|
||||||
|
GEOMAlgo_ShapeSet aSSi;
|
||||||
|
//
|
||||||
|
// 0. Find same domain solids for non-interferred solids
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
||||||
|
if (aS.ShapeType()!=TopAbs_SOLID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!aMFence.Add(aS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(myDraftSolids.Contains(aS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSSi.Clear();
|
||||||
|
aSSi.Add(aS, TopAbs_FACE);
|
||||||
|
//
|
||||||
|
aMSS.Bind(aS, aSSi);
|
||||||
|
} //for (i=1; i<=aNbS; ++i)
|
||||||
|
//
|
||||||
|
// 1. Build solids for interferred source solids
|
||||||
|
aSB.SetContext(aCtx);
|
||||||
|
aSB.ComputeInternalShapes(myComputeInternalShapes);
|
||||||
|
aNbS=myDraftSolids.Extent();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
const TopoDS_Shape& aS =myDraftSolids.FindKey(i);
|
||||||
|
const TopoDS_Shape& aSD=myDraftSolids.FindFromIndex(i);
|
||||||
|
const TopTools_ListOfShape& aLFIN=
|
||||||
|
(myInParts.Contains(aS)) ? myInParts.FindFromKey(aS) : aLSEmpty;
|
||||||
|
//
|
||||||
|
// 1.1 Fill Shell Faces Set
|
||||||
|
aSFS.Clear();
|
||||||
|
|
||||||
|
aExp.Init(aSD, TopAbs_FACE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aExp.Current();
|
||||||
|
aSFS.Append(aF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aIt.Initialize(aLFIN);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
TopoDS_Shape aF=aIt.Value();
|
||||||
|
//
|
||||||
|
aF.Orientation(TopAbs_FORWARD);
|
||||||
|
aSFS.Append(aF);
|
||||||
|
aF.Orientation(TopAbs_REVERSED);
|
||||||
|
aSFS.Append(aF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Standard_Integer aNbSFS;
|
||||||
|
aNbSFS=aSFS.Extent();
|
||||||
|
//
|
||||||
|
// 1.2
|
||||||
|
// Check whether aSFS contains a subsets of faces
|
||||||
|
// of solids that have been already built.
|
||||||
|
// If yes, shrink aSFS by these subsets.
|
||||||
|
aSSi.Clear();
|
||||||
|
aSSi.Add(aSFS);
|
||||||
|
//
|
||||||
|
aItSS.Initialize(aMSS);
|
||||||
|
for (; aItSS.More(); aItSS.Next()) {
|
||||||
|
const TopoDS_Shape& aSR=aItSS.Key();
|
||||||
|
const GEOMAlgo_ShapeSet& aSSR=aItSS.Value();
|
||||||
|
if (aSSi.Contains(aSSR)) {
|
||||||
|
// the aSR is SD solid for aS
|
||||||
|
aSSi.Subtract(aSSR);
|
||||||
|
// update images
|
||||||
|
if(myImages.HasImage(aS)) {
|
||||||
|
myImages.Add(aS, aSR);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myImages.Bind(aS, aSR);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// update SD Shapes
|
||||||
|
mySameDomainShapes.Add(aSR, aSR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const TopTools_ListOfShape& aSFS1=aSSi.GetSet();
|
||||||
|
aNbSFS=aSFS1.Extent();
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 09:53:15 2010f
|
||||||
|
if (!aNbSFS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Wed Oct 27 09:53:18 2010t
|
||||||
|
//
|
||||||
|
// 1.3 Build new solids
|
||||||
|
aSB.SetContext(aCtx);
|
||||||
|
aSB.SetShapes(aSFS1);
|
||||||
|
aSB.Perform();
|
||||||
|
iErr=aSB.ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=30; // SolidBuilder failed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLSR=aSB.Areas();
|
||||||
|
//
|
||||||
|
// 1.4 Collect resulting solids and theirs set of faces
|
||||||
|
aIt.Initialize(aLSR);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSR=aIt.Value();
|
||||||
|
//
|
||||||
|
aSSi.Clear();
|
||||||
|
aExp.Init(aSR, TopAbs_FACE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aF=aExp.Current();
|
||||||
|
aSSi.Add(aF);
|
||||||
|
}
|
||||||
|
aMSS.Bind(aSR, aSSi);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Update images
|
||||||
|
if (myImages.HasImage(aS)) {
|
||||||
|
myImages.Add(aS, aLSR);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myImages.Bind(aS, aLSR);
|
||||||
|
}
|
||||||
|
} // for (i=1; i<=aNbS; ++i) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function :FillInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::FillInternalShapes()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx= pPF->Context();
|
||||||
|
//
|
||||||
|
//Standard_Boolean bHasImage;
|
||||||
|
Standard_Integer i, j, jT, aNbS, aNbSI, aNbSx, aNbSd;
|
||||||
|
TopAbs_ShapeEnum aType, aT[]={ TopAbs_VERTEX, TopAbs_EDGE };
|
||||||
|
TopAbs_State aState;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt, aIt1;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMSx;
|
||||||
|
TopTools_IndexedMapOfShape aMx;
|
||||||
|
TopTools_MapOfShape aMSI, aMFence, aMSOr;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItM;
|
||||||
|
TopTools_ListOfShape aLSI, aLSd;
|
||||||
|
TopoDS_Iterator aItS;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
// 1. Shapes to process
|
||||||
|
//
|
||||||
|
// 1.1 Shapes from pure arguments aMSI
|
||||||
|
// 1.1.1 vertex, edge
|
||||||
|
for (i=0; i<2; ++i) {
|
||||||
|
jT=(Standard_Integer)aT[i];
|
||||||
|
const TopTools_ListOfShape &aLS=myShapes1[jT];
|
||||||
|
aIt.Initialize(aLS);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt.Value();
|
||||||
|
if (aMFence.Add(aS)) {
|
||||||
|
aLSI.Append(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 1.1.2 wire
|
||||||
|
{
|
||||||
|
jT=(Standard_Integer)TopAbs_WIRE;
|
||||||
|
const TopTools_ListOfShape &aLW=myShapes1[jT];
|
||||||
|
aIt.Initialize(aLW);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aW=aIt.Value();
|
||||||
|
aItS.Initialize(aW);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aItS.Value();
|
||||||
|
if (aMFence.Add(aE)) {
|
||||||
|
aLSI.Append(aE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 1.1.3 theirs images/sources
|
||||||
|
aIt1.Initialize(aLSI);
|
||||||
|
for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
const TopoDS_Shape& aS=aIt1.Value();
|
||||||
|
if (myImages.HasImage(aS)) {
|
||||||
|
const TopTools_ListOfShape &aLSp=myImages.Image(aS);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSI=aIt.Value();
|
||||||
|
aMSI.Add(aSI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMSI.Add(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aLSI.Clear();
|
||||||
|
aNbSI=aMSI.Extent();
|
||||||
|
//
|
||||||
|
// 2. Internal vertices, edges from source solids
|
||||||
|
aMFence.Clear();
|
||||||
|
aLSd.Clear();
|
||||||
|
//
|
||||||
|
aNbS=aDS.NumberOfShapesOfTheObject();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aDS.Shape(i);
|
||||||
|
aType=aS.ShapeType();
|
||||||
|
if (aType==TopAbs_SOLID) {
|
||||||
|
//
|
||||||
|
aMx.Clear();
|
||||||
|
OwnInternalShapes(aS, aMx);
|
||||||
|
//
|
||||||
|
aNbSx=aMx.Extent();
|
||||||
|
for (j=1; j<=aNbSx; ++j) {
|
||||||
|
const TopoDS_Shape& aSI=aMx(j);
|
||||||
|
if (myImages.HasImage(aSI)) {
|
||||||
|
const TopTools_ListOfShape &aLSp=myImages.Image(aSI);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSp=aIt.Value();
|
||||||
|
aMSI.Add(aSp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMSI.Add(aSI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// build aux map from splits of solids
|
||||||
|
if (myImages.HasImage(aS)) {
|
||||||
|
const TopTools_ListOfShape &aLSp=myImages.Image(aS);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSp=aIt.Value();
|
||||||
|
if (aMFence.Add(aSp)) {
|
||||||
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
|
||||||
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx);
|
||||||
|
TopExp::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx);
|
||||||
|
aLSd.Append(aSp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (aMFence.Add(aS)) {
|
||||||
|
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx);
|
||||||
|
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx);
|
||||||
|
TopExp::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx);
|
||||||
|
aLSd.Append(aS);
|
||||||
|
aMSOr.Add(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//if (aType==TopAbs_SOLID)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbSd=aLSd.Extent();
|
||||||
|
//
|
||||||
|
// 3. Some shapes of aMSI can be already tied with faces of
|
||||||
|
// split solids
|
||||||
|
aItM.Initialize(aMSI);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aSI=aItM.Key();
|
||||||
|
if (aMSx.Contains(aSI)) {
|
||||||
|
const TopTools_ListOfShape &aLSx=aMSx.FindFromKey(aSI);
|
||||||
|
aNbSx=aLSx.Extent();
|
||||||
|
if (aNbSx) {
|
||||||
|
aMSI.Remove(aSI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4. Just check it
|
||||||
|
aNbSI=aMSI.Extent();
|
||||||
|
if (!aNbSI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 5 Settle internal vertices and edges into solids
|
||||||
|
aMx.Clear();
|
||||||
|
aIt.Initialize(aLSd);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
|
||||||
|
//
|
||||||
|
aItM.Initialize(aMSI);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
TopoDS_Shape aSI=aItM.Key();
|
||||||
|
aSI.Orientation(TopAbs_INTERNAL);
|
||||||
|
//
|
||||||
|
aState=GEOMAlgo_Tools3D::ComputeStateByOnePoint(aSI, aSd, 1.e-11, aCtx);
|
||||||
|
if (aState==TopAbs_IN) {
|
||||||
|
//
|
||||||
|
if(aMSOr.Contains(aSd)) {
|
||||||
|
//
|
||||||
|
TopoDS_Solid aSdx;
|
||||||
|
//
|
||||||
|
aBB.MakeSolid(aSdx);
|
||||||
|
aItS.Initialize(aSd);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aSh=aItS.Value();
|
||||||
|
aBB.Add(aSdx, aSh);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aBB.Add(aSdx, aSI);
|
||||||
|
//
|
||||||
|
myImages.Bind(aSd, aSdx);
|
||||||
|
aMSOr.Remove(aSd);
|
||||||
|
aSd=aSdx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aBB.Add(aSd, aSI);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aMSI.Remove(aSI);
|
||||||
|
} //if (aState==TopAbs_IN) {
|
||||||
|
}// for (; aItM.More(); aItM.Next()) {
|
||||||
|
}//for (; aIt1.More(); aIt1.Next()) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : OwnInternalShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void OwnInternalShapes(const TopoDS_Shape& theS,
|
||||||
|
TopTools_IndexedMapOfShape& theMx)
|
||||||
|
{
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
aIt.Initialize(theS);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=aIt.Value();
|
||||||
|
if (aSx.ShapeType()!=TopAbs_SHELL) {
|
||||||
|
theMx.Add(aSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// ErrorStatus
|
||||||
|
// 30 - SolidBuilder failed
|
316
src/GEOMAlgo_NEW/GEOMAlgo_Builder_4.cxx
Normal file
316
src/GEOMAlgo_NEW/GEOMAlgo_Builder_4.cxx
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Builder_4.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_Context.hxx>
|
||||||
|
|
||||||
|
#include <NMTDS_ShapesDataStructure.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_PaveFiller.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Tools3D.hxx>
|
||||||
|
|
||||||
|
static
|
||||||
|
void MapShapes(const TopoDS_Shape& aS,
|
||||||
|
TopTools_MapOfShape& aM);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Generated
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS)
|
||||||
|
{
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx=pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bHasImage, bToReverse;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
myHistShapes.Clear();
|
||||||
|
//
|
||||||
|
if (theS.IsNull()) {
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(theS);
|
||||||
|
if (!bHasImage) {
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aType=theS.ShapeType();
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||||
|
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(theS);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSp=aIt.Value();
|
||||||
|
if (mySameDomainShapes.Contains(aSp)) {
|
||||||
|
if (myMapShape.Contains(aSp)) {
|
||||||
|
TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
aSpR.Orientation(theS.Orientation());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aSpR.Reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myHistShapes.Append(aSpR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Modified
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS)
|
||||||
|
{
|
||||||
|
NMTTools_PaveFiller* pPF=myPaveFiller;
|
||||||
|
const Handle(IntTools_Context)& aCtx=pPF->Context();
|
||||||
|
//
|
||||||
|
Standard_Boolean bHasImage, bToReverse;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
myHistShapes.Clear();
|
||||||
|
//
|
||||||
|
if (theS.IsNull()) {
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(theS);
|
||||||
|
if (!bHasImage) {
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aType=theS.ShapeType();
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||||
|
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(theS);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
TopoDS_Shape aSp=aIt.Value();
|
||||||
|
if (!mySameDomainShapes.Contains(aSp)) {
|
||||||
|
if (myMapShape.Contains(aSp)) {
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
aSp.Orientation(theS.Orientation());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx);
|
||||||
|
if (bToReverse) {
|
||||||
|
aSp.Reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myHistShapes.Append(aSp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return myHistShapes;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsDeleted
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet, bHasImage, bContains;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
//
|
||||||
|
if (theS.IsNull()) {
|
||||||
|
return !bRet; //true
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bContains=myMapShape.Contains(theS);
|
||||||
|
if (bContains) {
|
||||||
|
return bRet; //false
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(theS);
|
||||||
|
if (!bHasImage) {
|
||||||
|
return !bRet; //true
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aType=theS.ShapeType();
|
||||||
|
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||||
|
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(theS);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
TopoDS_Shape aSp=aIt.Value();
|
||||||
|
//
|
||||||
|
if (!mySameDomainShapes.Contains(aSp)) {
|
||||||
|
if (myMapShape.Contains(aSp)) {
|
||||||
|
return bRet; //false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp);
|
||||||
|
if (myMapShape.Contains(aSpR)) {
|
||||||
|
return bRet; //false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !bRet; // true
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PrepareHistory
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Builder::PrepareHistory()
|
||||||
|
{
|
||||||
|
if(myShape.IsNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Standard_Boolean bHasImage, bContainsSD;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
TopTools_MapOfShape aMS;
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
TopTools_MapIteratorOfMapOfShape aItM;
|
||||||
|
//
|
||||||
|
// 1. Clearing
|
||||||
|
GEOMAlgo_BuilderShape::PrepareHistory();
|
||||||
|
//
|
||||||
|
// 2. myMapShape - all shapes of result with theirs sub-shapes
|
||||||
|
MapShapes(myShape, myMapShape);
|
||||||
|
//
|
||||||
|
// 3. MS - all argument shapes with theirs sub-shapes
|
||||||
|
aIt.Initialize(myShapes);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=aIt.Value();
|
||||||
|
MapShapes(aSx, aMS);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4. Treatment
|
||||||
|
aItM.Initialize(aMS);
|
||||||
|
for (; aItM.More(); aItM.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=aItM.Key();
|
||||||
|
aType=aSx.ShapeType();
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f
|
||||||
|
//
|
||||||
|
// 4.1 .myImagesResult
|
||||||
|
TopTools_ListOfShape aLSx;
|
||||||
|
//
|
||||||
|
bHasImage=myImages.HasImage(aSx);
|
||||||
|
if (!bHasImage) {
|
||||||
|
if (myMapShape.Contains(aSx)) {
|
||||||
|
aLSx.Append(aSx);
|
||||||
|
myImagesResult.Add(aSx, aLSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSp=aIt.Value();
|
||||||
|
if (myMapShape.Contains(aSp)) {
|
||||||
|
aLSx.Append(aSp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myImagesResult.Add(aSx, aLSx);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t
|
||||||
|
//
|
||||||
|
// 4.2 As it was
|
||||||
|
if (!myHasDeleted) {
|
||||||
|
myHasDeleted=IsDeleted(aSx);//xx
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!myHasGenerated || !myHasModified) {
|
||||||
|
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||||
|
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f
|
||||||
|
//bHasImage=myImages.HasImage(aSx);
|
||||||
|
//modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t
|
||||||
|
if (bHasImage) {
|
||||||
|
const TopTools_ListOfShape& aLSp=myImages.Image(aSx);
|
||||||
|
aIt.Initialize(aLSp);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSp=aIt.Value();
|
||||||
|
//
|
||||||
|
if (myMapShape.Contains(aSp)) {
|
||||||
|
bContainsSD=mySameDomainShapes.Contains(aSp);
|
||||||
|
//
|
||||||
|
if (!myHasGenerated) {
|
||||||
|
if (bContainsSD) {
|
||||||
|
myHasGenerated=Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!myHasModified) {
|
||||||
|
if (!bContainsSD) {
|
||||||
|
myHasModified=Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // if (myMapShape.Contains(aSp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : MapShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void MapShapes(const TopoDS_Shape& theS,
|
||||||
|
TopTools_MapOfShape& theM)
|
||||||
|
{
|
||||||
|
theM.Add(theS);
|
||||||
|
TopoDS_Iterator anIt;
|
||||||
|
anIt.Initialize(theS);
|
||||||
|
for (; anIt.More(); anIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSx=anIt.Value();
|
||||||
|
MapShapes(aSx, theM);
|
||||||
|
}
|
||||||
|
}
|
107
src/GEOMAlgo_NEW/GEOMAlgo_Clsf.cxx
Normal file
107
src/GEOMAlgo_NEW/GEOMAlgo_Clsf.cxx
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Clsf.cxx
|
||||||
|
// Created: Wed Nov 22 10:23:04 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_Clsf, GEOMAlgo_HAlgo);
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_Clsf, GEOMAlgo_HAlgo);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Clsf::GEOMAlgo_Clsf()
|
||||||
|
:
|
||||||
|
GEOMAlgo_HAlgo()
|
||||||
|
{
|
||||||
|
myState=TopAbs_UNKNOWN;
|
||||||
|
myPnt.SetCoord(99.,99.,99.);
|
||||||
|
myTolerance=0.0001;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_Clsf::~GEOMAlgo_Clsf()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetTolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Clsf::SetTolerance(const Standard_Real aT)
|
||||||
|
{
|
||||||
|
myTolerance=aT;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Tolerance
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Real GEOMAlgo_Clsf::Tolerance()const
|
||||||
|
{
|
||||||
|
return myTolerance;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetPnt
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_Clsf::SetPnt(const gp_Pnt& aP)
|
||||||
|
{
|
||||||
|
myPnt=aP;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Pnt
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const gp_Pnt& GEOMAlgo_Clsf::Pnt()const
|
||||||
|
{
|
||||||
|
return myPnt;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : State
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TopAbs_State GEOMAlgo_Clsf::State() const
|
||||||
|
{
|
||||||
|
return myState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_Clsf::CanBeON(const Handle(Geom_Curve)& ) const
|
||||||
|
{
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_Clsf::CanBeON(const Handle(Geom_Surface)& ) const
|
||||||
|
{
|
||||||
|
return Standard_True;
|
||||||
|
}
|
87
src/GEOMAlgo_NEW/GEOMAlgo_Clsf.hxx
Normal file
87
src/GEOMAlgo_NEW/GEOMAlgo_Clsf.hxx
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_Clsf.hxx
|
||||||
|
// Created: Wed Nov 22 10:23:04 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_Clsf_HeaderFile
|
||||||
|
#define _GEOMAlgo_Clsf_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_DefineHandle.hxx>
|
||||||
|
//#include <Handle_GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#include <GEOMAlgo_HAlgo.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <Handle_Geom_Curve.hxx>
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
|
||||||
|
DEFINE_STANDARD_HANDLE(GEOMAlgo_Clsf, GEOMAlgo_HAlgo);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_Clsf
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_Clsf : public GEOMAlgo_HAlgo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetPnt(const gp_Pnt& aP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const gp_Pnt& Pnt() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetTolerance(const Standard_Real aT) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Real Tolerance() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
TopAbs_State State() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aCT) const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTI(GEOMAlgo_Clsf);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_Clsf();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_Clsf();
|
||||||
|
|
||||||
|
TopAbs_State myState;
|
||||||
|
gp_Pnt myPnt;
|
||||||
|
Standard_Real myTolerance;
|
||||||
|
};
|
||||||
|
#endif
|
222
src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.cxx
Normal file
222
src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.cxx
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_ClsfBox.cxx
|
||||||
|
// Created: Wed Nov 22 10:41:47 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_ClsfBox.hxx>
|
||||||
|
|
||||||
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
#include <GEOMAlgo_SurfaceTools.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <gp_Dir.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
#include <gp_Ax1.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfBox::GEOMAlgo_ClsfBox()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Clsf()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfBox::~GEOMAlgo_ClsfBox()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetBox
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfBox::SetBox(const TopoDS_Shape& aBox)
|
||||||
|
{
|
||||||
|
myBox=aBox;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Box
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Shape& GEOMAlgo_ClsfBox::Box() const
|
||||||
|
{
|
||||||
|
return myBox;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfBox::CheckData()
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNbF;
|
||||||
|
TopAbs_ShapeEnum aTypeShape;
|
||||||
|
TopAbs_Orientation aOr;
|
||||||
|
GeomAbs_SurfaceType aType;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
TopTools_IndexedMapOfShape aMF;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if(myBox.IsNull()) {
|
||||||
|
myErrorStatus=10; // myBox=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aTypeShape=myBox.ShapeType();
|
||||||
|
if (aTypeShape!=TopAbs_SOLID) {
|
||||||
|
myErrorStatus=11; // unallowed shape type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myBox, TopAbs_FACE, aMF);
|
||||||
|
aNbF=aMF.Extent();
|
||||||
|
if (aNbF!=6) {
|
||||||
|
myErrorStatus=12; // wrong number of faces
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aMF(i));
|
||||||
|
aOr=aF.Orientation();
|
||||||
|
if (!(aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED)) {
|
||||||
|
myErrorStatus=12; // unallowed orientation of face
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
myGAS[i-1].Load(aS);
|
||||||
|
aType=myGAS[i-1].GetType();
|
||||||
|
if (!aType==GeomAbs_Plane) {
|
||||||
|
myErrorStatus=13; // unallowed surface type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if(aOr==TopAbs_REVERSED) {
|
||||||
|
gp_Ax1 aAx1;
|
||||||
|
gp_Pln aPln;
|
||||||
|
gp_Pnt aP;
|
||||||
|
gp_Dir aD;
|
||||||
|
Handle(Geom_Plane) aSR;
|
||||||
|
//
|
||||||
|
aPln=myGAS[i-1].Plane();
|
||||||
|
aAx1=aPln.Axis();
|
||||||
|
aP=aAx1.Location();
|
||||||
|
aD=aAx1.Direction();
|
||||||
|
aD.Reverse();
|
||||||
|
aSR=new Geom_Plane(aP, aD);
|
||||||
|
myGAS[i-1].Load(aSR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfBox::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
const Standard_Integer aNbS=6;
|
||||||
|
Standard_Integer i, aNbON, aNbIN, iNext;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
/*
|
||||||
|
CheckData();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
iNext=1;
|
||||||
|
aNbON=0;
|
||||||
|
aNbIN=0;
|
||||||
|
for(i=0; i<aNbS && iNext; i++) {
|
||||||
|
GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS[i], myTolerance, aSt);
|
||||||
|
//
|
||||||
|
switch (aSt) {
|
||||||
|
case TopAbs_OUT:
|
||||||
|
myState=aSt;
|
||||||
|
iNext=0;
|
||||||
|
break;
|
||||||
|
case TopAbs_ON:
|
||||||
|
++aNbON;
|
||||||
|
break;
|
||||||
|
case TopAbs_IN:
|
||||||
|
++aNbIN;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
myState=TopAbs_UNKNOWN;
|
||||||
|
iNext=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (iNext) {
|
||||||
|
myState=TopAbs_UNKNOWN;
|
||||||
|
//
|
||||||
|
if (aNbON && aNbIN) {
|
||||||
|
myState=TopAbs_ON;
|
||||||
|
}
|
||||||
|
else if (aNbIN==aNbS){
|
||||||
|
myState=TopAbs_IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Curve)& aC) const
|
||||||
|
{
|
||||||
|
return GEOMAlgo_Clsf::CanBeON(aC);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Surface)& aS1) const
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
GeomAbs_SurfaceType aST1;
|
||||||
|
GeomAdaptor_Surface aGAS1;
|
||||||
|
//
|
||||||
|
aGAS1.Load(aS1);
|
||||||
|
aST1=aGAS1.GetType();
|
||||||
|
bRet=(aST1==GeomAbs_Plane);
|
||||||
|
//
|
||||||
|
return bRet;
|
||||||
|
}
|
97
src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.hxx
Normal file
97
src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.hxx
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_ClsfBox.hxx
|
||||||
|
// Created: Wed Nov 22 10:41:47 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_ClsfBox_HeaderFile
|
||||||
|
#define _GEOMAlgo_ClsfBox_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_DefineHandle.hxx>
|
||||||
|
//#include <Handle_GEOMAlgo_ClsfBox.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <Handle_Geom_Curve.hxx>
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
|
||||||
|
DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_ClsfBox
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_ClsfBox : public GEOMAlgo_Clsf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_ClsfBox();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_ClsfBox();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetBox(const TopoDS_Shape& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& Box() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfBox)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TopoDS_Shape myBox;
|
||||||
|
GeomAdaptor_Surface myGAS[6];
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// other Inline functions and methods (like "C++: function call" methods)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
141
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.cxx
Normal file
141
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.cxx
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_ClsfSolid.cxx
|
||||||
|
// Created: Mon Jan 29 10:35:46 2007
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_ClsfSolid.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfSolid::GEOMAlgo_ClsfSolid()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Clsf()
|
||||||
|
{
|
||||||
|
myPClsf=NULL;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfSolid::~GEOMAlgo_ClsfSolid()
|
||||||
|
{
|
||||||
|
if (myPClsf) {
|
||||||
|
BRepClass3d_SolidClassifier* pSC;
|
||||||
|
//
|
||||||
|
pSC=(BRepClass3d_SolidClassifier*)myPClsf;
|
||||||
|
delete pSC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSolid::SetShape(const TopoDS_Shape& aS)
|
||||||
|
{
|
||||||
|
myShape=aS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shape
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Shape& GEOMAlgo_ClsfSolid::Shape()const
|
||||||
|
{
|
||||||
|
return myShape;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSolid::CheckData()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
BRepClass3d_SolidClassifier* pSC;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Solid aS;
|
||||||
|
//
|
||||||
|
if (myShape.IsNull()) {
|
||||||
|
myErrorStatus=10; // mySolid=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aType=myShape.ShapeType();
|
||||||
|
if (!(aType==TopAbs_SOLID || aType==TopAbs_SHELL)) {
|
||||||
|
myErrorStatus=12;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//===
|
||||||
|
if (aType==TopAbs_SOLID) {
|
||||||
|
aS=TopoDS::Solid(myShape);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aBB.MakeSolid(aS);
|
||||||
|
aBB.Add(aS, myShape);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myPClsf) {
|
||||||
|
pSC=(BRepClass3d_SolidClassifier*)myPClsf;
|
||||||
|
delete pSC;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
pSC=new BRepClass3d_SolidClassifier(aS);
|
||||||
|
myPClsf=pSC;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSolid::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if (!myPClsf) {
|
||||||
|
myErrorStatus=11;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRepClass3d_SolidClassifier* pSC;
|
||||||
|
//
|
||||||
|
pSC=(BRepClass3d_SolidClassifier*)myPClsf;
|
||||||
|
pSC->Perform(myPnt, myTolerance);
|
||||||
|
myState=pSC->State();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// myErrorStatus :
|
||||||
|
//
|
||||||
|
// 10 - mySolid=NULL
|
||||||
|
// 11 - myPClsf=NULL
|
||||||
|
// 12 - unallowed type of myShape
|
||||||
|
|
69
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.hxx
Normal file
69
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.hxx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_ClsfSolid.hxx
|
||||||
|
// Created: Mon Jan 29 10:35:46 2007
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_ClsfSolid_HeaderFile
|
||||||
|
#define _GEOMAlgo_ClsfSolid_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_DefineHandle.hxx>
|
||||||
|
//#include <Handle_GEOMAlgo_ClsfSolid.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <Standard_Address.hxx>
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
|
||||||
|
DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_ClsfSolid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_ClsfSolid : public GEOMAlgo_Clsf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_ClsfSolid();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_ClsfSolid();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShape(const TopoDS_Shape& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& Shape() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSolid)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
Standard_Address myPClsf;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
141
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.cxx
Normal file
141
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.cxx
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_ClsfSurf.cxx
|
||||||
|
// Created: Wed Nov 22 10:41:47 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_ClsfSurf.hxx>
|
||||||
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
#include <GEOMAlgo_SurfaceTools.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf);
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfSurf::GEOMAlgo_ClsfSurf()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Clsf()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_ClsfSurf::~GEOMAlgo_ClsfSurf()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetSurface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSurf::SetSurface(const Handle(Geom_Surface)& aS)
|
||||||
|
{
|
||||||
|
myS=aS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Surface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Handle(Geom_Surface)& GEOMAlgo_ClsfSurf::Surface() const
|
||||||
|
{
|
||||||
|
return myS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSurf::CheckData()
|
||||||
|
{
|
||||||
|
GeomAbs_SurfaceType aType;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if(myS.IsNull()) {
|
||||||
|
myErrorStatus=10; // mySurface=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myGAS.Load(myS);
|
||||||
|
aType=myGAS.GetType();
|
||||||
|
if (!(aType==GeomAbs_Plane ||
|
||||||
|
aType==GeomAbs_Cylinder ||
|
||||||
|
aType==GeomAbs_Sphere)) {
|
||||||
|
myErrorStatus=11; // unallowed surface type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_ClsfSurf::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
/*
|
||||||
|
CheckData();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS, myTolerance, myState);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Curve)& aC) const
|
||||||
|
{
|
||||||
|
GeomAbs_SurfaceType aST;
|
||||||
|
GeomAbs_CurveType aCT;
|
||||||
|
GeomAdaptor_Curve aGAC;
|
||||||
|
//
|
||||||
|
aGAC.Load(aC);
|
||||||
|
aCT=aGAC.GetType();
|
||||||
|
//
|
||||||
|
aST=myGAS.GetType();
|
||||||
|
if (aCT==GeomAbs_Line && aST==GeomAbs_Sphere) {
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CanBeON
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Surface)& aS1) const
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
GeomAbs_SurfaceType aST, aST1;
|
||||||
|
GeomAdaptor_Surface aGAS1;
|
||||||
|
//
|
||||||
|
aST=myGAS.GetType();
|
||||||
|
aGAS1.Load(aS1);
|
||||||
|
aST1=aGAS1.GetType();
|
||||||
|
bRet=(aST1==aST);
|
||||||
|
//
|
||||||
|
return bRet;
|
||||||
|
}
|
81
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.hxx
Normal file
81
src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.hxx
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_ClsfSurf.hxx
|
||||||
|
// Created: Wed Nov 22 10:41:47 2006
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_ClsfSurf_HeaderFile
|
||||||
|
#define _GEOMAlgo_ClsfSurf_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_DefineHandle.hxx>
|
||||||
|
//#include <Handle_GEOMAlgo_ClsfSurf.hxx>
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <Handle_Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
|
||||||
|
DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf)
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// class : GEOMAlgo_ClsfSurf
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_ClsfSurf : public GEOMAlgo_Clsf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_ClsfSurf();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_ClsfSurf();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetSurface(const Handle(Geom_Surface)& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const Handle_Geom_Surface& Surface() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSurf);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Handle_Geom_Surface myS;
|
||||||
|
GeomAdaptor_Surface myGAS;
|
||||||
|
};
|
||||||
|
#endif
|
86
src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.cxx
Normal file
86
src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.cxx
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
// Copyright (C) 2007-2011 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
|
||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_CoupleOfShapes.cxx
|
||||||
|
// Created: Wed Dec 15 13:03:52 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_CoupleOfShapes.hxx>
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_CoupleOfShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_CoupleOfShapes::GEOMAlgo_CoupleOfShapes()
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_CoupleOfShapes::SetShapes(const TopoDS_Shape& aS1,
|
||||||
|
const TopoDS_Shape& aS2)
|
||||||
|
{
|
||||||
|
myShape1=aS1;
|
||||||
|
myShape2=aS2;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_CoupleOfShapes::Shapes(TopoDS_Shape& aS1,
|
||||||
|
TopoDS_Shape& aS2)const
|
||||||
|
{
|
||||||
|
aS1=myShape1;
|
||||||
|
aS2=myShape2;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShape1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_CoupleOfShapes::SetShape1(const TopoDS_Shape& aS1)
|
||||||
|
{
|
||||||
|
myShape1=aS1;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShape2
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_CoupleOfShapes::SetShape2(const TopoDS_Shape& aS2)
|
||||||
|
{
|
||||||
|
myShape2=aS2;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shape1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape1()const
|
||||||
|
{
|
||||||
|
return myShape1;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Shape2
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape2()const
|
||||||
|
{
|
||||||
|
return myShape2;
|
||||||
|
}
|
64
src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.hxx
Normal file
64
src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.hxx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_CoupleOfShapes.hxx
|
||||||
|
// Created: Wed Dec 15 13:03:52 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile
|
||||||
|
#define _GEOMAlgo_CoupleOfShapes_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_CoupleOfShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_CoupleOfShapes
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_CoupleOfShapes();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShapes(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShape1(const TopoDS_Shape& aS1) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShape2(const TopoDS_Shape& aS2) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void Shapes(TopoDS_Shape& aS1,TopoDS_Shape& aS2) const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& Shape1() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& Shape2() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TopoDS_Shape myShape1;
|
||||||
|
TopoDS_Shape myShape2;
|
||||||
|
};
|
||||||
|
#endif
|
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:05:01 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfOrientedShapeShape.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx
|
||||||
|
// Created: Wed Feb 22 10:58:14 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:01:34 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfPassKeyShapeShape.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx
|
||||||
|
// Created: Wed Feb 22 10:53:47 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfRealListOfShape.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:08:26 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx
|
||||||
|
// Created: Wed Feb 22 11:11:09 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfShapePnt.hxx>
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx
|
||||||
|
// Created: Wed Feb 22 10:49:11 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfShapeReal.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx
|
||||||
|
// Created: Wed Feb 22 08:39:02 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile
|
||||||
|
#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
42
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfOrientedShapeShape.hxx
Normal file
42
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfOrientedShapeShape.hxx
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfOrientedShapeShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:03:36 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_OrientedShapeMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_OrientedShapeMapHasher> GEOMAlgo_DataMapOfOrientedShapeShape;
|
||||||
|
typedef GEOMAlgo_DataMapOfOrientedShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
41
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyInteger.hxx
Normal file
41
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyInteger.hxx
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfPassKeyInteger.hxx
|
||||||
|
// Created: Wed Feb 22 10:55:55 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile
|
||||||
|
|
||||||
|
#include <GEOMAlgo_PassKey.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
#include <GEOMAlgo_PassKeyMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<GEOMAlgo_PassKey, Standard_Integer, GEOMAlgo_PassKeyMapHasher> GEOMAlgo_DataMapOfPassKeyInteger;
|
||||||
|
typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
40
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyShapeShape.hxx
Normal file
40
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyShapeShape.hxx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfPassKeyShapeShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:00:16 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile
|
||||||
|
|
||||||
|
#include <GEOMAlgo_PassKey.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <GEOMAlgo_PassKeyMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<GEOMAlgo_PassKey, TopoDS_Shape, GEOMAlgo_PassKeyMapHasher> GEOMAlgo_DataMapOfPassKeyShapeShape;
|
||||||
|
typedef GEOMAlgo_DataMapOfPassKeyShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
43
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfRealListOfShape.hxx
Normal file
43
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfRealListOfShape.hxx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfRealListOfShape.hxx
|
||||||
|
// Created: Wed Feb 22 10:51:48 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfRealListOfShape_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TColStd_MapRealHasher.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<Standard_Real, TopTools_ListOfShape, TColStd_MapRealHasher> GEOMAlgo_DataMapOfRealListOfShape;
|
||||||
|
typedef GEOMAlgo_DataMapOfRealListOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
44
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeMapOfShape.hxx
Normal file
44
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeMapOfShape.hxx
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfShapeMapOfShape.hxx
|
||||||
|
// Created: Wed Feb 22 11:07:16 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile
|
||||||
|
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ShapeMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<TopoDS_Shape, TopTools_MapOfShape, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeMapOfShape;
|
||||||
|
typedef GEOMAlgo_DataMapOfShapeMapOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
44
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapePnt.hxx
Normal file
44
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapePnt.hxx
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfShapePnt.hxx
|
||||||
|
// Created: Wed Feb 22 11:10:15 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfShapePnt_HeaderFile
|
||||||
|
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <TopTools_ShapeMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<TopoDS_Shape, gp_Pnt, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapePnt;
|
||||||
|
typedef GEOMAlgo_DataMapOfShapePnt::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
41
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeReal.hxx
Normal file
41
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeReal.hxx
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfShapeReal.hxx
|
||||||
|
// Created: Wed Feb 22 10:47:23 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfShapeReal_HeaderFile
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#include <TopTools_ShapeMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeReal;
|
||||||
|
typedef GEOMAlgo_DataMapOfShapeReal::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
42
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeShapeSet.hxx
Normal file
42
src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeShapeSet.hxx
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// 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: GEOMAlgo_DataMapOfShapeShapeSet.hxx
|
||||||
|
// Created: Wed Feb 22 08:36:15 2012
|
||||||
|
// Author:
|
||||||
|
// <pkv@BDEURI37616>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile
|
||||||
|
#define GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeSet.hxx>
|
||||||
|
#include <TopTools_ShapeMapHasher.hxx>
|
||||||
|
|
||||||
|
#define _NCollection_MapHasher
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
typedef NCollection_DataMap<TopoDS_Shape, GEOMAlgo_ShapeSet, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeShapeSet;
|
||||||
|
typedef GEOMAlgo_DataMapOfShapeShapeSet::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet;
|
||||||
|
|
||||||
|
#undef _NCollection_MapHasher
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
616
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.cxx
Normal file
616
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.cxx
Normal file
@ -0,0 +1,616 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn.cxx
|
||||||
|
// Created: Tue Jan 11 14:44:31 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_FinderShapeOn.hxx>
|
||||||
|
|
||||||
|
#include <Basics_OCCTVersion.hxx>
|
||||||
|
|
||||||
|
#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopAbs_Orientation.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
#include <TopoDS_Shell.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <BRepMesh_IncrementalMesh.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <BRepLib_MakeFace.hxx>
|
||||||
|
#include <BRepLib_FaceError.hxx>
|
||||||
|
|
||||||
|
#include <BOPTools_DSFiller.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_WireSolid.hxx>
|
||||||
|
#include <GEOMAlgo_ShellSolid.hxx>
|
||||||
|
#include <GEOMAlgo_VertexSolid.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeSolid.hxx>
|
||||||
|
#include <GEOMAlgo_SolidSolid.hxx>
|
||||||
|
#include <GEOMAlgo_SurfaceTools.hxx>
|
||||||
|
#include <GEOMAlgo_Tools.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn::GEOMAlgo_FinderShapeOn()
|
||||||
|
:
|
||||||
|
GEOMAlgo_ShapeAlgo()
|
||||||
|
{
|
||||||
|
myTolerance=0.0001;
|
||||||
|
myShapeType=TopAbs_VERTEX;
|
||||||
|
myState=GEOMAlgo_ST_UNKNOWN;
|
||||||
|
myIsAnalytic=Standard_True;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn::~GEOMAlgo_FinderShapeOn()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetSurface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::SetSurface(const Handle(Geom_Surface)& aS)
|
||||||
|
{
|
||||||
|
mySurface=aS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Surface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn::Surface() const
|
||||||
|
{
|
||||||
|
return mySurface;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::SetShapeType(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
myShapeType=aType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::ShapeType()const
|
||||||
|
{
|
||||||
|
return myShapeType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetState
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::SetState(const GEOMAlgo_State aState)
|
||||||
|
{
|
||||||
|
myState=aState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : State
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_State GEOMAlgo_FinderShapeOn::State() const
|
||||||
|
{
|
||||||
|
return myState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: Shapes
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn::Shapes() const
|
||||||
|
{
|
||||||
|
Standard_Boolean bIsConformState;
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopTools_ListOfShape* pL;
|
||||||
|
//
|
||||||
|
pL=(TopTools_ListOfShape*) &myLS;
|
||||||
|
pL->Clear();
|
||||||
|
//
|
||||||
|
aNb=myMSS.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=myMSS.FindKey(i);
|
||||||
|
aSt=myMSS.FindFromIndex(i);
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (bIsConformState) {
|
||||||
|
pL->Append(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myLS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
myWarningStatus=0;
|
||||||
|
myLS.Clear();
|
||||||
|
myMSS.Clear();
|
||||||
|
//
|
||||||
|
if (!myResult.IsNull()){
|
||||||
|
myResult.Nullify();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
CheckData();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_ShapeAlgo::Perform();
|
||||||
|
//
|
||||||
|
myIsAnalytic=GEOMAlgo_SurfaceTools::IsAnalytic(mySurface);
|
||||||
|
//
|
||||||
|
MakeArgument1();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myIsAnalytic && myShapeType==TopAbs_VERTEX) {
|
||||||
|
FindVertices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
MakeArgument2();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Find();
|
||||||
|
if(myErrorStatus || myWarningStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : FindVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::FindVertices()
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNb, iErr;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopAbs_Orientation aOr;
|
||||||
|
gp_Pnt aP;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myArg1, TopAbs_FACE, aM);
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aM(1));
|
||||||
|
aOr=aF.Orientation();
|
||||||
|
//
|
||||||
|
aM.Clear();
|
||||||
|
TopExp::MapShapes(myShape, myShapeType, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
if (!aNb) {
|
||||||
|
myWarningStatus=10; // No found sub-shapes of type myShapeType
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aM(i);
|
||||||
|
const TopoDS_Vertex& aV=TopoDS::Vertex(aS);
|
||||||
|
aP=BRep_Tool::Pnt(aV);
|
||||||
|
iErr=GEOMAlgo_SurfaceTools::GetState(aP, mySurface, myTolerance, aSt);
|
||||||
|
if (aOr==TopAbs_REVERSED) {
|
||||||
|
aSt=GEOMAlgo_SurfaceTools::ReverseState(aSt);
|
||||||
|
}
|
||||||
|
myMSS.Add(aS, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Find
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::Find()
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
Standard_Boolean bICS;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myArg2, myShapeType, aM);
|
||||||
|
//
|
||||||
|
aNb=aM.Extent();
|
||||||
|
if (!aNb) {
|
||||||
|
myWarningStatus=10; // No found sub-shapes of type myShapeType
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bICS=GEOMAlgo_Tools::IsCompositeShape(myArg2);
|
||||||
|
if (!bICS || myIsAnalytic) {
|
||||||
|
TopoDS_Compound aCmp;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
//
|
||||||
|
aBB.MakeCompound(aCmp);
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aSi=aM(i);
|
||||||
|
aBB.Add(aCmp, aSi);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aM.Clear();
|
||||||
|
aM.Add(aCmp);
|
||||||
|
aNb=1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aM(i);
|
||||||
|
Find(aS);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Find
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::Find(const TopoDS_Shape& aS)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsDone;
|
||||||
|
Standard_Integer i, iErr;
|
||||||
|
TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON};
|
||||||
|
TopTools_ListIteratorOfListOfShape aIt;
|
||||||
|
BOPTools_DSFiller aDF;
|
||||||
|
//
|
||||||
|
// 1. Prepare DSFiller
|
||||||
|
aDF.SetShapes (myArg1, aS);
|
||||||
|
bIsDone=aDF.IsDone();
|
||||||
|
if (!bIsDone) {
|
||||||
|
myErrorStatus=30; // wrong args are used for DSFiller
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aDF.Perform();
|
||||||
|
bIsDone=aDF.IsDone();
|
||||||
|
if (!bIsDone) {
|
||||||
|
myErrorStatus=31; // DSFiller failed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2. Find shapes
|
||||||
|
GEOMAlgo_ShapeSolid* pSS;
|
||||||
|
GEOMAlgo_VertexSolid aVXS;
|
||||||
|
GEOMAlgo_WireSolid aWRS;
|
||||||
|
GEOMAlgo_ShellSolid aSHS;
|
||||||
|
GEOMAlgo_SolidSolid aSLS;
|
||||||
|
//
|
||||||
|
pSS=NULL;
|
||||||
|
//
|
||||||
|
switch (myShapeType) {
|
||||||
|
case TopAbs_VERTEX:
|
||||||
|
pSS=&aVXS;
|
||||||
|
break;
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
pSS=&aWRS;
|
||||||
|
break;
|
||||||
|
case TopAbs_FACE:
|
||||||
|
pSS=&aSHS;
|
||||||
|
break;
|
||||||
|
case TopAbs_SOLID:
|
||||||
|
aSLS.SetShape2(myArg2);
|
||||||
|
pSS=&aSLS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
myErrorStatus=12; // unallowed sub-shape type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
pSS->SetFiller(aDF);
|
||||||
|
pSS->Perform();
|
||||||
|
iErr=pSS->ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=32; // builder ShapeSolid failed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=0; i<3; ++i) {
|
||||||
|
const TopTools_ListOfShape& aLS=pSS->Shapes(aSts[i]);
|
||||||
|
aIt.Initialize(aLS);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aSImage=aIt.Value();
|
||||||
|
if (myImages.IsBound(aSImage)) {
|
||||||
|
const TopoDS_Shape& aSx=myImages.Find(aSImage);
|
||||||
|
myMSS.Add(aSx, aSts[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myErrorStatus=33;// can not find original shape
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : MakeArgument1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::MakeArgument1()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
BRepLib_FaceError aFErr;
|
||||||
|
BRepLib_MakeFace aMF;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopoDS_Face aFace;
|
||||||
|
TopoDS_Shell aSh;
|
||||||
|
TopoDS_Solid aSd;
|
||||||
|
//
|
||||||
|
// Argument 1
|
||||||
|
if (!myIsAnalytic) {
|
||||||
|
#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
|
||||||
|
aMF.Init(mySurface, Standard_True, Precision::Confusion());
|
||||||
|
#else
|
||||||
|
aMF.Init(mySurface, Standard_True);
|
||||||
|
#endif
|
||||||
|
aFErr=aMF.Error();
|
||||||
|
if (aFErr!=BRepLib_FaceDone) {
|
||||||
|
myErrorStatus=20; // can not build the face
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aF=aMF.Shape();
|
||||||
|
aFace=TopoDS::Face(aF);
|
||||||
|
//
|
||||||
|
// update tolerances
|
||||||
|
aM.Add(aF);
|
||||||
|
TopExp::MapShapes(aF, TopAbs_VERTEX, aM);
|
||||||
|
TopExp::MapShapes(aF, TopAbs_EDGE, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aM(i);
|
||||||
|
aType=aS.ShapeType();
|
||||||
|
switch (aType) {
|
||||||
|
case TopAbs_VERTEX: {
|
||||||
|
const TopoDS_Vertex& aVx=TopoDS::Vertex(aS);
|
||||||
|
aBB.UpdateVertex(aVx, myTolerance);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TopAbs_EDGE: {
|
||||||
|
const TopoDS_Edge& aEx=TopoDS::Edge(aS);
|
||||||
|
aBB.UpdateEdge(aEx, myTolerance);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TopAbs_FACE: {
|
||||||
|
const TopoDS_Face& aFx=TopoDS::Face(aS);
|
||||||
|
aBB.UpdateFace(aFx, myTolerance);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //
|
||||||
|
else {
|
||||||
|
aBB.MakeFace(aFace, mySurface, myTolerance);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// make solid
|
||||||
|
aBB.MakeShell(aSh);
|
||||||
|
aBB.Add(aSh, aFace);
|
||||||
|
aBB.MakeSolid(aSd);
|
||||||
|
aBB.Add(aSd, aSh);
|
||||||
|
myArg1=aSd;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : MakeArgument2
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::MakeArgument2()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
TopoDS_Shape aSC;
|
||||||
|
TopTools_DataMapOfShapeShape aOriginals;
|
||||||
|
//
|
||||||
|
myImages.Clear();
|
||||||
|
//
|
||||||
|
GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC);
|
||||||
|
//
|
||||||
|
myArg2=aSC;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::CheckData()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if(mySurface.IsNull()) {
|
||||||
|
myErrorStatus=10; // mySurface=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myShape.IsNull()) {
|
||||||
|
myErrorStatus=11; // myShape=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!(myShapeType==TopAbs_VERTEX ||
|
||||||
|
myShapeType==TopAbs_EDGE ||
|
||||||
|
myShapeType==TopAbs_FACE ||
|
||||||
|
myShapeType==TopAbs_SOLID)) {
|
||||||
|
myErrorStatus=12; // unallowed sub-shape type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_UNKNOWN ||
|
||||||
|
myState==GEOMAlgo_ST_INOUT) {
|
||||||
|
myErrorStatus=13; // unallowed state type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : CopySource
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn::CopySource(const TopoDS_Shape& aE,
|
||||||
|
TopTools_DataMapOfShapeShape& aImages,
|
||||||
|
TopTools_DataMapOfShapeShape& aOriginals,
|
||||||
|
TopoDS_Shape& aEx)
|
||||||
|
{
|
||||||
|
Standard_Boolean bFree;
|
||||||
|
TopAbs_ShapeEnum aType;
|
||||||
|
Standard_Integer aR;
|
||||||
|
BRep_Builder BB;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
//
|
||||||
|
aType=aE.ShapeType();
|
||||||
|
//
|
||||||
|
if (aOriginals.IsBound(aE)) {
|
||||||
|
aEx=aOriginals.ChangeFind(aE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aEx=aE.EmptyCopied();
|
||||||
|
aOriginals.Bind(aE, aEx);
|
||||||
|
aImages.Bind(aEx, aE);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aR=(Standard_Integer)aType+1;
|
||||||
|
if (aR>TopAbs_VERTEX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bFree=aEx.Free();
|
||||||
|
aEx.Free(Standard_True);
|
||||||
|
//
|
||||||
|
aType=(TopAbs_ShapeEnum) aR;
|
||||||
|
//
|
||||||
|
aIt.Initialize(aE);//, Standard_False);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aIt.Value();
|
||||||
|
TopoDS_Shape aVx;
|
||||||
|
//
|
||||||
|
CopySource (aV, aImages, aOriginals, aVx);
|
||||||
|
//
|
||||||
|
aVx.Orientation(aV.Orientation());
|
||||||
|
BB.Add(aEx, aVx);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aEx.Free(bFree);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : BuildTriangulation
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean
|
||||||
|
GEOMAlgo_FinderShapeOn::BuildTriangulation (const TopoDS_Shape& theShape)
|
||||||
|
{
|
||||||
|
// calculate deflection
|
||||||
|
Standard_Real aDeviationCoefficient = 0.001;
|
||||||
|
|
||||||
|
Bnd_Box B;
|
||||||
|
BRepBndLib::Add(theShape, B);
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
|
||||||
|
Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
|
||||||
|
Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
|
||||||
|
Standard_Real aHLRAngle = 0.349066;
|
||||||
|
|
||||||
|
// build triangulation
|
||||||
|
BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle);
|
||||||
|
|
||||||
|
// check triangulation
|
||||||
|
bool isTriangulation = true;
|
||||||
|
|
||||||
|
TopExp_Explorer exp (theShape, TopAbs_FACE);
|
||||||
|
if (exp.More())
|
||||||
|
{
|
||||||
|
TopLoc_Location aTopLoc;
|
||||||
|
Handle(Poly_Triangulation) aTRF;
|
||||||
|
aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
|
||||||
|
if (aTRF.IsNull()) {
|
||||||
|
isTriangulation = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // no faces, try edges
|
||||||
|
{
|
||||||
|
TopExp_Explorer expe (theShape, TopAbs_EDGE);
|
||||||
|
if (!expe.More()) {
|
||||||
|
isTriangulation = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
|
||||||
|
if (aPE.IsNull()) {
|
||||||
|
isTriangulation = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isTriangulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// myErrorStatus :
|
||||||
|
//
|
||||||
|
// 10 -mySurface=NULL
|
||||||
|
// 11 -myShape=NULL
|
||||||
|
// 12 -unallowed type of sub-shapes
|
||||||
|
// 13 -unallowed state
|
||||||
|
// 20 -can not build the face
|
||||||
|
// 30 -wrong args are used for DSFiller
|
||||||
|
// 31 -DSFiller failed
|
||||||
|
// 32 -builder ShapeSolid failed
|
||||||
|
// 33 -can not find original shape
|
||||||
|
//
|
||||||
|
// myWarningStatus
|
||||||
|
//
|
||||||
|
// 10 - sub-shapes of type myShapeType can not be fond in myShape
|
120
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.hxx
Normal file
120
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.hxx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
|
||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn.hxx
|
||||||
|
// Created: Tue Jan 11 14:44:31 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile
|
||||||
|
#define _GEOMAlgo_FinderShapeOn_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <GEOMAlgo_State.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeAlgo.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_FinderShapeOn : public GEOMAlgo_ShapeAlgo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_FinderShapeOn();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_FinderShapeOn();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetSurface(const Handle(Geom_Surface)& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShapeType(const TopAbs_ShapeEnum aST) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetState(const GEOMAlgo_State aSF) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const Handle_Geom_Surface& Surface() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
TopAbs_ShapeEnum ShapeType() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_State State() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
static void CopySource(const TopoDS_Shape& aS,
|
||||||
|
TopTools_DataMapOfShapeShape& aImages,
|
||||||
|
TopTools_DataMapOfShapeShape& aOriginals,
|
||||||
|
TopoDS_Shape& aSC) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void MakeArgument1() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void MakeArgument2() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void Find() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void Find(const TopoDS_Shape& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FindVertices() ;
|
||||||
|
|
||||||
|
|
||||||
|
Handle_Geom_Surface mySurface;
|
||||||
|
TopAbs_ShapeEnum myShapeType;
|
||||||
|
GEOMAlgo_State myState;
|
||||||
|
TopoDS_Shape myArg1;
|
||||||
|
TopoDS_Shape myArg2;
|
||||||
|
TopTools_ListOfShape myLS;
|
||||||
|
TopTools_DataMapOfShapeShape myImages;
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeState myMSS;
|
||||||
|
Standard_Boolean myIsAnalytic;
|
||||||
|
};
|
||||||
|
#endif
|
854
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.cxx
Normal file
854
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.cxx
Normal file
@ -0,0 +1,854 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn1.cxx
|
||||||
|
// Created: Fri Mar 4 10:31:06 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_FinderShapeOn1.hxx>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <gp_Trsf.hxx>
|
||||||
|
#include <gp_Cylinder.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
|
|
||||||
|
#include <Poly_Array1OfTriangle.hxx>
|
||||||
|
#include <Poly_Triangle.hxx>
|
||||||
|
#include <Poly_PolygonOnTriangulation.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
|
#include <Poly_Polygon3D.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
#include <GeomAbs_CurveType.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepLib_MakeEdge.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_SurfaceTools.hxx>
|
||||||
|
#include <GEOMAlgo_StateCollector.hxx>
|
||||||
|
#include <GEOMAlgo_FinderShapeOn.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_PassKey.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn1::GEOMAlgo_FinderShapeOn1()
|
||||||
|
:
|
||||||
|
GEOMAlgo_ShapeAlgo()
|
||||||
|
{
|
||||||
|
myTolerance=0.0001;
|
||||||
|
myShapeType=TopAbs_VERTEX;
|
||||||
|
myState=GEOMAlgo_ST_UNKNOWN;
|
||||||
|
myNbPntsMin=3;
|
||||||
|
myNbPntsMax=0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn1::~GEOMAlgo_FinderShapeOn1()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetSurface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::SetSurface(const Handle(Geom_Surface)& aS)
|
||||||
|
{
|
||||||
|
mySurface=aS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Surface
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn1::Surface() const
|
||||||
|
{
|
||||||
|
return mySurface;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::SetShapeType(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
myShapeType=aType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn1::ShapeType()const
|
||||||
|
{
|
||||||
|
return myShapeType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetState
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::SetState(const GEOMAlgo_State aState)
|
||||||
|
{
|
||||||
|
myState=aState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : State
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_State GEOMAlgo_FinderShapeOn1::State() const
|
||||||
|
{
|
||||||
|
return myState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNbPntsMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::SetNbPntsMin(const Standard_Integer aNb)
|
||||||
|
{
|
||||||
|
myNbPntsMin=aNb;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPntsMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMin()const
|
||||||
|
{
|
||||||
|
return myNbPntsMin;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNbPntsMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::SetNbPntsMax(const Standard_Integer aNb)
|
||||||
|
{
|
||||||
|
myNbPntsMax=aNb;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPntsMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMax()const
|
||||||
|
{
|
||||||
|
return myNbPntsMax;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: MSS
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn1::MSS() const
|
||||||
|
{
|
||||||
|
return myMSS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: Shapes
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn1::Shapes() const
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
TopTools_ListOfShape* pL;
|
||||||
|
//
|
||||||
|
pL=(TopTools_ListOfShape*) &myLS;
|
||||||
|
pL->Clear();
|
||||||
|
//
|
||||||
|
aNb=myMSS.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=myMSS.FindKey(i);
|
||||||
|
if (aS.ShapeType()==myShapeType) {
|
||||||
|
pL->Append(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myLS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
myWarningStatus=0;
|
||||||
|
myLS.Clear();
|
||||||
|
myMSS.Clear();
|
||||||
|
//
|
||||||
|
CheckData();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_ShapeAlgo::Perform();
|
||||||
|
//
|
||||||
|
// 1
|
||||||
|
ProcessVertices();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_VERTEX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2
|
||||||
|
ProcessEdges();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_EDGE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 3
|
||||||
|
ProcessFaces();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_FACE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4
|
||||||
|
ProcessSolids();
|
||||||
|
//
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::ProcessVertices()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState;
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
gp_Pnt aP;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_VERTEX, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i));
|
||||||
|
aP=BRep_Tool::Pnt(aV);
|
||||||
|
//
|
||||||
|
aSt = GetPointState( aP );
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
//
|
||||||
|
if (myShapeType==TopAbs_VERTEX){
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aV, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aV, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessEdges
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::ProcessEdges()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState, bIsToBreak;
|
||||||
|
Standard_Integer i, aNb, iCnt;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
GEOMAlgo_ListIteratorOfListOfPnt aIt;
|
||||||
|
GeomAbs_SurfaceType aType1;
|
||||||
|
//
|
||||||
|
aType1=myGAS.GetType();
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_EDGE, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
GEOMAlgo_ListOfPnt aLP;
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
//
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
|
||||||
|
//
|
||||||
|
aExp.Init(aE, TopAbs_VERTEX);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aExp.Current();
|
||||||
|
//
|
||||||
|
bIsConformState=myMSS.Contains(aV);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// vertex has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aV);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // vertex has non-conformed state,skip edge
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) {
|
||||||
|
Standard_Real aT1, aT2;
|
||||||
|
Handle(Geom_Curve) aC;
|
||||||
|
GeomAdaptor_Curve aGAC;
|
||||||
|
GeomAbs_CurveType aType2;
|
||||||
|
//
|
||||||
|
aC=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
|
aGAC.Load(aC);
|
||||||
|
//
|
||||||
|
aType2=aGAC.GetType();
|
||||||
|
if (aType2==GeomAbs_Line) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
InnerPoints(aE, aLP);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsConformState=Standard_True;
|
||||||
|
aIt.Initialize(aLP);
|
||||||
|
for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
|
||||||
|
if (myNbPntsMax) {
|
||||||
|
if (iCnt > myNbPntsMax) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Pnt& aP=aIt.Value();
|
||||||
|
aSt = GetPointState( aP );
|
||||||
|
bIsToBreak=aSC.AppendState(aSt);
|
||||||
|
if (bIsToBreak) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (myShapeType==TopAbs_EDGE) {
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
}
|
||||||
|
} // for (i=1; i<=aNb; ++i) next edge
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::ProcessFaces()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState, bIsToBreak;
|
||||||
|
Standard_Integer i, aNbF, iCnt;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
GEOMAlgo_ListIteratorOfListOfPnt aIt;
|
||||||
|
GeomAbs_SurfaceType aType1, aType2;
|
||||||
|
//
|
||||||
|
aType1=myGAS.GetType();
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_FACE, aM);
|
||||||
|
aNbF=aM.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
GEOMAlgo_ListOfPnt aLP;
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aM(i));
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_ON) {
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
GeomAdaptor_Surface aGAS;
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
aGAS.Load(aS);
|
||||||
|
aType2=aGAS.GetType();
|
||||||
|
if (aType2!=aType1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aExp.Init(aF, TopAbs_EDGE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aExp.Current();
|
||||||
|
bIsConformState=myMSS.Contains(aE);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// edge has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aE);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // edge has non-conformed state,skip face
|
||||||
|
}
|
||||||
|
//
|
||||||
|
InnerPoints(aF, aLP);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsConformState=Standard_True;
|
||||||
|
aIt.Initialize(aLP);
|
||||||
|
for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
|
||||||
|
if (myNbPntsMax) {
|
||||||
|
if (iCnt > myNbPntsMax) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Pnt& aP=aIt.Value();
|
||||||
|
aSt = GetPointState( aP );
|
||||||
|
bIsToBreak=aSC.AppendState(aSt);
|
||||||
|
if (bIsToBreak) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (myShapeType==TopAbs_FACE) {
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aF, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aF, aSt);
|
||||||
|
}
|
||||||
|
}// for (i=1; i<=aNb; ++i) next face
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessSolids
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::ProcessSolids()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState;
|
||||||
|
Standard_Integer i, aNbS, j, aNbF;
|
||||||
|
TopTools_IndexedMapOfShape aM, aMF;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_SOLID, aM);
|
||||||
|
aNbS=aM.Extent();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aSd=aM(i);
|
||||||
|
aMF.Clear();
|
||||||
|
TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
|
||||||
|
aNbF=aMF.Extent();
|
||||||
|
for (j=1; j<=aNbF; ++j) {
|
||||||
|
const TopoDS_Shape& aF=aMF(j);
|
||||||
|
bIsConformState=myMSS.Contains(aF);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// face has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aF);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // face has non-conformed state,skip solid
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aSd, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
Handle(Poly_Triangulation) aTRF;
|
||||||
|
TColStd_MapOfInteger aMBN;
|
||||||
|
GEOMAlgo_DataMapOfPassKeyInteger aMPKI;
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
|
||||||
|
gp_Pnt aP, aP1, aP2;
|
||||||
|
//
|
||||||
|
aLP.Clear();
|
||||||
|
//
|
||||||
|
aTRF=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
if (aTRF.IsNull()) {
|
||||||
|
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) {
|
||||||
|
myWarningStatus=20; // no triangulation found
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aTRF=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const Poly_Array1OfTriangle& aTrs=aTRF->Triangles();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aTRF->Nodes();
|
||||||
|
//
|
||||||
|
// map link/nbtriangles
|
||||||
|
j1=aTrs.Lower();
|
||||||
|
j2=aTrs.Upper();
|
||||||
|
for (j=j1; j<=j2; ++j) {
|
||||||
|
const Poly_Triangle& aTr=aTrs(j);
|
||||||
|
aTr.Get(n[0], n[1], n[2]);
|
||||||
|
n[3]=n[0];
|
||||||
|
for (k=0; k<3; ++k) {
|
||||||
|
GEOMAlgo_PassKey aPK;
|
||||||
|
//
|
||||||
|
aPK.SetIds(n[k], n[k+1]);
|
||||||
|
if (aMPKI.IsBound(aPK)) {
|
||||||
|
Standard_Integer& iCntX=aMPKI.ChangeFind(aPK);
|
||||||
|
++iCntX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMPKI.Bind(aPK, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// boundary nodes aMBN
|
||||||
|
aNbLinks=aMPKI.Extent();
|
||||||
|
aIt.Initialize(aMPKI);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
iCnt=aIt.Value();
|
||||||
|
if (iCnt==1) {
|
||||||
|
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||||
|
//
|
||||||
|
aNx=(Standard_Integer)aPK.Id(1);
|
||||||
|
aMBN.Add(aNx);
|
||||||
|
aNx=(Standard_Integer)aPK.Id(2);
|
||||||
|
aMBN.Add(aNx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// inner nodes=all_nodes - boundary_nodes
|
||||||
|
j1=aNodes.Lower();
|
||||||
|
j2=aNodes.Upper();
|
||||||
|
for (j=j1; j<=j2; ++j) {
|
||||||
|
if (!aMBN.Contains(j)) {
|
||||||
|
aP=aNodes(j).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
//
|
||||||
|
if (!aNb && myNbPntsMin) {
|
||||||
|
// try to fill it yourself
|
||||||
|
Standard_Boolean bIsDone;
|
||||||
|
Standard_Integer aN1, aN2;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
GeomAdaptor_Surface aGAS;
|
||||||
|
GeomAbs_SurfaceType aType;
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
aGAS.Load(aS);
|
||||||
|
aType=aGAS.GetType();
|
||||||
|
if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
|
||||||
|
// inner links
|
||||||
|
aNbLinks=aMPKI.Extent();
|
||||||
|
aIt.Initialize(aMPKI);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
iCnt=aIt.Value();
|
||||||
|
if (iCnt>1) {
|
||||||
|
// take the first having occured inner link
|
||||||
|
// and discretize it
|
||||||
|
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||||
|
//
|
||||||
|
aN1=(Standard_Integer)aPK.Id(1);
|
||||||
|
aN2=(Standard_Integer)aPK.Id(2);
|
||||||
|
//
|
||||||
|
aP1=aNodes(aN1).Transformed(aTrsf);
|
||||||
|
aP2=aNodes(aN2).Transformed(aTrsf);
|
||||||
|
//
|
||||||
|
if (aType==GeomAbs_Cylinder) {
|
||||||
|
Standard_Real aTolSM;
|
||||||
|
gp_Cylinder aCyl;
|
||||||
|
//
|
||||||
|
aTolSM=1.523e-6;//~1.-cos(0.1 deg)
|
||||||
|
aCyl=aGAS.Cylinder();
|
||||||
|
if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRepLib_MakeEdge aBME(aP1, aP2);
|
||||||
|
bIsDone=aBME.IsDone();
|
||||||
|
if (!bIsDone) {
|
||||||
|
myErrorStatus=30; //can not obtain the line fron the link
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aSx=aBME.Shape();
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aSx);
|
||||||
|
//
|
||||||
|
InnerPoints(aE, myNbPntsMin, aLP);
|
||||||
|
break;
|
||||||
|
}// if (iCnt>1)
|
||||||
|
}// for (; aIt.More(); aIt.Next())
|
||||||
|
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
|
||||||
|
}// if (!aNb && myNbPntsMin) {
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 09:56:20 2012f
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
Standard_Integer aNbPntsMin;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
aNbPntsMin=21;
|
||||||
|
//
|
||||||
|
aLP.Clear();
|
||||||
|
InnerPoints(aE, aNbPntsMin, aLP);
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 09:56:32 2012t
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
const Standard_Integer aNbPntsMin,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
Standard_Boolean bInf1, bInf2;
|
||||||
|
Standard_Integer j, aNbT;
|
||||||
|
Standard_Real dT, aT, aT1, aT2;
|
||||||
|
gp_Pnt aP;
|
||||||
|
Handle(Geom_Curve) aC3D;
|
||||||
|
//
|
||||||
|
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
|
if (aC3D.IsNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bInf1=Precision::IsNegativeInfinite(aT1);
|
||||||
|
bInf2=Precision::IsPositiveInfinite(aT2);
|
||||||
|
if (bInf1 || bInf2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 09:51:20 2012f
|
||||||
|
/*
|
||||||
|
aNbT=myNbPntsMin+1;
|
||||||
|
dT=(aT2-aT1)/aNbT;
|
||||||
|
for (j=1; j<=aNbPntsMin; ++j) {
|
||||||
|
aT=aT1+j*dT;
|
||||||
|
aC3D->D0(aT, aP);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
aNbT=aNbPntsMin+1;
|
||||||
|
dT=(aT2-aT1)/aNbT;
|
||||||
|
for (j=1; j<aNbT; ++j) {
|
||||||
|
aT=aT1+j*dT;
|
||||||
|
aC3D->D0(aT, aP);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 09:51:24 2012t
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::CheckData()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if(mySurface.IsNull()) {
|
||||||
|
myErrorStatus=10; // mySurface=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myShape.IsNull()) {
|
||||||
|
myErrorStatus=11; // myShape=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!(myShapeType==TopAbs_VERTEX ||
|
||||||
|
myShapeType==TopAbs_EDGE ||
|
||||||
|
myShapeType==TopAbs_FACE ||
|
||||||
|
myShapeType==TopAbs_SOLID)) {
|
||||||
|
myErrorStatus=12; // unallowed subshape type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_UNKNOWN ||
|
||||||
|
myState==GEOMAlgo_ST_INOUT) {
|
||||||
|
myErrorStatus=13; // unallowed state type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
GeomAbs_SurfaceType aType;
|
||||||
|
//
|
||||||
|
myGAS.Load(mySurface);
|
||||||
|
aType=myGAS.GetType();
|
||||||
|
if (!(aType==GeomAbs_Plane ||
|
||||||
|
aType==GeomAbs_Cylinder ||
|
||||||
|
aType==GeomAbs_Sphere)) {
|
||||||
|
myErrorStatus=14; // unallowed surface type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetPointState
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP)
|
||||||
|
{
|
||||||
|
TopAbs_State aSt;
|
||||||
|
GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt);
|
||||||
|
return aSt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// myErrorStatus :
|
||||||
|
//
|
||||||
|
// 10 -mySurface=NULL
|
||||||
|
// 11 -myShape=NULL
|
||||||
|
// 12 -unallowed type of subshapes
|
||||||
|
// 13 -unallowed state
|
||||||
|
// 14 -unallowed surface type
|
||||||
|
// 15 -unallowed surface type
|
||||||
|
// 20- no triangulation found
|
||||||
|
// 30- can not obtain the line from the link
|
||||||
|
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 10:01:14 2012f
|
||||||
|
/*
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer j, aNbNodes, aIndex, aNb;
|
||||||
|
Handle(Poly_PolygonOnTriangulation) aPTE;
|
||||||
|
Handle(Poly_Triangulation) aTRE;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
gp_Pnt aP;
|
||||||
|
//
|
||||||
|
aLP.Clear();
|
||||||
|
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
|
||||||
|
if (aTRE.IsNull() || aPTE.IsNull()) {
|
||||||
|
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
|
||||||
|
if (aPE.IsNull()) {
|
||||||
|
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) {
|
||||||
|
myErrorStatus=20; // no triangulation found
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aPE = BRep_Tool::Polygon3D(aE, aLoc);
|
||||||
|
}
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aPE->Nodes();
|
||||||
|
//
|
||||||
|
aNbNodes=aPE->NbNodes();
|
||||||
|
Standard_Integer low = aNodes.Lower(), up = aNodes.Upper();
|
||||||
|
for (j=low+1; j<up; ++j) {
|
||||||
|
aP=aNodes(j).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
|
||||||
|
//
|
||||||
|
aNbNodes=aPTE->NbNodes();
|
||||||
|
const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
|
||||||
|
for (j=2; j<aNbNodes; ++j) {
|
||||||
|
aIndex=aInds(j);
|
||||||
|
aP=aNodes(aIndex).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
if (!aNb && myNbPntsMin) {
|
||||||
|
// try to fill it yourself
|
||||||
|
InnerPoints(aE, myNbPntsMin, aLP);
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//modified by NIZNHY-PKV Thu Jan 26 10:01:17 2012t
|
145
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.hxx
Normal file
145
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.hxx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn1.hxx
|
||||||
|
// Created: Fri Mar 4 10:31:06 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_FinderShapeOn1_HeaderFile
|
||||||
|
#define _GEOMAlgo_FinderShapeOn1_HeaderFile
|
||||||
|
|
||||||
|
#include <GEOMAlgo_State.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeAlgo.hxx>
|
||||||
|
#include <GEOMAlgo_ListOfPnt.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Handle_Geom_Surface.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_FinderShapeOn1 : public GEOMAlgo_ShapeAlgo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_FinderShapeOn1();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_FinderShapeOn1();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetSurface(const Handle(Geom_Surface)& aS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShapeType(const TopAbs_ShapeEnum aST) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetState(const GEOMAlgo_State aSF) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetNbPntsMin(const Standard_Integer aNb) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer NbPntsMin() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetNbPntsMax(const Standard_Integer aNb) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer NbPntsMax() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const Handle_Geom_Surface& Surface() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
TopAbs_ShapeEnum ShapeType() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_State State() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessVertices() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessEdges() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessFaces() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessSolids() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Face& aF,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
const Standard_Integer aNbPnts,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual TopAbs_State GetPointState(const gp_Pnt& aP) ;
|
||||||
|
|
||||||
|
|
||||||
|
Handle_Geom_Surface mySurface;
|
||||||
|
TopAbs_ShapeEnum myShapeType;
|
||||||
|
GEOMAlgo_State myState;
|
||||||
|
Standard_Integer myNbPntsMin;
|
||||||
|
Standard_Integer myNbPntsMax;
|
||||||
|
GeomAdaptor_Surface myGAS;
|
||||||
|
TopTools_ListOfShape myLS;
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeState myMSS;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
845
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.cxx
Normal file
845
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.cxx
Normal file
@ -0,0 +1,845 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn2.cxx
|
||||||
|
// Created: Fri Mar 4 10:31:06 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_FinderShapeOn2.hxx>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <gp_Trsf.hxx>
|
||||||
|
#include <gp_Cylinder.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
|
|
||||||
|
#include <Poly_Array1OfTriangle.hxx>
|
||||||
|
#include <Poly_Triangle.hxx>
|
||||||
|
#include <Poly_PolygonOnTriangulation.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
|
#include <Poly_Polygon3D.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
#include <GeomAbs_CurveType.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
|
||||||
|
#include <TopLoc_Location.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepLib_MakeEdge.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_SurfaceTools.hxx>
|
||||||
|
#include <GEOMAlgo_StateCollector.hxx>
|
||||||
|
#include <GEOMAlgo_FinderShapeOn.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_PassKey.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn1
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn2::GEOMAlgo_FinderShapeOn2()
|
||||||
|
:
|
||||||
|
GEOMAlgo_ShapeAlgo()
|
||||||
|
{
|
||||||
|
myTolerance=0.0001;
|
||||||
|
myShapeType=TopAbs_VERTEX;
|
||||||
|
myState=GEOMAlgo_ST_UNKNOWN;
|
||||||
|
myNbPntsMin=3;
|
||||||
|
myNbPntsMax=0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_FinderShapeOn2::~GEOMAlgo_FinderShapeOn2()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetClsf
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::SetClsf(const Handle(GEOMAlgo_Clsf)& aClsf)
|
||||||
|
{
|
||||||
|
myClsf=aClsf;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Clsf
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Handle(GEOMAlgo_Clsf)& GEOMAlgo_FinderShapeOn2::Clsf() const
|
||||||
|
{
|
||||||
|
return myClsf;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::SetShapeType(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
myShapeType=aType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShapeType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn2::ShapeType()const
|
||||||
|
{
|
||||||
|
return myShapeType;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetState
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::SetState(const GEOMAlgo_State aState)
|
||||||
|
{
|
||||||
|
myState=aState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : State
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_State GEOMAlgo_FinderShapeOn2::State() const
|
||||||
|
{
|
||||||
|
return myState;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNbPntsMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::SetNbPntsMin(const Standard_Integer aNb)
|
||||||
|
{
|
||||||
|
myNbPntsMin=aNb;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPntsMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_FinderShapeOn2::NbPntsMin()const
|
||||||
|
{
|
||||||
|
return myNbPntsMin;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNbPntsMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::SetNbPntsMax(const Standard_Integer aNb)
|
||||||
|
{
|
||||||
|
myNbPntsMax=aNb;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPntsMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMAlgo_FinderShapeOn2::NbPntsMax()const
|
||||||
|
{
|
||||||
|
return myNbPntsMax;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: MSS
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn2::MSS() const
|
||||||
|
{
|
||||||
|
return myMSS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: Shapes
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn2::Shapes() const
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNb;
|
||||||
|
TopTools_ListOfShape* pL;
|
||||||
|
//
|
||||||
|
pL=(TopTools_ListOfShape*) &myLS;
|
||||||
|
pL->Clear();
|
||||||
|
//
|
||||||
|
aNb=myMSS.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Shape& aS=myMSS.FindKey(i);
|
||||||
|
if (aS.ShapeType()==myShapeType) {
|
||||||
|
pL->Append(aS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myLS;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
myWarningStatus=0;
|
||||||
|
myLS.Clear();
|
||||||
|
myMSS.Clear();
|
||||||
|
//
|
||||||
|
CheckData();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_ShapeAlgo::Perform();
|
||||||
|
//
|
||||||
|
myClsf->SetTolerance(myTolerance);
|
||||||
|
//
|
||||||
|
// 1
|
||||||
|
ProcessVertices();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_VERTEX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 2
|
||||||
|
ProcessEdges();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_EDGE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 3
|
||||||
|
ProcessFaces();
|
||||||
|
if(myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (myShapeType==TopAbs_FACE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4
|
||||||
|
ProcessSolids();
|
||||||
|
//
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::CheckData()
|
||||||
|
{
|
||||||
|
Standard_Integer iErr;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
if(myClsf.IsNull()) {
|
||||||
|
myErrorStatus=10; // myClsf=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myClsf->CheckData();
|
||||||
|
iErr=myClsf->ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=41; // invalid data for classifier
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myShape.IsNull()) {
|
||||||
|
myErrorStatus=11; // myShape=NULL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!(myShapeType==TopAbs_VERTEX ||
|
||||||
|
myShapeType==TopAbs_EDGE ||
|
||||||
|
myShapeType==TopAbs_FACE ||
|
||||||
|
myShapeType==TopAbs_SOLID)) {
|
||||||
|
myErrorStatus=12; // unallowed sub-shape type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_UNKNOWN ||
|
||||||
|
myState==GEOMAlgo_ST_INOUT) {
|
||||||
|
myErrorStatus=13; // unallowed state type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::ProcessVertices()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState;
|
||||||
|
Standard_Integer i, aNb, iErr;
|
||||||
|
gp_Pnt aP;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_VERTEX, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i));
|
||||||
|
aP=BRep_Tool::Pnt(aV);
|
||||||
|
//
|
||||||
|
myClsf->SetPnt(aP);
|
||||||
|
myClsf->Perform();
|
||||||
|
iErr=myClsf->ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=40; // point can not be classified
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=myClsf->State();
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
//
|
||||||
|
if (myShapeType==TopAbs_VERTEX){
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aV, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aV, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessEdges
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::ProcessEdges()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState, bIsToBreak;
|
||||||
|
Standard_Integer i, aNb, iCnt, iErr;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
GEOMAlgo_ListIteratorOfListOfPnt aIt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_EDGE, aM);
|
||||||
|
aNb=aM.Extent();
|
||||||
|
for (i=1; i<=aNb; ++i) {
|
||||||
|
GEOMAlgo_ListOfPnt aLP;
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
//
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
|
||||||
|
//
|
||||||
|
aExp.Init(aE, TopAbs_VERTEX);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aExp.Current();
|
||||||
|
//
|
||||||
|
bIsConformState=myMSS.Contains(aV);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// vertex has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aV);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // vertex has non-conformed state,skip edge
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (BRep_Tool::Degenerated(aE)) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_ON) {
|
||||||
|
Standard_Boolean bCanBeON;
|
||||||
|
Standard_Real aT1, aT2;
|
||||||
|
Handle(Geom_Curve) aC;
|
||||||
|
//
|
||||||
|
aC=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
|
bCanBeON=myClsf->CanBeON(aC);
|
||||||
|
if(!bCanBeON) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
InnerPoints(aE, aLP);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsConformState=Standard_True;
|
||||||
|
aIt.Initialize(aLP);
|
||||||
|
for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
|
||||||
|
if (myNbPntsMax) {
|
||||||
|
if (iCnt > myNbPntsMax) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Pnt& aP=aIt.Value();
|
||||||
|
//
|
||||||
|
myClsf->SetPnt(aP);
|
||||||
|
myClsf->Perform();
|
||||||
|
iErr=myClsf->ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=40; // point can not be classified
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=myClsf->State();
|
||||||
|
//
|
||||||
|
bIsToBreak=aSC.AppendState(aSt);
|
||||||
|
if (bIsToBreak) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (myShapeType==TopAbs_EDGE) {
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aE, aSt);
|
||||||
|
}
|
||||||
|
} // for (i=1; i<=aNb; ++i) next edge
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::ProcessFaces()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState, bIsToBreak, bCanBeON;
|
||||||
|
Standard_Integer i, aNbF, iCnt, iErr;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
TopTools_IndexedMapOfShape aM;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
GEOMAlgo_ListIteratorOfListOfPnt aIt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_FACE, aM);
|
||||||
|
aNbF=aM.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
GEOMAlgo_ListOfPnt aLP;
|
||||||
|
//
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aM(i));
|
||||||
|
//
|
||||||
|
if (myState==GEOMAlgo_ST_ON) {
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
bCanBeON=myClsf->CanBeON(aS);
|
||||||
|
if(!bCanBeON) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aExp.Init(aF, TopAbs_EDGE);
|
||||||
|
for (; aExp.More(); aExp.Next()) {
|
||||||
|
const TopoDS_Shape& aE=aExp.Current();
|
||||||
|
bIsConformState=myMSS.Contains(aE);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// edge has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aE);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // edge has non-conformed state,skip face
|
||||||
|
}
|
||||||
|
//
|
||||||
|
InnerPoints(aF, aLP);
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsConformState=Standard_True;
|
||||||
|
aIt.Initialize(aLP);
|
||||||
|
for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
|
||||||
|
if (myNbPntsMax) {
|
||||||
|
if (iCnt > myNbPntsMax) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Pnt& aP=aIt.Value();
|
||||||
|
//
|
||||||
|
myClsf->SetPnt(aP);
|
||||||
|
myClsf->Perform();
|
||||||
|
iErr=myClsf->ErrorStatus();
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=40; // point can not be classified
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=myClsf->State();
|
||||||
|
//
|
||||||
|
bIsToBreak=aSC.AppendState(aSt);
|
||||||
|
if (bIsToBreak) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (myShapeType==TopAbs_FACE) {
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aF, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bIsConformState || aSt==TopAbs_ON) {
|
||||||
|
myMSS.Add(aF, aSt);
|
||||||
|
}
|
||||||
|
}// for (i=1; i<=aNb; ++i) next face
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProcessSolids
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::ProcessSolids()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Boolean bIsConformState;
|
||||||
|
Standard_Integer i, aNbS, j, aNbF;
|
||||||
|
TopTools_IndexedMapOfShape aM, aMF;
|
||||||
|
TopAbs_State aSt;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_SOLID, aM);
|
||||||
|
aNbS=aM.Extent();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
GEOMAlgo_StateCollector aSC;
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aSd=aM(i);
|
||||||
|
aMF.Clear();
|
||||||
|
TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
|
||||||
|
aNbF=aMF.Extent();
|
||||||
|
for (j=1; j<=aNbF; ++j) {
|
||||||
|
const TopoDS_Shape& aF=aMF(j);
|
||||||
|
bIsConformState=myMSS.Contains(aF);
|
||||||
|
if (!bIsConformState) {
|
||||||
|
break;// face has non-conformed state
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aSt=myMSS.FindFromKey(aF);
|
||||||
|
aSC.AppendState(aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!bIsConformState) {
|
||||||
|
continue; // face has non-conformed state,skip solid
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSt=aSC.State();
|
||||||
|
//
|
||||||
|
bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
|
||||||
|
if (bIsConformState) {
|
||||||
|
myMSS.Add(aSd, aSt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
Handle(Poly_Triangulation) aTRF;
|
||||||
|
TColStd_MapOfInteger aMBN;
|
||||||
|
GEOMAlgo_DataMapOfPassKeyInteger aMPKI;
|
||||||
|
GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
|
||||||
|
gp_Pnt aP, aP1, aP2;
|
||||||
|
//
|
||||||
|
aLP.Clear();
|
||||||
|
//
|
||||||
|
aTRF=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
if (aTRF.IsNull()) {
|
||||||
|
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) {
|
||||||
|
myWarningStatus=20; // no triangulation found
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aTRF=BRep_Tool::Triangulation(aF, aLoc);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const Poly_Array1OfTriangle& aTrs=aTRF->Triangles();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aTRF->Nodes();
|
||||||
|
//
|
||||||
|
// map link/nbtriangles
|
||||||
|
j1=aTrs.Lower();
|
||||||
|
j2=aTrs.Upper();
|
||||||
|
for (j=j1; j<=j2; ++j) {
|
||||||
|
const Poly_Triangle& aTr=aTrs(j);
|
||||||
|
aTr.Get(n[0], n[1], n[2]);
|
||||||
|
n[3]=n[0];
|
||||||
|
for (k=0; k<3; ++k) {
|
||||||
|
GEOMAlgo_PassKey aPK;
|
||||||
|
//
|
||||||
|
aPK.SetIds(n[k], n[k+1]);
|
||||||
|
if (aMPKI.IsBound(aPK)) {
|
||||||
|
Standard_Integer& iCntX=aMPKI.ChangeFind(aPK);
|
||||||
|
++iCntX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aMPKI.Bind(aPK, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// boundary nodes aMBN
|
||||||
|
aNbLinks=aMPKI.Extent();
|
||||||
|
aIt.Initialize(aMPKI);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
iCnt=aIt.Value();
|
||||||
|
if (iCnt==1) {
|
||||||
|
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||||
|
//qf
|
||||||
|
/*
|
||||||
|
aNbMax=aPK.NbMax();
|
||||||
|
pIds=(Standard_Integer*)aPK.Key();
|
||||||
|
for (k=1; k<3; ++k) {
|
||||||
|
aNx=*(pIds+aNbMax-k);
|
||||||
|
aMBN.Add(aNx);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
aNx=(Standard_Integer)aPK.Id(1);
|
||||||
|
aMBN.Add(aNx);
|
||||||
|
aNx=(Standard_Integer)aPK.Id(2);
|
||||||
|
aMBN.Add(aNx);
|
||||||
|
//qt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// inner nodes=all_nodes - boundary_nodes
|
||||||
|
j1=aNodes.Lower();
|
||||||
|
j2=aNodes.Upper();
|
||||||
|
for (j=j1; j<=j2; ++j) {
|
||||||
|
if (!aMBN.Contains(j)) {
|
||||||
|
aP=aNodes(j).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
//
|
||||||
|
if (!aNb && myNbPntsMin) {
|
||||||
|
// try to fill it yourself
|
||||||
|
Standard_Boolean bIsDone;
|
||||||
|
Standard_Integer aN1, aN2;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
GeomAdaptor_Surface aGAS;
|
||||||
|
GeomAbs_SurfaceType aType;
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
aGAS.Load(aS);
|
||||||
|
aType=aGAS.GetType();
|
||||||
|
if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
|
||||||
|
// inner links
|
||||||
|
aNbLinks=aMPKI.Extent();
|
||||||
|
aIt.Initialize(aMPKI);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
iCnt=aIt.Value();
|
||||||
|
if (iCnt>1) {
|
||||||
|
// take the first having occured inner link
|
||||||
|
// and discretize it
|
||||||
|
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||||
|
//qf
|
||||||
|
/*
|
||||||
|
aNbMax=aPK.NbMax();
|
||||||
|
pIds=(Standard_Integer*)aPK.Key();
|
||||||
|
aN1=*(pIds+aNbMax-1);
|
||||||
|
aN2=*(pIds+aNbMax-2);
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
aN1=(Standard_Integer)aPK.Id(1);
|
||||||
|
aN2=(Standard_Integer)aPK.Id(2);
|
||||||
|
//qt
|
||||||
|
aP1=aNodes(aN1).Transformed(aTrsf);
|
||||||
|
aP2=aNodes(aN2).Transformed(aTrsf);
|
||||||
|
//
|
||||||
|
if (aType==GeomAbs_Cylinder) {
|
||||||
|
Standard_Real aTolSM;
|
||||||
|
gp_Cylinder aCyl;
|
||||||
|
//
|
||||||
|
aTolSM=1.523e-6;//~1.-cos(0.1 deg)
|
||||||
|
aCyl=aGAS.Cylinder();
|
||||||
|
if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BRepLib_MakeEdge aBME(aP1, aP2);
|
||||||
|
bIsDone=aBME.IsDone();
|
||||||
|
if (!bIsDone) {
|
||||||
|
myErrorStatus=30; //can not obtain the line fron the link
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aSx=aBME.Shape();
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aSx);
|
||||||
|
//
|
||||||
|
InnerPoints(aE, myNbPntsMin, aLP);
|
||||||
|
break;
|
||||||
|
}// if (iCnt>1)
|
||||||
|
}// for (; aIt.More(); aIt.Next())
|
||||||
|
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
|
||||||
|
}// if (!aNb && myNbPntsMin) {
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer j, aNbNodes, aIndex, aNb;
|
||||||
|
Handle(Poly_PolygonOnTriangulation) aPTE;
|
||||||
|
Handle(Poly_Triangulation) aTRE;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
gp_Pnt aP;
|
||||||
|
//
|
||||||
|
aLP.Clear();
|
||||||
|
BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
|
||||||
|
if (aTRE.IsNull() || aPTE.IsNull()) {
|
||||||
|
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
|
||||||
|
if (aPE.IsNull()) {
|
||||||
|
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) {
|
||||||
|
myErrorStatus=20; // no triangulation found
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aPE = BRep_Tool::Polygon3D(aE, aLoc);
|
||||||
|
}
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aPE->Nodes();
|
||||||
|
//
|
||||||
|
aNbNodes=aPE->NbNodes();
|
||||||
|
Standard_Integer low = aNodes.Lower(), up = aNodes.Upper();
|
||||||
|
for (j=low+1; j<up; ++j) {
|
||||||
|
aP=aNodes(j).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const gp_Trsf& aTrsf=aLoc.Transformation();
|
||||||
|
const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
|
||||||
|
//
|
||||||
|
aNbNodes=aPTE->NbNodes();
|
||||||
|
const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
|
||||||
|
for (j=2; j<aNbNodes; ++j) {
|
||||||
|
aIndex=aInds(j);
|
||||||
|
aP=aNodes(aIndex).Transformed(aTrsf);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
if (!aNb && myNbPntsMin) {
|
||||||
|
// try to fill it yourself
|
||||||
|
InnerPoints(aE, myNbPntsMin, aLP);
|
||||||
|
aNb=aLP.Extent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : InnerPoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
const Standard_Integer aNbPntsMin,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP)
|
||||||
|
{
|
||||||
|
// try to fill it yourself
|
||||||
|
Standard_Boolean bInf1, bInf2;
|
||||||
|
Standard_Integer j, aNbT;
|
||||||
|
Standard_Real dT, aT, aT1, aT2;
|
||||||
|
gp_Pnt aP;
|
||||||
|
Handle(Geom_Curve) aC3D;
|
||||||
|
//
|
||||||
|
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
|
if (aC3D.IsNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bInf1=Precision::IsNegativeInfinite(aT1);
|
||||||
|
bInf2=Precision::IsPositiveInfinite(aT2);
|
||||||
|
if (bInf1 || bInf2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbT=myNbPntsMin+1;
|
||||||
|
dT=(aT2-aT1)/aNbT;
|
||||||
|
for (j=1; j<=aNbPntsMin; ++j) {
|
||||||
|
aT=aT1+j*dT;
|
||||||
|
aC3D->D0(aT, aP);
|
||||||
|
aLP.Append(aP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// myErrorStatus :
|
||||||
|
//
|
||||||
|
// 10 -myClsf=NULL
|
||||||
|
// 11 -myShape=NULL
|
||||||
|
// 12 -unallowed type of sub-shapes
|
||||||
|
// 13 -unallowed state
|
||||||
|
// 15 -unallowed surface type
|
||||||
|
// 20- no triangulation found
|
||||||
|
// 30- can not obtain the line from the link
|
||||||
|
// 40- point can not be classified
|
||||||
|
// 41- invalid data for classifier
|
136
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.hxx
Normal file
136
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.hxx
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_FinderShapeOn2.hxx
|
||||||
|
// Created: Fri Mar 4 10:31:06 2005
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#ifndef _GEOMAlgo_FinderShapeOn2_HeaderFile
|
||||||
|
#define _GEOMAlgo_FinderShapeOn2_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <GEOMAlgo_State.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
//#include <Handle_GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
|
||||||
|
#include <GEOMAlgo_ShapeAlgo.hxx>
|
||||||
|
#include <GEOMAlgo_Clsf.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <GEOMAlgo_ListOfPnt.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_FinderShapeOn2
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_FinderShapeOn2 : public GEOMAlgo_ShapeAlgo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_FinderShapeOn2();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_FinderShapeOn2();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetClsf(const Handle(GEOMAlgo_Clsf)& aClsf) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const Handle_GEOMAlgo_Clsf& Clsf() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetShapeType(const TopAbs_ShapeEnum aST) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
TopAbs_ShapeEnum ShapeType() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetState(const GEOMAlgo_State aSF) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_State State() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetNbPntsMin(const Standard_Integer aNb) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer NbPntsMin() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetNbPntsMax(const Standard_Integer aNb) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Integer NbPntsMax() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& Shapes() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessVertices() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessEdges() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessFaces() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void ProcessSolids() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Face& aF,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void InnerPoints(const TopoDS_Edge& aE,
|
||||||
|
const Standard_Integer aNbPnts,
|
||||||
|
GEOMAlgo_ListOfPnt& aLP) ;
|
||||||
|
|
||||||
|
|
||||||
|
TopAbs_ShapeEnum myShapeType;
|
||||||
|
GEOMAlgo_State myState;
|
||||||
|
Standard_Integer myNbPntsMin;
|
||||||
|
Standard_Integer myNbPntsMax;
|
||||||
|
Handle_GEOMAlgo_Clsf myClsf;
|
||||||
|
TopTools_ListOfShape myLS;
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeState myMSS;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
144
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.cxx
Normal file
144
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.cxx
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 : GEOMAlgo_FinderShapeOnQuad.cxx
|
||||||
|
// Created : Mon Oct 17 17:31:45 2005
|
||||||
|
// Author : Edward AGAPOV (eap)
|
||||||
|
//
|
||||||
|
#include "GEOMAlgo_FinderShapeOnQuad.hxx"
|
||||||
|
#include "GEOMAlgo_SurfaceTools.hxx"
|
||||||
|
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
GEOMAlgo_FinderShapeOnQuad::GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint,
|
||||||
|
const gp_Pnt & theTopRigthPoint,
|
||||||
|
const gp_Pnt & theBottomLeftPoint,
|
||||||
|
const gp_Pnt & theBottomRigthPoint)
|
||||||
|
{
|
||||||
|
myPoints.resize(6);
|
||||||
|
myPoints[0] = theTopLeftPoint ;
|
||||||
|
myPoints[1] = theTopRigthPoint ;
|
||||||
|
myPoints[2] = theBottomRigthPoint;
|
||||||
|
myPoints[3] = theBottomLeftPoint ;
|
||||||
|
myPoints[4] = myPoints[0];
|
||||||
|
myPoints[5] = myPoints[1];
|
||||||
|
|
||||||
|
// Find plane normal defined by corner points, it will be used to define a plane
|
||||||
|
// for each quadrangle side.
|
||||||
|
myQuadNormal.SetCoord (0,0,0);
|
||||||
|
for ( int i = 1; i <= 4; ++i )
|
||||||
|
myQuadNormal += gp_Vec( myPoints[i], myPoints[i+1] ) ^ gp_Vec( myPoints[i], myPoints[i-1] );
|
||||||
|
//std::cout<<std::endl<<" X Vec : "<<myQuadNormal.X()<<" "<<myQuadNormal.Y()<<" "<<myQuadNormal.Z()<<" "<<endl;
|
||||||
|
|
||||||
|
if ( myQuadNormal.SquareMagnitude() <= DBL_MIN ) {
|
||||||
|
myErrorStatus = 101;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// detect concave quadrangle sides
|
||||||
|
myConcaveQuad = false;
|
||||||
|
myConcaveSide.resize (4, false);
|
||||||
|
for ( int i = 1; i <= 4; ++i ) {
|
||||||
|
gp_Vec localQN = gp_Vec( myPoints[i], myPoints[i+1] ) ^ gp_Vec( myPoints[i], myPoints[i-1] );
|
||||||
|
if ( myQuadNormal * localQN < 0 )
|
||||||
|
myConcaveSide[i-1] = myConcaveSide[i] = myConcaveQuad = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// loop on quadrangle sides
|
||||||
|
myPlanes.reserve( 4 );
|
||||||
|
for ( int i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
// point1 -> point2 vector
|
||||||
|
gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]);
|
||||||
|
//std::cout<<" Y Vec : "<<aSideVec.X()<<" "<<aSideVec.Y()<<" "<<aSideVec.Z()<<" "<<endl;
|
||||||
|
|
||||||
|
// plane normal
|
||||||
|
gp_Vec aSideNorm = aSideVec ^ myQuadNormal;
|
||||||
|
if ( aSideNorm.SquareMagnitude() <= DBL_MIN )
|
||||||
|
continue;
|
||||||
|
//std::cout<<" Z Vec : "<<aSideNorm.X()<<" "<<aSideNorm.Y()<<" "<<aSideNorm.Z()<<" "<<endl;
|
||||||
|
|
||||||
|
// make plane
|
||||||
|
Handle(Geom_Plane) aPlane = new Geom_Plane( myPoints[ i ], aSideNorm );
|
||||||
|
myPlanes.push_back( GeomAdaptor_Surface() );
|
||||||
|
myPlanes.back().Load( aPlane );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckData
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void GEOMAlgo_FinderShapeOnQuad::CheckData()
|
||||||
|
{
|
||||||
|
if ( !myPlanes.empty() )
|
||||||
|
mySurface = myPlanes[0].Surface();
|
||||||
|
GEOMAlgo_FinderShapeOn1::CheckData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetPointState
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopAbs_State GEOMAlgo_FinderShapeOnQuad::GetPointState(const gp_Pnt& aP)
|
||||||
|
{
|
||||||
|
// Return IN if aP has TopAbs_IN with all sides.
|
||||||
|
// In the case of concave quadrangle, return IN if
|
||||||
|
// aP is OUT of only one concave side
|
||||||
|
double nbIn = 0.;
|
||||||
|
for ( int i = 0; i < myPlanes.size(); ++i )
|
||||||
|
{
|
||||||
|
TopAbs_State aSt;
|
||||||
|
GEOMAlgo_SurfaceTools::GetState(aP, myPlanes[i], myTolerance, aSt);
|
||||||
|
if ( aSt == TopAbs_IN )
|
||||||
|
{
|
||||||
|
nbIn += myConcaveSide[i] ? 0.5 : 1.0;
|
||||||
|
}
|
||||||
|
else if ( aSt == TopAbs_ON )
|
||||||
|
{
|
||||||
|
// check that aP is between quadrangle corners
|
||||||
|
Handle(Geom_Plane) aSidePlane = Handle(Geom_Plane)::DownCast( myPlanes[i].Surface() );
|
||||||
|
gp_Vec aSideNorm = aSidePlane->Axis().Direction();
|
||||||
|
gp_Vec aSideVec = myQuadNormal ^ aSideNorm;
|
||||||
|
gp_Vec c1p ( myPoints[i], aP );
|
||||||
|
gp_Vec pc2 ( aP, myPoints[i+1] );
|
||||||
|
if ( aSideVec * c1p >= 0. && aSideVec * pc2 >= 0. )
|
||||||
|
return TopAbs_ON;
|
||||||
|
// consider to be IN (???????????)
|
||||||
|
//nbIn += myConcaveSide[i] ? 0.5 : 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Standard_Real inThreshold = myPlanes.size(); // usually 4.0
|
||||||
|
if ( myConcaveQuad )
|
||||||
|
inThreshold = 2.5; // 1.0 + 1.0 + 0.5
|
||||||
|
|
||||||
|
if ( nbIn >= inThreshold )
|
||||||
|
return TopAbs_IN;
|
||||||
|
|
||||||
|
return TopAbs_OUT;
|
||||||
|
}
|
||||||
|
|
61
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.hxx
Normal file
61
src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.hxx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2007-2011 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 : GEOMAlgo_FinderShapeOnQuad.hxx
|
||||||
|
// Created : Mon Oct 17 17:15:59 2005
|
||||||
|
// Author : Edward AGAPOV (eap)
|
||||||
|
//
|
||||||
|
#ifndef GEOMAlgo_FinderShapeOnQuad_HeaderFile
|
||||||
|
#define GEOMAlgo_FinderShapeOnQuad_HeaderFile
|
||||||
|
|
||||||
|
#include "GEOMAlgo_FinderShapeOn1.hxx"
|
||||||
|
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
class GEOMAlgo_FinderShapeOnQuad: public GEOMAlgo_FinderShapeOn1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint,
|
||||||
|
const gp_Pnt & theTopRigthPoint,
|
||||||
|
const gp_Pnt & theBottomLeftPoint,
|
||||||
|
const gp_Pnt & theBottomRigthPoint);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
virtual TopAbs_State GetPointState(const gp_Pnt& aP) ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool myConcaveQuad;
|
||||||
|
std::vector<bool> myConcaveSide;
|
||||||
|
std::vector<gp_Pnt> myPoints;
|
||||||
|
std::vector<GeomAdaptor_Surface> myPlanes;
|
||||||
|
gp_Vec myQuadNormal;
|
||||||
|
};
|
||||||
|
#endif
|
1151
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.cxx
Normal file
1151
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.cxx
Normal file
File diff suppressed because it is too large
Load Diff
324
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.hxx
Normal file
324
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.hxx
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GetInPlace.hxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_GetInPlace_HeaderFile
|
||||||
|
#define _GEOMAlgo_GetInPlace_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <Standard_Integer.hxx>
|
||||||
|
#include <Standard_Real.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_CoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_ListOfCoupleOfShape.hxx>
|
||||||
|
#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_GluerAlgo.hxx>
|
||||||
|
#include <GEOMAlgo_Algo.hxx>
|
||||||
|
#include <GEOMAlgo_DataMapOfShapePnt.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
/**
|
||||||
|
* The implementation of iterator of intersected shapes
|
||||||
|
* for Get In Place Algorithm.
|
||||||
|
* The intersection is in terms of 3D bounding boxes.
|
||||||
|
*/
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_GetInPlaceIterator
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_GetInPlaceIterator {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
GEOMAlgo_GetInPlaceIterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_GetInPlaceIterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the internal content.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
void Clear() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append the pair of intersected shapes.
|
||||||
|
* @param theCS
|
||||||
|
* The pair of intersected shapes.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
void AppendPair(const NMTTools_CoupleOfShape& theCS) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the iterator.
|
||||||
|
* @param theT1
|
||||||
|
* The type of (sub)shape What.
|
||||||
|
* @param theT2
|
||||||
|
* The type of (sub)shape Where.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
void Initialize(const TopAbs_ShapeEnum theT1,
|
||||||
|
const TopAbs_ShapeEnum theT2) ;
|
||||||
|
/**
|
||||||
|
* Check the existence of pairs to iterare.
|
||||||
|
* @return
|
||||||
|
* Standard_True if there are pairs to iterare.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
Standard_Boolean More() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift to the next pair.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
void Next() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pair of intersected shapes.
|
||||||
|
* @return
|
||||||
|
* The pair of intersected shapes.
|
||||||
|
*/
|
||||||
|
//Standard_EXPORT
|
||||||
|
const NMTTools_CoupleOfShape& Value() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_Integer myDim;
|
||||||
|
NMTTools_ListOfCoupleOfShape myLists[10];
|
||||||
|
NMTTools_ListOfCoupleOfShape myEmptyList;
|
||||||
|
NMTTools_ListIteratorOfListOfCoupleOfShape myIterator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
/**
|
||||||
|
* The implementation of Get In Place Algorithm.
|
||||||
|
* The algorithm provides the search the argument [What]
|
||||||
|
* in the shape [Where].
|
||||||
|
*/
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_GetInPlace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_GetInPlace : public GEOMAlgo_GluerAlgo,
|
||||||
|
public GEOMAlgo_Algo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_GetInPlace();
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_GetInPlace();
|
||||||
|
/**
|
||||||
|
* Modifier. Sets the shape where the search is intended.
|
||||||
|
* @param theShape
|
||||||
|
* The shape where the search is intended.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void SetShapeWhere(const TopoDS_Shape& theShape) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selector. Returns the shape where the search is intended.
|
||||||
|
* @return
|
||||||
|
* The shape where the search is intended.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopoDS_Shape& ShapeWhere() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifier. Sets the tolerance of mass.
|
||||||
|
* @param theTol
|
||||||
|
* The value tolerance of mass.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetTolMass(const Standard_Real theTol) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selector. Returns the value tolerance of mass.
|
||||||
|
* @return
|
||||||
|
* The value tolerance of mass.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Real TolMass() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifier. Sets the tolerance of center of gravily.
|
||||||
|
* @param theTol
|
||||||
|
* The value tolerance of center of gravily.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
void SetTolCG(const Standard_Real theTol) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selector. Returns the tolerance of center of gravily.
|
||||||
|
* @return
|
||||||
|
* The value tolerance of center of gravily.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Real TolCG() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform the algorithm.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns state of the search.
|
||||||
|
* @return
|
||||||
|
* Standard_True if the argument is found.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean IsFound() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks data
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void CheckData() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the internal content.
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Clear() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the map of shapes IN.
|
||||||
|
* @return
|
||||||
|
** Returns the map of shapes IN.
|
||||||
|
* The Key - the (sub)shape of the argument [What].
|
||||||
|
* The Item- the (sub)shapes of the shape [Where] that have
|
||||||
|
* the state IN in respect of [What].
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesIn() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the map of shapes ON.
|
||||||
|
* @return
|
||||||
|
* Returns the map of shapes ON.
|
||||||
|
* The Key - the (sub)shape of the argument [What].
|
||||||
|
* The Item- the (sub)shapes of the shape [Where] that have
|
||||||
|
* the state ON in respect of [What].
|
||||||
|
*/
|
||||||
|
Standard_EXPORT
|
||||||
|
const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesOn() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
void Intersect() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformVV() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformVE() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformEE() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformVF() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformEF() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformFF() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillEdgesOn() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillFacesOn() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillSolidsOn() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformZF() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void PerformZZ() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImages() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillImagesCompound(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void CheckGProps() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void CheckGProps(const TopoDS_Shape& theS) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillShapesIn(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void FillShapesOn(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean CheckCoincidence(const TopoDS_Shape& theS1,
|
||||||
|
const TopoDS_Shape& theS2);
|
||||||
|
|
||||||
|
|
||||||
|
TopoDS_Shape myShapeWhere;
|
||||||
|
GEOMAlgo_GetInPlaceIterator myIterator;
|
||||||
|
GEOMAlgo_DataMapOfShapeMapOfShape myShapesIn;
|
||||||
|
GEOMAlgo_DataMapOfShapeMapOfShape myShapesOn;
|
||||||
|
Standard_Real myTolMass;
|
||||||
|
Standard_Real myTolCG;
|
||||||
|
Standard_Boolean myFound;
|
||||||
|
GEOMAlgo_DataMapOfShapePnt myMapShapePnt;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
401
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_1.cxx
Normal file
401
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_1.cxx
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GetInPlace_1.cxx
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_GetInPlace.hxx>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
#include <gp_Pnt2d.hxx>
|
||||||
|
#include <gp_Dir2d.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom2d_Curve.hxx>
|
||||||
|
#include <Geom2d_Line.hxx>
|
||||||
|
#include <Geom2d_TrimmedCurve.hxx>
|
||||||
|
#include <Geom2dAdaptor_Curve.hxx>
|
||||||
|
#include <Geom2dHatch_Hatcher.hxx>
|
||||||
|
#include <Geom2dHatch_Intersector.hxx>
|
||||||
|
#include <HatchGen_Domain.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_State.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
#include <TopAbs_Orientation.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
|
#include <IntTools_Tools.hxx>
|
||||||
|
|
||||||
|
#include <BOPTools_Tools3D.hxx>
|
||||||
|
#include <BOPTools_Tools2D.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Integer PntInEdge(const TopoDS_Edge& aF,
|
||||||
|
gp_Pnt& aP);
|
||||||
|
static
|
||||||
|
Standard_Integer PntInEdge(const TopoDS_Edge& aF,
|
||||||
|
gp_Pnt& aP,
|
||||||
|
Standard_Real& aT);
|
||||||
|
static
|
||||||
|
Standard_Integer PntInFace(const TopoDS_Face& aF,
|
||||||
|
gp_Pnt& aP);
|
||||||
|
static
|
||||||
|
Standard_Integer PntInFace(const TopoDS_Face& aF,
|
||||||
|
gp_Pnt& aP,
|
||||||
|
gp_Pnt2d& theP2D);
|
||||||
|
static
|
||||||
|
Standard_Integer PntInSolid(const TopoDS_Solid& aZ,
|
||||||
|
const Standard_Real aTol,
|
||||||
|
gp_Pnt& aP);
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckCoincidence
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GetInPlace::CheckCoincidence(const TopoDS_Shape& aS1,
|
||||||
|
const TopoDS_Shape& aS2)
|
||||||
|
{
|
||||||
|
Standard_Boolean bOk;
|
||||||
|
Standard_Integer iErr;
|
||||||
|
Standard_Real aTol2;
|
||||||
|
TopAbs_ShapeEnum aType1, aType2;
|
||||||
|
TopAbs_State aState;
|
||||||
|
gp_Pnt aP1, aP2;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
iErr=0;
|
||||||
|
bOk=Standard_False;
|
||||||
|
aTol2=myTolerance*myTolerance;
|
||||||
|
aType1=aS1.ShapeType();
|
||||||
|
aType2=aS2.ShapeType();
|
||||||
|
//
|
||||||
|
// 1. A point on shape #2 -> aP2
|
||||||
|
if (myMapShapePnt.IsBound(aS2)) {
|
||||||
|
aP2=myMapShapePnt.Find(aS2);
|
||||||
|
}
|
||||||
|
else {//else 1
|
||||||
|
if (aType2==TopAbs_VERTEX) {
|
||||||
|
const TopoDS_Vertex& aV2=*((TopoDS_Vertex*)&aS2);
|
||||||
|
aP2=BRep_Tool::Pnt(aV2);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else if (aType2==TopAbs_EDGE) {
|
||||||
|
const TopoDS_Edge& aE2=*((TopoDS_Edge*)&aS2);
|
||||||
|
iErr=PntInEdge(aE2, aP2);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else if (aType2==TopAbs_FACE) {
|
||||||
|
const TopoDS_Face& aF2=*((TopoDS_Face*)&aS2);
|
||||||
|
iErr=PntInFace(aF2, aP2);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else if (aType2==TopAbs_SOLID) {
|
||||||
|
const TopoDS_Solid& aZ2=*((TopoDS_Solid*)&aS2);
|
||||||
|
iErr=PntInSolid(aZ2, myTolerance, aP2);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else {
|
||||||
|
iErr=1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=50;
|
||||||
|
return bOk;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myMapShapePnt.Bind(aS2, aP2);
|
||||||
|
} //else 1
|
||||||
|
//
|
||||||
|
// 2. Project the point aP2 on shape #1 and check
|
||||||
|
if (aType1==TopAbs_EDGE) {
|
||||||
|
Standard_Integer aNbPoints;
|
||||||
|
Standard_Real aDmin, aT, aT1, aT2, dT;
|
||||||
|
//
|
||||||
|
const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1);
|
||||||
|
//
|
||||||
|
GeomAPI_ProjectPointOnCurve& aPPC=myContext->ProjPC(aE1);
|
||||||
|
aPPC.Perform(aP2);
|
||||||
|
aNbPoints=aPPC.NbPoints();
|
||||||
|
if (aNbPoints) {
|
||||||
|
aDmin=aPPC.LowerDistance();
|
||||||
|
aT=aPPC.LowerDistanceParameter();
|
||||||
|
if (aDmin < myTolerance) {
|
||||||
|
dT=1.e-12;
|
||||||
|
BRep_Tool::Curve(aE1, aT1, aT2);
|
||||||
|
if(aT > (aT1-dT) && aT < (aT2+dT)) {
|
||||||
|
bOk=Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else {
|
||||||
|
// iErr=2;
|
||||||
|
//}
|
||||||
|
}//if (aType1==TopAbs_EDGE) {
|
||||||
|
//
|
||||||
|
else if (aType1==TopAbs_FACE) {
|
||||||
|
const TopoDS_Face& aF1=*((TopoDS_Face*)&aS1);
|
||||||
|
//
|
||||||
|
bOk=myContext->IsValidPointForFace(aP2, aF1, myTolerance);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
else if (aType1==TopAbs_SOLID) {
|
||||||
|
const TopoDS_Solid& aZ1=*((TopoDS_Solid*)&aS1);
|
||||||
|
//
|
||||||
|
BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aZ1);
|
||||||
|
aSC.Perform(aP2, myTolerance);
|
||||||
|
aState=aSC.State();
|
||||||
|
bOk=(aState==TopAbs_IN);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=50;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
return bOk;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//
|
||||||
|
//=======================================================================
|
||||||
|
//function : PntInEdge
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PntInEdge(const TopoDS_Edge& aE,
|
||||||
|
gp_Pnt& aP)
|
||||||
|
|
||||||
|
{
|
||||||
|
Standard_Integer iErr;
|
||||||
|
Standard_Real aT;
|
||||||
|
//
|
||||||
|
iErr=PntInEdge(aE, aP, aT);
|
||||||
|
//
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PntInEdge
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PntInEdge(const TopoDS_Edge& aE,
|
||||||
|
gp_Pnt& aP,
|
||||||
|
Standard_Real& aT)
|
||||||
|
{
|
||||||
|
Standard_Integer iErr;
|
||||||
|
Standard_Real aT1, aT2;
|
||||||
|
Handle(Geom_Curve) aC3D;
|
||||||
|
//
|
||||||
|
iErr=0;
|
||||||
|
//
|
||||||
|
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
|
aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
|
||||||
|
aC3D->D0(aT, aP);
|
||||||
|
//
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PntInSolid
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PntInSolid(const TopoDS_Solid& aZ,
|
||||||
|
const Standard_Real aTol,
|
||||||
|
gp_Pnt& aP)
|
||||||
|
{
|
||||||
|
Standard_Integer iErr;
|
||||||
|
Standard_Real aUx, aVx, aCoef;
|
||||||
|
gp_Pnt aPx;
|
||||||
|
gp_Pnt2d aP2Dx;
|
||||||
|
gp_Vec aDNx;
|
||||||
|
|
||||||
|
TopoDS_Face aF;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
//
|
||||||
|
iErr=0;
|
||||||
|
aCoef=10.;
|
||||||
|
//
|
||||||
|
aExp.Init (aZ, TopAbs_FACE);
|
||||||
|
for (; aExp.More() ; aExp.Next()) {
|
||||||
|
aF=*((TopoDS_Face*)&aExp.Current());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
iErr=PntInFace(aF, aPx, aP2Dx);
|
||||||
|
if (iErr) {
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aP2Dx.Coord(aUx, aVx);
|
||||||
|
BOPTools_Tools2D::FaceNormal(aF, aUx, aVx, aDNx);
|
||||||
|
aDNx.Reverse();
|
||||||
|
//
|
||||||
|
aP.SetXYZ(aPx.XYZ()+aCoef*aTol*aDNx.XYZ());
|
||||||
|
//
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PntInFace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PntInFace(const TopoDS_Face& aF,
|
||||||
|
gp_Pnt& aP)
|
||||||
|
{
|
||||||
|
Standard_Integer iErr;
|
||||||
|
//
|
||||||
|
gp_Pnt2d aP2Dx;
|
||||||
|
//
|
||||||
|
iErr=PntInFace(aF, aP, aP2Dx);
|
||||||
|
//
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : PntInFace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PntInFace(const TopoDS_Face& aF,
|
||||||
|
gp_Pnt& theP,
|
||||||
|
gp_Pnt2d& theP2D)
|
||||||
|
{
|
||||||
|
Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
|
||||||
|
Standard_Integer iErr, aIx, aNbDomains, i;
|
||||||
|
Standard_Real aUMin, aUMax, aVMin, aVMax;
|
||||||
|
Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT;
|
||||||
|
Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D;
|
||||||
|
gp_Dir2d aD2D (0., 1.);
|
||||||
|
gp_Pnt2d aP2D;
|
||||||
|
gp_Pnt aPx;
|
||||||
|
Handle(Geom2d_Curve) aC2D;
|
||||||
|
Handle(Geom2d_TrimmedCurve) aCT2D;
|
||||||
|
Handle(Geom2d_Line) aL2D;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
TopAbs_Orientation aOrE;
|
||||||
|
TopoDS_Face aFF;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
//
|
||||||
|
aTolHatch2D=1.e-8;
|
||||||
|
aTolHatch3D=1.e-8;
|
||||||
|
aTotArcIntr=1.e-10;
|
||||||
|
aTolTangfIntr=1.e-10;
|
||||||
|
//
|
||||||
|
Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
|
||||||
|
Geom2dHatch_Hatcher aHatcher(aIntr,
|
||||||
|
aTolHatch2D, aTolHatch3D,
|
||||||
|
Standard_True, Standard_False);
|
||||||
|
//
|
||||||
|
iErr=0;
|
||||||
|
aEpsT=1.e-12;
|
||||||
|
//
|
||||||
|
aFF=aF;
|
||||||
|
aFF.Orientation (TopAbs_FORWARD);
|
||||||
|
//
|
||||||
|
aS=BRep_Tool::Surface(aFF);
|
||||||
|
BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
|
||||||
|
//
|
||||||
|
// 1
|
||||||
|
aExp.Init (aFF, TopAbs_EDGE);
|
||||||
|
for (; aExp.More() ; aExp.Next()) {
|
||||||
|
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current());
|
||||||
|
aOrE=aE.Orientation();
|
||||||
|
//
|
||||||
|
aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2);
|
||||||
|
if (aC2D.IsNull() ) {
|
||||||
|
iErr=1;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
if (fabs(aU1-aU2) < aEpsT) {
|
||||||
|
iErr=2;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2);
|
||||||
|
aHatcher.AddElement(aCT2D, aOrE);
|
||||||
|
}// for (; aExp.More() ; aExp.Next()) {
|
||||||
|
//
|
||||||
|
// 2
|
||||||
|
aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
|
||||||
|
aP2D.SetCoord(aUx, 0.);
|
||||||
|
aL2D=new Geom2d_Line (aP2D, aD2D);
|
||||||
|
Geom2dAdaptor_Curve aHCur(aL2D);
|
||||||
|
//
|
||||||
|
aIx=aHatcher.AddHatching(aHCur) ;
|
||||||
|
//
|
||||||
|
// 3.
|
||||||
|
aHatcher.Trim();
|
||||||
|
bIsDone=aHatcher.TrimDone(aIx);
|
||||||
|
if (!bIsDone) {
|
||||||
|
iErr=3;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aHatcher.ComputeDomains(aIx);
|
||||||
|
bIsDone=aHatcher.IsDone(aIx);
|
||||||
|
if (!bIsDone) {
|
||||||
|
iErr=4;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 4.
|
||||||
|
aNbDomains=aHatcher.NbDomains(aIx);
|
||||||
|
for (i=1; i<=aNbDomains; ++i) {
|
||||||
|
const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
|
||||||
|
bHasFirstPoint=aDomain.HasFirstPoint();
|
||||||
|
if (!bHasFirstPoint) {
|
||||||
|
iErr=5;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aV1=aDomain.FirstPoint().Parameter();
|
||||||
|
//
|
||||||
|
bHasSecondPoint=aDomain.HasSecondPoint();
|
||||||
|
if (!bHasSecondPoint) {
|
||||||
|
iErr=6;
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aV2=aDomain.SecondPoint().Parameter();
|
||||||
|
//
|
||||||
|
aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aS->D0(aUx, aVx, aPx);
|
||||||
|
//
|
||||||
|
theP2D.SetCoord(aUx, aVx);
|
||||||
|
theP=aPx;
|
||||||
|
//
|
||||||
|
return iErr;
|
||||||
|
}
|
||||||
|
|
232
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_2.cxx
Normal file
232
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_2.cxx
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GetInPlace_2.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_GetInPlace.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
|
||||||
|
#include <GProp_GProps.hxx>
|
||||||
|
#include <BRepGProp.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Integer Dimension(const TopAbs_ShapeEnum aType);
|
||||||
|
static
|
||||||
|
void PointProperties(const TopoDS_Shape& aS,
|
||||||
|
GProp_GProps& aGProps);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckGProps
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlace::CheckGProps()
|
||||||
|
{
|
||||||
|
myFound=Standard_False;
|
||||||
|
CheckGProps(myArgument);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : CheckGProps
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlace::CheckGProps(const TopoDS_Shape& aS1)
|
||||||
|
{
|
||||||
|
Standard_Boolean bOnlyClosed;
|
||||||
|
Standard_Integer iDim, aNbS2;
|
||||||
|
Standard_Real aMass1, aMass2, aD2, aTolCG2, dM;
|
||||||
|
TopAbs_ShapeEnum aType1;
|
||||||
|
gp_Pnt aCG1, aCG2;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopoDS_Compound aC2;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItLS;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
aType1=aS1.ShapeType();
|
||||||
|
if (aType1==TopAbs_COMPOUND) {
|
||||||
|
aIt.Initialize(aS1);
|
||||||
|
for(; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aS1x=aIt.Value();
|
||||||
|
CheckGProps(aS1x);
|
||||||
|
if (!myFound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
iDim=Dimension(aType1);
|
||||||
|
//
|
||||||
|
if (!myImages.IsBound(aS1)) {
|
||||||
|
// it should not be.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const TopTools_ListOfShape& aLS2=myImages.Find(aS1);
|
||||||
|
aNbS2=aLS2.Extent();
|
||||||
|
if (!aNbS2) {
|
||||||
|
// it should not be.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aBB.MakeCompound(aC2);
|
||||||
|
aItLS.Initialize(aLS2);
|
||||||
|
for (; aItLS.More(); aItLS.Next()) {
|
||||||
|
const TopoDS_Shape& aS2x=aItLS.Value();
|
||||||
|
aBB.Add(aC2, aS2x);
|
||||||
|
}
|
||||||
|
//-------------------------
|
||||||
|
GProp_GProps aG1, aG2;
|
||||||
|
//
|
||||||
|
aTolCG2=myTolCG*myTolCG;
|
||||||
|
bOnlyClosed=Standard_False;
|
||||||
|
//
|
||||||
|
if (iDim==0) {
|
||||||
|
PointProperties(aS1, aG1);
|
||||||
|
PointProperties(aC2, aG2);
|
||||||
|
}
|
||||||
|
else if (iDim==1) {
|
||||||
|
BRepGProp::LinearProperties(aS1, aG1);
|
||||||
|
BRepGProp::LinearProperties(aC2, aG2);
|
||||||
|
}
|
||||||
|
else if (iDim==2) {
|
||||||
|
BRepGProp::SurfaceProperties(aS1, aG1);
|
||||||
|
BRepGProp::SurfaceProperties(aC2, aG2);
|
||||||
|
}
|
||||||
|
else if (iDim==3) {
|
||||||
|
BRepGProp::VolumeProperties(aS1, aG1, bOnlyClosed);
|
||||||
|
BRepGProp::VolumeProperties(aC2, aG2, bOnlyClosed);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aMass1=aG1.Mass();
|
||||||
|
aMass2=aG2.Mass();
|
||||||
|
aCG1=aG1.CentreOfMass();
|
||||||
|
aCG2=aG2.CentreOfMass();
|
||||||
|
//
|
||||||
|
dM=fabs(aMass1-aMass2);
|
||||||
|
if (aMass1 > myTolMass) {
|
||||||
|
dM=dM/aMass1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aD2=aCG1.SquareDistance(aCG2);
|
||||||
|
//
|
||||||
|
if ((dM > myTolMass) || (aD2 > aTolCG2)) {
|
||||||
|
myFound=Standard_False;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myFound=Standard_True;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Dimension
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer Dimension(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
Standard_Integer iDim;
|
||||||
|
//
|
||||||
|
iDim=-1;
|
||||||
|
switch (aType) {
|
||||||
|
case TopAbs_VERTEX:
|
||||||
|
iDim=0;
|
||||||
|
break;
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
case TopAbs_WIRE:
|
||||||
|
iDim=1;
|
||||||
|
break;
|
||||||
|
case TopAbs_FACE:
|
||||||
|
case TopAbs_SHELL:
|
||||||
|
iDim=2;
|
||||||
|
break;
|
||||||
|
case TopAbs_SOLID:
|
||||||
|
case TopAbs_COMPSOLID:
|
||||||
|
iDim=3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return iDim;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//class : GEOMAlgo_GProps
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_GProps : public GProp_GProps {
|
||||||
|
public:
|
||||||
|
GEOMAlgo_GProps() : GProp_GProps() {
|
||||||
|
};
|
||||||
|
//
|
||||||
|
GEOMAlgo_GProps(const gp_Pnt& aPLoc) : GProp_GProps(aPLoc) {
|
||||||
|
};
|
||||||
|
//
|
||||||
|
~GEOMAlgo_GProps() {
|
||||||
|
};
|
||||||
|
//
|
||||||
|
void SetMass(const Standard_Real aMass) {
|
||||||
|
dim=aMass;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
void SetCG(const gp_Pnt& aPCG) {
|
||||||
|
g=aPCG;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//=======================================================================
|
||||||
|
//function : PointProperties
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void PointProperties(const TopoDS_Shape& aS, GProp_GProps& aGProps)
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNbS;
|
||||||
|
Standard_Real aDensity;
|
||||||
|
gp_Pnt aPX;
|
||||||
|
TopTools_IndexedMapOfShape aMS;
|
||||||
|
//
|
||||||
|
aDensity=1.;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(aS, TopAbs_VERTEX, aMS);
|
||||||
|
aNbS=aMS.Extent();
|
||||||
|
for (i=1; i<=aNbS; ++i) {
|
||||||
|
GEOMAlgo_GProps aGPropsX;
|
||||||
|
//
|
||||||
|
const TopoDS_Vertex& aVX=*((TopoDS_Vertex*)&aMS(i));
|
||||||
|
aPX=BRep_Tool::Pnt(aVX);
|
||||||
|
aGPropsX.SetMass(1.);
|
||||||
|
aGPropsX.SetCG(aPX);
|
||||||
|
aGProps.Add(aGPropsX, aDensity);
|
||||||
|
}
|
||||||
|
}
|
172
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_3.cxx
Normal file
172
src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_3.cxx
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GetInPlaceIterator.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_GetInPlace.hxx>
|
||||||
|
|
||||||
|
#include <NMTTools_CoupleOfShape.hxx>
|
||||||
|
|
||||||
|
static
|
||||||
|
Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
|
||||||
|
const TopAbs_ShapeEnum aType2);
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GetInPlaceIterator::GEOMAlgo_GetInPlaceIterator()
|
||||||
|
{
|
||||||
|
myDim=10;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GetInPlaceIterator::~GEOMAlgo_GetInPlaceIterator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Clear
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlaceIterator::Clear()
|
||||||
|
{
|
||||||
|
Standard_Integer i;
|
||||||
|
//
|
||||||
|
for (i=0; i<myDim; ++i) {
|
||||||
|
myLists[i].Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : AppendPair
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS)
|
||||||
|
{
|
||||||
|
Standard_Integer iX;
|
||||||
|
TopAbs_ShapeEnum aType1, aType2;
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aS1=theCS.Shape1();
|
||||||
|
const TopoDS_Shape& aS2=theCS.Shape2();
|
||||||
|
aType1=aS1.ShapeType();
|
||||||
|
aType2=aS2.ShapeType();
|
||||||
|
//
|
||||||
|
iX=TypeToInteger(aType1, aType2);
|
||||||
|
if (iX>=0) {
|
||||||
|
myLists[iX].Append(theCS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ShapeWhere
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlaceIterator::Initialize(const TopAbs_ShapeEnum aType1,
|
||||||
|
const TopAbs_ShapeEnum aType2)
|
||||||
|
{
|
||||||
|
Standard_Integer iX;
|
||||||
|
//
|
||||||
|
iX=TypeToInteger(aType1, aType2);
|
||||||
|
if (iX>=0) {
|
||||||
|
myIterator.Initialize(myLists[iX]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myIterator.Initialize(myEmptyList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: More
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GetInPlaceIterator::More()const
|
||||||
|
{
|
||||||
|
return myIterator.More();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: Next
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GetInPlaceIterator::Next()
|
||||||
|
{
|
||||||
|
myIterator.Next();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
// function: Value
|
||||||
|
// purpose:
|
||||||
|
//=======================================================================
|
||||||
|
const NMTTools_CoupleOfShape& GEOMAlgo_GetInPlaceIterator::Value()const
|
||||||
|
{
|
||||||
|
return myIterator.Value();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : TypeToInteger
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1,
|
||||||
|
const TopAbs_ShapeEnum aType2)
|
||||||
|
{
|
||||||
|
Standard_Integer iRet, iT1, iT2, iX;
|
||||||
|
//
|
||||||
|
iRet=-1;
|
||||||
|
//
|
||||||
|
if (aType1==TopAbs_VERTEX) {
|
||||||
|
if (aType2==TopAbs_VERTEX) {
|
||||||
|
iRet=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aType1==TopAbs_EDGE) {
|
||||||
|
if (aType2==TopAbs_VERTEX) {
|
||||||
|
iRet=1;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_EDGE) {
|
||||||
|
iRet=2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aType1==TopAbs_FACE) {
|
||||||
|
if (aType2==TopAbs_VERTEX) {
|
||||||
|
iRet=3;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_EDGE) {
|
||||||
|
iRet=4;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_FACE) {
|
||||||
|
iRet=5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// So_1,*_2
|
||||||
|
else if (aType1==TopAbs_SOLID) {
|
||||||
|
if (aType2==TopAbs_VERTEX) {
|
||||||
|
iRet=6;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_EDGE) {
|
||||||
|
iRet=7;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_FACE) {
|
||||||
|
iRet=8;
|
||||||
|
}
|
||||||
|
else if (aType2==TopAbs_SOLID) {
|
||||||
|
iRet=9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
}
|
466
src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.cxx
Normal file
466
src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.cxx
Normal file
@ -0,0 +1,466 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GlueDetector.cxx
|
||||||
|
// Created: Wed Dec 15 11:08:09 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#include <GEOMAlgo_GlueAnalyser.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_PassKeyShape.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_Tools.hxx>
|
||||||
|
#include <GEOMAlgo_CoupleOfShapes.hxx>
|
||||||
|
#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_Gluer.hxx>
|
||||||
|
#include <Bnd_HArray1OfBox.hxx>
|
||||||
|
#include <Bnd_BoundSortBox.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <TColStd_ListOfInteger.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GlueAnalyser::GEOMAlgo_GlueAnalyser()
|
||||||
|
:
|
||||||
|
GEOMAlgo_Gluer()
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GlueAnalyser::~GEOMAlgo_GlueAnalyser()
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasSolidsToGlue
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsToGlue()const
|
||||||
|
{
|
||||||
|
return !mySolidsToGlue.IsEmpty();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasSolidsAlone
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsAlone()const
|
||||||
|
{
|
||||||
|
return !mySolidsAlone.IsEmpty();
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SolidsToGlue
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const GEOMAlgo_ListOfCoupleOfShapes& GEOMAlgo_GlueAnalyser::SolidsToGlue()const
|
||||||
|
{
|
||||||
|
return mySolidsToGlue;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : SolidsAlone
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const TopTools_ListOfShape& GEOMAlgo_GlueAnalyser::SolidsAlone()const
|
||||||
|
{
|
||||||
|
return mySolidsAlone;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
myWarningStatus=0;
|
||||||
|
//
|
||||||
|
mySolidsToGlue.Clear();
|
||||||
|
mySolidsAlone.Clear();
|
||||||
|
//
|
||||||
|
CheckData();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_ShapeAlgo::Perform();
|
||||||
|
//
|
||||||
|
InnerTolerance();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectVertices();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectEdges();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectFaces();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectSolids();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::DetectVertices()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer j, i, aNbV, aIndex, aNbVSD;
|
||||||
|
TColStd_ListIteratorOfListOfInteger aIt;
|
||||||
|
Handle(Bnd_HArray1OfBox) aHAB;
|
||||||
|
Bnd_BoundSortBox aBSB;
|
||||||
|
TopoDS_Shape aSTmp, aVF;
|
||||||
|
TopoDS_Vertex aVnew;
|
||||||
|
TopTools_IndexedMapOfShape aMV, aMVProcessed;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItS;
|
||||||
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
|
||||||
|
GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
|
||||||
|
GEOMAlgo_IndexedDataMapOfShapeBox aMSB;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV);
|
||||||
|
aNbV=aMV.Extent();
|
||||||
|
if (!aNbV) {
|
||||||
|
myErrorStatus=2; // no vertices in source shape
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aHAB=new Bnd_HArray1OfBox(1, aNbV);
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
const TopoDS_Shape& aV=aMV(i);
|
||||||
|
Bnd_Box aBox;
|
||||||
|
//
|
||||||
|
aBox.SetGap(myTol);
|
||||||
|
BRepBndLib::Add(aV, aBox);
|
||||||
|
aHAB->SetValue(i, aBox);
|
||||||
|
aMIS.Add(i, aV);
|
||||||
|
aMSB.Add(aV, aBox);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aBSB.Initialize(aHAB);
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
const TopoDS_Shape& aV=aMV(i);
|
||||||
|
//
|
||||||
|
if (aMVProcessed.Contains(aV)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const Bnd_Box& aBoxV=aMSB.FindFromKey(aV);
|
||||||
|
const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV);
|
||||||
|
aNbVSD=aLI.Extent();
|
||||||
|
if (!aNbVSD) {
|
||||||
|
myErrorStatus=3; // it must not be
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Images
|
||||||
|
TopTools_ListOfShape aLVSD;
|
||||||
|
//
|
||||||
|
aIt.Initialize(aLI);
|
||||||
|
for (j=0; aIt.More(); aIt.Next(), ++j) {
|
||||||
|
aIndex=aIt.Value();
|
||||||
|
const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex);
|
||||||
|
if(!j) {
|
||||||
|
aVF=aVx;
|
||||||
|
}
|
||||||
|
aLVSD.Append(aVx);
|
||||||
|
aMVProcessed.Add(aVx);
|
||||||
|
}
|
||||||
|
myImages.Bind(aVF, aLVSD);
|
||||||
|
}
|
||||||
|
// Origins
|
||||||
|
aItIm.Initialize(myImages);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aItIm.Key();
|
||||||
|
const TopTools_ListOfShape& aLVSD=aItIm.Value();
|
||||||
|
//
|
||||||
|
aItS.Initialize(aLVSD);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aVSD=aItS.Value();
|
||||||
|
if (!myOrigins.IsBound(aVSD)) {
|
||||||
|
myOrigins.Bind(aVSD, aV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::DetectFaces()
|
||||||
|
{
|
||||||
|
DetectShapes(TopAbs_FACE);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectEdges
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::DetectEdges()
|
||||||
|
{
|
||||||
|
DetectShapes(TopAbs_EDGE);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::DetectShapes(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer i, aNbF, aNbSDF, iErr;
|
||||||
|
TopoDS_Shape aNewShape;
|
||||||
|
TopTools_IndexedMapOfShape aMF;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItS;
|
||||||
|
GEOMAlgo_PassKeyShape aPKF;
|
||||||
|
GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myShape, aType, aMF);
|
||||||
|
//
|
||||||
|
aNbF=aMF.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aMF(i);
|
||||||
|
//
|
||||||
|
//aPKF.Clear();//qft
|
||||||
|
if (aType==TopAbs_FACE) {
|
||||||
|
const TopoDS_Face& aF=TopoDS::Face(aS);
|
||||||
|
FacePassKey(aF, aPKF);
|
||||||
|
}
|
||||||
|
else if (aType==TopAbs_EDGE) {
|
||||||
|
const TopoDS_Edge& aE=TopoDS::Edge(aS);
|
||||||
|
EdgePassKey(aE, aPKF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aMPKLF.Contains(aPKF)) {
|
||||||
|
TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF);
|
||||||
|
aLSDF.Append(aS);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape aLSDF;
|
||||||
|
//
|
||||||
|
aLSDF.Append(aS);
|
||||||
|
aMPKLF.Add(aPKF, aLSDF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check geometric coincidence
|
||||||
|
if (myCheckGeometry) {
|
||||||
|
iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); //XX
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=200;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Images/Origins
|
||||||
|
aNbF=aMPKLF.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
const TopTools_ListOfShape& aLSDF=aMPKLF(i);
|
||||||
|
aNbSDF=aLSDF.Extent();
|
||||||
|
if (!aNbSDF) {
|
||||||
|
myErrorStatus=4; // it must not be
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aS1=aLSDF.First();
|
||||||
|
aNewShape=aS1;
|
||||||
|
//
|
||||||
|
myImages.Bind(aNewShape, aLSDF);
|
||||||
|
// origins
|
||||||
|
aItS.Initialize(aLSDF);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aFSD=aItS.Value();
|
||||||
|
if (!myOrigins.IsBound(aFSD)) {
|
||||||
|
myOrigins.Bind(aFSD, aNewShape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectSolids
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueAnalyser::DetectSolids()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
Standard_Integer i, aNbF, aNbS, aNbC, aNbX;
|
||||||
|
TopoDS_Compound aCmp;
|
||||||
|
BRep_Builder aBB;
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape aMFS;
|
||||||
|
TopTools_IndexedMapOfShape aMx, aMS;
|
||||||
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
|
||||||
|
GEOMAlgo_CoupleOfShapes aCS;
|
||||||
|
//
|
||||||
|
GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLS;
|
||||||
|
GEOMAlgo_PassKeyShape aPKSx;
|
||||||
|
//
|
||||||
|
aBB.MakeCompound(aCmp);
|
||||||
|
//
|
||||||
|
TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS);
|
||||||
|
//
|
||||||
|
aItIm.Initialize(myImages);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
const TopoDS_Shape& aIm=aItIm.Key();
|
||||||
|
if (aIm.ShapeType()!=TopAbs_FACE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLF=aItIm.Value();
|
||||||
|
aNbF=aLF.Extent();
|
||||||
|
if (aNbF!=2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
TopoDS_Shape aSx[2], aFx[2];
|
||||||
|
//
|
||||||
|
aFx[0]=aLF.First();
|
||||||
|
aFx[1]=aLF.Last();
|
||||||
|
for (i=0; i<2; ++i) {
|
||||||
|
if (!aMFS.Contains(aFx[i])) {
|
||||||
|
continue;// it must not be so
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aFx[i]);
|
||||||
|
aNbS=aLS.Extent();
|
||||||
|
if (aNbS!=1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
aSx[i]=aLS.First();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aSx[0].IsNull() || aSx[1].IsNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//aPKSx.Clear();//qft
|
||||||
|
//qf
|
||||||
|
//aPKSx.SetIds(aSx[0], aSx[1]);
|
||||||
|
aPKSx.SetShapes(aSx[0], aSx[1]);
|
||||||
|
//qt
|
||||||
|
//
|
||||||
|
if (!aMPKLS.Contains(aPKSx)) {
|
||||||
|
TopTools_ListOfShape aLSx;
|
||||||
|
//
|
||||||
|
aLSx.Append(aSx[0]);
|
||||||
|
aLSx.Append(aSx[1]);
|
||||||
|
//
|
||||||
|
aMPKLS.Add(aPKSx, aLSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
mySolidsToGlue.Clear();
|
||||||
|
mySolidsAlone.Clear();
|
||||||
|
|
||||||
|
//
|
||||||
|
aNbC=aMPKLS.Extent();
|
||||||
|
if (!aNbC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbC; ++i) {
|
||||||
|
const TopTools_ListOfShape& aLSx=aMPKLS(i);
|
||||||
|
const TopoDS_Shape& aSx1=aLSx.First();
|
||||||
|
const TopoDS_Shape& aSx2=aLSx.Last();
|
||||||
|
aCS.SetShape1(aSx1);
|
||||||
|
aCS.SetShape2(aSx2);
|
||||||
|
mySolidsToGlue.Append(aCS);
|
||||||
|
//
|
||||||
|
if (!aMx.Contains(aSx1)) {
|
||||||
|
aBB.Add(aCmp, aSx1);
|
||||||
|
aMx.Add(aSx1);
|
||||||
|
}
|
||||||
|
if (!aMx.Contains(aSx2)) {
|
||||||
|
aBB.Add(aCmp, aSx2);
|
||||||
|
aMx.Add(aSx2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myResult=aCmp;
|
||||||
|
//
|
||||||
|
// check alone solids
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_SOLID, aMS);
|
||||||
|
//
|
||||||
|
aNbX=aMx.Extent();
|
||||||
|
for (i=1; i<=aNbX; ++i) {
|
||||||
|
const TopoDS_Shape& aSx=aMx(i);
|
||||||
|
if (!aMS.Contains(aSx)) {
|
||||||
|
mySolidsAlone.Append(aSx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// A
|
||||||
|
// Make vertices
|
||||||
|
aMV.Clear();
|
||||||
|
aItIm.Initialize(myImages);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aItIm.Key();
|
||||||
|
aMV.Add(aV);
|
||||||
|
const TopTools_ListOfShape& aLVSD=aItIm.Value();
|
||||||
|
MakeVertex(aLVSD, aVnew);//ZZ
|
||||||
|
myImages.Bind(aVnew, aLVSD);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aNbV=aMV.Extent();
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
const TopoDS_Shape& aV=aMV(i);
|
||||||
|
myImages.UnBind(aV);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
*/
|
86
src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.hxx
Normal file
86
src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.hxx
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GlueDetector.hxx
|
||||||
|
// Created: Wed Dec 15 11:08:09 2004
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
|
||||||
|
#ifndef _GEOMAlgo_GlueAnalyser_HeaderFile
|
||||||
|
#define _GEOMAlgo_GlueAnalyser_HeaderFile
|
||||||
|
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_Gluer.hxx>
|
||||||
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMAlgo_GlueAnalyser
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
class GEOMAlgo_GlueAnalyser : public GEOMAlgo_Gluer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Standard_EXPORT
|
||||||
|
GEOMAlgo_GlueAnalyser();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual ~GEOMAlgo_GlueAnalyser();
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
virtual void Perform() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean HasSolidsToGlue() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const GEOMAlgo_ListOfCoupleOfShapes& SolidsToGlue() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean HasSolidsAlone() const;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
const TopTools_ListOfShape& SolidsAlone() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Standard_EXPORT
|
||||||
|
void DetectVertices() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void DetectEdges() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void DetectFaces() ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void DetectShapes(const TopAbs_ShapeEnum aType) ;
|
||||||
|
|
||||||
|
Standard_EXPORT
|
||||||
|
void DetectSolids() ;
|
||||||
|
|
||||||
|
|
||||||
|
GEOMAlgo_ListOfCoupleOfShapes mySolidsToGlue;
|
||||||
|
TopTools_ListOfShape mySolidsAlone;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
430
src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.cxx
Normal file
430
src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.cxx
Normal file
@ -0,0 +1,430 @@
|
|||||||
|
// Copyright (C) 2007-2011 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: GEOMAlgo_GlueDetector.cxx
|
||||||
|
// Created:
|
||||||
|
// Author: Peter KURNEV
|
||||||
|
// <pkv@irinox>
|
||||||
|
//
|
||||||
|
#include <GEOMAlgo_GlueDetector.hxx>
|
||||||
|
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <NCollection_UBTreeFiller.hxx>
|
||||||
|
|
||||||
|
#include <TColStd_ListOfInteger.hxx>
|
||||||
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Compound.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
|
||||||
|
#include <NMTDS_BndSphereTree.hxx>
|
||||||
|
#include <NMTDS_BndSphere.hxx>
|
||||||
|
#include <NMTDS_IndexedDataMapOfShapeBndSphere.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
|
||||||
|
#include <GEOMAlgo_PassKeyShape.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
|
||||||
|
#include <GEOMAlgo_Tools.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function :
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GlueDetector::GEOMAlgo_GlueDetector()
|
||||||
|
:
|
||||||
|
GEOMAlgo_GluerAlgo(),
|
||||||
|
GEOMAlgo_Algo()
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
GEOMAlgo_GlueDetector::~GEOMAlgo_GlueDetector()
|
||||||
|
{}
|
||||||
|
//=======================================================================
|
||||||
|
//function : Perform
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::Perform()
|
||||||
|
{
|
||||||
|
myErrorStatus=0;
|
||||||
|
myWarningStatus=0;
|
||||||
|
//
|
||||||
|
CheckData();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Initialize the context
|
||||||
|
GEOMAlgo_GluerAlgo::Perform();
|
||||||
|
//
|
||||||
|
DetectVertices();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectEdges();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
DetectFaces();
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectVertices
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::DetectVertices()
|
||||||
|
{
|
||||||
|
Standard_Integer j, i, aNbV, aNbVSD;
|
||||||
|
Standard_Real aTolV;
|
||||||
|
gp_Pnt aPV;
|
||||||
|
TColStd_ListIteratorOfListOfInteger aIt;
|
||||||
|
TopoDS_Shape aVF;
|
||||||
|
TopTools_IndexedMapOfShape aMV;
|
||||||
|
TopTools_MapOfShape aMVProcessed;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItS;
|
||||||
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
|
||||||
|
TopTools_DataMapOfShapeListOfShape aMVV;
|
||||||
|
GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
|
||||||
|
NMTDS_IndexedDataMapOfShapeBndSphere aMSB;
|
||||||
|
//
|
||||||
|
NMTDS_BndSphereTreeSelector aSelector;
|
||||||
|
NMTDS_BndSphereTree aBBTree;
|
||||||
|
NCollection_UBTreeFiller <Standard_Integer, NMTDS_BndSphere> aTreeFiller(aBBTree);
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMV);
|
||||||
|
aNbV=aMV.Extent();
|
||||||
|
if (!aNbV) {
|
||||||
|
myErrorStatus=2; // no vertices in source shape
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
NMTDS_BndSphere aBox;
|
||||||
|
//
|
||||||
|
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i));
|
||||||
|
aPV=BRep_Tool::Pnt(aV);
|
||||||
|
aTolV=BRep_Tool::Tolerance(aV);
|
||||||
|
//
|
||||||
|
aBox.SetGap(myTolerance);
|
||||||
|
aBox.SetCenter(aPV);
|
||||||
|
aBox.SetRadius(aTolV);
|
||||||
|
//
|
||||||
|
aTreeFiller.Add(i, aBox);
|
||||||
|
//
|
||||||
|
aMIS.Add(i, aV);
|
||||||
|
aMSB.Add(aV, aBox);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aTreeFiller.Fill();
|
||||||
|
//
|
||||||
|
//---------------------------------------------------
|
||||||
|
// Chains
|
||||||
|
for (i=1; i<=aNbV; ++i) {
|
||||||
|
const TopoDS_Shape& aV=aMV(i);
|
||||||
|
//
|
||||||
|
if (aMVProcessed.Contains(aV)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
|
||||||
|
TopTools_ListOfShape aLVSD;
|
||||||
|
TColStd_MapOfInteger aMIP, aMIP1, aMIPC;
|
||||||
|
TColStd_MapIteratorOfMapOfInteger aIt1;
|
||||||
|
//
|
||||||
|
aMIP.Add(i);
|
||||||
|
while(1) {
|
||||||
|
aNbIP=aMIP.Extent();
|
||||||
|
aIt1.Initialize(aMIP);
|
||||||
|
for(; aIt1.More(); aIt1.Next()) {
|
||||||
|
aIP=aIt1.Key();
|
||||||
|
if (aMIPC.Contains(aIP)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
|
||||||
|
const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP);
|
||||||
|
//
|
||||||
|
aSelector.Clear();
|
||||||
|
aSelector.SetBox(aBoxVP);
|
||||||
|
//
|
||||||
|
aNbVSD=aBBTree.Select(aSelector);
|
||||||
|
if (!aNbVSD) {
|
||||||
|
continue; // it shoild not be so [at least IP itself]
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TColStd_ListOfInteger& aLI=aSelector.Indices();
|
||||||
|
aIt.Initialize(aLI);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
aIP1=aIt.Value();
|
||||||
|
if (aMIP.Contains(aIP1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
aMIP1.Add(aIP1);
|
||||||
|
} //for (; aIt.More(); aIt.Next()) {
|
||||||
|
}//for(; aIt1.More(); aIt1.Next()) {
|
||||||
|
//
|
||||||
|
aNbIP1=aMIP1.Extent();
|
||||||
|
if (!aNbIP1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aIt1.Initialize(aMIP);
|
||||||
|
for(; aIt1.More(); aIt1.Next()) {
|
||||||
|
aIP=aIt1.Key();
|
||||||
|
aMIPC.Add(aIP);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aMIP.Clear();
|
||||||
|
aIt1.Initialize(aMIP1);
|
||||||
|
for(; aIt1.More(); aIt1.Next()) {
|
||||||
|
aIP=aIt1.Key();
|
||||||
|
aMIP.Add(aIP);
|
||||||
|
}
|
||||||
|
aMIP1.Clear();
|
||||||
|
}// while(1)
|
||||||
|
//
|
||||||
|
// Fill myImages
|
||||||
|
aNbIP=aMIPC.Extent();
|
||||||
|
//
|
||||||
|
if (!aNbIP) {// no SD vertices is found
|
||||||
|
aMVProcessed.Add(aV);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//else { // SD vertices founded [ aMIPC ]
|
||||||
|
aIt1.Initialize(aMIPC);
|
||||||
|
for(j=0; aIt1.More(); aIt1.Next(), ++j) {
|
||||||
|
aIP=aIt1.Key();
|
||||||
|
const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
|
||||||
|
if (!j) {
|
||||||
|
aVF=aVP;
|
||||||
|
}
|
||||||
|
aLVSD.Append(aVP);
|
||||||
|
aMVProcessed.Add(aVP);
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
myImages.Bind(aVF, aLVSD);
|
||||||
|
}// for (i=1; i<=aNbV; ++i) {
|
||||||
|
//------------------------------
|
||||||
|
// Origins
|
||||||
|
aItIm.Initialize(myImages);
|
||||||
|
for (; aItIm.More(); aItIm.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aItIm.Key();
|
||||||
|
const TopTools_ListOfShape& aLVSD=aItIm.Value();
|
||||||
|
aItS.Initialize(aLVSD);
|
||||||
|
for (; aItS.More(); aItS.Next()) {
|
||||||
|
const TopoDS_Shape& aVSD=aItS.Value();
|
||||||
|
if (!myOrigins.IsBound(aVSD)) {
|
||||||
|
myOrigins.Bind(aVSD, aV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectFaces
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::DetectFaces()
|
||||||
|
{
|
||||||
|
DetectShapes(TopAbs_FACE);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectEdges
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::DetectEdges()
|
||||||
|
{
|
||||||
|
DetectShapes(TopAbs_EDGE);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : DetectShapes
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::DetectShapes(const TopAbs_ShapeEnum aType)
|
||||||
|
{
|
||||||
|
Standard_Boolean bDegenerated;
|
||||||
|
Standard_Integer i, aNbF, aNbSDF, iErr;
|
||||||
|
TopTools_IndexedMapOfShape aMF;
|
||||||
|
TopTools_ListIteratorOfListOfShape aItLS;
|
||||||
|
GEOMAlgo_PassKeyShape aPKF;
|
||||||
|
GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF;
|
||||||
|
//
|
||||||
|
myErrorStatus=0;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(myArgument, aType, aMF);
|
||||||
|
//
|
||||||
|
aNbF=aMF.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
const TopoDS_Shape& aS=aMF(i);
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_FACE) {
|
||||||
|
const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
|
||||||
|
FacePassKey(aF, aPKF);
|
||||||
|
}
|
||||||
|
else if (aType==TopAbs_EDGE) {
|
||||||
|
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
|
||||||
|
EdgePassKey(aE, aPKF);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myErrorStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aMPKLF.Contains(aPKF)) {
|
||||||
|
TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF);
|
||||||
|
aLSDF.Append(aS);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TopTools_ListOfShape aLSDF;
|
||||||
|
//
|
||||||
|
aLSDF.Append(aS);
|
||||||
|
aMPKLF.Add(aPKF, aLSDF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check geometric coincidence
|
||||||
|
if (myCheckGeometry) {
|
||||||
|
iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTolerance, myContext);
|
||||||
|
if (iErr) {
|
||||||
|
myErrorStatus=200;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Images/Origins
|
||||||
|
aNbF=aMPKLF.Extent();
|
||||||
|
for (i=1; i<=aNbF; ++i) {
|
||||||
|
const TopTools_ListOfShape& aLSDF=aMPKLF(i);
|
||||||
|
aNbSDF=aLSDF.Extent();
|
||||||
|
if (!aNbSDF) {
|
||||||
|
myErrorStatus=4; // it must not be
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aNbSDF==1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const TopoDS_Shape& aS1=aLSDF.First();
|
||||||
|
//
|
||||||
|
if (aType==TopAbs_EDGE) {
|
||||||
|
const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1);
|
||||||
|
bDegenerated=BRep_Tool::Degenerated(aE1);
|
||||||
|
if (bDegenerated) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
myImages.Bind(aS1, aLSDF);
|
||||||
|
// origins
|
||||||
|
aItLS.Initialize(aLSDF);
|
||||||
|
for (; aItLS.More(); aItLS.Next()) {
|
||||||
|
const TopoDS_Shape& aFSD=aItLS.Value();
|
||||||
|
if (!myOrigins.IsBound(aFSD)) {
|
||||||
|
myOrigins.Bind(aFSD, aS1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}// for (i=1; i<=aNbF; ++i)
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : FacePassKey
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF,
|
||||||
|
GEOMAlgo_PassKeyShape& aPK)
|
||||||
|
{
|
||||||
|
Standard_Integer i, aNbE;
|
||||||
|
TopoDS_Shape aER;
|
||||||
|
TopTools_ListOfShape aLE;
|
||||||
|
TopTools_IndexedMapOfShape aME;
|
||||||
|
//
|
||||||
|
TopExp::MapShapes(aF, TopAbs_EDGE, aME);
|
||||||
|
//
|
||||||
|
aNbE=aME.Extent();
|
||||||
|
for (i=1; i<=aNbE; ++i) {
|
||||||
|
const TopoDS_Shape& aE=aME(i);
|
||||||
|
//
|
||||||
|
const TopoDS_Edge& aEE=*((TopoDS_Edge*)&aE);
|
||||||
|
if (BRep_Tool::Degenerated(aEE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (myOrigins.IsBound(aE)) {
|
||||||
|
aER=myOrigins.Find(aE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aER=aE;
|
||||||
|
}
|
||||||
|
aLE.Append(aER);
|
||||||
|
}
|
||||||
|
aPK.SetShapes(aLE);
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : EdgePassKey
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE,
|
||||||
|
GEOMAlgo_PassKeyShape& aPK)
|
||||||
|
{
|
||||||
|
TopAbs_Orientation aOr;
|
||||||
|
TopoDS_Shape aVR;
|
||||||
|
TopoDS_Iterator aIt;
|
||||||
|
TopTools_ListOfShape aLV;
|
||||||
|
//
|
||||||
|
aIt.Initialize(aE);
|
||||||
|
for (; aIt.More(); aIt.Next()) {
|
||||||
|
const TopoDS_Shape& aV=aIt.Value();
|
||||||
|
aOr=aV.Orientation();
|
||||||
|
if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
|
||||||
|
if (myOrigins.IsBound(aV)) {
|
||||||
|
aVR=myOrigins.Find(aV);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aVR=aV;
|
||||||
|
}
|
||||||
|
aLV.Append(aVR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aPK.SetShapes(aLV);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user