From 267d9aad809b8d0f42b5c467376b773e3d574b1d Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 29 Dec 2004 14:11:13 +0000 Subject: [PATCH] Check and improve shapes with seam and/or degenerated edges. Done by SKL. --- src/GEOMAlgo/BlockFix.cdl | 50 ++ src/GEOMAlgo/BlockFix.cxx | 195 +++++++ src/GEOMAlgo/BlockFix.hxx | 105 ++++ src/GEOMAlgo/BlockFix.ixx | 26 + src/GEOMAlgo/BlockFix.jxx | 6 + src/GEOMAlgo/BlockFix_BlockFixAPI.cdl | 48 ++ src/GEOMAlgo/BlockFix_BlockFixAPI.cxx | 48 ++ src/GEOMAlgo/BlockFix_BlockFixAPI.hxx | 118 ++++ src/GEOMAlgo/BlockFix_BlockFixAPI.ixx | 76 +++ src/GEOMAlgo/BlockFix_BlockFixAPI.jxx | 9 + src/GEOMAlgo/BlockFix_BlockFixAPI.lxx | 42 ++ src/GEOMAlgo/BlockFix_CheckTool.cdl | 46 ++ src/GEOMAlgo/BlockFix_CheckTool.cxx | 224 ++++++++ src/GEOMAlgo/BlockFix_CheckTool.hxx | 118 ++++ src/GEOMAlgo/BlockFix_CheckTool.ixx | 26 + src/GEOMAlgo/BlockFix_CheckTool.jxx | 6 + .../BlockFix_PeriodicSurfaceModifier.cdl | 115 ++++ .../BlockFix_PeriodicSurfaceModifier.cxx | 230 ++++++++ .../BlockFix_PeriodicSurfaceModifier.hxx | 140 +++++ .../BlockFix_PeriodicSurfaceModifier.ixx | 78 +++ .../BlockFix_PeriodicSurfaceModifier.jxx | 27 + src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl | 120 ++++ src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx | 224 ++++++++ src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx | 141 +++++ src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx | 78 +++ src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx | 27 + src/GEOMAlgo/BlockFix_UnionEdges.cdl | 28 + src/GEOMAlgo/BlockFix_UnionEdges.cxx | 325 +++++++++++ src/GEOMAlgo/BlockFix_UnionEdges.hxx | 99 ++++ src/GEOMAlgo/BlockFix_UnionEdges.ixx | 26 + src/GEOMAlgo/BlockFix_UnionEdges.jxx | 9 + src/GEOMAlgo/BlockFix_UnionFaces.cdl | 46 ++ src/GEOMAlgo/BlockFix_UnionFaces.cxx | 512 ++++++++++++++++++ src/GEOMAlgo/BlockFix_UnionFaces.hxx | 101 ++++ src/GEOMAlgo/BlockFix_UnionFaces.ixx | 26 + src/GEOMAlgo/BlockFix_UnionFaces.jxx | 9 + src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx | 91 ++++ ...andle_BlockFix_PeriodicSurfaceModifier.hxx | 91 ++++ .../Handle_BlockFix_SphereSpaceModifier.hxx | 91 ++++ src/GEOMAlgo/Makefile.in | 15 +- 40 files changed, 3790 insertions(+), 2 deletions(-) create mode 100644 src/GEOMAlgo/BlockFix.cdl create mode 100644 src/GEOMAlgo/BlockFix.cxx create mode 100644 src/GEOMAlgo/BlockFix.hxx create mode 100644 src/GEOMAlgo/BlockFix.ixx create mode 100644 src/GEOMAlgo/BlockFix.jxx create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.cdl create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.cxx create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.hxx create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.ixx create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.jxx create mode 100644 src/GEOMAlgo/BlockFix_BlockFixAPI.lxx create mode 100644 src/GEOMAlgo/BlockFix_CheckTool.cdl create mode 100644 src/GEOMAlgo/BlockFix_CheckTool.cxx create mode 100644 src/GEOMAlgo/BlockFix_CheckTool.hxx create mode 100644 src/GEOMAlgo/BlockFix_CheckTool.ixx create mode 100644 src/GEOMAlgo/BlockFix_CheckTool.jxx create mode 100644 src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl create mode 100644 src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx create mode 100644 src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx create mode 100644 src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx create mode 100644 src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx create mode 100644 src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl create mode 100644 src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx create mode 100644 src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx create mode 100644 src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx create mode 100644 src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx create mode 100644 src/GEOMAlgo/BlockFix_UnionEdges.cdl create mode 100644 src/GEOMAlgo/BlockFix_UnionEdges.cxx create mode 100644 src/GEOMAlgo/BlockFix_UnionEdges.hxx create mode 100644 src/GEOMAlgo/BlockFix_UnionEdges.ixx create mode 100644 src/GEOMAlgo/BlockFix_UnionEdges.jxx create mode 100644 src/GEOMAlgo/BlockFix_UnionFaces.cdl create mode 100644 src/GEOMAlgo/BlockFix_UnionFaces.cxx create mode 100644 src/GEOMAlgo/BlockFix_UnionFaces.hxx create mode 100644 src/GEOMAlgo/BlockFix_UnionFaces.ixx create mode 100644 src/GEOMAlgo/BlockFix_UnionFaces.jxx create mode 100644 src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx create mode 100644 src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx create mode 100644 src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx diff --git a/src/GEOMAlgo/BlockFix.cdl b/src/GEOMAlgo/BlockFix.cdl new file mode 100644 index 000000000..f8bfaa2a0 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.cdl @@ -0,0 +1,50 @@ +-- File: BlockFix.cdl +-- Created: Tue Dec 7 11:59:05 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + + + +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; diff --git a/src/GEOMAlgo/BlockFix.cxx b/src/GEOMAlgo/BlockFix.cxx new file mode 100644 index 000000000..b359031f7 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.cxx @@ -0,0 +1,195 @@ +// File: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +//======================================================================= +//function : 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))) { + + 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(); + + // remove neighbour seam edges + if(isDone) { + for( i = 1; iNbEdges();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; +} diff --git a/src/GEOMAlgo/BlockFix.hxx b/src/GEOMAlgo/BlockFix.hxx new file mode 100644 index 000000000..c85590ef6 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.hxx @@ -0,0 +1,105 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_HeaderFile +#define _BlockFix_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#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 +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#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 diff --git a/src/GEOMAlgo/BlockFix.ixx b/src/GEOMAlgo/BlockFix.ixx new file mode 100644 index 000000000..ad18c4bfa --- /dev/null +++ b/src/GEOMAlgo/BlockFix.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix.jxx b/src/GEOMAlgo/BlockFix.jxx new file mode 100644 index 000000000..649432a98 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl new file mode 100644 index 000000000..b5cfa0e45 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl @@ -0,0 +1,48 @@ +-- File: BlockFix_BlockFixAPI.cdl +-- Created: Tue Dec 7 17:56:09 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + +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; diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx new file mode 100644 index 000000000..444ddd693 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx @@ -0,0 +1,48 @@ +// File: BlockFix_BlockFixAPI.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + + +#include +#include +#include +#include +#include + +//======================================================================= +//function : ShapeConvert_CanonicAPI +//purpose : +//======================================================================= + +BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() +{ + myTolerance = Precision::Confusion(); +} + +//======================================================================= +//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; + TopoDS_Shape aResult; + aResult = aFaceUnifier.Perform(myShape); + + + BlockFix_UnionEdges anEdgeUnifier; + myShape = anEdgeUnifier.Perform(aResult,myTolerance); + + TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); + myShape = aRes; + +} diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..9eb2198db --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx @@ -0,0 +1,118 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#define _BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile +#include +#endif + +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#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_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; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_ShapeBuild_ReShape myContext; +TopoDS_Shape myShape; +Standard_Real myTolerance; + + +}; + + +#include + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx new file mode 100644 index 000000000..4fc77f490 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx @@ -0,0 +1,76 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#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() {} + diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx new file mode 100644 index 000000000..a02004dd5 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx @@ -0,0 +1,9 @@ +#ifndef _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx new file mode 100644 index 000000000..f3de13aef --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx @@ -0,0 +1,42 @@ +#include + +//======================================================================= +//function : Shape +//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; +} + diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cdl b/src/GEOMAlgo/BlockFix_CheckTool.cdl new file mode 100644 index 000000000..959ada723 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.cdl @@ -0,0 +1,46 @@ +-- File: BlockFix_CheckTool.cdl +-- Created: Fri Dec 17 10:36:58 2004 +-- Author: Sergey KUUL +-- +---Copyright: Open CASCADE SA 2004 + +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; + myNbUF : Integer; + myNbUE : Integer; + myNbUFUE : Integer; + myBadRanges : Integer; + +end CheckTool; diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cxx b/src/GEOMAlgo/BlockFix_CheckTool.cxx new file mode 100644 index 000000000..ba902ba5a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.cxx @@ -0,0 +1,224 @@ +// File: BlockFix_CheckTool.cxx +// Created: 17.12.04 11:15:25 +// Author: Sergey KUUL +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//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; + myNbUF=0; + myNbUE=0; + myNbUFUE=0; + TopExp_Explorer exps; + for(exps.Init(myShape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + myNbSolids++; + Standard_Boolean IsBlock=Standard_True; + Standard_Boolean MayBeUF=Standard_False; + Standard_Boolean MayBeUE=Standard_False; + Standard_Integer nf=0; + TopExp_Explorer expf; + for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++; + + if(nf<6) { + IsBlock=Standard_False; + } + else if(nf>6) { + IsBlock=Standard_False; + // check faces unification + TopTools_SequenceOfShape faces; + for( expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + faces.Append(aFace); + } + Standard_Boolean HasFacesForUnification = Standard_False; + for(Standard_Integer i=1; i12) { + IsBlock=Standard_False; + // check edges unification + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + for(expe.Init(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()); + 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!"< +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TopTools_SequenceOfShape_HeaderFile +#include +#endif +#ifndef _Standard_OStream_HeaderFile +#include +#endif +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#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 myNbUF; +Standard_Integer myNbUE; +Standard_Integer myNbUFUE; +Standard_Integer myBadRanges; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_CheckTool.ixx b/src/GEOMAlgo/BlockFix_CheckTool.ixx new file mode 100644 index 000000000..1b3f08c4b --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_CheckTool.jxx b/src/GEOMAlgo/BlockFix_CheckTool.jxx new file mode 100644 index 000000000..ed3116843 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_CheckTool_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl new file mode 100644 index 000000000..63598cfe9 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl @@ -0,0 +1,115 @@ +-- File: BlockFix_PeriodicSurfaceModifier.cdl +-- Created: Wed Dec 15 10:03:50 2004 +-- Author: Sergey KUUL +-- +---Copyright: Open CASCADE SA 2004 + +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 has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , 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 has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , 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 has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- 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 has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . 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 has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- 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 between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + +fields + + myTolerance : Real; + myMapOfFaces : DataMapOfShapeInteger from TopTools; + myMapOfSurfaces: IndexedMapOfTransient from TColStd; + +end PeriodicSurfaceModifier; diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx new file mode 100644 index 000000000..9ca792fed --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx @@ -0,0 +1,230 @@ +// File: BlockFix_PeriodicSurfaceModifier.cxx +// Created: 15.12.04 10:08:50 +// Author: Sergey KUUL +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//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*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*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); +} + diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..b55096ce9 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,140 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#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 diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx new file mode 100644 index 000000000..7bdcfb449 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx @@ -0,0 +1,78 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#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() {} + diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx new file mode 100644 index 000000000..0a556d598 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx @@ -0,0 +1,27 @@ +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl new file mode 100644 index 000000000..eae4b8a7a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl @@ -0,0 +1,120 @@ +-- File: BlockFix_SphereSpaceModifier.cdl +-- Created: Tue Dec 7 12:01:49 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + +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 has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , 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 has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , 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 has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- 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 has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . 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 has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- 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 between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + 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; + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx new file mode 100644 index 000000000..c5f774d82 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx @@ -0,0 +1,224 @@ +// File: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//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 = PI/2.; + if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { + if(Abs(Vmax-Vmin) < PI2) { + Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); + gp_Sphere sp = aSphere->Sphere(); + gp_Ax3 ax3 = sp.Position(); + 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; + } + } + } + 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); +} + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..463277a46 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,141 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_SphereSpaceModifier_HeaderFile +#define _BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#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 diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx new file mode 100644 index 000000000..55b027172 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx @@ -0,0 +1,78 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#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() {} + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx new file mode 100644 index 000000000..a2a6afec0 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx @@ -0,0 +1,27 @@ +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cdl b/src/GEOMAlgo/BlockFix_UnionEdges.cdl new file mode 100644 index 000000000..8a6a4b905 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cdl @@ -0,0 +1,28 @@ +-- 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; diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx new file mode 100644 index 000000000..f36e8c7e1 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cxx @@ -0,0 +1,325 @@ +// File: BlockFix_UnionEdges.cxx +// Created: 07.12.04 15:27:30 +// Author: Sergey KUUL + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : 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()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)) ) { + 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())) 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)) ) { + 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(); + 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); + Standard_Real lpar = C->XAxis().Direction().Angle(D2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); + TopoDS_Edge E; + 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.); + ShapeFix_Edge sfe; + sfe.FixAddPCurve(E,aFace,Standard_False); + sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + } + if(j1) { + // second step: union edges with various curves + cout<<"can not make analitical union => make approximation"<Apply(Shape); + + TopTools_IndexedMapOfShape ChangedFaces; + + // 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); + + // processing each face + TopExp_Explorer exp; + for(exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(myContext->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(myContext->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 + myContext->Replace(SeqEdges(1),E); + for(Standard_Integer j=2; j<=SeqEdges.Length(); j++) { + myContext->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 + + } // end processing each solid + + for(Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { + TopoDS_Face aFace = TopoDS::Face(myContext->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(); + //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(); + //} + } + + aResult = myContext->Apply(Shape); + return aResult; +} diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.hxx b/src/GEOMAlgo/BlockFix_UnionEdges.hxx new file mode 100644 index 000000000..3b8aa2102 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.hxx @@ -0,0 +1,99 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_UnionEdges_HeaderFile +#define _BlockFix_UnionEdges_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +class ShapeBuild_ReShape; +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#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 diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.ixx b/src/GEOMAlgo/BlockFix_UnionEdges.ixx new file mode 100644 index 000000000..addb6a314 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.jxx b/src/GEOMAlgo/BlockFix_UnionEdges.jxx new file mode 100644 index 000000000..a8b40958b --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.jxx @@ -0,0 +1,9 @@ +#ifndef _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionEdges_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cdl b/src/GEOMAlgo/BlockFix_UnionFaces.cdl new file mode 100644 index 000000000..7fe6caed2 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.cdl @@ -0,0 +1,46 @@ +-- File: BlockFix_UnionFaces.cdl +-- Created: Tue Dec 7 17:15:42 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + +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; + + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cxx b/src/GEOMAlgo/BlockFix_UnionFaces.cxx new file mode 100644 index 000000000..2f4e212ae --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.cxx @@ -0,0 +1,512 @@ +// File: BlockFix_UnionFaces.cxx +// Created: Tue Dec 7 17:15:42 2004 +// Author: Pavel DURANDIN +// Open CASCADE SA 2004 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +//======================================================================= +//function : BlockFix_UnionFaces +//purpose : +//======================================================================= + +BlockFix_UnionFaces::BlockFix_UnionFaces() + : myTolerance(Precision::Confusion()) +{ +} + + +//======================================================================= +//function : GetTolearnce +//purpose : +//======================================================================= + +Standard_Real& BlockFix_UnionFaces::GetTolerance() +{ + return myTolerance; +} + + +//======================================================================= +//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); + // processing each face + TopExp_Explorer exp; + //for( exp.Init(Shape, TopAbs_FACE); exp.More(); exp.Next()) { + for( exp.Init(aSolid, TopAbs_FACE); exp.More(); 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 eny 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)); + } + } + + //TopoDS_Shape aResult = Shape; + if(NbModif>0) { + TopoDS_Shape aResult = aSolid; + if(!hasFailed) { + 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 : +//======================================================================= + +Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aCheckedFace) const +{ + //checking the same handless + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1, S2; + + S1 = BRep_Tool::Surface(aFace,L1); + S2 = BRep_Tool::Surface(aCheckedFace,L2); + + return (S1 == S2 && L1 == L2); +} + + +//======================================================================= +//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); + } +} + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.hxx b/src/GEOMAlgo/BlockFix_UnionFaces.hxx new file mode 100644 index 000000000..a67693762 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.hxx @@ -0,0 +1,101 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_UnionFaces_HeaderFile +#define _BlockFix_UnionFaces_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopoDS_Face; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +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() ; +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; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.ixx b/src/GEOMAlgo/BlockFix_UnionFaces.ixx new file mode 100644 index 000000000..bae71ca14 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.jxx b/src/GEOMAlgo/BlockFix_UnionFaces.jxx new file mode 100644 index 000000000..8ccb1344a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.jxx @@ -0,0 +1,9 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionFaces_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..1664fde18 --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile +#define _Handle_BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class BlockFix_BlockFixAPI; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_BlockFixAPI); + +class Handle(BlockFix_BlockFixAPI) : public Handle(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); + } + Handle(BlockFix_BlockFixAPI)():Handle(MMgt_TShared)() {} + Handle(BlockFix_BlockFixAPI)(const Handle(BlockFix_BlockFixAPI)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(BlockFix_BlockFixAPI)(const BlockFix_BlockFixAPI* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(BlockFix_BlockFixAPI)& operator=(const Handle(BlockFix_BlockFixAPI)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_BlockFixAPI)& operator=(const BlockFix_BlockFixAPI* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_BlockFixAPI* operator->() + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + BlockFix_BlockFixAPI* operator->() const + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_BlockFixAPI)(); + + Standard_EXPORT static const Handle(BlockFix_BlockFixAPI) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..114b7606a --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_PeriodicSurfaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier); + +class Handle(BlockFix_PeriodicSurfaceModifier) : public Handle(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); + } + Handle(BlockFix_PeriodicSurfaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_PeriodicSurfaceModifier)(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)(const BlockFix_PeriodicSurfaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const BlockFix_PeriodicSurfaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_PeriodicSurfaceModifier* operator->() + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + BlockFix_PeriodicSurfaceModifier* operator->() const + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_PeriodicSurfaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_PeriodicSurfaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..2541a6ddf --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile +#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_SphereSpaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_SphereSpaceModifier); + +class Handle(BlockFix_SphereSpaceModifier) : public Handle(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); + } + Handle(BlockFix_SphereSpaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_SphereSpaceModifier)(const Handle(BlockFix_SphereSpaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_SphereSpaceModifier)(const BlockFix_SphereSpaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const Handle(BlockFix_SphereSpaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const BlockFix_SphereSpaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_SphereSpaceModifier* operator->() + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + BlockFix_SphereSpaceModifier* operator->() const + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_SphereSpaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_SphereSpaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Makefile.in b/src/GEOMAlgo/Makefile.in index e0e46a126..da1cfa641 100644 --- a/src/GEOMAlgo/Makefile.in +++ b/src/GEOMAlgo/Makefile.in @@ -52,7 +52,14 @@ LIB_SRC = \ GEOMAlgo_PassKey.cxx \ GEOMAlgo_PassKeyMapHasher.cxx \ GEOMAlgo_ShapeAlgo.cxx \ - GEOMAlgo_Tools.cxx + GEOMAlgo_Tools.cxx \ + BlockFix.cxx \ + BlockFix_BlockFixAPI.cxx \ + BlockFix_CheckTool.cxx \ + BlockFix_PeriodicSurfaceModifier.cxx \ + BlockFix_SphereSpaceModifier.cxx \ + BlockFix_UnionEdges.cxx \ + BlockFix_UnionFaces.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -66,7 +73,11 @@ EXPORT_HEADERS = \ GEOMAlgo_CoupleOfShapes.hxx \ GEOMAlgo_ListOfCoupleOfShapes.hxx \ GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx \ - Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx + Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx \ + BlockFix_BlockFixAPI.hxx \ + BlockFix_CheckTool.hxx \ + Handle_BlockFix_BlockFixAPI.hxx \ + BlockFix_BlockFixAPI.lxx # idl files EXPORT_IDLS= -- 2.39.2