From: jfa Date: Thu, 18 Oct 2012 13:04:45 +0000 (+0000) Subject: Mantis issue 0021565: [CEA 557] Opposite of the pipe X-Git-Tag: V6_6_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44f9ad210fa4ea6548b4a71ca3b62f747de0104e;p=modules%2Fgeom.git Mantis issue 0021565: [CEA 557] Opposite of the pipe --- diff --git a/doc/salome/gui/GEOM/images/pipe_path.png b/doc/salome/gui/GEOM/images/pipe_path.png new file mode 100644 index 000000000..92d5d626a Binary files /dev/null and b/doc/salome/gui/GEOM/images/pipe_path.png differ diff --git a/doc/salome/gui/GEOM/images/pipe_path_dlg.png b/doc/salome/gui/GEOM/images/pipe_path_dlg.png new file mode 100644 index 000000000..e2f969d8c Binary files /dev/null and b/doc/salome/gui/GEOM/images/pipe_path_dlg.png differ diff --git a/doc/salome/gui/GEOM/input/creating_complex_obj.doc b/doc/salome/gui/GEOM/input/creating_complex_obj.doc index 0d0404336..46c4baa90 100644 --- a/doc/salome/gui/GEOM/input/creating_complex_obj.doc +++ b/doc/salome/gui/GEOM/input/creating_complex_obj.doc @@ -14,7 +14,7 @@ axis, creating a body of revolution.
  • \subpage create_filling_page "Create a surface" from a set of edges.
  • \subpage create_extrusion_alongpath_page "Extrude an object along a path", creating a more complex trajectory object.
  • - +
  • \subpage create_pipe_path_page "Restore Path" of a pipe-like shape.
  • */ diff --git a/doc/salome/gui/GEOM/input/creating_pipe_path.doc b/doc/salome/gui/GEOM/input/creating_pipe_path.doc new file mode 100644 index 000000000..abf97b5ec --- /dev/null +++ b/doc/salome/gui/GEOM/input/creating_pipe_path.doc @@ -0,0 +1,44 @@ +/*! + +\page create_pipe_path_page Restore Path + +To generate a \b Path in the Main Menu select New Entity - > Generation - > Restore Path + +\image html pipe_path_dlg.png + +\n To obtain a \b Path of a pipe-like shape, you should define the +Pipe-like shell or solid and two pipe \b Bases, each of them can +be set as a wire, a face or a list of edges.
    +\n Select unpublished edges checkbox - if checked, allows +selection of edges in the viewer, that are not published in the Object +Browser.
    +\n The \b Result of the operation will be a GEOM_Object (edge or wire).
    + +\n Advanced options: +
    + +\note It is not assumed that exact or approximate copy of the Shape + can be obtained by applying existing Pipe operation on the + resulting "Path" wire taking the first Base as the base - it is + not always possible; though in some particular cases it might + work it is not guaranteed. Thus, RestorePath function should not + be considered as an exact reverse operation of the Pipe.
    + +\n Example: + +\image html pipe_path.png "Path (red) between two faces (green)" + +\n TUI Command: geompy.RestorePath(aShape, aBase1, aBase2) +\n Arguments: Name + 1 pipe-like shape (shell or solid) + 1 +shape (edge, wire or face) for the first base + 1 shape (edge, wire or +face) for the last base. +\n TUI Command: geompy.RestorePathEdges(aShape, listEdges1, listEdges2) +\n Arguments: Name + 1 pipe-like shape (shell or solid) + 1 +list of edges for the first base + 1 list of edges for the last base. + +Our TUI Scripts provide you with useful examples of creation of +\ref tui_creation_pipe_path "Complex Geometric Objects". + +*/ diff --git a/doc/salome/gui/GEOM/input/tui_complex_objs.doc b/doc/salome/gui/GEOM/input/tui_complex_objs.doc index 7dcf151c1..2cdcf156a 100644 --- a/doc/salome/gui/GEOM/input/tui_complex_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_complex_objs.doc @@ -623,31 +623,78 @@ from math import pi spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2) \endcode -

    Creation of Tangent Plane On Face

    + +\anchor tui_creation_pipe_path +

    Creation of a Middle Path

    + \code import salome import geompy - # Create Vertexes for curve - Vertex_1 = geompy.MakeVertex(0, 0, 0) - Vertex_2 = geompy.MakeVertex(0, 90, 30) - Vertex_3 = geompy.MakeVertex(100, 90, 0) - Vertex_4 = geompy.MakeVertex(-100, 90, 0) - # Create curve - Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1]) - # Create Face by Extrusion of the Curve - Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60) - # Make Tangent on this Extrusion (Face) - Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150) - # Publish in the study - geompy.addToStudy( Vertex_1, "Vertex_1" ) - geompy.addToStudy( Vertex_2, "Vertex_2" ) - geompy.addToStudy( Vertex_3, "Vertex_3" ) - geompy.addToStudy( Vertex_4, "Vertex_4" ) - geompy.addToStudy( Curve_1, "Curve_1" ) - geompy.addToStudy( Extrusion_1, "Extrusion_1" ) - geompy.addToStudy( Tangent_1, "Tangent_1" ) +# Create a box +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# Get two opposite faces +[Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33]) + +# Get edges +Box_1_edge_12 = geompy.GetSubShape(Box_1, [12]) +Box_1_edge_22 = geompy.GetSubShape(Box_1, [22]) +Box_1_edge_25 = geompy.GetSubShape(Box_1, [25]) +Box_1_edge_29 = geompy.GetSubShape(Box_1, [29]) +Box_1_edge_8 = geompy.GetSubShape(Box_1, [8]) +Box_1_edge_18 = geompy.GetSubShape(Box_1, [18]) +Box_1_edge_26 = geompy.GetSubShape(Box_1, [26]) +Box_1_edge_30 = geompy.GetSubShape(Box_1, [30]) + +# These three calls to RestorePath return the same result +Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2) +Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2]) +Path_3 = geompy.RestorePathEdges(Box_1, + [Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29], + [Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30]) + +# Publish created objects +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' ) +geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' ) +geompy.addToStudy( Path_1, 'Path_1' ) +geompy.addToStudy( Path_2, 'Path_2' ) +geompy.addToStudy( Path_3, 'Path_3' ) \endcode +

    Creation of Tangent Plane On Face

    +\code +import salome +import geompy + +# Create Vertexes for curve +Vertex_1 = geompy.MakeVertex(0, 0, 0) +Vertex_2 = geompy.MakeVertex(0, 90, 30) +Vertex_3 = geompy.MakeVertex(100, 90, 0) +Vertex_4 = geompy.MakeVertex(-100, 90, 0) +# Create curve +Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1]) +# Create Face by Extrusion of the Curve +Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60) +# Make Tangent on this Extrusion (Face) +Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150) +# Publish in the study +geompy.addToStudy( Vertex_1, "Vertex_1" ) +geompy.addToStudy( Vertex_2, "Vertex_2" ) +geompy.addToStudy( Vertex_3, "Vertex_3" ) +geompy.addToStudy( Vertex_4, "Vertex_4" ) +geompy.addToStudy( Curve_1, "Curve_1" ) +geompy.addToStudy( Extrusion_1, "Extrusion_1" ) +geompy.addToStudy( Tangent_1, "Tangent_1" ) +\endcode */ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 8f90021eb..9c6896aad 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -715,6 +715,11 @@ module GEOM in double theTrimSize); }; + /*! + * \brief Interface for shapes transforming. + * + * Translation, rotation, scaling, mirroring, offset, projection, recomputing. + */ interface GEOM_ITransformOperations : GEOM_IOperations { /*! @@ -1077,7 +1082,8 @@ module GEOM * \param thePath Wire or Edge along that the object will be translated. * \param theDistance progress of Path (0 = actual location, 1 = end of path location). * \param theCopy is a true or false parameter. true is to create a copy, false to move the object. - * \param theReverse is a true or false parameter. true is to reverse direction, false is to move normal direction. + * \param theReverse is a true or false parameter. True is to reverse + * direction, false is to move normal direction. * \return New GEOM_Object, containing the displaced shape. */ GEOM_Object PositionAlongPath (in GEOM_Object theObject, @@ -1105,7 +1111,6 @@ module GEOM GEOM_Object RecomputeObject (in GEOM_Object theObject); }; - // # GEOM_I3DPrimOperations: /*! * \brief Interface for 3D primitives creation * @@ -1485,9 +1490,49 @@ module GEOM in GEOM_Object thePath, in GEOM_Object theVec); + /*! + * \brief Build a middle path of a pipe-like shape. + * + * The path shape can be a wire or an edge. + * \param theShape It can be closed or unclosed pipe-like shell + * or a pipe-like solid. + * \param theBase1, theBase2 Two bases of the supposed pipe. This + * should be wires or faces of \a theShape. + * \note It is not assumed that exact or approximate copy of \a theShape + * can be obtained by applying existing Pipe operation on the + * resulting "Path" wire taking \a theBase1 as the base - it is not + * always possible; though in some particular cases it might work + * it is not guaranteed. Thus, RestorePath function should not be + * considered as an exact reverse operation of the Pipe. + * \return New GEOM_Object, containing an edge or wire that represent + * source pipe's "path". + */ + GEOM_Object RestorePath (in GEOM_Object theShape, + in GEOM_Object theBase1, + in GEOM_Object theBase2); + + /*! + * \brief Build a middle path of a pipe-like shape. + * + * The path shape can be a wire or an edge. + * \param theShape It can be closed or unclosed pipe-like shell + * or a pipe-like solid. + * \param theBase1, theBase2 Two bases of the supposed pipe. This + * should be lists of edges of \a theShape. + * \note It is not assumed that exact or approximate copy of \a theShape + * can be obtained by applying existing Pipe operation on the + * resulting "Path" wire taking \a theBase1 as the base - it is not + * always possible; though in some particular cases it might work + * it is not guaranteed. Thus, RestorePath function should not be + * considered as an exact reverse operation of the Pipe. + * \return New GEOM_Object, containing an edge or wire that represent + * source pipe's "path". + */ + GEOM_Object RestorePathEdges (in GEOM_Object theShape, + in ListOfGO theBase1, + in ListOfGO theBase2); }; - // # GEOM_IShapesOperations /*! * \brief Interface for Shapes creation: * diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 96b164f7b..9cd7e615e 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -363,6 +363,10 @@ ICON_DLG_PARTITION_PLANE partitionplane.png + + ICON_DLG_PIPE_PATH + pipe.png + ICON_DLG_PIPE pipe.png @@ -995,6 +999,10 @@ ICO_PIPE pipe.png + + ICO_PIPE_PATH + pipe.png + ICO_PLANE plane.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 19b71ca9e..20c80d6b6 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1278,6 +1278,26 @@ Please, select face, shell or solid and try again GEOM_PIPE_TITLE Pipe Construction + + GEOM_PIPE_PATH + Path + + + GEOM_PIPE_PATH_TITLE + Restore Path + + + GEOM_PIPE_LIKE_SHAPE + Pipe-like shell or solid + + + GEOM_PIPE_BASE1_OBJECT + First base face/wire/edges + + + GEOM_PIPE_BASE2_OBJECT + Last base face/wire/edges + GEOM_PROFILE Profile @@ -2714,6 +2734,10 @@ Please, select face, shell or solid and try again MEN_PIPE Extrusion Along Path + + MEN_PIPE_PATH + Restore Path + MEN_PLANE Plane @@ -3494,6 +3518,10 @@ Please, select face, shell or solid and try again STB_PIPE Create a shape by extrusion along a path + + STB_PIPE_PATH + Restore path from a pipe-like shape + STB_PLANE Create a plane @@ -4114,6 +4142,10 @@ Please, select face, shell or solid and try again TOP_PIPE Extrusion along path + + TOP_PIPE_PATH + Restore path + TOP_PLANE Create a plane diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index cfb646deb..d13a0fd99 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -107,7 +107,6 @@ #include - #include "GEOMImpl_Types.hxx" extern "C" { @@ -135,7 +134,7 @@ GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen() bool GeometryGUI::InitGeomGen() { GeometryGUI aGG; - if( CORBA::is_nil( myComponentGeom ) ) return false; + if ( CORBA::is_nil( myComponentGeom ) ) return false; return true; } @@ -173,12 +172,12 @@ SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy) return aDSStudy._retn(); } -void GeometryGUI::Modified( bool theIsUpdateActions ) +void GeometryGUI::Modified (bool theIsUpdateActions) { - if( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) { - if( SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ) ) { + if ( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) { + if ( SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ) ) { appStudy->Modified(); - if( theIsUpdateActions ) + if ( theIsUpdateActions ) app->updateActions(); } } @@ -281,17 +280,17 @@ void GeometryGUI::ActiveWorkingPlane() bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); - if( ViewOCC ) { + if ( ViewOCC ) { OCCViewer_ViewWindow* vw = dynamic_cast( window ); if ( vw ) { Handle(V3d_View) view3d = vw->getViewPort()->getView(); view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z()); view3d->SetUp(DY.X(), DY.Y(), DY.Z()); - vw->onViewFitAll(); + vw->onViewFitAll(); } } - else if( ViewVTK ) { + else if ( ViewVTK ) { SVTK_ViewWindow* vw = dynamic_cast( window ); if ( vw ) { vtkCamera* camera = vw->getRenderer()->GetActiveCamera(); @@ -473,6 +472,7 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION case GEOMOp::OpFilling: // MENU GENERATION - FILLING case GEOMOp::OpPipe: // MENU GENERATION - PIPE + case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH libName = "GenerationGUI"; break; case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER @@ -596,15 +596,15 @@ void GeometryGUI::OnGUIEvent( int id ) // call method of corresponding GUI library if ( library ) { library->OnGUIEvent( id, desk ); - + // Update a list of materials for "Preferences" dialog if ( id == GEOMOp::OpMaterialProperties ) { LightApp_Preferences* pref = preferences(); if ( pref ) { - Material_ResourceMgr aMatResMgr; - setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(), - "strings", - aMatResMgr.materials() ); + Material_ResourceMgr aMatResMgr; + setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(), + "strings", + aMatResMgr.materials() ); } } } @@ -689,11 +689,11 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS void GeometryGUI::createOriginAndBaseVectors() { SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); - if( appStudy ) { + if ( appStudy ) { _PTR(Study) studyDS = appStudy->studyDS(); - if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) { + if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) { GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() ); - if( !aBasicOperations->_is_nil() ) { + if ( !aBasicOperations->_is_nil() ) { SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 ); GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 ); @@ -751,6 +751,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" ); createGeomAction( GEOMOp::OpFilling, "FILLING" ); createGeomAction( GEOMOp::OpPipe, "PIPE" ); + createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" ); createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" ); createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" ); @@ -950,6 +951,9 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpRevolution, genId, -1 ); createMenu( GEOMOp::OpFilling, genId, -1 ); createMenu( GEOMOp::OpPipe, genId, -1 ); +#if OCC_VERSION_LARGE > 0x06050300 + createMenu( GEOMOp::OpPipePath, genId, -1 ); +#endif // int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); @@ -983,9 +987,9 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpShell, buildId, -1 ); createMenu( GEOMOp::OpSolid, buildId, -1 ); createMenu( GEOMOp::OpCompound, buildId, -1 ); - + createMenu( separator(), newEntId, -1 ); - + createMenu( GEOMOp::OpPictureImport, newEntId, -1 ); #ifdef WITH_OPENCV createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 ); @@ -1110,7 +1114,7 @@ void GeometryGUI::initialize( CAM_Application* app ) */ // ---- create toolbars -------------------------- - + int basicTbId = createTool( tr( "TOOL_BASIC" ) ); createTool( GEOMOp::OpPoint, basicTbId ); createTool( GEOMOp::OpLine, basicTbId ); @@ -1124,11 +1128,11 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpPlane, basicTbId ); createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId ); - + // int sketchTbId = createTool( tr( "TOOL_SKETCH" ) ); // createTool( GEOMOp::Op2dSketcher, sketchTbId ); // createTool( GEOMOp::Op3dSketcher, sketchTbId ); - + int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); createTool( GEOMOp::OpBox, primTbId ); createTool( GEOMOp::OpCylinder, primTbId ); @@ -1138,26 +1142,29 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpRectangle, primTbId ); createTool( GEOMOp::OpDisk, primTbId ); createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc - + int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) ); createTool( GEOMOp::OpDividedDisk, blocksTbId ); createTool( GEOMOp::OpDividedCylinder, blocksTbId ); - + // int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc // createTool( GEOMOp::OpPipeTShape, advancedTbId ); - + int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); createTool( GEOMOp::OpFuse, boolTbId ); createTool( GEOMOp::OpCommon, boolTbId ); createTool( GEOMOp::OpCut, boolTbId ); createTool( GEOMOp::OpSection, boolTbId ); - - int genTbId = createTool( tr( "TOOL_GENERATION" ) ); + + int genTbId = createTool( tr( "TOOL_GENERATION" ) ); createTool( GEOMOp::OpPrism, genTbId ); createTool( GEOMOp::OpRevolution, genTbId ); createTool( GEOMOp::OpFilling, genTbId ); createTool( GEOMOp::OpPipe, genTbId ); - +#if OCC_VERSION_LARGE > 0x06050300 + createTool( GEOMOp::OpPipePath, genTbId ); +#endif + int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) ); createTool( GEOMOp::OpTranslate, transTbId ); createTool( GEOMOp::OpRotate, transTbId ); @@ -1169,14 +1176,14 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( separator(), transTbId ); createTool( GEOMOp::OpMultiTranslate, transTbId ); createTool( GEOMOp::OpMultiRotate, transTbId ); - + int operTbId = createTool( tr( "TOOL_OPERATIONS" ) ); createTool( GEOMOp::OpExplode, operTbId ); createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId ); - + int featTbId = createTool( tr( "TOOL_FEATURES" ) ); createTool( GEOMOp::OpFillet1d, featTbId ); createTool( GEOMOp::OpFillet2d, featTbId ); @@ -1184,7 +1191,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpChamfer, featTbId ); createTool( GEOMOp::OpExtrudedBoss, featTbId ); createTool( GEOMOp::OpExtrudedCut, featTbId ); - + int buildTbId = createTool( tr( "TOOL_BUILD" ) ); createTool( GEOMOp::OpEdge, buildTbId ); createTool( GEOMOp::OpWire, buildTbId ); @@ -1219,7 +1226,7 @@ void GeometryGUI::initialize( CAM_Application* app ) #ifdef WITH_OPENCV createTool( GEOMOp::OpFeatureDetect, picturesTbId ); #endif - + // int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// @@ -1261,7 +1268,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule ); mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule ); mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front - mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule ); + mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule ); #endif mgr->insert( separator(), -1, -1 ); // ----------- dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu @@ -1293,7 +1300,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule ); - mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties + mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); // texture mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); @@ -1304,7 +1311,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); - + mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule ); @@ -1363,7 +1370,6 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); - mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule ); @@ -1372,9 +1378,8 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->hide( mgr->actionId( action( myEraseAll ) ) ); - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - if(resMgr) { + if (resMgr) { GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0)); QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) ); GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c)); @@ -1399,16 +1404,18 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module) PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager"); - if(pluginsmanager==NULL) + PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager"); + if (pluginsmanager == NULL) PyErr_Print(); - else - { - PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"geom",tr("MEN_NEW_ENTITY").toStdString().c_str(),tr("GEOM_PLUGINS_OTHER").toStdString().c_str()); - if(result==NULL) - PyErr_Print(); - Py_XDECREF(result); - } + else { + PyObject* result = + PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom", + tr("MEN_NEW_ENTITY").toStdString().c_str(), + tr("GEOM_PLUGINS_OTHER").toStdString().c_str()); + if (result == NULL) + PyErr_Print(); + Py_XDECREF(result); + } PyGILState_Release(gstate); // end of GEOM plugins loading @@ -1466,13 +1473,13 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) // 0020836 (Basic vectors and origin) SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); - if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) { + if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) { SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); - if( appStudy ) { + if ( appStudy ) { _PTR(Study) studyDS = appStudy->studyDS(); - if( studyDS ) { + if ( studyDS ) { _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM"); - if( !aSComponent ) // create objects automatically only if there is no GEOM component + if ( !aSComponent ) // create objects automatically only if there is no GEOM component createOriginAndBaseVectors(); } } @@ -1481,7 +1488,6 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) return true; } - //======================================================================= // function : GeometryGUI::deactivateModule() // purpose : Called when GEOM module is deactivated @@ -1571,7 +1577,7 @@ void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm ) this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ), this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) ); - + LightApp_SelectionMgr* sm = getApp()->selectionMgr(); myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) ); @@ -1741,31 +1747,30 @@ void GeometryGUI::createPreferences() LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); int material = addPreference( tr( "PREF_MATERIAL" ), genGroup, - LightApp_Preferences::Selector, - "Geometry", "material" ); - + LightApp_Preferences::Selector, + "Geometry", "material" ); + const int nb = 4; int wd[nb]; int iter=0; wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "edge_width" ); + LightApp_Preferences::IntSpin, "Geometry", "edge_width" ); wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "isolines_width" ); + LightApp_Preferences::IntSpin, "Geometry", "isolines_width" ); wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" ); - + LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" ); + wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" ); + LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" ); - for(int i = 0; i < nb; i++) { - setPreferenceProperty( wd[i], "min", 1 ); + for (int i = 0; i < nb; i++) { + setPreferenceProperty( wd[i], "min", 1 ); setPreferenceProperty( wd[i], "max", 5 ); } - // Quantities with individual precision settings int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId ); setPreferenceProperty( precGroup, "columns", 2 ); @@ -1819,7 +1824,6 @@ void GeometryGUI::createPreferences() setPreferenceProperty( dispmode, "strings", aModesList ); setPreferenceProperty( dispmode, "indexes", anIndexesList ); - // Set property for top level display mode QStringList aTopModesList; aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") ); @@ -1891,7 +1895,6 @@ void GeometryGUI::createPreferences() addPreference( tr( "PREF_AUTO_CREATE" ), originGroup, LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" ); - int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId ); setPreferenceProperty( operationsGroup, "columns", 2 ); @@ -1906,18 +1909,20 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par if (param == QString("SettingsGeomStep")) { double spin_step = aResourceMgr->doubleValue(section, param, 100.); EmitSignalDefaultStepValueChanged(spin_step); - } else if(param == QString("toplevel_color")) { + } + else if (param == QString("toplevel_color")) { QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) ); GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c)); - } else if(param == QString("toplevel_dm")) { + } + else if (param == QString("toplevel_dm")) { GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0)); } - } + } } LightApp_Displayer* GeometryGUI::displayer() { - if( !myDisplayer ) + if ( !myDisplayer ) myDisplayer = new GEOM_Displayer( dynamic_cast( getApp()->activeStudy() ) ); return myDisplayer; } @@ -1926,6 +1931,7 @@ void GeometryGUI::setLocalSelectionMode(const int mode) { myLocalSelectionMode = mode; } + int GeometryGUI::getLocalSelectionMode() const { return myLocalSelectionMode; @@ -1986,7 +1992,7 @@ void GeometryGUI::storeVisualParameters (int savePoint) std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName); _PTR(GenericAttribute) anAttr; - if( !obj->FindAttribute(anAttr, "AttributeIOR")) + if (!obj->FindAttribute(anAttr, "AttributeIOR")) continue; std::string param,occParam = vType.toLatin1().data(); @@ -1994,17 +2000,17 @@ void GeometryGUI::storeVisualParameters (int savePoint) occParam += QString::number(aMgrId).toLatin1().data(); occParam += NAME_SEPARATOR; - if(aProps.contains(VISIBILITY_PROP)) { + if (aProps.contains(VISIBILITY_PROP)) { param = occParam + VISIBILITY_PROP; ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off"); } - if(aProps.contains(DISPLAY_MODE_PROP)) { + if (aProps.contains(DISPLAY_MODE_PROP)) { param = occParam + DISPLAY_MODE_PROP; ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data()); } - if(aProps.contains(COLOR_PROP)) { + if (aProps.contains(COLOR_PROP)) { QColor c = aProps.value(COLOR_PROP).value(); QString colorStr = QString::number(c.red()/255.); colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.); @@ -2013,59 +2019,59 @@ void GeometryGUI::storeVisualParameters (int savePoint) ip->setParameter(entry, param, colorStr.toLatin1().data()); } - if(vType == SVTK_Viewer::Type()) { - if(aProps.contains(OPACITY_PROP)) { + if (vType == SVTK_Viewer::Type()) { + if (aProps.contains(OPACITY_PROP)) { param = occParam + OPACITY_PROP; ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); } } else if (vType == SOCC_Viewer::Type()) { - if(aProps.contains(TRANSPARENCY_PROP)) { + if (aProps.contains(TRANSPARENCY_PROP)) { param = occParam + TRANSPARENCY_PROP; ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); } - if(aProps.contains(TOP_LEVEL_PROP)) { + if (aProps.contains(TOP_LEVEL_PROP)) { param = occParam + TOP_LEVEL_PROP; - Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value(); - if (val == Standard_True) - ip->setParameter(entry, param, "1"); - } + Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value(); + if (val == Standard_True) + ip->setParameter(entry, param, "1"); + } } - if(aProps.contains(ISOS_PROP)) { + if (aProps.contains(ISOS_PROP)) { param = occParam + ISOS_PROP; ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data()); } - if(aProps.contains(VECTOR_MODE_PROP)) { + if (aProps.contains(VECTOR_MODE_PROP)) { param = occParam + VECTOR_MODE_PROP; ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data()); } - if(aProps.contains(DEFLECTION_COEFF_PROP)) { + if (aProps.contains(DEFLECTION_COEFF_PROP)) { param = occParam + DEFLECTION_COEFF_PROP; ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data()); } //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex" - if(aProps.contains(MARKER_TYPE_PROP)) { + if (aProps.contains(MARKER_TYPE_PROP)) { param = occParam + MARKER_TYPE_PROP; ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data()); } - if(aProps.contains(MATERIAL_PROP)) { + if (aProps.contains(MATERIAL_PROP)) { param = occParam + MATERIAL_PROP; ip->setParameter(entry, param, aProps.value(MATERIAL_PROP).toString().toLatin1().data()); } - if(aProps.contains( EDGE_WIDTH_PROP )) { + if (aProps.contains(EDGE_WIDTH_PROP)) { param = occParam + EDGE_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data()); + ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data()); } - - if(aProps.contains( ISOS_WIDTH_PROP )) { - param = occParam + ISOS_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data()); + + if (aProps.contains(ISOS_WIDTH_PROP)) { + param = occParam + ISOS_WIDTH_PROP; + ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data()); } } // object iterator } // for (views) @@ -2141,52 +2147,42 @@ void GeometryGUI::restoreVisualParameters (int savePoint) if (!ok) // bad conversion of view index to integer continue; - if((viewIndex + 1) > aListOfMap.count()) { + if ((viewIndex + 1) > aListOfMap.count()) { aListOfMap.resize(viewIndex + 1); } QString val((*valuesIt).c_str()); - if(paramNameStr == VISIBILITY_PROP){ + if (paramNameStr == VISIBILITY_PROP) { aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0); - - } else if(paramNameStr == OPACITY_PROP) { + } else if (paramNameStr == OPACITY_PROP) { aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble()); - - } else if(paramNameStr == TRANSPARENCY_PROP) { + } else if (paramNameStr == TRANSPARENCY_PROP) { aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() ); - - } else if(paramNameStr == TOP_LEVEL_PROP) { - aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False ); - - } else if(paramNameStr == DISPLAY_MODE_PROP) { + } else if (paramNameStr == TOP_LEVEL_PROP) { + aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False ); + } else if (paramNameStr == DISPLAY_MODE_PROP) { aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt()); - - } else if(paramNameStr == ISOS_PROP) { + } else if (paramNameStr == ISOS_PROP) { aListOfMap[viewIndex].insert( ISOS_PROP, val); - - } else if(paramNameStr == COLOR_PROP) { + } else if (paramNameStr == COLOR_PROP) { QStringList rgb = val.split(DIGIT_SEPARATOR); - if(rgb.count() == 3) { + if (rgb.count() == 3) { QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255)); aListOfMap[viewIndex].insert( COLOR_PROP, c); } - } else if(paramNameStr == VECTOR_MODE_PROP) { + } else if (paramNameStr == VECTOR_MODE_PROP) { aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt()); - - } else if(paramNameStr == DEFLECTION_COEFF_PROP) { + } else if (paramNameStr == DEFLECTION_COEFF_PROP) { aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble()); - } else if(paramNameStr == MARKER_TYPE_PROP) { + } else if (paramNameStr == MARKER_TYPE_PROP) { aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val); - } else if(paramNameStr == MATERIAL_PROP) { + } else if (paramNameStr == MATERIAL_PROP) { aListOfMap[viewIndex].insert( MATERIAL_PROP, val); - } else if(paramNameStr == EDGE_WIDTH_PROP) { - aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val); - } else if(paramNameStr == ISOS_WIDTH_PROP) { - aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP , val); + } else if (paramNameStr == EDGE_WIDTH_PROP) { + aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP, val); + } else if (paramNameStr == ISOS_WIDTH_PROP) { + aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP, val); } - - - } // for names/parameters iterator QList lst = getApp()->viewManagers(); @@ -2202,7 +2198,6 @@ void GeometryGUI::restoreVisualParameters (int savePoint) displayer()->Display(entry, true, dynamic_cast(vmodel)); } } - } // for entries iterator // update all VTK and OCC views @@ -2243,7 +2238,7 @@ void GeometryGUI::onViewAboutToShow() /*! \brief Return action by id \param id identifier of the action - \return action + \return action */ QAction* GeometryGUI::getAction(const int id) { return action(id); @@ -2261,32 +2256,32 @@ QAction* GeometryGUI::getAction(const int id) { bool GeometryGUI::renameAllowed( const QString& entry) const { SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; + SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; SalomeApp_DataObject* obj = appStudy ? dynamic_cast(appStudy->findObjectByEntry(entry)) : 0; - + return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference()); } - /*! Rename object by entry. \param entry entry of the object \param name new name of the object \brief Return \c true if rename operation finished successfully, \c false otherwise. */ -bool GeometryGUI::renameObject( const QString& entry, const QString& name) { - +bool GeometryGUI::renameObject( const QString& entry, const QString& name) +{ bool result = false; - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication()); + + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication()); SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; - - if(!appStudy) + + if (!appStudy) return result; - + _PTR(Study) aStudy = appStudy->studyDS(); - - if(!aStudy) + + if (!aStudy) return result; bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked(); @@ -2311,4 +2306,3 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name) { } return result; } - diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 75e45e43f..e17172e49 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -98,6 +98,7 @@ namespace GEOMOp { OpRevolution = 3201, // MENU NEW ENTITY - GENERATION - REVOLUTION OpFilling = 3202, // MENU NEW ENTITY - GENERATION - FILLING OpPipe = 3203, // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH + OpPipePath = 3204, // MENU NEW ENTITY - GENERATION - RESTORE PATH // EntityGUI -------------------//-------------------------------- Op2dSketcher = 3300, // MENU NEW ENTITY - SKETCHER Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index 884da5cb1..f8f02247d 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifdef WNT #pragma warning( disable:4786 ) @@ -54,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +122,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_PipePathDriver::GetID(), new GEOMImpl_PipePathDriver()); 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()); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index dc2ab3599..b4103f9fa 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -49,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +69,7 @@ #include #include #include +#include #include @@ -2176,7 +2177,6 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( } - //============================================================================= /*! * MakePipeBiNormalAlongVector @@ -2236,3 +2236,173 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Han SetErrorCode(OK); return aPipe; } + +//============================================================================= +/*! + * RestorePath + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theBase1, + Handle(GEOM_Object) theBase2) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL; + + // Add a new Path object + Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH); + + // Add a new Path function + Handle(GEOM_Function) aFunction = + aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES); + if (aFunction.IsNull()) return NULL; + + // Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL; + + GEOMImpl_IPipePath aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction(); + Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction(); + + if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetBase1(aRefBase1); + aCI.SetBase2(aRefBase2); + + // Compute the Path value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("PipePath 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) << aPath << " = geompy.RestorePath(" + << theShape << ", " << theBase1 << ", " << theBase2 << ")"; + + SetErrorCode(OK); + return aPath; +} + +//============================================================================= +/*! + * RestorePath + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath + (Handle(GEOM_Object) theShape, + const Handle(TColStd_HSequenceOfTransient)& theBase1, + const Handle(TColStd_HSequenceOfTransient)& theBase2) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL; + + Standard_Integer nbBases1 = theBase1->Length(); + Standard_Integer nbBases2 = theBase2->Length(); + + if (!nbBases1 || !nbBases2) + return NULL; + + // Add a new Path object + Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH); + + // Add a new Path function + Handle(GEOM_Function) aFunction = + aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS); + if (aFunction.IsNull()) return NULL; + + // Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL; + + GEOMImpl_IPipePath aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient; + + Standard_Integer i; + for (i = 1; i <= nbBases1; i++) { + Handle(Standard_Transient) anItem = theBase1->Value(i); + if (!anItem.IsNull()) { + Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem); + if (!aBase.IsNull()) { + Handle(GEOM_Function) aRefBase = aBase->GetLastFunction(); + if (!aRefBase.IsNull()) + aSeqBases1->Append(aRefBase); + } + } + } + for (i = 1; i <= nbBases2; i++) { + Handle(Standard_Transient) anItem = theBase2->Value(i); + if (!anItem.IsNull()) { + Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem); + if (!aBase.IsNull()) { + Handle(GEOM_Function) aRefBase = aBase->GetLastFunction(); + if (!aRefBase.IsNull()) + aSeqBases2->Append(aRefBase); + } + } + } + if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetBaseSeq1(aSeqBases1); + aCI.SetBaseSeq2(aSeqBases2); + + // Compute the Path value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("PipePath 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 pyDump (aFunction); + pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", ["; + for (i = 1; i <= nbBases1; i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i)); + if (!anObj.IsNull()) { + pyDump << anObj; + if (i < nbBases1) + pyDump << ", "; + } + } + pyDump<< "], ["; + for (i = 1; i <= nbBases2; i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i)); + if (!anObj.IsNull()) { + pyDump << anObj; + if (i < nbBases2) + pyDump << ", "; + } + } + pyDump << "])"; + + SetErrorCode(OK); + return aPath; +} diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index c567d0333..6cd2dd25d 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_I3DPrimOperations_HXX_ #define _GEOMImpl_I3DPrimOperations_HXX_ @@ -131,14 +130,21 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { bool theWithContact, bool theWithCorrections); - Standard_EXPORT Handle(GEOM_Object) MakePipeShellsWithoutPath( - const Handle(TColStd_HSequenceOfTransient)& theBases, - const Handle(TColStd_HSequenceOfTransient)& theLocations); + Standard_EXPORT Handle(GEOM_Object) MakePipeShellsWithoutPath + (const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations); Standard_EXPORT Handle(GEOM_Object) MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase, Handle(GEOM_Object) thePath, Handle(GEOM_Object) theVec); + Standard_EXPORT Handle(GEOM_Object) RestorePath (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theBase1, + Handle(GEOM_Object) theBase2); + + Standard_EXPORT Handle(GEOM_Object) RestorePath (Handle(GEOM_Object) theShape, + const Handle(TColStd_HSequenceOfTransient)& theBase1, + const Handle(TColStd_HSequenceOfTransient)& theBase2); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IPipePath.hxx b/src/GEOMImpl/GEOMImpl_IPipePath.hxx new file mode 100644 index 000000000..028ab2f53 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPipePath.hxx @@ -0,0 +1,61 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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/ or email : webmaster.salome@opencascade.com + +// NOTE: This is an interface to the function RestorePath. + +#ifndef _GEOMImpl_IPIPEPATH_HXX_ +#define _GEOMImpl_IPIPEPATH_HXX_ + +#include "GEOM_Function.hxx" + +class GEOMImpl_IPipePath +{ + public: + + enum { + PIPE_PATH_SHAPE = 1, + PIPE_PATH_BASE1 = 2, + PIPE_PATH_BASE2 = 3, + PIPE_PATH_SEQ1 = 4, + PIPE_PATH_SEQ2 = 5 + }; + + GEOMImpl_IPipePath (Handle(GEOM_Function)& theFunction): _func(theFunction) {} + + void SetShape (Handle(GEOM_Function) theShape) { _func->SetReference(PIPE_PATH_SHAPE, theShape); } + void SetBase1 (Handle(GEOM_Function) theBase1) { _func->SetReference(PIPE_PATH_BASE1, theBase1); } + void SetBase2 (Handle(GEOM_Function) theBase2) { _func->SetReference(PIPE_PATH_BASE2, theBase2); } + void SetBaseSeq1 (const Handle(TColStd_HSequenceOfTransient)& theBase1) + { _func->SetReferenceList(PIPE_PATH_SEQ1, theBase1); } + void SetBaseSeq2 (const Handle(TColStd_HSequenceOfTransient)& theBase2) + { _func->SetReferenceList(PIPE_PATH_SEQ2, theBase2); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(PIPE_PATH_SHAPE); } + Handle(GEOM_Function) GetBase1() { return _func->GetReference(PIPE_PATH_BASE1); } + Handle(GEOM_Function) GetBase2() { return _func->GetReference(PIPE_PATH_BASE2); } + Handle(TColStd_HSequenceOfTransient) GetBaseSeq1 () + { return _func->GetReferenceList(PIPE_PATH_SEQ1); } + Handle(TColStd_HSequenceOfTransient) GetBaseSeq2 () + { return _func->GetReferenceList(PIPE_PATH_SEQ2); } + + protected: + + Handle(GEOM_Function) _func; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 21475ee42..400c2a03c 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -41,15 +42,14 @@ #include #include +#include +#include #include #include #include +#include #include #include -#include -#include -#include -#include #include #include @@ -68,6 +68,8 @@ #include #include +#include + #include #include #include @@ -88,6 +90,7 @@ #include #include + #include #include #include @@ -100,7 +103,7 @@ //======================================================================= const Standard_GUID& GEOMImpl_PipeDriver::GetID() { - static Standard_GUID aPipeDriver("FF1BBB19-5D14-4df2-980B-3A668264EA16"); + static Standard_GUID aPipeDriver ("FF1BBB19-5D14-4df2-980B-3A668264EA16"); return aPipeDriver; } @@ -2277,23 +2280,23 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath, //function : Execute //purpose : //======================================================================= -Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const +Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const { - //cout<<"PipeDriver::Execute"<GetType(); + + GEOMImpl_IPipe* aCI = 0; if (aType == PIPE_BASE_PATH) - aCI = new GEOMImpl_IPipe(aFunction); + aCI = new GEOMImpl_IPipe (aFunction); else if (aType == PIPE_DIFFERENT_SECTIONS) - aCI = new GEOMImpl_IPipeDiffSect(aFunction); + aCI = new GEOMImpl_IPipeDiffSect (aFunction); else if (aType == PIPE_SHELL_SECTIONS) - aCI = new GEOMImpl_IPipeShellSect(aFunction); + aCI = new GEOMImpl_IPipeShellSect (aFunction); else if (aType == PIPE_SHELLS_WITHOUT_PATH) - aCI = new GEOMImpl_IPipeShellSect(aFunction); + aCI = new GEOMImpl_IPipeShellSect (aFunction); else if (aType == PIPE_BI_NORMAL_ALONG_VECTOR) - aCI = new GEOMImpl_IPipeBiNormal(aFunction); + aCI = new GEOMImpl_IPipeBiNormal (aFunction); else return 0; diff --git a/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx b/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx new file mode 100644 index 000000000..5acf28f12 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PipePathDriver.cxx @@ -0,0 +1,242 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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/ or email : webmaster.salome@opencascade.com + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if OCC_VERSION_LARGE > 0x06050300 +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "utilities.h" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PipePathDriver::GetID() +{ + static Standard_GUID aPipePathDriver ("FF1BBB19-5D14-4df2-980B-3A668264EA17"); + return aPipePathDriver; +} + +//======================================================================= +//function : GEOMImpl_PipePathDriver +//purpose : +//======================================================================= +GEOMImpl_PipePathDriver::GEOMImpl_PipePathDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PipePathDriver::Execute (TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aRes; + + // RestorePath + if (aType == PIPE_PATH_TWO_BASES) { + GEOMImpl_IPipePath aPI (aFunction); + + Handle(GEOM_Function) aRefShape = aPI.GetShape(); + Handle(GEOM_Function) aRefBase1 = aPI.GetBase1(); + Handle(GEOM_Function) aRefBase2 = aPI.GetBase2(); + + TopoDS_Shape aShape = aRefShape->GetValue(); + TopoDS_Shape aBase1 = aRefBase1->GetValue(); + TopoDS_Shape aBase2 = aRefBase2->GetValue(); + + if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) + Standard_NullObject::Raise("RestorePath aborted : null argument"); + +#if OCC_VERSION_LARGE > 0x06050300 + BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2); + aMPB.Build(); + if (aMPB.IsDone()) { + aRes = aMPB.Shape(); + } +#else + Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version"); +#endif + } + else if (aType == PIPE_PATH_TWO_SEQS) { + GEOMImpl_IPipePath aPI (aFunction); + + Handle(GEOM_Function) aRefShape = aPI.GetShape(); + TopoDS_Shape aShape = aRefShape->GetValue(); + + Handle(TColStd_HSequenceOfTransient) aBaseSeq1 = aPI.GetBaseSeq1(); + Handle(TColStd_HSequenceOfTransient) aBaseSeq2 = aPI.GetBaseSeq2(); + + TopoDS_Shape aBase1; + TopoDS_Shape aBase2; + + if (aBaseSeq1->Length() == 1 && aBaseSeq2->Length() == 1) { + Handle(GEOM_Function) aRefShape1 = Handle(GEOM_Function)::DownCast(aBaseSeq1->Value(1)); + Handle(GEOM_Function) aRefShape2 = Handle(GEOM_Function)::DownCast(aBaseSeq2->Value(1)); + aBase1 = aRefShape1->GetValue(); + aBase2 = aRefShape2->GetValue(); + } + else { + aBase1 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq1, Precision::Confusion()); + aBase2 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq2, Precision::Confusion()); + } + + if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) + Standard_NullObject::Raise("RestorePath aborted : null argument"); + +#if OCC_VERSION_LARGE > 0x06050300 + BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2); + aMPB.Build(); + if (aMPB.IsDone()) { + aRes = aMPB.Shape(); + } +#else + Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version"); +#endif + } + else { + } + + if (aRes.IsNull()) return 0; + + aFunction->SetValue(aRes); + log.SetTouched(Label()); + + return 1; +} + +//======================================================================= +//function : GEOMImpl_PipePathDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipePathDriver_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_PipePathDriver", + sizeof(GEOMImpl_PipePathDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PipePathDriver) Handle(GEOMImpl_PipePathDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PipePathDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipePathDriver))) { + _anOtherObject = Handle(GEOMImpl_PipePathDriver)((Handle(GEOMImpl_PipePathDriver)&)AnObject); + } + } + + return _anOtherObject; +} diff --git a/src/GEOMImpl/GEOMImpl_PipePathDriver.hxx b/src/GEOMImpl/GEOMImpl_PipePathDriver.hxx new file mode 100644 index 000000000..36bf36314 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PipePathDriver.hxx @@ -0,0 +1,167 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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/ or email : webmaster.salome@opencascade.com + +// File : GEOMImpl_PipePathDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PipePathDriver_HeaderFile +#define _GEOMImpl_PipePathDriver_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_PipePathDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PipePathDriver); + +class Handle(GEOMImpl_PipePathDriver) : 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_PipePathDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PipePathDriver)(const Handle(GEOMImpl_PipePathDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PipePathDriver)(const GEOMImpl_PipePathDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PipePathDriver)& operator=(const Handle(GEOMImpl_PipePathDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PipePathDriver)& operator=(const GEOMImpl_PipePathDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PipePathDriver* operator->() + { + return (GEOMImpl_PipePathDriver *)ControlAccess(); + } + + GEOMImpl_PipePathDriver* operator->() const + { + return (GEOMImpl_PipePathDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PipePathDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PipePathDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +#include +#include +#include + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PipePathDriver : 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_PipePathDriver(); + 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_PipePathDriver() {}; + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PipePathDriver_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const + { return STANDARD_TYPE(GEOMImpl_PipePathDriver) ; } + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const + { return (STANDARD_TYPE(GEOMImpl_PipePathDriver) == AType || + TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index c83f91417..12962ffc7 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -133,66 +133,12 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (aType == WIRE_EDGES) { Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); - TopoDS_Wire aWire; - B.MakeWire(aWire); - // add edges - for (unsigned int ind = 1; ind <= aShapes->Length(); ind++) { - Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); - TopoDS_Shape aShape_i = aRefShape->GetValue(); - if (aShape_i.IsNull()) { - Standard_NullObject::Raise("Shape for wire construction is null"); - } - if (aShape_i.ShapeType() == TopAbs_EDGE || aShape_i.ShapeType() == TopAbs_WIRE) { - TopExp_Explorer exp (aShape_i, TopAbs_EDGE); - for (; exp.More(); exp.Next()) - B.Add(aWire, TopoDS::Edge(exp.Current())); - } else { - Standard_TypeMismatch::Raise - ("Shape for wire construction is neither an edge nor a wire"); - } - } - - // fix edges order - Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire; - aFW->Load(aWire); - aFW->FixReorder(); - - if (aFW->StatusReorder(ShapeExtend_FAIL1)) { - Standard_ConstructionError::Raise("Wire construction failed: several loops detected"); - } else if (aFW->StatusReorder(ShapeExtend_FAIL)) { - Standard_ConstructionError::Raise("Wire construction failed"); - } else { - } - - // IMP 0019766: Building a Wire from unconnected edges by introducing a tolerance Standard_Real aTolerance = aCI.GetTolerance(); if (aTolerance < Precision::Confusion()) aTolerance = Precision::Confusion(); - aFW->ClosedWireMode() = Standard_False; - aFW->FixConnected(aTolerance); - if (aFW->StatusConnected(ShapeExtend_FAIL)) { - Standard_ConstructionError::Raise("Wire construction failed: cannot build connected wire"); - } - // IMP 0019766 - if (aFW->StatusConnected(ShapeExtend_DONE3)) { - // Confused with but not Analyzer.Precision(), set the same - aFW->FixGapsByRangesMode() = Standard_True; - if (aFW->FixGaps3d()) { - Handle(ShapeExtend_WireData) sbwd = aFW->WireData(); - Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge; - for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) { - TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge)); - aFe->FixVertexTolerance(aEdge); - aFe->FixSameParameter(aEdge); - } - } - else if (aFW->StatusGaps3d(ShapeExtend_FAIL)) { - Standard_ConstructionError::Raise("Wire construction failed: cannot fix 3d gaps"); - } - } - aShape = aFW->WireAPIMake(); + aShape = MakeWireFromEdges(aShapes, aTolerance); } else if (aType == FACE_WIRE) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); @@ -610,6 +556,73 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const return 1; } +TopoDS_Wire GEOMImpl_ShapeDriver::MakeWireFromEdges(const Handle(TColStd_HSequenceOfTransient)& theEdgesFuncs, + const Standard_Real theTolerance) +{ + BRep_Builder B; + + TopoDS_Wire aWire; + B.MakeWire(aWire); + + // add edges + for (unsigned int ind = 1; ind <= theEdgesFuncs->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(theEdgesFuncs->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("Shape for wire construction is null"); + } + if (aShape_i.ShapeType() == TopAbs_EDGE || aShape_i.ShapeType() == TopAbs_WIRE) { + TopExp_Explorer exp (aShape_i, TopAbs_EDGE); + for (; exp.More(); exp.Next()) + B.Add(aWire, TopoDS::Edge(exp.Current())); + } else { + Standard_TypeMismatch::Raise + ("Shape for wire construction is neither an edge nor a wire"); + } + } + + // fix edges order + Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire; + aFW->Load(aWire); + aFW->FixReorder(); + + if (aFW->StatusReorder(ShapeExtend_FAIL1)) { + Standard_ConstructionError::Raise("Wire construction failed: several loops detected"); + } + else if (aFW->StatusReorder(ShapeExtend_FAIL)) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + else { + } + + // IMP 0019766: Building a Wire from unconnected edges by introducing a tolerance + aFW->ClosedWireMode() = Standard_False; + aFW->FixConnected(theTolerance); + if (aFW->StatusConnected(ShapeExtend_FAIL)) { + Standard_ConstructionError::Raise("Wire construction failed: cannot build connected wire"); + } + // IMP 0019766 + if (aFW->StatusConnected(ShapeExtend_DONE3)) { + // Confused with but not Analyzer.Precision(), set the same + aFW->FixGapsByRangesMode() = Standard_True; + if (aFW->FixGaps3d()) { + Handle(ShapeExtend_WireData) sbwd = aFW->WireData(); + Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge; + for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) { + TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge)); + aFe->FixVertexTolerance(aEdge); + aFe->FixSameParameter(aEdge); + } + } + else if (aFW->StatusGaps3d(ShapeExtend_FAIL)) { + Standard_ConstructionError::Raise("Wire construction failed: cannot fix 3d gaps"); + } + } + aWire = aFW->WireAPIMake(); + + return aWire; +} + TopoDS_Edge GEOMImpl_ShapeDriver::MakeEdgeFromWire(const TopoDS_Shape& aWire, const Standard_Real LinTol, const Standard_Real AngTol) diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx index 653ad7e13..87c55c501 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx @@ -120,6 +120,8 @@ class Handle(GEOMImpl_ShapeDriver) : public Handle(TFunction_Driver) { #include #include +#include +#include class TColStd_SequenceOfExtendedString; @@ -151,9 +153,13 @@ public: Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT static TopoDS_Edge MakeEdgeFromWire(const TopoDS_Shape& aWire, - const Standard_Real LinTol, - const Standard_Real AngTol); + Standard_EXPORT static TopoDS_Edge MakeEdgeFromWire (const TopoDS_Shape& aWire, + const Standard_Real LinTol, + const Standard_Real AngTol); + + Standard_EXPORT static TopoDS_Wire MakeWireFromEdges + (const Handle(TColStd_HSequenceOfTransient)& theEdgesFuncs, + const Standard_Real theTolerance); // Type management // diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 5182f8cdc..4aeed6398 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -100,6 +100,8 @@ #define GEOM_EXTRUDED_BOSS 47 +#define GEOM_PIPE_PATH 48 + //GEOM_Function types #define COPY_WITH_REF 1 @@ -214,6 +216,10 @@ #define PIPE_SHELLS_WITHOUT_PATH 4 #define PIPE_BI_NORMAL_ALONG_VECTOR 5 +// RestorePath +#define PIPE_PATH_TWO_BASES 1 +#define PIPE_PATH_TWO_SEQS 2 + #define THRUSECTIONS_RULED 1 #define THRUSECTIONS_SMOOTHED 2 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 69cda82da..8ce12ca2e 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -83,6 +83,7 @@ salomeinclude_HEADERS = \ GEOMImpl_ITorus.hxx \ GEOMImpl_IPrism.hxx \ GEOMImpl_IPipe.hxx \ + GEOMImpl_IPipePath.hxx \ GEOMImpl_IRevolution.hxx \ GEOMImpl_IMeasure.hxx \ GEOMImpl_IShapes.hxx \ @@ -111,6 +112,7 @@ salomeinclude_HEADERS = \ GEOMImpl_TorusDriver.hxx \ GEOMImpl_PrismDriver.hxx \ GEOMImpl_PipeDriver.hxx \ + GEOMImpl_PipePathDriver.hxx \ GEOMImpl_ThruSectionsDriver.hxx \ GEOMImpl_RevolutionDriver.hxx \ GEOMImpl_ShapeDriver.hxx \ @@ -185,6 +187,7 @@ dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_TorusDriver.cxx \ GEOMImpl_PrismDriver.cxx \ GEOMImpl_PipeDriver.cxx \ + GEOMImpl_PipePathDriver.cxx \ GEOMImpl_ThruSectionsDriver.cxx \ GEOMImpl_RevolutionDriver.cxx \ GEOMImpl_ShapeDriver.cxx \ diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index 76febf836..95948ed24 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -1096,7 +1095,6 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeShellsWithoutPath return GetObject(anObject); } - //============================================================================= /*! * MakePipeBiNormalAlongVector @@ -1127,3 +1125,81 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeBiNormalAlongVector return GetObject(anObject); } + +//============================================================================= +/*! + * RestorePath + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::RestorePath + (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theBase1, + GEOM::GEOM_Object_ptr theBase2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Get the reference objects + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(GEOM_Object) aBase1 = GetObjectImpl(theBase1); + Handle(GEOM_Object) aBase2 = GetObjectImpl(theBase2); + + if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) return aGEOMObject._retn(); + + // Create the Path + Handle(GEOM_Object) anObject = GetOperations()->RestorePath(aShape, aBase1, aBase2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * RestorePathEdges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::RestorePathEdges + (GEOM::GEOM_Object_ptr theShape, + const GEOM::ListOfGO& theBase1, + const GEOM::ListOfGO& theBase2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Get the reference objects + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return aGEOMObject._retn(); + + Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient; + + int ind; + int aNbBases1 = theBase1.length(); + int aNbBases2 = theBase2.length(); + + for (ind = 0; ind < aNbBases1; ind++) { + Handle(GEOM_Object) aBase = GetObjectImpl(theBase1[ind]); + if (!aBase.IsNull()) + aSeqBases1->Append(aBase); + } + for (ind = 0; ind < aNbBases2; ind++) { + Handle(GEOM_Object) aBase = GetObjectImpl(theBase2[ind]); + if (!aBase.IsNull()) + aSeqBases2->Append(aBase); + } + + if (!aSeqBases1->Length() || !aSeqBases2->Length()) + return aGEOMObject._retn(); + + // Create the Path + Handle(GEOM_Object) anObject = GetOperations()->RestorePath(aShape, aSeqBases1, aSeqBases2); + 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 05a748932..5b274671b 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_I3DPrimOperations_i_HeaderFile #define _GEOM_I3DPrimOperations_i_HeaderFile @@ -188,6 +187,13 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr thePath, GEOM::GEOM_Object_ptr theVec); + GEOM::GEOM_Object_ptr RestorePath (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theBase1, + GEOM::GEOM_Object_ptr theBase2); + GEOM::GEOM_Object_ptr RestorePathEdges (GEOM::GEOM_Object_ptr theShape, + const GEOM::ListOfGO& theBase1, + const GEOM::ListOfGO& theBase2); + ::GEOMImpl_I3DPrimOperations* GetOperations() { return (::GEOMImpl_I3DPrimOperations*)GetImpl(); } }; diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 0dd628e5a..8833a4de9 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -2867,6 +2867,76 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakePipeBiNormalAlongVector", self.PrimOp) return anObj + ## Build a middle path of a pipe-like shape. + # The path shape can be a wire or an edge. + # @param theShape It can be closed or unclosed pipe-like shell + # or a pipe-like solid. + # @param theBase1, theBase2 Two bases of the supposed pipe. This + # should be wires or faces of theShape. + # @note It is not assumed that exact or approximate copy of theShape + # can be obtained by applying existing Pipe operation on the + # resulting "Path" wire taking theBase1 as the base - it is not + # always possible; though in some particular cases it might work + # it is not guaranteed. Thus, RestorePath function should not be + # considered as an exact reverse operation of the Pipe. + # @return New GEOM.GEOM_Object, containing an edge or wire that represent + # source pipe's "path". + # + # @ref tui_creation_pipe_path "Example" + def RestorePath (self, theShape, theBase1, theBase2): + """ + Build a middle path of a pipe-like shape. + The path shape can be a wire or an edge. + + Parameters: + theShape It can be closed or unclosed pipe-like shell + or a pipe-like solid. + theBase1, theBase2 Two bases of the supposed pipe. This + should be wires or faces of theShape. + + Returns: + New GEOM_Object, containing an edge or wire that represent + source pipe's path. + """ + anObj = self.PrimOp.RestorePath(theShape, theBase1, theBase2) + RaiseIfFailed("RestorePath", self.PrimOp) + return anObj + + ## Build a middle path of a pipe-like shape. + # The path shape can be a wire or an edge. + # @param theShape It can be closed or unclosed pipe-like shell + # or a pipe-like solid. + # @param listEdges1, listEdges2 Two bases of the supposed pipe. This + # should be lists of edges of theShape. + # @note It is not assumed that exact or approximate copy of theShape + # can be obtained by applying existing Pipe operation on the + # resulting "Path" wire taking theBase1 as the base - it is not + # always possible; though in some particular cases it might work + # it is not guaranteed. Thus, RestorePath function should not be + # considered as an exact reverse operation of the Pipe. + # @return New GEOM.GEOM_Object, containing an edge or wire that represent + # source pipe's "path". + # + # @ref tui_creation_pipe_path "Example" + def RestorePathEdges (self, theShape, listEdges1, listEdges2): + """ + Build a middle path of a pipe-like shape. + The path shape can be a wire or an edge. + + Parameters: + theShape It can be closed or unclosed pipe-like shell + or a pipe-like solid. + listEdges1, listEdges2 Two bases of the supposed pipe. This + should be lists of edges of theShape. + + Returns: + New GEOM_Object, containing an edge or wire that represent + source pipe's path. + """ + anObj = self.PrimOp.RestorePathEdges(theShape, listEdges1, listEdges2) + RaiseIfFailed("RestorePath", self.PrimOp) + return anObj + # end of l3_complex ## @} diff --git a/src/GenerationGUI/GenerationGUI.cxx b/src/GenerationGUI/GenerationGUI.cxx index b341a92b0..3f94071ec 100644 --- a/src/GenerationGUI/GenerationGUI.cxx +++ b/src/GenerationGUI/GenerationGUI.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GenerationGUI.cxx // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #include "GenerationGUI.h" #include @@ -36,6 +35,7 @@ #include "GenerationGUI_RevolDlg.h" // Method REVOL #include "GenerationGUI_FillingDlg.h" // Method FILLING #include "GenerationGUI_PipeDlg.h" // Method PIPE +#include "GenerationGUI_PipePathDlg.h" // Method RESTORE PATH //======================================================================= // function : GenerationGUI() @@ -73,6 +73,7 @@ bool GenerationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case GEOMOp::OpRevolution: aDlg = new GenerationGUI_RevolDlg ( getGeometryGUI(), parent ); break; case GEOMOp::OpFilling: aDlg = new GenerationGUI_FillingDlg ( getGeometryGUI(), parent ); break; case GEOMOp::OpPipe: aDlg = new GenerationGUI_PipeDlg ( getGeometryGUI(), parent ); break; + case GEOMOp::OpPipePath: aDlg = new GenerationGUI_PipePathDlg( getGeometryGUI(), parent ); break; default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } diff --git a/src/GenerationGUI/GenerationGUI_PipePathDlg.cxx b/src/GenerationGUI/GenerationGUI_PipePathDlg.cxx new file mode 100644 index 000000000..b2d2d8d6b --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PipePathDlg.cxx @@ -0,0 +1,392 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : GenerationGUI_PipePathDlg.cxx + +#include "GenerationGUI_PipePathDlg.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +//================================================================================= +// class : GenerationGUI_PipePathDlg() +// purpose : Constructs a GenerationGUI_PipePathDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GenerationGUI_PipePathDlg::GenerationGUI_PipePathDlg (GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl) +{ + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPE_PATH"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_PIPE_PATH_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_PIPE_PATH")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->close(); + + GroupPoints = new DlgRef_3Sel1Check(centralWidget()); + + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_PIPE_LIKE_SHAPE")); + GroupPoints->TextLabel2->setText(tr("GEOM_PIPE_BASE1_OBJECT")); + GroupPoints->TextLabel3->setText(tr("GEOM_PIPE_BASE2_OBJECT")); + GroupPoints->PushButton1->setIcon(image1); + GroupPoints->PushButton2->setIcon(image1); + GroupPoints->PushButton3->setIcon(image1); + GroupPoints->CheckButton1->setText(tr("GEOM_SELECT_UNPUBLISHED_EDGES")); + + QVBoxLayout* layout = new QVBoxLayout (centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(GroupPoints); + /***************************************************************/ + + setHelpFileName("create_pipe_path_page.html"); + + // Initialisation + Init(); +} + +//================================================================================= +// function : ~GenerationGUI_PipePathDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GenerationGUI_PipePathDlg::~GenerationGUI_PipePathDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GenerationGUI_PipePathDlg::Init() +{ + // init variables + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); + GroupPoints->LineEdit3->setReadOnly(true); + + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); + GroupPoints->LineEdit3->setText(""); + + myShape.nullify(); + + GroupPoints->CheckButton1->setEnabled(false); + + showOnlyPreviewControl(); + + // signals and slots connections + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked())); + + initName(tr("GEOM_PIPE_PATH")); + + updateGeometry(); + resize(100,100); + + GroupPoints->PushButton1->click(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : SelectionBittonClicked() +// purpose : Selection type Radio button management +//================================================================================= +void GenerationGUI_PipePathDlg::SelectionTypeButtonClicked() +{ + globalSelection(); + if (GroupPoints->CheckButton1->isChecked()) { + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else { + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_FACE); + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection(aMap); + } + processPreview(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GenerationGUI_PipePathDlg::ClickOnOk() +{ + setIsApplyAndClose(true); + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool GenerationGUI_PipePathDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + // activate selection and connect selection manager + GroupPoints->PushButton1->click(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection is changed or on dialog initialization or activation +//================================================================================= +void GenerationGUI_PipePathDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + QList types; + types << TopAbs_SOLID << TopAbs_SHELL << TopAbs_FACE; + myShape = getSelected(types); + if (myShape) { + QString aName = GEOMBase::GetName(myShape.get()); + myEditCurrentArgument->setText(aName); + if (myBase1Objects.isEmpty()) + GroupPoints->PushButton2->click(); + else if (myBase2Objects.isEmpty()) + GroupPoints->PushButton3->click(); + } + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myBase1Objects.clear(); + QList objects = getSelected(TopAbs_SHAPE, -1); + for (int i = 0; i < objects.count(); i++) { + GEOM::shape_type stype = objects[i]->GetMaxShapeType(); + if (GEOM::FACE <= stype && stype <= GEOM::EDGE) + myBase1Objects << objects[i]; + } + int nbObj = myBase1Objects.count(); + if (nbObj) { + QString aName = + nbObj > 1 ? QString("%1_objects").arg(nbObj) : GEOMBase::GetName(myBase1Objects[0].get()); + myEditCurrentArgument->setText(aName); + } + } + else if (myEditCurrentArgument == GroupPoints->LineEdit3) { + myBase2Objects.clear(); + QList objects = getSelected(TopAbs_SHAPE, -1); + for (int i = 0; i < objects.count(); i++) { + GEOM::shape_type stype = objects[i]->GetMaxShapeType(); + if (GEOM::FACE <= stype && stype <= GEOM::EDGE) + myBase2Objects << objects[i]; + } + int nbObj = myBase2Objects.count(); + if (nbObj) { + QString aName = + nbObj > 1 ? QString("%1_objects").arg(nbObj) : GEOMBase::GetName(myBase2Objects[0].get()); + myEditCurrentArgument->setText(aName); + } + } + + processPreview(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GenerationGUI_PipePathDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + + globalSelection(GEOM_ALLSHAPES); + + GroupPoints->PushButton1->setDown(false); + GroupPoints->PushButton2->setDown(false); + GroupPoints->PushButton3->setDown(false); + GroupPoints->LineEdit1->setEnabled(false); + GroupPoints->LineEdit2->setEnabled(false); + GroupPoints->LineEdit3->setEnabled(false); + + if (send == GroupPoints->PushButton1) { + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->CheckButton1->setEnabled(false); + } + else if (send == GroupPoints->PushButton2) { + myEditCurrentArgument = GroupPoints->LineEdit2; + + if (GroupPoints->CheckButton1->isChecked()) { + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else { + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_FACE); + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection(aMap); + } + GroupPoints->CheckButton1->setEnabled(true); + } + else if (send == GroupPoints->PushButton3) { + myEditCurrentArgument = GroupPoints->LineEdit3; + + if (GroupPoints->CheckButton1->isChecked()) { + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else { + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_FACE); + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection(aMap); + } + GroupPoints->CheckButton1->setEnabled(true); + } + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); + + // seems we need it only to avoid preview disappearing, caused by selection mode change + processPreview(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GenerationGUI_PipePathDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + GroupPoints->PushButton1->click(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GenerationGUI_PipePathDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr GenerationGUI_PipePathDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool GenerationGUI_PipePathDlg::isValid (QString&) +{ + bool ok = myShape && !myBase1Objects.isEmpty() && !myBase2Objects.isEmpty(); + return ok; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool GenerationGUI_PipePathDlg::execute (ObjectList& objects) +{ + GEOM::ListOfGO_var aBase1 = new GEOM::ListOfGO(); + GEOM::ListOfGO_var aBase2 = new GEOM::ListOfGO(); + + aBase1->length(myBase1Objects.count()); + aBase2->length(myBase2Objects.count()); + + int i; + for (i = 0; i < myBase1Objects.count(); i++) + aBase1[i] = myBase1Objects[i].copy(); + for (i = 0; i < myBase2Objects.count(); i++) + aBase2[i] = myBase2Objects[i].copy(); + + GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); + GEOM::GEOM_Object_var anObj = anOper->RestorePathEdges(myShape.get(), aBase1.in(), aBase2.in()); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return true; +} + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void GenerationGUI_PipePathDlg::addSubshapesToStudy() +{ + int i; + for (i = 0; i < myBase1Objects.count(); i++) + GEOMBase::PublishSubObject(myBase1Objects[i].get()); + for (i = 0; i < myBase2Objects.count(); i++) + GEOMBase::PublishSubObject(myBase2Objects[i].get()); +} diff --git a/src/GenerationGUI/GenerationGUI_PipePathDlg.h b/src/GenerationGUI/GenerationGUI_PipePathDlg.h new file mode 100644 index 000000000..2c900bbc3 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PipePathDlg.h @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : GenerationGUI_PipePathDlg.h + +#ifndef GENERATIONGUI_PIPEPATHDLG_H +#define GENERATIONGUI_PIPEPATHDLG_H + +#include "GEOMBase_Skeleton.h" +#include "GEOM_GenericObjPtr.h" + +class DlgRef_3Sel1Check; + +//================================================================================= +// class : GenerationGUI_PipePathDlg +// purpose : +//================================================================================= +class GenerationGUI_PipePathDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + GenerationGUI_PipePathDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0); + ~GenerationGUI_PipePathDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual void addSubshapesToStudy(); + +private: + void Init(); + void enterEvent (QEvent*); + +private: + GEOM::GeomObjPtr myShape; /* Pipe-like shape */ + QList myBase1Objects; /* Base 1 edges / wire / face */ + QList myBase2Objects; /* Base 2 edges / wire / face */ + + DlgRef_3Sel1Check* GroupPoints; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void SelectionTypeButtonClicked(); +}; + +#endif // GENERATIONGUI_PIPEPATHDLG_H diff --git a/src/GenerationGUI/Makefile.am b/src/GenerationGUI/Makefile.am index 35afde04d..cda0fad02 100644 --- a/src/GenerationGUI/Makefile.am +++ b/src/GenerationGUI/Makefile.am @@ -15,13 +15,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # GEOM GENERATIONGUI : # File : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : GenerationGUI -# + include $(top_srcdir)/adm_local/unix/make_common_starter.am # Libraries targets @@ -33,7 +32,8 @@ salomeinclude_HEADERS = \ GenerationGUI_PrismDlg.h \ GenerationGUI_RevolDlg.h \ GenerationGUI_FillingDlg.h \ - GenerationGUI_PipeDlg.h + GenerationGUI_PipeDlg.h \ + GenerationGUI_PipePathDlg.h dist_libGenerationGUI_la_SOURCES = \ GenerationGUI.h \ @@ -41,18 +41,21 @@ dist_libGenerationGUI_la_SOURCES = \ GenerationGUI_RevolDlg.h \ GenerationGUI_FillingDlg.h \ GenerationGUI_PipeDlg.h \ + GenerationGUI_PipePathDlg.h \ \ GenerationGUI.cxx \ GenerationGUI_PrismDlg.cxx \ GenerationGUI_RevolDlg.cxx \ GenerationGUI_FillingDlg.cxx \ - GenerationGUI_PipeDlg.cxx + GenerationGUI_PipeDlg.cxx \ + GenerationGUI_PipePathDlg.cxx MOC_FILES = \ GenerationGUI_PrismDlg_moc.cxx \ GenerationGUI_RevolDlg_moc.cxx \ GenerationGUI_FillingDlg_moc.cxx \ - GenerationGUI_PipeDlg_moc.cxx + GenerationGUI_PipeDlg_moc.cxx \ + GenerationGUI_PipePathDlg_moc.cxx nodist_libGenerationGUI_la_SOURCES = \ $(MOC_FILES)