From: vsv Date: Thu, 25 May 2006 09:01:57 +0000 (+0000) Subject: New functions from PAL development X-Git-Tag: V3_2_0rc~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d72ae1930266d98876acc93ddd1e7dbce83e52d;p=modules%2Fgeom.git New functions from PAL development --- diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 4cf10fc97..e9e682735 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -52,6 +52,7 @@ #include "GEOM_AISShape.hxx" #include "GEOM_AssemblyBuilder.h" #include "GEOM_InteractiveObject.hxx" +#include "GEOM_Displayer.h" #include "SALOME_Event.hxx" @@ -64,11 +65,14 @@ #include #include #include +#include // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) +#include + using namespace std; @@ -174,7 +178,8 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry) "GEOM", const_cast( obj->GetID().c_str())); - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) { + GEOM_Displayer(ActiveStudy).Display(anIO, true); + /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) { SVTK_View* aView = aViewWindow->getView(); int aMode = aView->GetDisplayMode(); @@ -196,7 +201,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry) aSh->setIO(anIO); ic->Display(aSh); ic->AddOrRemoveCurrentObject(aSh,true); - } + }*/ // update object browser SalomeApp_Application* app = NULL; //dynamic_cast(app); if (app) { @@ -464,3 +469,136 @@ bool GEOM_Swig::initGeomGen() { return ProcessEvent(new TInitGeomGenEvent()); } + + + +void GEOM_Swig::eraseGO (const char* Entry, bool allWindows) +{ + class TEvent: public SALOME_Event + { + std::string myEntry; + bool myFromAllWindows; + public: + TEvent(const char* theEntry, bool fromAllWindows): + myEntry(theEntry), myFromAllWindows(fromAllWindows) + {} + virtual void Execute() + { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if (!app) return; + SalomeApp_Study* ActiveStudy = dynamic_cast(app->activeStudy()); + if (!ActiveStudy) return; + + Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + GEOM_Displayer(ActiveStudy).Erase(aIO, true); + /* if (myFromAllWindows) { + QPtrList aWindows = app->desktop()->windows(); + SUIT_ViewWindow* aWin = 0; + for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) { + EraseObject(aWin, aIO); + } + } else { + SUIT_ViewWindow* aWin = app->desktop()->activeWindow(); + if (aWin) + EraseObject(aWin, aIO); + }*/ + } + + /* private: + void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO) + { + if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){ + OCCViewer_ViewWindow* vw = dynamic_cast( theWin ); + if ( vw ) { + OCCViewer_ViewManager* vm = dynamic_cast( vw->getViewManager() ); + if ( vm ) { + SOCC_Viewer* aViewer = dynamic_cast(vm->getOCCViewer()); + if (aViewer) { + SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str()); + if (aPrs) { + SALOME_OCCPrs* aOccPrs = dynamic_cast(aPrs); + if (aOccPrs) { + aViewer->Erase(aOccPrs); + aViewer->Repaint(); + } + } + } + } + } + } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){ + SVTK_ViewWindow* aViewWindow = dynamic_cast( theWin ); + if (aViewWindow) { + aViewWindow->Erase(theIO); + } + } + }*/ + + }; + ProcessVoidEvent(new TEvent(Entry, allWindows)); +} + + + +void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect) +{ + class TEvent: public SALOME_Event { + std::string myEntry; + float myParam; + public: + TEvent(const char* theEntryArg, float theParam): + myEntry(theEntryArg), myParam(theParam) + {} + virtual void Execute() { + SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); + if (!anApp) return; + + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { + vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors(); + aActors->InitTraversal(); + while (vtkActor* aAct = aActors->GetNextActor()) { + if (GEOM_Actor* aGeomActor = dynamic_cast(aAct)) { + if (aGeomActor->hasIO()) { + Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO(); + if (aNextIO->isSame(anIO)) { + aGeomActor->setDeflection(myParam); + aViewWindow->Repaint(); + return; + } + } + } + } + // aView->SetTransparency(anIO, myParam); + //aView->Repaint(); + } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { + Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext(); + AIS_ListOfInteractive aAISList; + aContext->DisplayedObjects(aAISList); + AIS_ListIteratorOfListOfInteractive it(aAISList); + for (; it.More(); it.Next()) { + Handle(SALOME_InteractiveObject) aObj = + Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner()); + if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value()); + if (!aShape.IsNull()) { + Handle(AIS_Drawer) aDrawer = aShape->Attributes(); + if (aDrawer.IsNull()) + aDrawer = new AIS_Drawer(); + aDrawer->SetDeviationCoefficient(myParam); + aShape->SetAttributes(aDrawer); + aContext->Redisplay(aShape, true, true); + aContext->UpdateCurrentViewer(); + return; + } + } + } + } + } + }; + + ProcessVoidEvent(new TEvent (theEntry, theDeflect)); +} + diff --git a/src/GEOMGUI/GeometryGUI_Swig.hxx b/src/GEOMGUI/GeometryGUI_Swig.hxx index e519ecad0..fa835c93c 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.hxx +++ b/src/GEOMGUI/GeometryGUI_Swig.hxx @@ -50,10 +50,12 @@ public: ~GEOM_Swig(); void createAndDisplayGO(const char* Entry); + void eraseGO(const char* Entry, bool allWindows); void createAndDisplayFitAllGO(const char* Entry); void setDisplayMode(const char* Entry, int mode); void setColor(const char* Entry, int red, int green, int blue); void setTransparency(const char* Entry, float transp); + void setDeflection(const char* Entry, float deflect); int getIndexTopology(const char *SubEntry, const char *Entry); const char* getShapeTypeString(const char *Entry); diff --git a/src/GEOMGUI/GeometryGUI_Swig.i b/src/GEOMGUI/GeometryGUI_Swig.i index 460e666c4..69f28e725 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.i +++ b/src/GEOMGUI/GeometryGUI_Swig.i @@ -37,6 +37,7 @@ class GEOM_Swig ~GEOM_Swig(); void createAndDisplayGO(const char* Entry); + void eraseGO(const char* Entry, bool allWindows); void createAndDisplayFitAllGO(const char* Entry); int getIndexTopology(const char *SubEntry, const char *Entry); const char* getShapeTypeString(const char *Entry); @@ -44,6 +45,7 @@ class GEOM_Swig void setDisplayMode(const char* Entry, int mode); void setColor(const char* Entry, int red, int green, int blue); void setTransparency(const char* Entry, float transp); + void setDeflection(const char* Entry, float deflect); const char* getShapeTypeIcon(const char *Ior); bool initGeomGen(); diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index 74ebd75c3..28d385de5 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,7 @@ GEOMImpl_Gen::GEOMImpl_Gen() TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeDriver::GetID(), new GEOMImpl_PipeDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ThruSectionsDriver::GetID(), new GEOMImpl_ThruSectionsDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RevolutionDriver::GetID(), new GEOMImpl_RevolutionDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SphereDriver::GetID(), new GEOMImpl_SphereDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TorusDriver::GetID(), new GEOMImpl_TorusDriver()); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 266e4de26..d61feca83 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,8 @@ #include #include #include +#include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -933,3 +936,242 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling SetErrorCode(OK); return aFilling; } + +//============================================================================= +/*! + * MakeThruSections + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections( + const Handle(TColStd_HSequenceOfTransient)& theSeqSections, + bool theModeSolid, + double thePreci, + bool theRuled) +{ + Handle(GEOM_Object) anObj; + SetErrorCode(KO); + if(theSeqSections.IsNull()) + return anObj; + + Standard_Integer nbObj = theSeqSections->Length(); + if (!nbObj) + return anObj; + + //Add a new ThruSections object + Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS); + + + //Add a new ThruSections function + + int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED); + Handle(GEOM_Function) aFunction = + aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc); + if (aFunction.IsNull()) return anObj; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL; + + GEOMImpl_IThruSections aCI (aFunction); + + Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient; + + Standard_Integer i =1; + for( ; i <= nbObj; i++) { + + Handle(Standard_Transient) anItem = theSeqSections->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem); + if(!aSectObj.IsNull()) + { + Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction(); + if(!aRefSect.IsNull()) + aSeqSections->Append(aRefSect); + } + } + + if(!aSeqSections->Length()) + return anObj; + + aCI.SetSections(aSeqSections); + aCI.SetSolidMode(theModeSolid); + aCI.SetPrecision(thePreci); + + //Compute the ThruSections value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("ThruSections driver failed"); + return anObj; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return anObj; + } + + //Make a Python command + GEOM::TPythonDump pyDump(aFunction); + pyDump << aThruSect << " = geompy.MakeThruSections(["; + + for(i =1 ; i <= nbObj; i++) { + + Handle(Standard_Transient) anItem = theSeqSections->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem); + if(!aSectObj.IsNull()) { + pyDump<< aSectObj; + if(i < nbObj) + pyDump<<", "; + } + } + + pyDump<< "],"<Length(); + + if (!nbBases) + return anObj; + + Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length()); + //Add a new Pipe object + Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE); + + //Add a new Pipe function + + Handle(GEOM_Function) aFunction = + aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS); + if (aFunction.IsNull()) return anObj; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj; + + GEOMImpl_IPipeDiffSect aCI (aFunction); + + Handle(GEOM_Function) aRefPath = thePath->GetLastFunction(); + if(aRefPath.IsNull()) + return anObj; + + Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient; + + Standard_Integer i =1; + for( ; i <= nbBases; i++) { + + Handle(Standard_Transient) anItem = theBases->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem); + if(aBase.IsNull()) + continue; + Handle(GEOM_Function) aRefBase = aBase->GetLastFunction(); + if(aRefBase.IsNull()) + continue; + if(nbLocs) + { + Handle(Standard_Transient) anItemLoc = theLocations->Value(i); + if(anItemLoc.IsNull()) + continue; + + Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc); + if(aLoc.IsNull()) + continue; + Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction(); + if(aRefLoc.IsNull()) + continue; + aSeqLocs->Append(aRefLoc); + } + aSeqBases->Append(aRefBase); + } + + if(!aSeqBases->Length()) + return anObj; + + aCI.SetBases(aSeqBases); + aCI.SetLocations(aSeqLocs); + aCI.SetPath(aRefPath); + aCI.SetWithContactMode(theWithContact); + aCI.SetWithCorrectionMode(theWithCorrections); + + //Compute the Pipe value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Pipe with defferent section driver failed"); + return anObj; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return anObj; + } + + //Make a Python command + GEOM::TPythonDump pyDump(aFunction); + pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections(["; + + for(i =1 ; i <= nbBases; i++) { + + Handle(Standard_Transient) anItem = theBases->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem); + if(!anObj.IsNull()) { + pyDump<< anObj; + if(i < nbBases) + pyDump<<", "; + } + + } + + pyDump<< "], ["; + + for(i =1 ; i <= nbLocs; i++) { + + Handle(Standard_Transient) anItem = theLocations->Value(i); + if(anItem.IsNull()) + continue; + + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem); + if(!anObj.IsNull()) { + pyDump<< anObj; + if(i < nbLocs) + pyDump<<", "; + } + } + + pyDump<< "], "< +#include class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { public: @@ -73,6 +74,17 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter); + Standard_EXPORT Handle(GEOM_Object) MakeThruSections(const Handle(TColStd_HSequenceOfTransient)& theSeqSections, + bool theModeSolid, + double thePreci, + bool theRuled); + + Standard_EXPORT Handle(GEOM_Object) MakePipeWithDifferentSections( + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations, + const Handle(GEOM_Object)& thePath, + bool theWithContact, + bool theWithCorrections); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 9a7ba439c..0ea2c9f09 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -221,6 +221,55 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve return aPoint; } +//============================================================================= +/*! + * MakeTangentOnCurve + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve + (const Handle(GEOM_Object)& theCurve, double theParameter) +{ + SetErrorCode(KO); + + if (theCurve.IsNull()) return NULL; + + //Add a new Vector object + Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR); + + //Add a new Point function for creation a point relativley another point + Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; + + GEOMImpl_IVector aVI (aFunction); + + Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction(); + if (aRefFunction.IsNull()) return NULL; + + aVI.SetCurve(aRefFunction); + aVI.SetParameter(theParameter); + + //Compute the vector value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve(" + << theCurve << ", " << theParameter << ")"; + + SetErrorCode(OK); + return aVec; +} //============================================================================= /*! @@ -641,3 +690,61 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker SetErrorCode(OK); return aMarker; } + +//============================================================================= +/*! + * MakeTangentPlaneOnFace + */ +//============================================================================= + +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace, + double theParamU, + double theParamV, + double theSize) +{ + SetErrorCode(KO); + + if (theFace.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRef = theFace->GetLastFunction(); + if (aRef.IsNull()) return NULL; + + aPI.SetFace(aRef); + aPI.SetSize(theSize); + aPI.SetParameterU(theParamU); + aPI.SetParameterV(theParamV); + + //Compute the Plane value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace(" + << theFace << ", " <GetReference(PIPE_ARG_BASE); } Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPE_ARG_PATH); } - private: + protected: Handle(GEOM_Function) _func; }; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IPlane.hxx b/src/GEOMImpl/GEOMImpl_IPlane.hxx index 5129d6a9d..d7c75d2f9 100644 --- a/src/GEOMImpl/GEOMImpl_IPlane.hxx +++ b/src/GEOMImpl/GEOMImpl_IPlane.hxx @@ -32,6 +32,10 @@ #define PLN_ARG_REF 6 +#define PLN_ARG_PARAM_U 7 + +#define PLN_ARG_PARAM_V 8 + class GEOMImpl_IPlane { public: @@ -59,6 +63,12 @@ class GEOMImpl_IPlane Handle(GEOM_Function) GetPoint1() { return _func->GetReference(PLN_ARG_PNT1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(PLN_ARG_PNT2); } Handle(GEOM_Function) GetPoint3() { return _func->GetReference(PLN_ARG_PNT3); } + + void SetParameterU(double theParamU) { _func->SetReal(PLN_ARG_PARAM_U, theParamU); } + double GetParameterU() { return _func->GetReal(PLN_ARG_PARAM_U); } + + void SetParameterV(double theParamV) { _func->SetReal(PLN_ARG_PARAM_V, theParamV); } + double GetParameterV() { return _func->GetReal(PLN_ARG_PARAM_V); } private: diff --git a/src/GEOMImpl/GEOMImpl_IVector.hxx b/src/GEOMImpl/GEOMImpl_IVector.hxx index 2214d7dfa..b83636731 100644 --- a/src/GEOMImpl/GEOMImpl_IVector.hxx +++ b/src/GEOMImpl/GEOMImpl_IVector.hxx @@ -29,6 +29,10 @@ #define VEC_ARG_PNT1 4 #define VEC_ARG_PNT2 5 +#define VEC_ARG_CURVE 6 +#define VEC_ARG_PARAM 7 + + class GEOMImpl_IVector { public: @@ -49,6 +53,14 @@ class GEOMImpl_IVector Handle(GEOM_Function) GetPoint1() { return _func->GetReference(VEC_ARG_PNT1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(VEC_ARG_PNT2); } + void SetCurve(Handle(GEOM_Function) theRef) { _func->SetReference(VEC_ARG_CURVE, theRef); } + + Handle(GEOM_Function) GetCurve() { return _func->GetReference(VEC_ARG_CURVE); } + + void SetParameter(double theParam) { _func->SetReal(VEC_ARG_PARAM, theParam); } + + double GetParameter() { return _func->GetReal(VEC_ARG_PARAM); } + private: Handle(GEOM_Function) _func; diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 7ab584415..84d023704 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -35,10 +35,18 @@ #include #include #include +#include +#include +#include #include #include #include +#include "utilities.h" +#include +#include +#include +#include //======================================================================= //function : GetID @@ -67,51 +75,195 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); - - GEOMImpl_IPipe aCI (aFunction); + GEOMImpl_IPipe* aCI= 0; Standard_Integer aType = aFunction->GetType(); + if(aType == PIPE_BASE_PATH) + aCI = new GEOMImpl_IPipe(aFunction); + else if(aType == PIPE_DIFFERENT_SECTIONS) + aCI = new GEOMImpl_IPipeDiffSect(aFunction); + else + return 0; - TopoDS_Shape aShape; + Handle(GEOM_Function) aRefPath = aCI->GetPath(); + TopoDS_Shape aShapePath = aRefPath->GetValue(); - if (aType == PIPE_BASE_PATH) { - Handle(GEOM_Function) aRefBase = aCI.GetBase(); - Handle(GEOM_Function) aRefPath = aCI.GetPath(); - TopoDS_Shape aShapeBase = aRefBase->GetValue(); - TopoDS_Shape aShapePath = aRefPath->GetValue(); - if (aShapeBase.IsNull() || aShapePath.IsNull()) { - Standard_NullObject::Raise("MakePipe aborted : null shape argument"); - } - // Get path contour - TopoDS_Wire aWire; - if (aShapePath.ShapeType() == TopAbs_WIRE) { - aWire = TopoDS::Wire(aShapePath); - } else { - if (aShapePath.ShapeType() == TopAbs_EDGE) { + if (aShapePath.IsNull()) + { + cout<<"Driver : path is null"<GetBase(); + + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + + if (aShapeBase.IsNull()) { + if(aCI) delete aCI; + Standard_NullObject::Raise("MakePipe aborted : null base argument"); } // Make pipe - aShape = BRepOffsetAPI_MakePipe(aWire, aShapeBase); - } - else { + aShape = BRepOffsetAPI_MakePipe(aWirePath, aShapeBase); } + //building pipe with different sections + else if (aType == PIPE_DIFFERENT_SECTIONS) + { + GEOMImpl_IPipeDiffSect* aCIDS = (GEOMImpl_IPipeDiffSect*)aCI; + //GEOMImpl_IPipeDiffSect* aCIDS = static_cast(aCI); + BRepOffsetAPI_MakePipeShell aBuilder(aWirePath); + Handle(TColStd_HSequenceOfTransient) aBasesObjs = aCIDS->GetBases (); + Handle(TColStd_HSequenceOfTransient) aLocObjs = aCIDS->GetLocations (); + Standard_Boolean aWithContact = (aCIDS->GetWithContactMode()); + Standard_Boolean aWithCorrect = (aCIDS->GetWithCorrectionMode()); + + Standard_Integer i =1, nbBases = aBasesObjs->Length(), + nbLocs = (aLocObjs.IsNull() ? 0 :aLocObjs->Length()); + + if(nbLocs && nbLocs != nbBases) + { + if(aCI) delete aCI; + Standard_ConstructionError::Raise("Number of sections is not equal to number of locations "); + } + TopTools_SequenceOfShape aSeqBases; + TopTools_SequenceOfShape aSeqLocs; + TopTools_SequenceOfShape aSeqFaces; + for( ; i <= nbBases; i++) + { + Handle(Standard_Transient) anItem = aBasesObjs->Value(i); + if(anItem.IsNull()) + continue; + Handle(GEOM_Function) aRefBase = Handle(GEOM_Function)::DownCast(anItem); + if(aRefBase.IsNull()) + continue; + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + if(aShapeBase.IsNull()) + continue; + TopAbs_ShapeEnum aTypeBase = aShapeBase.ShapeType(); + + //if for section was specified face with a few wires then a few + // pipes were build and make solid + if(aTypeBase == TopAbs_FACE) + { + //for case one path should be used other type function + aSeqFaces.Append(aShapeBase); + TopExp_Explorer aExpW(aShapeBase,TopAbs_WIRE); + for( ; aExpW.More(); aExpW.Next()) + { + TopoDS_Shape aWireProf = aExpW.Current(); + aSeqBases.Append(aWireProf); + } + } + else if(aTypeBase == TopAbs_WIRE || aTypeBase == TopAbs_VERTEX) + aSeqBases.Append(aShapeBase); + else if(aTypeBase == TopAbs_EDGE) + { + TopoDS_Edge anEdge = TopoDS::Edge(aShapeBase); + TopoDS_Shape aWireProf = BRepBuilderAPI_MakeWire(anEdge); + aSeqBases.Append(aWireProf); + } + if(nbLocs) + { + Handle(Standard_Transient) anItemLoc = aLocObjs->Value(i); + if(anItemLoc.IsNull()) + continue; + Handle(GEOM_Function) aRefLoc = Handle(GEOM_Function)::DownCast(anItemLoc); + TopoDS_Shape aShapeLoc = aRefLoc->GetValue(); + if(aShapeLoc.IsNull() || aShapeLoc.ShapeType() != TopAbs_VERTEX) + continue; + aSeqLocs.Append(aShapeLoc); + } + } + + nbLocs = aSeqLocs.Length(); + Standard_Integer nbShapes = aSeqBases.Length(); + Standard_Integer step = nbShapes/nbBases; + + if(nbShapes < nbBases || fmod(nbShapes,nbBases)) + { + if(aCI) delete aCI; + Standard_ConstructionError::Raise("Invalid sections were specified for building pipe"); + } + + Standard_Integer ind =0; + for( i=1; i <= nbShapes && ind < nbShapes; i++) //i+nbBases <= nbShapes + { + TopTools_SequenceOfShape usedBases; + Standard_Integer j = 1; + for( ; j <= nbBases ; j++) + { + ind = i + (j-1)*step; + + TopoDS_Shape aWireProf = aSeqBases.Value(ind); + usedBases.Append(aWireProf); + if(nbLocs) + { + TopoDS_Shape aShapeLoc = aSeqLocs.Value(j); + TopoDS_Vertex aVert = TopoDS::Vertex(aShapeLoc); + aBuilder.Add(aWireProf,aVert,aWithContact,aWithCorrect); + } + else + aBuilder.Add(aWireProf,aWithContact,aWithCorrect); + } + if(!aBuilder.IsReady()) + { + if(aCI) delete aCI; + Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid"); + } + aBuilder.Build(); + aShape = aBuilder.Shape(); + aSeqFaces.Append(aShape); + for( j = 1; j <=usedBases.Length(); j++) + aBuilder.Delete(usedBases.Value(j)); + } + + //for case if section is face + if(aSeqFaces.Length() >1) + { + BRep_Builder aB; + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + for( i = 1; i <= aSeqFaces.Length(); i++) + aB.Add(aComp,aSeqFaces.Value(i)); + aShape = aComp; + } + } if (aShape.IsNull()) return 0; BRepCheck_Analyzer ana (aShape, Standard_False); if (!ana.IsValid()) { + if(aCI) delete aCI; Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); } aFunction->SetValue(aShape); log.SetTouched(Label()); - + if(aCI) delete aCI; return 1; } diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index 8941ba280..dd09d2941 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include @@ -42,6 +44,8 @@ #include #include #include +#include +#include #include #include @@ -126,7 +130,45 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); } aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); - } else { + } + else if (aType == PLANE_TANGENT_FACE) + { + Handle(GEOM_Function) aRefFace = aPI.GetFace(); + TopoDS_Shape aShape1 = aRefFace->GetValue(); + if(aShape1.IsNull()) + Standard_TypeMismatch::Raise("Plane was not created.Basis face was not specified"); + TopoDS_Face aFace = TopoDS::Face(aShape1); + + Standard_Real aKoefU = aPI.GetParameterU(); + Standard_Real aKoefV = aPI.GetParameterV(); + Standard_Real aUmin,aUmax,aVmin,aVmax; + ShapeAnalysis::GetFaceUVBounds(aFace,aUmin,aUmax,aVmin,aVmax); + Standard_Real aDeltaU = aUmax - aUmin; + Standard_Real aDeltaV = aVmax - aVmin; + Standard_Real aParamU = aUmin + aDeltaU*aKoefU; + Standard_Real aParamV = aVmin + aDeltaV*aKoefV; + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + if(aSurf.IsNull()) + Standard_TypeMismatch::Raise("Plane was not created.Base surface is absent"); + gp_Vec aVecU,aVecV; + gp_Pnt aPLoc; + aSurf->D1(aParamU,aParamV,aPLoc,aVecU,aVecV); + BRepTopAdaptor_FClass2d clas(aFace,Precision::PConfusion()); + + TopAbs_State stOut= clas.PerformInfinitePoint(); + gp_Pnt2d aP2d(aParamU,aParamV); + TopAbs_State st= clas.Perform(aP2d); + if(st == stOut) + Standard_TypeMismatch::Raise("Plane was not created.Point lies outside the face"); + gp_Vec aNorm = aVecU^aVecV; + gp_Ax3 anAxis(aPLoc,gp_Dir(aNorm),gp_Dir(aVecU)); + gp_Pln aPlane(anAxis); + BRepBuilderAPI_MakeFace aTool(aPlane, -aSize, +aSize, -aSize, +aSize); + if(aTool.IsDone()) + aShape = aTool.Shape(); + } + + else { } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 392163c0d..b193798a2 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -79,6 +79,8 @@ #define GEOM_MARKER 39 +#define GEOM_THRUSECTIONS 40 + //GEOM_Function types #define COPY_WITH_REF 1 @@ -90,13 +92,16 @@ #define POINT_XYZ 1 #define POINT_XYZ_REF 2 #define POINT_CURVE_PAR 3 +//#define POINT_FACE_PAR 4 #define VECTOR_TWO_PNT 1 #define VECTOR_DX_DY_DZ 2 +#define VECTOR_TANGENT_CURVE_PAR 3 #define PLANE_PNT_VEC 1 #define PLANE_FACE 2 #define PLANE_THREE_PNT 3 +#define PLANE_TANGENT_FACE 4 #define LINE_TWO_PNT 1 #define LINE_PNT_DIR 2 @@ -152,6 +157,10 @@ #define REVOLUTION_BASE_AXIS_ANGLE 1 #define PIPE_BASE_PATH 1 +#define PIPE_DIFFERENT_SECTIONS 2 + +#define THRUSECTIONS_RULED 1 +#define THRUSECTIONS_SMOOTHED 2 #define BOOLEAN_COMMON 1 #define BOOLEAN_CUT 2 diff --git a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx index 531077599..cb0b81c2b 100644 --- a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx @@ -34,6 +34,8 @@ #include #include +#include +#include #include #include @@ -67,7 +69,7 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const GEOMImpl_IVector aPI (aFunction); Standard_Integer aType = aFunction->GetType(); - if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT) return 0; + if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT && aType != VECTOR_TANGENT_CURVE_PAR) return 0; TopoDS_Shape aShape; @@ -98,7 +100,32 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const Standard_ConstructionError::Raise("The end points are too close"); } aShape = BRepBuilderAPI_MakeEdge(V1, V2).Shape(); - } else { + } + else if(aType == VECTOR_TANGENT_CURVE_PAR) { + Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); + TopoDS_Shape aRefShape = aRefCurve->GetValue(); + if (aRefShape.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise + ("Tangent On Curve creation aborted : curve shape is not an edge"); + } + Standard_Real aFParam =0., aLParam =0., aParam =0.; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFParam, aLParam); + if(aCurve.IsNull()) { + Standard_TypeMismatch::Raise + ("Tangent On Curve creation aborted : curve is null"); + } + + aParam = aFParam + (aLParam - aFParam) * aPI.GetParameter(); + gp_Pnt aPoint1,aPoint2; + gp_Vec aVec; + aCurve->D1(aParam,aPoint1,aVec); + if(aVec.Magnitude() < gp::Resolution()) + Standard_TypeMismatch::Raise + ("Tangent On Curve creation aborted : invalid value of tangent"); + aPoint2.SetXYZ(aPoint1.XYZ() + aVec.XYZ()); + BRepBuilderAPI_MakeEdge aBuilder(aPoint1,aPoint2); + if(aBuilder.IsDone()) + aShape = aBuilder.Shape(); } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GUID.txt b/src/GEOMImpl/GUID.txt index 285d047d6..0c03153c7 100755 --- a/src/GEOMImpl/GUID.txt +++ b/src/GEOMImpl/GUID.txt @@ -18,6 +18,7 @@ FF1BBB16-5D14-4df2-980B-3A668264EA16 // Sphere FF1BBB17-5D14-4df2-980B-3A668264EA16 // Prism (Extrusion) FF1BBB18-5D14-4df2-980B-3A668264EA16 // Revolution FF1BBB19-5D14-4df2-980B-3A668264EA16 // Pipe +FF1BB971-E99C-4f89-B989-5B48E061049B //ThruSections FF1BBB21-5D14-4df2-980B-3A668264EA16 // Boolean FF1BBB22-5D14-4df2-980B-3A668264EA16 // Partition diff --git a/src/GEOMImpl/Makefile.in b/src/GEOMImpl/Makefile.in index 48bfdb040..9209e4e5a 100644 --- a/src/GEOMImpl/Makefile.in +++ b/src/GEOMImpl/Makefile.in @@ -59,6 +59,7 @@ LIB_SRC = GEOMImpl_IBasicOperations.cxx \ GEOMImpl_TorusDriver.cxx \ GEOMImpl_PrismDriver.cxx \ GEOMImpl_PipeDriver.cxx \ + GEOMImpl_ThruSectionsDriver.cxx \ GEOMImpl_RevolutionDriver.cxx \ GEOMImpl_ShapeDriver.cxx \ GEOMImpl_BlockDriver.cxx \ diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index ac8d8fb6b..fbb7e1bf6 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -484,3 +484,101 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_pt return GetObject(anObject); } + +//============================================================================= +/*! + * MakeThruSections + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeThruSections(const GEOM::ListOfGO& theSeqSections, + CORBA::Boolean theModeSolid, + CORBA::Double thePreci, + CORBA::Boolean theRuled) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient; + int ind, aLen; + + //Get the shapes + aLen = theSeqSections.length(); + for (ind = 0; ind < aLen; ind++) { + if (theSeqSections[ind] == NULL) continue; + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theSeqSections[ind]->GetStudyID(), theSeqSections[ind]->GetEntry()); + if (!aSh.IsNull()) + aSeqSections->Append(aSh); + } + if(!aSeqSections->Length()) + return aGEOMObject._retn(); + + // Make shell or solid + Handle(GEOM_Object) anObject = + GetOperations()->MakeThruSections(aSeqSections,theModeSolid,thePreci,theRuled); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePipeWithDifferentSections + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithDifferentSections(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations, + GEOM::GEOM_Object_ptr thePath, + CORBA::Boolean theWithContact, + CORBA::Boolean theWithCorrections) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient; + int ind=0, aNbBases =0,aNbLocs=0; + + //Get the shapes + aNbBases = theBases.length(); + aNbLocs = theLocations.length(); + + if( aNbLocs && aNbBases != aNbLocs) + return aGEOMObject._retn(); + + Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject + (thePath->GetStudyID(), thePath->GetEntry()); + if(aPath.IsNull()) + return aGEOMObject._retn(); + + for (ind = 0; ind < aNbBases; ind++) { + if (theBases[ind] == NULL) continue; + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject(theBases[ind]->GetStudyID(), + theBases[ind]->GetEntry()); + if(aBase.IsNull()) + continue; + if(aNbLocs) + { + Handle(GEOM_Object) aLoc = GetOperations()->GetEngine()->GetObject + (theLocations[ind]->GetStudyID(), theLocations[ind]->GetEntry()); + if(aLoc.IsNull()) + continue; + aSeqLocations->Append(aLoc); + } + aSeqBases->Append(aBase); + } + if(!aSeqBases->Length()) + return aGEOMObject._retn(); + + // Make pipe + Handle(GEOM_Object) anObject = + GetOperations()->MakePipeWithDifferentSections(aSeqBases,aSeqLocations ,aPath, + theWithContact,theWithCorrections); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index acee1fdfc..bd44463d4 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -94,6 +94,17 @@ class GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter); + GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections, + CORBA::Boolean theModeSolid, + CORBA::Double thePreci, + CORBA::Boolean theRuled); + + GEOM::GEOM_Object_ptr MakePipeWithDifferentSections(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations, + GEOM::GEOM_Object_ptr thePath, + CORBA::Boolean theWithContact, + CORBA::Boolean theWithCorrections); + ::GEOMImpl_I3DPrimOperations* GetOperations() { return (::GEOMImpl_I3DPrimOperations*)GetImpl(); } }; diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index b24857da1..cc5fa043a 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -136,6 +136,37 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve return GetObject(anObject); } +//============================================================================= +/*! + * MakeTangentOnCurve + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve + (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCurve == NULL) return aGEOMObject._retn(); + + //Get the reference curve + + Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject + (theCurve->GetStudyID(), theCurve->GetEntry()); + if (aRefernce.IsNull()) return aGEOMObject._retn(); + + //Create the point + + Handle(GEOM_Object) anObject = + GetOperations()->MakeTangentOnCurve(aRefernce, theParameter); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! @@ -388,3 +419,39 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker return GetObject(anObject); } + +//============================================================================= +/*! + * MakeTangentPlaneOnFace + */ +//============================================================================= + +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace + (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace == NULL) return aGEOMObject._retn(); + + //Get the reference face + + Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject + (theFace->GetStudyID(), theFace->GetEntry()); + if (aRef.IsNull()) return aGEOMObject._retn(); + + //Create the plane + + Handle(GEOM_Object) anObject = + GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index e46f50431..b4d3db0cf 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -52,6 +52,9 @@ class GEOM_IBasicOperations_i : GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakeVectorDXDYDZ (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ); @@ -81,6 +84,11 @@ class GEOM_IBasicOperations_i : CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize); + ::GEOMImpl_IBasicOperations* GetOperations() { return (::GEOMImpl_IBasicOperations*)GetImpl(); } }; diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 38455e4ce..d53601a3e 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -536,6 +536,17 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the return myBasicOp->MakePointOnCurve(theRefCurve, theParameter); } +//============================================================================= +// MakeTangentOnCurve: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theParameter) +{ + MESSAGE("GEOM_Superv_i::MakeTangentOnCurve"); + getBasicOp(); + return myBasicOp->MakeTangentOnCurve(theRefCurve, theParameter); +} + //============================================================================= // MakeVectorDXDYDZ: //============================================================================= @@ -619,6 +630,19 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarker return myBasicOp->MakeMarker(theOX, theOY, theOZ, theXDX, theXDY, theXDZ, theYDX, theYDY, theYDZ); } +//============================================================================= +// MakeTangentPlaneOnFace: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize) +{ + MESSAGE("GEOM_Superv_i::MakeTangentPlaneOnFace"); + getBasicOp(); + return myBasicOp->MakeTangentPlaneOnFace(theFace, theParameterU,theParameterV,theTrimSize); +} + //================= Primitives Construction : 3DPrimOperations ================ //============================================================================= // MakeBox: @@ -845,6 +869,32 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoolean (GEOM::GEOM_Object_ptr theShape return myBoolOp->MakeBoolean(theShape1, theShape2, theOperation); } +//============================================================================= +// MakeThruSections: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeThruSections(const GEOM::ListOfGO& theSeqSections, + CORBA::Boolean theModeSolid, + CORBA::Double thePreci, + CORBA::Boolean theRuled) +{ + MESSAGE("GEOM_Superv_i::MakeThruSections"); + get3DPrimOp(); + return my3DPrimOp->MakeThruSections(theSeqSections, theModeSolid,thePreci,theRuled); +} + +//============================================================================= +// MakePipe: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePipeWithDifferentSections(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations, + GEOM::GEOM_Object_ptr thePath, + CORBA::Boolean theWithContact, + CORBA::Boolean theWithCorrections) +{ + MESSAGE("GEOM_Superv_i::MakePipeWithDifferentSections"); + get3DPrimOp(); + return my3DPrimOp->MakePipeWithDifferentSections(theBases,theLocations, thePath,theWithContact,theWithCorrections); +} //============================================================================= // MakeFuse: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index d64bfb912..733d7d955 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -142,6 +142,8 @@ public: CORBA::Double theZ); GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakeVectorDXDYDZ (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ); @@ -162,6 +164,11 @@ public: CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize); + //-----------------------------------------------------------// // Primitives Construction : 3DPrimOperations // //-----------------------------------------------------------// @@ -218,6 +225,17 @@ public: CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter); + + GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections, + CORBA::Boolean theModeSolid, + CORBA::Double thePreci, + CORBA::Boolean theRuled); + + GEOM::GEOM_Object_ptr MakePipeWithDifferentSections(const GEOM::ListOfGO& theBases, + const GEOM::ListOfGO& theLocations, + GEOM::GEOM_Object_ptr thePath, + CORBA::Boolean theWithContact, + CORBA::Boolean theWithCorrections); //-----------------------------------------------------------// // BooleanOperations // diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index bab57fe78..311337bc0 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -184,6 +184,20 @@ def MakeVertexOnCurve(theRefCurve, theParameter): print "MakePointOnCurve : ", BasicOp.GetErrorCode() return anObj +def MakeTangentOnCurve(theRefCurve, theParameter): + """ + * Create a tangent, corresponding to the given parameter on the given curve. + * \param theRefCurve The referenced curve. + * \param theParameter Value of parameter on the referenced curve. + * \return New GEOM_Object, containing the created tangent. + + * + """ + anObj = BasicOp.MakeTangentOnCurve(theRefCurve, theParameter) + if BasicOp.IsDone() == 0: + print "MakeTangentOnCurve : ", BasicOp.GetErrorCode() + return anObj + ## Create a vector with the given components. # @param theDX X component of the vector. # @param theDY Y component of the vector. @@ -668,6 +682,45 @@ def MakeRevolution(theBase, theAxis, theAngle): print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode() return anObj +def MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled): + """ + * Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices. + * \param theSeqSections - set of specified sections. + * \param theModeSolid - mode defining building solid or shell + * \param thePreci - precision 3D used for smoothing by default 1.e-6 + * \param theRuled - mode defining type of the result surfaces (ruled or smoothed). + * \return New GEOM_Object, containing the created shell or solid. + + * Example: see GEOM_TestAll.py + """ + anObj = PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled) + if PrimOp.IsDone() == 0: + print "MakeThruSections : ", PrimOp.GetErrorCode() + return anObj + +def MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection): + """ + * Create a shape by extrusion of the profile shape along + * the path shape. The path shape can be a wire or an edge. + * the several profiles can be specified in the several locations of path. + * \param theSeqBases - list of Bases shape to be extruded. + * \param theLocations - list of locations on the path corresponding + * specified list of the Bases shapes. Number of locations + * should be equal to number of bases or list of locations can be empty. + * \param thePath - Path shape to extrude the base shape along it. + * \param theWithContact - the mode defining that the section is translated to be in + * contact with the spine. + * \param - WithCorrection - defining that the section is rotated to be + * orthogonal to the spine tangent in the correspondent point + * \return New GEOM_Object, containing the created pipe. + + * Example: see GEOM_TestAll.py + """ + anObj = PrimOp.MakePipeWithDifferentSections(theSeqBases, theLocations,thePath,theWithContact,theWithCorrection) + if PrimOp.IsDone() == 0: + print "MakePipeWithDifferentSections : ", PrimOp.GetErrorCode() + return anObj + # ----------------------------------------------------------------------------- # Create base shapes # -----------------------------------------------------------------------------