<li>\subpage create_filling_page "Create a surface" from a set of edges.</li>
<li>\subpage create_extrusion_alongpath_page "Extrude an object along a path",
creating a more complex trajectory object.</li>
-
+<li>\subpage create_pipe_path_page "Restore Path" of a pipe-like shape.</li>
</ul>
*/
--- /dev/null
+/*!
+
+\page create_pipe_path_page Restore Path
+
+To generate a \b Path in the <b>Main Menu</b> select <b>New Entity - > Generation - > Restore Path</b>
+
+\image html pipe_path_dlg.png
+
+\n To obtain a \b Path of a pipe-like shape, you should define the
+<b>Pipe-like shell or solid</b> and two pipe \b Bases, each of them can
+be set as a wire, a face or a list of edges.<br>
+\n <b>Select unpublished edges</b> checkbox - if checked, allows
+selection of edges in the viewer, that are not published in the Object
+Browser.<br>
+\n The \b Result of the operation will be a GEOM_Object (edge or wire).<br>
+
+\n <b>Advanced options</b>:
+<ul>
+<li>\ref preview_anchor "Preview"</li>
+</ul><br>
+
+\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.<br>
+
+\n <b>Example:</b>
+
+\image html pipe_path.png "Path (red) between two faces (green)"
+
+\n <b>TUI Command:</b> <em>geompy.RestorePath(aShape, aBase1, aBase2)</em>
+\n <b>Arguments:</b> 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 <b>TUI Command:</b> <em>geompy.RestorePathEdges(aShape, listEdges1, listEdges2)</em>
+\n <b>Arguments:</b> 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 <b>TUI Scripts</b> provide you with useful examples of creation of
+\ref tui_creation_pipe_path "Complex Geometric Objects".
+
+*/
spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)
\endcode
-<br><h2>Creation of Tangent Plane On Face</h2>
+
+\anchor tui_creation_pipe_path
+<br><h2>Creation of a Middle Path</h2>
+
\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
+<br><h2>Creation of Tangent Plane On Face</h2>
+\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
*/
in double theTrimSize);
};
+ /*!
+ * \brief Interface for shapes transforming.
+ *
+ * Translation, rotation, scaling, mirroring, offset, projection, recomputing.
+ */
interface GEOM_ITransformOperations : GEOM_IOperations
{
/*!
* \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,
GEOM_Object RecomputeObject (in GEOM_Object theObject);
};
- // # GEOM_I3DPrimOperations:
/*!
* \brief Interface for 3D primitives creation
*
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:
*
<source>ICON_DLG_PARTITION_PLANE</source>
<translation>partitionplane.png</translation>
</message>
+ <message>
+ <source>ICON_DLG_PIPE_PATH</source>
+ <translation>pipe.png</translation>
+ </message>
<message>
<source>ICON_DLG_PIPE</source>
<translation>pipe.png</translation>
<source>ICO_PIPE</source>
<translation>pipe.png</translation>
</message>
+ <message>
+ <source>ICO_PIPE_PATH</source>
+ <translation>pipe.png</translation>
+ </message>
<message>
<source>ICO_PLANE</source>
<translation>plane.png</translation>
<source>GEOM_PIPE_TITLE</source>
<translation>Pipe Construction</translation>
</message>
+ <message>
+ <source>GEOM_PIPE_PATH</source>
+ <translation>Path</translation>
+ </message>
+ <message>
+ <source>GEOM_PIPE_PATH_TITLE</source>
+ <translation>Restore Path</translation>
+ </message>
+ <message>
+ <source>GEOM_PIPE_LIKE_SHAPE</source>
+ <translation>Pipe-like shell or solid</translation>
+ </message>
+ <message>
+ <source>GEOM_PIPE_BASE1_OBJECT</source>
+ <translation>First base face/wire/edges</translation>
+ </message>
+ <message>
+ <source>GEOM_PIPE_BASE2_OBJECT</source>
+ <translation>Last base face/wire/edges</translation>
+ </message>
<message>
<source>GEOM_PROFILE</source>
<translation>Profile</translation>
<source>MEN_PIPE</source>
<translation>Extrusion Along Path</translation>
</message>
+ <message>
+ <source>MEN_PIPE_PATH</source>
+ <translation>Restore Path</translation>
+ </message>
<message>
<source>MEN_PLANE</source>
<translation>Plane</translation>
<source>STB_PIPE</source>
<translation>Create a shape by extrusion along a path</translation>
</message>
+ <message>
+ <source>STB_PIPE_PATH</source>
+ <translation>Restore path from a pipe-like shape</translation>
+ </message>
<message>
<source>STB_PLANE</source>
<translation>Create a plane</translation>
<source>TOP_PIPE</source>
<translation>Extrusion along path</translation>
</message>
+ <message>
+ <source>TOP_PIPE_PATH</source>
+ <translation>Restore path</translation>
+ </message>
<message>
<source>TOP_PLANE</source>
<translation>Create a plane</translation>
#include <GEOM_version.h>
-
#include "GEOMImpl_Types.hxx"
extern "C" {
bool GeometryGUI::InitGeomGen()
{
GeometryGUI aGG;
- if( CORBA::is_nil( myComponentGeom ) ) return false;
+ if ( CORBA::is_nil( myComponentGeom ) ) return false;
return true;
}
return aDSStudy._retn();
}
-void GeometryGUI::Modified( bool theIsUpdateActions )
+void GeometryGUI::Modified (bool theIsUpdateActions)
{
- if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
- if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
+ if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
+ if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
appStudy->Modified();
- if( theIsUpdateActions )
+ if ( theIsUpdateActions )
app->updateActions();
}
}
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<OCCViewer_ViewWindow*>( 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<SVTK_ViewWindow*>( window );
if ( vw ) {
vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
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
// 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() );
}
}
}
void GeometryGUI::createOriginAndBaseVectors()
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( 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 );
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" );
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 );
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 );
*/
// ---- create toolbars --------------------------
-
+
int basicTbId = createTool( tr( "TOOL_BASIC" ) );
createTool( GEOMOp::OpPoint, basicTbId );
createTool( GEOMOp::OpLine, basicTbId );
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 );
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 );
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 );
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 );
#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 @@//
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
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 );
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 );
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 );
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));
// 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
// 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<SalomeApp_Study*>( 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();
}
}
return true;
}
-
//=======================================================================
// function : GeometryGUI::deactivateModule()
// purpose : Called when GEOM module is deactivated
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 ) );
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 );
setPreferenceProperty( dispmode, "strings", aModesList );
setPreferenceProperty( dispmode, "indexes", anIndexesList );
-
// Set property for top level display mode
QStringList aTopModesList;
aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
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 );
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<SalomeApp_Study*>( getApp()->activeStudy() ) );
return myDisplayer;
}
{
myLocalSelectionMode = mode;
}
+
int GeometryGUI::getLocalSelectionMode() const
{
return myLocalSelectionMode;
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();
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<QColor>();
QString colorStr = QString::number(c.red()/255.);
colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
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<Standard_Boolean>();
- if (val == Standard_True)
- ip->setParameter(entry, param, "1");
- }
+ Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
+ 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)
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<SUIT_ViewManager*> lst = getApp()->viewManagers();
displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
}
}
-
} // for entries iterator
// update all VTK and OCC views
/*!
\brief Return action by id
\param id identifier of the action
- \return action
+ \return action
*/
QAction* GeometryGUI::getAction(const int id) {
return action(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<SalomeApp_Study*>( app->activeStudy() ) : 0;
+ SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(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<SalomeApp_Study*>( 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();
}
return result;
}
-
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
// 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 )
#include <GEOMImpl_CylinderDriver.hxx>
#include <GEOMImpl_PrismDriver.hxx>
#include <GEOMImpl_PipeDriver.hxx>
+#include <GEOMImpl_PipePathDriver.hxx>
#include <GEOMImpl_ThruSectionsDriver.hxx>
#include <GEOMImpl_RevolutionDriver.hxx>
#include <GEOMImpl_ShapeDriver.hxx>
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());
// 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 <Standard_Stream.hxx>
#include <GEOMImpl_TorusDriver.hxx>
#include <GEOMImpl_PrismDriver.hxx>
#include <GEOMImpl_PipeDriver.hxx>
+#include <GEOMImpl_PipePathDriver.hxx>
#include <GEOMImpl_RevolutionDriver.hxx>
#include <GEOMImpl_ShapeDriver.hxx>
#include <GEOMImpl_FillingDriver.hxx>
#include <GEOMImpl_IPipeDiffSect.hxx>
#include <GEOMImpl_IPipeShellSect.hxx>
#include <GEOMImpl_IPipeBiNormal.hxx>
+#include <GEOMImpl_IPipePath.hxx>
#include <Precision.hxx>
}
-
//=============================================================================
/*!
* MakePipeBiNormalAlongVector
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;
+}
// 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_
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
--- /dev/null
+// 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
#include <GEOMImpl_IPipeShellSect.hxx>
#include <GEOMImpl_IPipeBiNormal.hxx>
#include <GEOMImpl_IPipe.hxx>
+#include <GEOMImpl_IPipePath.hxx>
#include <GEOMImpl_GlueDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepCheck_Analyzer.hxx>
+#include <BRepGProp.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
-#include <GProp_GProps.hxx>
-#include <BRepGProp.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_Copy.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <GProp_GProps.hxx>
+
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_Interpolate.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Precision.hxx>
+
#include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Standard_ConstructionError.hxx>
//=======================================================================
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;
}
//function : Execute
//purpose :
//=======================================================================
-Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const
+Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const
{
- //cout<<"PipeDriver::Execute"<<endl;
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
- GEOMImpl_IPipe* aCI= 0;
Standard_Integer aType = aFunction->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;
--- /dev/null
+// 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 <Standard_Stream.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <GEOMImpl_PipePathDriver.hxx>
+
+#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMImpl_ShapeDriver.hxx>
+#include <GEOMImpl_IPipePath.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOM_Function.hxx>
+
+#include <ShapeAnalysis_FreeBounds.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Shell.hxx>
+#include <ShapeFix_Shape.hxx>
+#include <ShapeFix_ShapeTolerance.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_Sewing.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <BRepGProp.hxx>
+#include <BRepOffsetAPI_MakePipe.hxx>
+#include <BRepOffsetAPI_MakePipeShell.hxx>
+
+#if OCC_VERSION_LARGE > 0x06050300
+#include <BRepOffsetAPI_MiddlePath.hxx>
+#endif
+
+#include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <GProp_GProps.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_Interpolate.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_BezierSurface.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Conic.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <GeomFill_BSplineCurves.hxx>
+#include <GeomConvert_ApproxCurve.hxx>
+#include <GeomConvert.hxx>
+
+#include <TColgp_SequenceOfPnt.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <TColgp_Array2OfPnt.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include <Precision.hxx>
+
+#include <Standard_NullObject.hxx>
+#include <Standard_TypeMismatch.hxx>
+#include <Standard_ConstructionError.hxx>
+
+#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;
+}
--- /dev/null
+// 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 <TColStd_SequenceOfExtendedString.hxx>
+#endif
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#endif
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_GUID_HeaderFile
+#include <Standard_GUID.hxx>
+#endif
+
+#ifndef _Handle_TFunction_Driver_HeaderFile
+#include <Handle_TFunction_Driver.hxx>
+#endif
+
+
+class Standard_Transient;
+class Handle_Standard_Type;
+class Handle(TFunction_Driver);
+class GEOMImpl_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 <TFunction_Driver.hxx>
+#endif
+#ifndef _TFunction_Logbook_HeaderFile
+#include <TFunction_Logbook.hxx>
+#endif
+#ifndef _Standard_CString_HeaderFile
+#include <Standard_CString.hxx>
+#endif
+
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+
+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
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 <prec> 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();
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 <prec> 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)
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
class TColStd_SequenceOfExtendedString;
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
//
#define GEOM_EXTRUDED_BOSS 47
+#define GEOM_PIPE_PATH 48
+
//GEOM_Function types
#define COPY_WITH_REF 1
#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
GEOMImpl_ITorus.hxx \
GEOMImpl_IPrism.hxx \
GEOMImpl_IPipe.hxx \
+ GEOMImpl_IPipePath.hxx \
GEOMImpl_IRevolution.hxx \
GEOMImpl_IMeasure.hxx \
GEOMImpl_IShapes.hxx \
GEOMImpl_TorusDriver.hxx \
GEOMImpl_PrismDriver.hxx \
GEOMImpl_PipeDriver.hxx \
+ GEOMImpl_PipePathDriver.hxx \
GEOMImpl_ThruSectionsDriver.hxx \
GEOMImpl_RevolutionDriver.hxx \
GEOMImpl_ShapeDriver.hxx \
GEOMImpl_TorusDriver.cxx \
GEOMImpl_PrismDriver.cxx \
GEOMImpl_PipeDriver.cxx \
+ GEOMImpl_PipePathDriver.cxx \
GEOMImpl_ThruSectionsDriver.cxx \
GEOMImpl_RevolutionDriver.cxx \
GEOMImpl_ShapeDriver.cxx \
// 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 <Standard_Stream.hxx>
return GetObject(anObject);
}
-
//=============================================================================
/*!
* 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);
+}
// 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
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(); }
};
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
## @}
// 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 <GeometryGUI.h>
#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()
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;
}
--- /dev/null
+// 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 <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
+#include <GEOMImpl_Types.hxx>
+
+//=================================================================================
+// 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<TopAbs_ShapeEnum> 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<GEOM::GeomObjPtr> 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<GEOM::GeomObjPtr> 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());
+}
--- /dev/null
+// 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<GEOM::GeomObjPtr> myBase1Objects; /* Base 1 edges / wire / face */
+ QList<GEOM::GeomObjPtr> 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
# 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
GenerationGUI_PrismDlg.h \
GenerationGUI_RevolDlg.h \
GenerationGUI_FillingDlg.h \
- GenerationGUI_PipeDlg.h
+ GenerationGUI_PipeDlg.h \
+ GenerationGUI_PipePathDlg.h
dist_libGenerationGUI_la_SOURCES = \
GenerationGUI.h \
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)