diff --git a/src/GEOMAlgo/GEOMAlgo.cdl b/src/GEOMAlgo/GEOMAlgo.cdl index b7f770f3a..98ed925d1 100755 --- a/src/GEOMAlgo/GEOMAlgo.cdl +++ b/src/GEOMAlgo/GEOMAlgo.cdl @@ -46,6 +46,7 @@ is class CoupleOfShapes; class PassKey; class PassKeyMapHasher; + class SurfaceTools; class Tools; -- -- finder on @@ -53,8 +54,10 @@ is class WireSolid; class ShellSolid; class VertexSolid; + class SolidSolid; class FinderShapeOn; -- + -- instantiations class IndexedDataMapOfPassKeyListOfShape instantiates IndexedDataMap from TCollection (PassKey from GEOMAlgo, ListOfShape from TopTools, @@ -73,4 +76,9 @@ is instantiates List from TCollection (CoupleOfShapes from GEOMAlgo); + class IndexedDataMapOfShapeState + instantiates IndexedDataMap from TCollection (Shape from TopoDS, + State from TopAbs, + ShapeMapHasher from TopTools); + end GEOMAlgo; diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl index bd0a29934..4f8cfaaf3 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl @@ -16,7 +16,8 @@ uses ListOfShape from TopTools, DataMapOfShapeShape from TopTools, Shape from TopoDS, - State from GEOMAlgo + State from GEOMAlgo, + IndexedDataMapOfShapeState from GEOMAlgo --raises @@ -57,12 +58,22 @@ is CheckData(me:out) is redefined protected; - MakeArguments(me:out) + MakeArgument1(me:out) is protected; + MakeArgument2(me:out) + is protected; + Find(me:out) is protected; + Find(me:out; + aS:Shape from TopoDS) + is protected; + + FindVertices(me:out) + is protected; + CopySource(myclass; aS :Shape from TopoDS; aImages : out DataMapOfShapeShape from TopTools; @@ -79,5 +90,7 @@ fields myArg2 : Shape from TopoDS is protected; myLS : ListOfShape from TopTools is protected; myImages : DataMapOfShapeShape from TopTools is protected; - + myMSS : IndexedDataMapOfShapeState from GEOMAlgo is protected; + myIsAnalytic : Boolean from Standard is protected; + end FinderShapeOn; diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx index 775522cab..ce9b55f8d 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx @@ -6,7 +6,10 @@ #include +#include + #include +#include #include #include @@ -16,7 +19,6 @@ #include #include #include - #include #include @@ -24,6 +26,7 @@ #include #include +#include #include #include @@ -37,7 +40,9 @@ #include #include #include - +#include +#include +#include //======================================================================= //function : GEOMAlgo_FinderShapeOn @@ -49,7 +54,8 @@ GEOMAlgo_FinderShapeOn::GEOMAlgo_FinderShapeOn() { myTolerance=0.0001; myShapeType=TopAbs_VERTEX; - myState=GEOMAlgo_ST_UNKNOWN; + myState=GEOMAlgo_ST_UNKNOWN; + myIsAnalytic=Standard_True; } //======================================================================= //function : ~ @@ -112,6 +118,24 @@ GEOMAlgo_State GEOMAlgo_FinderShapeOn::State() const //======================================================================= const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn::Shapes() const { + Standard_Boolean bIsConformState; + Standard_Integer i, aNb; + TopAbs_State aSt; + TopTools_ListOfShape* pL; + // + pL=(TopTools_ListOfShape*) &myLS; + pL->Clear(); + // + aNb=myMSS.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myMSS.FindKey(i); + aSt=myMSS.FindFromIndex(i); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (bIsConformState) { + pL->Append(aS); + } + } return myLS; } //======================================================================= @@ -123,6 +147,7 @@ void GEOMAlgo_FinderShapeOn::Perform() myErrorStatus=0; myWarningStatus=0; myLS.Clear(); + myMSS.Clear(); // if (!myResult.IsNull()){ myResult.Nullify(); @@ -133,34 +158,122 @@ void GEOMAlgo_FinderShapeOn::Perform() return; } // - MakeArguments(); - if(myErrorStatus || myWarningStatus) { - return; - } + myIsAnalytic=GEOMAlgo_SurfaceTools::IsAnalytic(mySurface); // - Find(); + MakeArgument1(); if(myErrorStatus) { return; } // + if (myIsAnalytic && myShapeType==TopAbs_VERTEX) { + FindVertices(); + return; + } + // + MakeArgument2(); + if(myErrorStatus) { + return; + } + // + Find(); + if(myErrorStatus || myWarningStatus) { + return; + } + // +} +//======================================================================= +//function : FindVertices +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::FindVertices() +{ + Standard_Integer i, aNb, iErr; + TopAbs_State aSt; + TopAbs_Orientation aOr; + gp_Pnt aP; + TopTools_IndexedMapOfShape aM; + // + TopExp::MapShapes(myArg1, TopAbs_FACE, aM); + const TopoDS_Face& aF=TopoDS::Face(aM(1)); + aOr=aF.Orientation(); + // + aM.Clear(); + TopExp::MapShapes(myShape, myShapeType, aM); + aNb=aM.Extent(); + if (!aNb) { + myWarningStatus=10; // No found subshapes of type myShapeType + return; + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + const TopoDS_Vertex& aV=TopoDS::Vertex(aS); + aP=BRep_Tool::Pnt(aV); + iErr=GEOMAlgo_SurfaceTools::GetState(aP, mySurface, myTolerance, aSt); + if (aOr==TopAbs_REVERSED) { + aSt=GEOMAlgo_SurfaceTools::ReverseState(aSt); + } + myMSS.Add(aS, aSt); + } } //======================================================================= //function : Find //purpose : //======================================================================= void GEOMAlgo_FinderShapeOn::Find() +{ + Standard_Integer i, aNb; + Standard_Boolean bICS; + TopTools_IndexedMapOfShape aM; + // + TopExp::MapShapes(myArg2, myShapeType, aM); + // + aNb=aM.Extent(); + if (!aNb) { + myWarningStatus=10; // No found subshapes of type myShapeType + return; + } + // + bICS=GEOMAlgo_Tools::IsCompositeShape(myArg2); + if (!bICS || myIsAnalytic) { + TopoDS_Compound aCmp; + BRep_Builder aBB; + // + aBB.MakeCompound(aCmp); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aSi=aM(i); + aBB.Add(aCmp, aSi); + } + // + aM.Clear(); + aM.Add(aCmp); + aNb=1; + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + Find(aS); + if (myErrorStatus) { + return; + } + } +} +//======================================================================= +//function : Find +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Find(const TopoDS_Shape& aS) { myErrorStatus=0; // Standard_Boolean bIsDone; - Standard_Integer iErr; + Standard_Integer i, iErr; + TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON}; TopTools_ListIteratorOfListOfShape aIt; - BRep_Builder aBB; BOPTools_DSFiller aDF; - GEOMAlgo_ShapeSolid* pSS; // // 1. Prepare DSFiller - aDF.SetShapes (myArg1, myArg2); + aDF.SetShapes (myArg1, aS); bIsDone=aDF.IsDone(); if (!bIsDone) { myErrorStatus=30; // wrong args are used for DSFiller @@ -174,16 +287,31 @@ void GEOMAlgo_FinderShapeOn::Find() } // // 2. Find shapes - myLS.Clear(); + GEOMAlgo_ShapeSolid* pSS; + GEOMAlgo_VertexSolid aVXS; + GEOMAlgo_WireSolid aWRS; + GEOMAlgo_ShellSolid aSHS; + GEOMAlgo_SolidSolid aSLS; // - if (myShapeType==TopAbs_VERTEX) { - pSS=new GEOMAlgo_VertexSolid; - } - else if (myShapeType==TopAbs_EDGE) { - pSS=new GEOMAlgo_WireSolid; - } - else if (myShapeType==TopAbs_FACE) { - pSS=new GEOMAlgo_ShellSolid; + pSS=NULL; + // + switch (myShapeType) { + case TopAbs_VERTEX: + pSS=&aVXS; + break; + case TopAbs_EDGE: + pSS=&aWRS; + break; + case TopAbs_FACE: + pSS=&aSHS; + break; + case TopAbs_SOLID: + aSLS.SetShape2(myArg2); + pSS=&aSLS; + break; + default: + myErrorStatus=12; // unallowed subshape type + return; } // pSS->SetFiller(aDF); @@ -191,97 +319,111 @@ void GEOMAlgo_FinderShapeOn::Find() iErr=pSS->ErrorStatus(); if (iErr) { myErrorStatus=32; // builder ShapeSolid failed - delete pSS; return; } // - const TopTools_ListOfShape& aLS=pSS->Shapes(myState); - // - aIt.Initialize(aLS); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSImage=aIt.Value(); - if (myImages.IsBound(aSImage)) { - const TopoDS_Shape& aS=myImages.Find(aSImage); - myLS.Append(aS); - } - else { - myErrorStatus=33;// can not find original shape - return; + for (i=0; i<3; ++i) { + const TopTools_ListOfShape& aLS=pSS->Shapes(aSts[i]); + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSImage=aIt.Value(); + if (myImages.IsBound(aSImage)) { + const TopoDS_Shape& aSx=myImages.Find(aSImage); + myMSS.Add(aSx, aSts[i]); + } + else { + myErrorStatus=33;// can not find original shape + return; + } } } - // - delete pSS; } //======================================================================= -//function : MakeArguments +//function : MakeArgument1 //purpose : //======================================================================= -void GEOMAlgo_FinderShapeOn::MakeArguments() +void GEOMAlgo_FinderShapeOn::MakeArgument1() { myErrorStatus=0; // Standard_Integer i, aNb; + TopAbs_ShapeEnum aType; BRepLib_FaceError aFErr; BRepLib_MakeFace aMF; TopTools_IndexedMapOfShape aM; BRep_Builder aBB; - TopoDS_Compound aCmp; + TopoDS_Face aFace; TopoDS_Shell aSh; TopoDS_Solid aSd; - TopoDS_Shape aSC; - TopTools_DataMapOfShapeShape aOriginals; - TopExp_Explorer aExp; // // Argument 1 - aMF.Init(mySurface, Standard_True); - aFErr=aMF.Error(); - if (aFErr!=BRepLib_FaceDone) { - myErrorStatus=20; // can not build the face - return; + if (!myIsAnalytic) { + aMF.Init(mySurface, Standard_True); + aFErr=aMF.Error(); + if (aFErr!=BRepLib_FaceDone) { + myErrorStatus=20; // can not build the face + return; + } + // + const TopoDS_Shape& aF=aMF.Shape(); + aFace=TopoDS::Face(aF); + // + // update tolerances + aM.Add(aF); + TopExp::MapShapes(aF, TopAbs_VERTEX, aM); + TopExp::MapShapes(aF, TopAbs_EDGE, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + aType=aS.ShapeType(); + switch (aType) { + case TopAbs_VERTEX: { + const TopoDS_Vertex& aVx=TopoDS::Vertex(aS); + aBB.UpdateVertex(aVx, myTolerance); + } + break; + case TopAbs_EDGE: { + const TopoDS_Edge& aEx=TopoDS::Edge(aS); + aBB.UpdateEdge(aEx, myTolerance); + } + break; + case TopAbs_FACE: { + const TopoDS_Face& aFx=TopoDS::Face(aS); + aBB.UpdateFace(aFx, myTolerance); + } + break; + default: + break; + } + } + } // + else { + aBB.MakeFace(aFace, mySurface, myTolerance); } // - const TopoDS_Shape& aF=aMF.Shape(); - // - // update tolerance - aExp.Init(aF, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Vertex& aV=TopoDS::Vertex(aExp.Current()); - aBB.UpdateVertex(aV, myTolerance); - } - aExp.Init(aF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); - aBB.UpdateEdge(aE, myTolerance); - } - const TopoDS_Face& aFace=TopoDS::Face(aF); - aBB.UpdateFace(aFace, myTolerance); - // // make solid aBB.MakeShell(aSh); aBB.Add(aSh, aFace); aBB.MakeSolid(aSd); aBB.Add(aSd, aSh); myArg1=aSd; +} +//======================================================================= +//function : MakeArgument2 +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::MakeArgument2() +{ + myErrorStatus=0; // - // Argument 2 + TopoDS_Shape aSC; + TopTools_DataMapOfShapeShape aOriginals; // myImages.Clear(); // GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC); // - TopExp::MapShapes(aSC, myShapeType, aM); - aNb=aM.Extent(); - if (!aNb) { - myWarningStatus=10; // No found subshapes of type myShapeType - return; - } - // - aBB.MakeCompound(aCmp); - for (i=1; i<=aNb; ++i) { - const TopoDS_Shape& aS=aM(i); - aBB.Add(aCmp, aS); - } - myArg2=aCmp; + myArg2=aSC; } //======================================================================= //function : CheckData @@ -303,7 +445,8 @@ void GEOMAlgo_FinderShapeOn::CheckData() // if (!(myShapeType==TopAbs_VERTEX || myShapeType==TopAbs_EDGE || - myShapeType==TopAbs_FACE)) { + myShapeType==TopAbs_FACE || + myShapeType==TopAbs_SOLID)) { myErrorStatus=12; // unallowed subshape type return; } @@ -334,9 +477,7 @@ void GEOMAlgo_FinderShapeOn::CopySource(const TopoDS_Shape& aE, // if (aOriginals.IsBound(aE)) { aEx=aOriginals.ChangeFind(aE); - if (aType==TopAbs_EDGE) { - return; - } + return; } else { aEx=aE.EmptyCopied(); diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx index 12bf74c16..42129bc28 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx @@ -40,6 +40,12 @@ #ifndef _TopTools_DataMapOfShapeShape_HeaderFile #include #endif +#ifndef _GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif #ifndef _GEOMAlgo_ShapeAlgo_HeaderFile #include #endif @@ -95,8 +101,11 @@ protected: // Methods PROTECTED // Standard_EXPORT virtual void CheckData() ; -Standard_EXPORT void MakeArguments() ; +Standard_EXPORT void MakeArgument1() ; +Standard_EXPORT void MakeArgument2() ; Standard_EXPORT void Find() ; +Standard_EXPORT void Find(const TopoDS_Shape& aS) ; +Standard_EXPORT void FindVertices() ; // Fields PROTECTED @@ -108,6 +117,8 @@ TopoDS_Shape myArg1; TopoDS_Shape myArg2; TopTools_ListOfShape myLS; TopTools_DataMapOfShapeShape myImages; +GEOMAlgo_IndexedDataMapOfShapeState myMSS; +Standard_Boolean myIsAnalytic; private: diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx new file mode 100644 index 000000000..da467f38b --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx @@ -0,0 +1,146 @@ +// 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 _GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile +#define _GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TopAbs_State_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopTools_ShapeMapHasher; +class GEOMAlgo_IndexedDataMapOfShapeState; + + +class GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState : public TCollection_MapNode { + +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 + // +GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState(const TopoDS_Shape& K1,const Standard_Integer K2,const TopAbs_State& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2); + TopoDS_Shape& Key1() const; + Standard_Integer& Key2() const; + TCollection_MapNodePtr& Next2() const; + TopAbs_State& Value() const; +Standard_EXPORT ~GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_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 + // +TopoDS_Shape myKey1; +Standard_Integer myKey2; +TopAbs_State myValue; +TCollection_MapNodePtr myNext2; + + +}; + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopAbs_State +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_Type_() GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_Type_() +#define TCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeState +#define TCollection_IndexedDataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_hxx +#undef Handle_TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_Type_ +#undef TCollection_IndexedDataMap +#undef TCollection_IndexedDataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_0.cxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_0.cxx new file mode 100644 index 000000000..a29a65763 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_0.cxx @@ -0,0 +1,100 @@ +// 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 + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile +#include +#endif +GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState::~GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + 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("GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState", + sizeof(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState))) { + _anOtherObject = Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)((Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState::DynamicType() const +{ + return STANDARD_TYPE(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) ; +} +Standard_Boolean GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState::~Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState() {} +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopAbs_State +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_Type_() GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_Type_() +#define TCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeState +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState.hxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState.hxx new file mode 100644 index 000000000..35397a9a0 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState.hxx @@ -0,0 +1,143 @@ +// 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 _GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile +#define _GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _TopAbs_State_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_OutOfRange; +class Standard_NoSuchObject; +class TopoDS_Shape; +class TopTools_ShapeMapHasher; +class GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_IndexedDataMapOfShapeState : public TCollection_BasicMap { + +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 GEOMAlgo_IndexedDataMapOfShapeState(const Standard_Integer NbBuckets = 1); +Standard_EXPORT GEOMAlgo_IndexedDataMapOfShapeState& Assign(const GEOMAlgo_IndexedDataMapOfShapeState& Other) ; + GEOMAlgo_IndexedDataMapOfShapeState& operator =(const GEOMAlgo_IndexedDataMapOfShapeState& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~GEOMAlgo_IndexedDataMapOfShapeState() +{ + Clear(); +} + +Standard_EXPORT Standard_Integer Add(const TopoDS_Shape& K,const TopAbs_State& I) ; +Standard_EXPORT void Substitute(const Standard_Integer I,const TopoDS_Shape& K,const TopAbs_State& T) ; +Standard_EXPORT void RemoveLast() ; +Standard_EXPORT Standard_Boolean Contains(const TopoDS_Shape& K) const; +Standard_EXPORT const TopoDS_Shape& FindKey(const Standard_Integer I) const; +Standard_EXPORT const TopAbs_State& FindFromIndex(const Standard_Integer I) const; + const TopAbs_State& operator ()(const Standard_Integer I) const +{ + return FindFromIndex(I); +} + +Standard_EXPORT TopAbs_State& ChangeFromIndex(const Standard_Integer I) ; + TopAbs_State& operator ()(const Standard_Integer I) +{ + return ChangeFromIndex(I); +} + +Standard_EXPORT Standard_Integer FindIndex(const TopoDS_Shape& K) const; +Standard_EXPORT const TopAbs_State& FindFromKey(const TopoDS_Shape& K) const; +Standard_EXPORT TopAbs_State& ChangeFromKey(const TopoDS_Shape& K) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT GEOMAlgo_IndexedDataMapOfShapeState(const GEOMAlgo_IndexedDataMapOfShapeState& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState_0.cxx b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState_0.cxx new file mode 100644 index 000000000..f95fd1c70 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_IndexedDataMapOfShapeState_0.cxx @@ -0,0 +1,57 @@ +// 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 + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopAbs_State +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState +#define TCollection_IndexedDataMapNode_Type_() GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_Type_() +#define TCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeState +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl index 8c78910e2..c0dcdd422 100644 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl @@ -10,9 +10,9 @@ deferred class ShapeSolid from GEOMAlgo ---Purpose: -uses +uses + State from TopAbs, ListOfShape from TopTools, - State from GEOMAlgo, PDSFiller from BOPTools, DSFiller from BOPTools --raises @@ -26,8 +26,9 @@ is aDSF:DSFiller from BOPTools); ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_ShapeSolid();" + Shapes(me; - aState:State from GEOMAlgo) + aState:State from TopAbs) returns ListOfShape from TopTools; ---C++: return const & @@ -41,8 +42,6 @@ fields myLSIN : ListOfShape from TopTools is protected; myLSOUT : ListOfShape from TopTools is protected; myLSON : ListOfShape from TopTools is protected; - - myLS : ListOfShape from TopTools is protected; myRank : Integer from Standard is protected; myDSFiller : PDSFiller from BOPTools is protected; diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx index 72ed66f46..e0cebcf23 100644 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx @@ -35,80 +35,27 @@ void GEOMAlgo_ShapeSolid::SetFiller(const BOPTools_DSFiller& aDSFiller) { myDSFiller=(BOPTools_DSFiller*) &aDSFiller; } - //======================================================================= // function: Shapes // purpose: //======================================================================= -const TopTools_ListOfShape& GEOMAlgo_ShapeSolid::Shapes(const GEOMAlgo_State aState) const +const TopTools_ListOfShape& GEOMAlgo_ShapeSolid::Shapes(const TopAbs_State aState) const { - TopTools_ListIteratorOfListOfShape aIt; - // - TopTools_ListOfShape* pLS=(TopTools_ListOfShape*)&myLS; - // - pLS->Clear(); + const TopTools_ListOfShape *pL; // switch (aState) { - case GEOMAlgo_ST_IN: { - aIt.Initialize(myLSIN); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - } + case TopAbs_IN: + pL=&myLSIN; break; - // - case GEOMAlgo_ST_OUT: { - aIt.Initialize(myLSOUT); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - } + case TopAbs_OUT: + pL=&myLSOUT; break; - // - case GEOMAlgo_ST_ON: { - aIt.Initialize(myLSON); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - } - break; - // - case GEOMAlgo_ST_ONIN: { - aIt.Initialize(myLSON); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - aIt.Initialize(myLSIN); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - } - break; - // - case GEOMAlgo_ST_ONOUT: { - aIt.Initialize(myLSON); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - aIt.Initialize(myLSOUT); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aS=aIt.Value(); - pLS->Append(aS); - } - } - break; - // - case GEOMAlgo_ST_UNKNOWN: - case GEOMAlgo_ST_INOUT: + case TopAbs_ON: + pL=&myLSON; + break; default: - break; + pL=&myLSON; + break; } - return myLS; + return *pL; } - diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx index 050c7b552..6142c1b72 100644 --- a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx @@ -34,8 +34,8 @@ #ifndef _GEOMAlgo_Algo_HeaderFile #include #endif -#ifndef _GEOMAlgo_State_HeaderFile -#include +#ifndef _TopAbs_State_HeaderFile +#include #endif class BOPTools_DSFiller; class TopTools_ListOfShape; @@ -68,7 +68,7 @@ public: // Standard_EXPORT void SetFiller(const BOPTools_DSFiller& aDSF) ; Standard_EXPORT virtual ~GEOMAlgo_ShapeSolid(); -Standard_EXPORT const TopTools_ListOfShape& Shapes(const GEOMAlgo_State aState) const; +Standard_EXPORT const TopTools_ListOfShape& Shapes(const TopAbs_State aState) const; @@ -88,7 +88,6 @@ Standard_EXPORT virtual void Prepare() = 0; TopTools_ListOfShape myLSIN; TopTools_ListOfShape myLSOUT; TopTools_ListOfShape myLSON; -TopTools_ListOfShape myLS; Standard_Integer myRank; BOPTools_PDSFiller myDSFiller; diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx index cd53db7fe..e7da2ac05 100644 --- a/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx @@ -10,24 +10,25 @@ #include #include +#include +#include #include #include -#include #include #include #include +#include +#include #include #include -#include - #include #include - +#include #include #include @@ -46,28 +47,10 @@ #include #include #include -// -#include -#include -#include -#include -#include -#include -#include + #include #include #include -#include -#include -#include -#include -#include -#include -#include - -static - Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2); //======================================================================= //function : GEOMAlgo_ShellSolid @@ -345,10 +328,10 @@ void GEOMAlgo_ShellSolid::DetectSDFaces() Standard_Boolean bIsValidIn2D, bNegativeFlag; bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); if (bIsValidIn2D) { - if(CheckSameDomainFaceInside(aFaceResult, aF2)) { - iZone=1; - break; - } + //if(CheckSameDomainFaceInside(aFaceResult, aF2)) { + iZone=1; + break; + //} } // } @@ -365,52 +348,3 @@ void GEOMAlgo_ShellSolid::DetectSDFaces() aFF.SetSenseFlag (iSenseFlag); }// end of for (i=1; i<=aNb; i++) } -//======================================================================= -//function : CheckSameDomainFaceInside -//purpose : -//======================================================================= -Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, - const TopoDS_Face& theFace2) -{ - Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.; - BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax); - IntTools_Context aContext; - Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1); - Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1); - - TopExp_Explorer anExpE(theFace1, TopAbs_EDGE); - - for(; anExpE.More(); anExpE.Next()) { - const TopoDS_Edge& anEdge = TopoDS::Edge(anExpE.Current()); - Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge); - aTolerance = (aTolerance < anEdgeTol) ? anEdgeTol : aTolerance; - } - aTolerance += BRep_Tool::Tolerance(theFace2); - - Standard_Integer nbpoints = 5; - Standard_Real adeltau = (umax - umin) / (nbpoints + 1); - Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1); - Standard_Real U = umin + adeltau; - GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2); - - for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) { - Standard_Real V = vmin + adeltav; - - for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) { - gp_Pnt2d aPoint(U,V); - - if(aContext.IsPointInFace(theFace1, aPoint)) { - gp_Pnt aP3d = aSurface->Value(U, V); - aProjector.Perform(aP3d); - - if(aProjector.IsDone()) { - - if(aProjector.LowerDistance() > aTolerance) - return Standard_False; - } - } - } - } - - return Standard_True; -} diff --git a/src/GEOMAlgo/GEOMAlgo_SolidSolid.cdl b/src/GEOMAlgo/GEOMAlgo_SolidSolid.cdl new file mode 100644 index 000000000..3634282e8 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SolidSolid.cdl @@ -0,0 +1,39 @@ +-- File: GEOMAlgo_SolidSolid.cdl +-- Created: Wed Jan 26 12:05:14 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class SolidSolid from GEOMAlgo + inherits ShellSolid from GEOMAlgo + + ---Purpose: + +uses + Shape from TopoDS + +--raises + +is + Create + returns SolidSolid from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_SolidSolid();" + + Perform (me:out) + is redefined; + + BuildResult (me:out) + is redefined protected; + + SetShape2 (me:out; + aS: Shape from TopoDS); + + Shape2 (me) + returns Shape from TopoDS; + ---C++: return const & + +fields + myS2: Shape from TopoDS is protected; + +end SolidSolid; diff --git a/src/GEOMAlgo/GEOMAlgo_SolidSolid.cxx b/src/GEOMAlgo/GEOMAlgo_SolidSolid.cxx new file mode 100644 index 000000000..c4596bdb0 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SolidSolid.cxx @@ -0,0 +1,182 @@ +// File: GEOMAlgo_SolidSolid.cxx +// Created: Wed Jan 26 12:06:26 2005 +// Author: Peter KURNEV +// + + +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +//======================================================================= +//function : GEOMAlgo_SolidSolid +//purpose : +//======================================================================= +GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid() +: + GEOMAlgo_ShellSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid() +{ +} +//======================================================================= +// function: SetShape2 +// purpose: +//======================================================================= +void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2) +{ + myS2=aS2; +} +//======================================================================= +// function: Shape2 +// purpose: +//======================================================================= +const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const +{ + return myS2; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_SolidSolid::Perform() +{ + myErrorStatus=0; + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + // + myRank=2; + BuildResult(); + } + catch (Standard_Failure) { + myErrorStatus=12; + } +} +//================================================================================= +// function: BuildResult +// purpose: +//================================================================================= +void GEOMAlgo_SolidSolid::BuildResult() +{ + myErrorStatus=0; + // + Standard_Integer i, j, aNbF, aNbS; + Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR; + TopAbs_State aState; + TopTools_ListIteratorOfListOfShape aIt; + TopTools_IndexedMapOfShape aMF, aMS; + GEOMAlgo_IndexedDataMapOfShapeState aMFS; + // + // 1. classify the faces + GEOMAlgo_ShellSolid::BuildResult(); + // + // 2. fill Shape-State map + aIt.Initialize(myLSIN); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_IN); + } + aIt.Initialize(myLSOUT); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_OUT); + } + aIt.Initialize(myLSON); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_ON); + } + myLSIN.Clear(); + myLSON.Clear(); + myLSOUT.Clear(); + // + // 3. fill states for solids + TopExp::MapShapes(myS2, TopAbs_SOLID, aMS); + // + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSolid=aMS(i); + // + aMF.Clear(); + TopExp::MapShapes(aSolid, TopAbs_FACE, aMF); + // + aNbFIN=0; + aNbFOUT=0; + aNbFON=0; + aNbFINTR=0; + // + aNbF=aMF.Extent(); + for(j=1; j +#endif +#ifndef _GEOMAlgo_ShellSolid_HeaderFile +#include +#endif +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_SolidSolid : public GEOMAlgo_ShellSolid { + +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 GEOMAlgo_SolidSolid(); +Standard_EXPORT virtual ~GEOMAlgo_SolidSolid(); +Standard_EXPORT virtual void Perform() ; +Standard_EXPORT void SetShape2(const TopoDS_Shape& aS) ; +Standard_EXPORT const TopoDS_Shape& Shape2() const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT virtual void BuildResult() ; + + + // Fields PROTECTED + // +TopoDS_Shape myS2; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_SolidSolid.ixx b/src/GEOMAlgo/GEOMAlgo_SolidSolid.ixx new file mode 100644 index 000000000..9db5bd64f --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SolidSolid.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/GEOMAlgo_SolidSolid.jxx b/src/GEOMAlgo/GEOMAlgo_SolidSolid.jxx new file mode 100644 index 000000000..abe70c5ce --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SolidSolid.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_SolidSolid_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cdl b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cdl new file mode 100644 index 000000000..f5ffe9e42 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cdl @@ -0,0 +1,61 @@ +-- File: GEOMAlgo_SurfaceTools.cdl +-- Created: Thu Jan 27 11:03:49 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class SurfaceTools from GEOMAlgo + + ---Purpose: + +uses + Pnt from gp, + Pln from gp, + Cylinder from gp, + Sphere from gp, + Surface from Geom, + State from TopAbs, + State from GEOMAlgo + +--raises + +is + IsAnalytic(myclass; + aS:Surface from Geom) + returns Boolean from Standard; + + IsConformState(myclass; + aST1:State from TopAbs; + aST2:State from GEOMAlgo) + returns Boolean from Standard; + + GetState(myclass; + aP:Pnt from gp; + aS:Surface from Geom; + aTol:Real from Standard; + aSt:out State from TopAbs) + returns Integer from Standard; + + Distance(myclass; + aP:Pnt from gp; + aPln:Pln from gp) + returns Real from Standard; + + Distance(myclass; + aP:Pnt from gp; + aCyl:Cylinder from gp) + returns Real from Standard; + + Distance(myclass; + aP:Pnt from gp; + aSph:Sphere from gp) + returns Real from Standard; + + ReverseState(myclass; + aSt: State from TopAbs) + returns State from TopAbs; + +--fields + +end SurfaceTools; diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx new file mode 100644 index 000000000..b07749692 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx @@ -0,0 +1,204 @@ +// File: GEOMAlgo_SurfaceTools.cxx +// Created: Thu Jan 27 11:05:16 2005 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetState +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP, + const Handle(Geom_Surface)& aSurf, + const Standard_Real aTol, + TopAbs_State& aState) +{ + Standard_Integer iErr; + Standard_Real aDp, aR; + GeomAbs_SurfaceType aType; + GeomAdaptor_Surface aGAS; + gp_Sphere aSph; + gp_Cylinder aCyl; + gp_Pln aPln; + // + iErr=0; + aState=TopAbs_UNKNOWN; + aGAS.Load(aSurf); + // + aType=aGAS.GetType(); + switch (aType) { + case GeomAbs_Plane: + aPln=aGAS.Plane(); + aR=0.; + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aPln); + break; + + case GeomAbs_Cylinder: + aCyl=aGAS.Cylinder(); + aR=aCyl.Radius(); + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aCyl); + break; + + case GeomAbs_Sphere: + aSph=aGAS.Sphere(); + aR=aSph.Radius(); + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aSph); + break; + + default: + iErr=1; // unprocessed surface type + break; + } + // + if (!iErr) { + aState=TopAbs_ON; + if (aDp>aR+aTol) { + aState=TopAbs_OUT; + } + else if (aDp +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopAbs_State_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_State_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +class Geom_Surface; +class gp_Pnt; +class gp_Pln; +class gp_Cylinder; +class gp_Sphere; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_SurfaceTools { + +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 Standard_Boolean IsAnalytic(const Handle(Geom_Surface)& aS) ; +Standard_EXPORT static Standard_Boolean IsConformState(const TopAbs_State aST1,const GEOMAlgo_State aST2) ; +Standard_EXPORT static Standard_Integer GetState(const gp_Pnt& aP,const Handle(Geom_Surface)& aS,const Standard_Real aTol,TopAbs_State& aSt) ; +Standard_EXPORT static Standard_Real Distance(const gp_Pnt& aP,const gp_Pln& aPln) ; +Standard_EXPORT static Standard_Real Distance(const gp_Pnt& aP,const gp_Cylinder& aCyl) ; +Standard_EXPORT static Standard_Real Distance(const gp_Pnt& aP,const gp_Sphere& aSph) ; +Standard_EXPORT static TopAbs_State ReverseState(const TopAbs_State aSt) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.ixx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.ixx new file mode 100644 index 000000000..5a0ce4e92 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.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/GEOMAlgo_SurfaceTools.jxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.jxx new file mode 100644 index 000000000..061597445 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.jxx @@ -0,0 +1,18 @@ +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _gp_Pln_HeaderFile +#include +#endif +#ifndef _gp_Cylinder_HeaderFile +#include +#endif +#ifndef _gp_Sphere_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_SurfaceTools_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.cdl b/src/GEOMAlgo/GEOMAlgo_Tools.cdl index 54b4c0327..7b50b0c39 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.cdl +++ b/src/GEOMAlgo/GEOMAlgo_Tools.cdl @@ -11,9 +11,10 @@ class Tools from GEOMAlgo uses Pnt from gp, - Surface from Geom, - Edge from TopoDS, - Face from TopoDS, + Surface from Geom, + ShapeEnum from TopAbs, + Edge from TopoDS, + Face from TopoDS, Shape from TopoDS, ListOfShape from TopTools, IndexedDataMapOfShapeListOfShape from TopTools, @@ -23,6 +24,10 @@ uses --raises is + IsCompositeShape(myclass; + aS :Shape from TopoDS) + returns Boolean from Standard; + RefineSDShapes(myclass; aMSD:out IndexedDataMapOfPassKeyListOfShape from GEOMAlgo; aTol:Real from Standard; @@ -83,6 +88,7 @@ is IsUPeriodic(myclass; aS:Surface from Geom) returns Boolean from Standard; + --fields end Tools; diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.cxx b/src/GEOMAlgo/GEOMAlgo_Tools.cxx index 97bdbb03e..e9f4df621 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,55 @@ #include #include -// + +static + void GetCount(const TopoDS_Shape& aS, + Standard_Integer& iCnt); + +//======================================================================= +//function : IsCompositeShape +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Tools::IsCompositeShape(const TopoDS_Shape& aS) +{ + Standard_Boolean bRet; + Standard_Integer iCnt; + TopoDS_Iterator aIt; + // + iCnt=0; + GetCount(aS, iCnt); + bRet=(iCnt>1); + // + return bRet; +} + +//======================================================================= +//function : GetCount +//purpose : +//======================================================================= +void GetCount(const TopoDS_Shape& aS, + Standard_Integer& iCnt) +{ + TopoDS_Iterator aIt; + TopAbs_ShapeEnum aTS; + // + aTS=aS.ShapeType(); + // + if (aTS==TopAbs_SHAPE) { + return; + } + if (aTS!=TopAbs_COMPOUND) { + ++iCnt; + return; + } + // + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + GetCount(aSx, iCnt); + } +} + //======================================================================= //function : RefineSDShapes //purpose : diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.hxx b/src/GEOMAlgo/GEOMAlgo_Tools.hxx index 80fd51788..947c0c8bd 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.hxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools.hxx @@ -22,23 +22,23 @@ #ifndef _GEOMAlgo_Tools_HeaderFile #define _GEOMAlgo_Tools_HeaderFile +#ifndef _Standard_Boolean_HeaderFile +#include +#endif #ifndef _Standard_Integer_HeaderFile #include #endif #ifndef _Standard_Real_HeaderFile #include #endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif #ifndef _Handle_Geom_Surface_HeaderFile #include #endif +class TopoDS_Shape; class GEOMAlgo_IndexedDataMapOfPassKeyListOfShape; class IntTools_Context; class TopTools_ListOfShape; class TopTools_IndexedDataMapOfShapeListOfShape; -class TopoDS_Shape; class gp_Pnt; class TopoDS_Edge; class TopoDS_Face; @@ -70,6 +70,7 @@ public: } // Methods PUBLIC // +Standard_EXPORT static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ; Standard_EXPORT static Standard_Integer RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyListOfShape& aMSD,const Standard_Real aTol,IntTools_Context& aCtx) ; Standard_EXPORT static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,const Standard_Real aTol,TopTools_IndexedDataMapOfShapeListOfShape& aMEE,IntTools_Context& aCtx) ; Standard_EXPORT static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,const TopTools_ListOfShape& aLE,const Standard_Real aTol,TopTools_ListOfShape& aLESD,IntTools_Context& aCtx) ; diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.jxx b/src/GEOMAlgo/GEOMAlgo_Tools.jxx index 7c60f19bd..e22f3c3ea 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.jxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools.jxx @@ -1,3 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif #ifndef _GEOMAlgo_IndexedDataMapOfPassKeyListOfShape_HeaderFile #include #endif @@ -10,9 +13,6 @@ #ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile #include #endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif #ifndef _gp_Pnt_HeaderFile #include #endif diff --git a/src/GEOMAlgo/Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx b/src/GEOMAlgo/Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx new file mode 100644 index 000000000..2ee27d5e9 --- /dev/null +++ b/src/GEOMAlgo/Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.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_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile +#define _Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState); + +class Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) : public Handle(TCollection_MapNode) { + 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(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)():Handle(TCollection_MapNode)() {} + Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)(const Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)(const GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)& operator=(const Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)& operator=(const GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState* operator->() + { + return (GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState *)ControlAccess(); + } + + GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState* operator->() const + { + return (GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState)(); + + Standard_EXPORT static const Handle(GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Makefile.in b/src/GEOMAlgo/Makefile.in index ee8b2b62e..0af9311f1 100644 --- a/src/GEOMAlgo/Makefile.in +++ b/src/GEOMAlgo/Makefile.in @@ -64,7 +64,11 @@ LIB_SRC = \ GEOMAlgo_ShapeSolid.cxx \ GEOMAlgo_ShellSolid.cxx \ GEOMAlgo_VertexSolid.cxx \ - GEOMAlgo_WireSolid.cxx + GEOMAlgo_WireSolid.cxx \ + GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState_0.cxx \ + GEOMAlgo_IndexedDataMapOfShapeState_0.cxx \ + GEOMAlgo_SolidSolid.cxx \ + GEOMAlgo_SurfaceTools.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -84,7 +88,9 @@ EXPORT_HEADERS = \ BlockFix_CheckTool.hxx \ Handle_BlockFix_BlockFixAPI.hxx \ GEOMAlgo_State.hxx \ - GEOMAlgo_FinderShapeOn.hxx + GEOMAlgo_FinderShapeOn.hxx \ + GEOMAlgo_IndexedDataMapOfShapeState.hxx \ + Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfShapeState.hxx # idl files EXPORT_IDLS=