New Functions from PAL development

This commit is contained in:
vsv 2006-05-26 06:29:59 +00:00
parent c4e92d3d86
commit e924cc5684
4 changed files with 497 additions and 0 deletions

View File

@ -0,0 +1,80 @@
// 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/
//
//NOTE: This is an intreface to a function for the Pipe creation.
#ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_
#define _GEOMImpl_IPIPEDIFFSECT_HXX_
#include "GEOM_Function.hxx"
#ifndef _GEOMImpl_IPIPE_HXX_
#include "GEOMImpl_IPipe.hxx"
#endif
#define PIPEDS_LIST_BASES 1
#define PIPEDS_LIST_LOCATIONS 3
//#define PIPEDS_ARG_PATH 2
#define PIPEDS_ARG_WITHCONTACT 4
#define PIPEDS_ARG_WITHCORRECT 5
class GEOMImpl_IPipeDiffSect : public GEOMImpl_IPipe
{
public:
GEOMImpl_IPipeDiffSect(const Handle(GEOM_Function)& theFunction):GEOMImpl_IPipe(theFunction) {}
void SetBases (const Handle(TColStd_HSequenceOfTransient)& theBases)
{ _func->SetReferenceList(PIPEDS_LIST_BASES,theBases); }
Handle(TColStd_HSequenceOfTransient) GetBases ()
{
Handle(TColStd_HSequenceOfTransient) aBases = _func->GetReferenceList(PIPEDS_LIST_BASES);
return aBases;
}
void SetLocations (const Handle(TColStd_HSequenceOfTransient)& theLocations)
{ _func->SetReferenceList(PIPEDS_LIST_LOCATIONS,theLocations); }
Handle(TColStd_HSequenceOfTransient) GetLocations ()
{
Handle(TColStd_HSequenceOfTransient) aLocs = _func->GetReferenceList(PIPEDS_LIST_LOCATIONS);
return aLocs;
}
//void SetPath (const Handle(GEOM_Function)& thePath) { _func->SetReference(PIPEDS_ARG_PATH, thePath); }
//Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPEDS_ARG_PATH); }
void SetWithContactMode(int theWithContact)
{ _func->SetInteger(PIPEDS_ARG_WITHCONTACT,theWithContact); }
int GetWithContactMode()
{ return _func->GetInteger(PIPEDS_ARG_WITHCONTACT); }
void SetWithCorrectionMode(int theWithCorrection)
{ _func->SetInteger(PIPEDS_ARG_WITHCORRECT,theWithCorrection); }
int GetWithCorrectionMode()
{ return _func->GetInteger(PIPEDS_ARG_WITHCORRECT); }
};
#endif

View File

@ -0,0 +1,59 @@
// 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/
//
//NOTE: This is an intreface to a function for the Pipe creation.
#include "GEOM_Function.hxx"
#include <TColStd_HSequenceOfTransient.hxx>
#define THRUSECTIONS_LIST_SECTIONS 1
#define THRUSECTIONS_SOLIDMODE 2
#define THRUSECTIONS_PRECISION 3
class GEOMImpl_IThruSections
{
public:
GEOMImpl_IThruSections(const Handle(GEOM_Function)& theFunction): _func(theFunction) {}
void SetSections (const Handle(TColStd_HSequenceOfTransient)& theSections)
{ _func->SetReferenceList(THRUSECTIONS_LIST_SECTIONS,theSections); }
Handle(TColStd_HSequenceOfTransient) GetSections ()
{ return _func->GetReferenceList(THRUSECTIONS_LIST_SECTIONS); }
void SetSolidMode(int theSolidMode)
{ _func->SetInteger(THRUSECTIONS_SOLIDMODE,theSolidMode); }
int GetSolidMode()
{ return _func->GetInteger(THRUSECTIONS_SOLIDMODE); }
void SetPrecision(double thePreci)
{ _func->SetReal(THRUSECTIONS_PRECISION,thePreci); }
double GetPrecision()
{ return _func->GetReal(THRUSECTIONS_PRECISION);}
private:
Handle(GEOM_Function) _func;
};

View File

@ -0,0 +1,196 @@
// 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 <Standard_Stream.hxx>
#include <GEOMImpl_ThruSectionsDriver.hxx>
#include <GEOMImpl_IThruSections.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Precision.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepOffsetAPI_ThruSections.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Standard_ConstructionError.hxx>
#include <ShapeFix_Shape.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <Precision.hxx>
//=======================================================================
//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);
aBuilder.CheckCompatibility(Standard_False);
//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();
TopAbs_ShapeEnum aTypeSect = aShapeSection.ShapeType();
if(aTypeSect == TopAbs_WIRE)
aBuilder.AddWire(TopoDS::Wire(aShapeSection));
else if(aTypeSect == TopAbs_EDGE) {
TopoDS_Edge anEdge = TopoDS::Edge(aShapeSection);
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge);
aBuilder.AddWire(aWire);
}
else if(aTypeSect == TopAbs_VERTEX) {
TopoDS_Vertex aVert = TopoDS::Vertex(aShapeSection);
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()) {
//algoritm thru section creats on the arcs invalid shapes gka
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
aSfs->SetPrecision(Precision::Confusion());
aSfs->Perform();
aShape = aSfs->Shape();
//ana.Init(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 ;
}

View File

@ -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 <TColStd_SequenceOfExtendedString.hxx>
#endif
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
#endif
#ifndef _Handle_TFunction_Driver_HeaderFile
#include <Handle_TFunction_Driver.hxx>
#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 <TFunction_Driver.hxx>
#endif
#ifndef _TFunction_Logbook_HeaderFile
#include <TFunction_Logbook.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#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