From: gka Date: Mon, 24 Apr 2006 07:35:06 +0000 (+0000) Subject: Add building thrusections X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e2e98ab877ea80e5936a5bc8f87d07b309d4ae6;p=modules%2Fgeom.git Add building thrusections --- diff --git a/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.cxx b/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.cxx new file mode 100644 index 000000000..90ae81513 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.cxx @@ -0,0 +1,181 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,F +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ThruSectionsDriver::GetID() +{ + static Standard_GUID aThruSectionsDriver("FF1BB971-E99C-4f89-B989-5B48E061049B"); + return aThruSectionsDriver; +} + + +//======================================================================= +//function : GEOMImpl_ThruSectionsDriver +//purpose : +//======================================================================= +GEOMImpl_ThruSectionsDriver::GEOMImpl_ThruSectionsDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ThruSectionsDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IThruSections aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + Standard_Boolean isSolid = (aCI.GetSolidMode() == 1); + Handle(TColStd_HSequenceOfTransient) aSeqSections = aCI.GetSections(); + + if( aSeqSections.IsNull()) + return 0; + + Standard_Integer aNbSections = aSeqSections->Length(); + Standard_Real aPreci = Max(aCI.GetPrecision(),Precision::Confusion()); + if(!aNbSections ) + return 0; + + BRepOffsetAPI_ThruSections aBuilder(isSolid,aType == THRUSECTIONS_RULED,aPreci); + + //added sections for building surface + Standard_Integer i =1; + Standard_Integer nbAdded =0; + for( ; i <= aNbSections; i++,nbAdded++) + { + Handle(Standard_Transient) anItem = aSeqSections->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Function) aSection = Handle(GEOM_Function)::DownCast(anItem); + if(aSection.IsNull()) + continue; + + TopoDS_Shape aShapeSection = aSection->GetValue(); + if(aShapeSection == TopAbs_WIRE) + { + TopoDS_Wire aWire = TopoDS::Wire(aShapeSection); + aBuilder.AddWire(aSectWire); + } + else if(aShapeSection == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aShapePath); + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge); + aBuilder.AddWire(aWire); + } + else if(aShapeSection == TopAbs_VERTEX) { + TopoDS_Vertex aVert = TopoDS::Vertex(aShapePath); + aBuilder.AddVertex(aVert); + } + else + nbAdded--; + } + if(!nbAdded) + Standard_TypeMismatch::Raise("ThruSections aborted : invalid types of sections"); + + //make surface by sections + aBuilder.Build(); + TopoDS_Shape aShape = aBuilder.Shape(); + + if (aShape.IsNull()) return 0; + + BRepCheck_Analyzer ana (aShape, Standard_False); + if (!ana.IsValid()) { + Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ThruSectionsDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ThruSectionsDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ThruSectionsDriver", + sizeof(GEOMImpl_ThruSectionsDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ThruSectionsDriver) Handle(GEOMImpl_ThruSectionsDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ThruSectionsDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ThruSectionsDriver))) { + _anOtherObject = Handle(GEOMImpl_ThruSectionsDriver)((Handle(GEOMImpl_ThruSectionsDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.hxx b/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.hxx new file mode 100644 index 000000000..4d2027a4b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ThruSectionsDriver.hxx @@ -0,0 +1,162 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// +// File : GEOMImpl_ThruSectionsDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ThruSectionsDriver_HeaderFile +#define _GEOMImpl_ThruSectionsDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ThruSectionsDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ThruSectionsDriver); + +class Handle(GEOMImpl_ThruSectionsDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ThruSectionsDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ThruSectionsDriver)(const Handle(GEOMImpl_ThruSectionsDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ThruSectionsDriver)(const GEOMImpl_ThruSectionsDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ThruSectionsDriver)& operator=(const Handle(GEOMImpl_ThruSectionsDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ThruSectionsDriver)& operator=(const GEOMImpl_ThruSectionsDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ThruSectionsDriver* operator->() + { + return (GEOMImpl_ThruSectionsDriver *)ControlAccess(); + } + + GEOMImpl_ThruSectionsDriver* operator->() const + { + return (GEOMImpl_ThruSectionsDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ThruSectionsDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ThruSectionsDriver) DownCast(const Handle(Standard_Transient)& AnObject); + +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ThruSectionsDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ThruSectionsDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ThruSectionsDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ThruSectionsDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ThruSectionsDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ThruSectionsDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif