0020021: EDF 799 GEOM: Creation of 3D wired tubing

This commit is contained in:
dmv 2009-01-20 11:01:52 +00:00
parent 5143ff4b1f
commit 9c83a20dd8
6 changed files with 143 additions and 54 deletions

View File

@ -11,9 +11,8 @@ To create a 3D Sketch, select in the main menu <em>New Entity -> 3D Sketch</em>.
The position of each coordinates can be defined by absolute coordinates X, Y, Z or The position of each coordinates can be defined by absolute coordinates X, Y, Z or
by relative coordinates DX, DY, DZ with respect to the previous Applied point. by relative coordinates DX, DY, DZ with respect to the previous Applied point.
Type of coordinates can be selected by the <b>Coordinates Type</b> radio buttons. Type of coordinates can be selected by the <b>Coordinates Type</b> radio buttons.
\n <b>"Sketch Validation"</b> button applies the whole wire. \n <b>"Sketch Validation"</b> button applies the wire, only red part will be built by "Sketch Validation".
\n <b>"Sketch Closure"</b> button connects the first and the last points closing \n <b>"Sketch Closure"</b> will close the Sketch by straight line from last red part and apply it.
the contour and applies the closed wire.
To make a closed wire using the TUI command, the first and the last point shoul To make a closed wire using the TUI command, the first and the last point shoul
have the same coordinates. have the same coordinates.

View File

@ -52,6 +52,11 @@ is predefined and is equal to 90 degrees);</li>
<li>Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius and angle).</li> <li>Parameters of an element (for segment : length or target X or Y coordinate value, for arc : radius and angle).</li>
</ol> </ol>
\b Buttons:
<b>"Sketch Validation"</b> button applies the wire, only red part will be built by "Sketch Validation".
\n <b>"Sketch Closure"</b> will close the Sketch by straight line from last red part and apply it.
\n <b>Dialog Box:</b> \n <b>Dialog Box:</b>
\image html neo-scetcher1.png \image html neo-scetcher1.png

View File

@ -67,8 +67,11 @@ private:
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent, EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl,
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) const double lineWidth )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
myGeometryGUI( theGeometryGUI ),
myLineWidth( lineWidth )
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) ); QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
@ -169,6 +172,7 @@ void EntityGUI_3DSketcherDlg::Init()
initName( tr( "GEOM_3DSKETCHER" ) ); initName( tr( "GEOM_3DSKETCHER" ) );
UpdateButtonsState(); UpdateButtonsState();
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
//================================================================================= //=================================================================================
@ -212,16 +216,14 @@ void EntityGUI_3DSketcherDlg::TypeClicked()
//================================================================================= //=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnAddPoint() void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
{ {
Locker lock( myOK );
double x, y, z; double x, y, z;
GetCurrentPoints(x, y, z); GetCurrentPoints(x, y, z);
myPointsList.append(x); myPointsList.append(x);
myPointsList.append(y); myPointsList.append(y);
myPointsList.append(z); myPointsList.append(z);
/*if (myRedoList.size() >= 2) { // Remove this positions from Redo List
for (int i = 0; i <= 2; i++)
myRedoList.removeFirst();
}*/
myRedoList.clear(); myRedoList.clear();
if ( GroupType->RadioButton2->isChecked() ) { if ( GroupType->RadioButton2->isChecked() ) {
@ -229,8 +231,8 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
Group3Spin->SpinBox_DY->setValue( 0.0 ); Group3Spin->SpinBox_DY->setValue( 0.0 );
Group3Spin->SpinBox_DZ->setValue( 0.0 ); Group3Spin->SpinBox_DZ->setValue( 0.0 );
} }
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
UpdateButtonsState(); UpdateButtonsState();
displayPreview();
} }
//================================================================================= //=================================================================================
@ -263,7 +265,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
myPointsList.removeLast(); myPointsList.removeLast();
UpdateButtonsState(); UpdateButtonsState();
displayPreview(); GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
} }
@ -283,7 +285,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
myRedoList.removeLast(); myRedoList.removeLast();
UpdateButtonsState(); UpdateButtonsState();
displayPreview(); GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
} }
@ -346,7 +348,7 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
} }
} }
} }
displayPreview(); GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
//================================================================================= //=================================================================================
@ -376,7 +378,7 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
displayPreview(); GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
@ -386,7 +388,7 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
//================================================================================= //=================================================================================
void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue ) void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
{ {
displayPreview(); GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
} }
//================================================================================= //=================================================================================
@ -414,11 +416,7 @@ GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
//================================================================================= //=================================================================================
bool EntityGUI_3DSketcherDlg::isValid( QString& msg ) bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
{ {
int nbPoints = myPointsList.count()/3; return true;
if ( myOK )
return nbPoints >= 2;
else
return nbPoints >= 1;
} }
//================================================================================= //=================================================================================
@ -428,10 +426,10 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects ) bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
{ {
GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble; GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
if (myOK) if (!myOK || myPointsList.size() == 0)
aCoordsArray->length(myPointsList.size());
else
aCoordsArray->length(myPointsList.size()+3); aCoordsArray->length(myPointsList.size()+3);
else
aCoordsArray->length(myPointsList.size());
int i = 0; int i = 0;
QList<double>::const_iterator it; QList<double>::const_iterator it;
@ -440,7 +438,7 @@ bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
i++; i++;
} }
if (!myOK) { if (!myOK || myPointsList.size() == 0) {
double x, y, z; double x, y, z;
GetCurrentPoints(x, y, z); GetCurrentPoints(x, y, z);
aCoordsArray[i] = x; aCoordsArray[i] = x;
@ -448,8 +446,7 @@ bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
aCoordsArray[i+2] = z; aCoordsArray[i+2] = z;
} }
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );
@ -482,24 +479,6 @@ void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step )
Group3Spin->SpinBox_DZ->setSingleStep(step); Group3Spin->SpinBox_DZ->setSingleStep(step);
} }
//=================================================================================
// function : isSameAsPrevious()
// purpose : Compare Last point in the list with current selected point
//=================================================================================
/*bool EntityGUI_3DSketcherDlg::isSameAsPrevious() // Not used this time
{
double curX, curY, curZ;
double lastX, lastY, lastZ;
GetCurrentPoints(curX, curY, curZ);
GetLastPoints(lastX, lastY, lastZ);
if ( abs(lastX - curX) < Precision::Confusion() &&
abs(lastY - curY) < Precision::Confusion() &&
abs(lastZ - curZ) < Precision::Confusion() )
return true;
return false;
}*/
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
@ -564,3 +543,87 @@ void EntityGUI_3DSketcherDlg::GetCurrentPoints(double& x, double& y, double& z)
z += Group3Spin->SpinBox_DZ->value(); z += Group3Spin->SpinBox_DZ->value();
} }
} }
//================================================================
// Function : displayPreview
// Purpose : Method for displaying preview of resulting shape
// Redefined from GEOMBase_Helper.
//================================================================
void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
const bool append,
const bool activate,
const bool update,
const double lineWidth,
const int displayMode,
const int color )
{
// Set color for preview shape
getDisplayer()->SetColor( Quantity_NOC_RED );
// set width of displayed shape
getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
// Disable activation of selection
getDisplayer()->SetToActivate( activate );
// Make a reference to GEOM_Object
CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
getDisplayer()->SetName( objStr.in() );
// Create wire from applayed object
TopoDS_Shape anApplyedWire, aLastSegment;
if ( !createShapes( object, anApplyedWire, aLastSegment ) )
return;
// Build prs
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
if ( aPrs != 0 && !aPrs->IsNull() )
GEOMBase_Helper::displayPreview( aPrs, append, update );
getDisplayer()->SetColor( Quantity_NOC_VIOLET );
aPrs = getDisplayer()->BuildPrs( aLastSegment );
if ( aPrs != 0 && !aPrs->IsNull() )
GEOMBase_Helper::displayPreview( aPrs, append, update );
getDisplayer()->UnsetName();
// Enable activation of displayed objects
getDisplayer()->SetToActivate( true );
}
//================================================================
// Function : createShapes
// Purpose : Create applyed wire, and last segment from entry object
//================================================================
bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
TopoDS_Shape& theApplyedWire,
TopoDS_Shape& theLastSegment )
{
TopoDS_Shape aShape;
if ( !GEOMBase::GetShape( theObject, aShape ) ||
aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
return false;
if ( myOK ) {
theApplyedWire = aShape;
return true;
}
BRepBuilderAPI_MakeWire aBuilder;
TopExp_Explorer anExp( aShape, TopAbs_EDGE );
while ( 1 ) {
TopoDS_Shape anEdge = anExp.Current();
anExp.Next();
if ( anExp.More() ) // i.e. non-last edge
aBuilder.Add( TopoDS::Edge( anEdge ) );
else {
theLastSegment = anEdge;
break;
}
}
if ( aBuilder.IsDone() )
theApplyedWire = aBuilder.Shape();
return true;
}

View File

@ -48,7 +48,7 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
Q_OBJECT Q_OBJECT
public: public:
EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 ); EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. );
~EntityGUI_3DSketcherDlg(); ~EntityGUI_3DSketcherDlg();
protected: protected:
@ -65,6 +65,18 @@ private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent( QEvent* );
virtual void displayPreview( GEOM::GEOM_Object_ptr,
const bool = false,
const bool = false,
const bool = true,
const double = -1,
const int = -1,
const int = -1);
bool createShapes( GEOM::GEOM_Object_ptr,
TopoDS_Shape&,
TopoDS_Shape& );
private: private:
QList<double> myPointsList; QList<double> myPointsList;
QList<double> myRedoList; QList<double> myRedoList;
@ -73,6 +85,8 @@ private:
DlgRef_3Radio* GroupType; DlgRef_3Radio* GroupType;
bool myOK; bool myOK;
double myLineWidth;
GeometryGUI* myGeometryGUI;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();

View File

@ -3614,7 +3614,7 @@ Please, select face, shell or solid and try again</translation>
</message> </message>
<message> <message>
<source>GEOM_PLANAR_FACE</source> <source>GEOM_PLANAR_FACE</source>
<translation>Planar face</translation> <translation>Planar Face</translation>
</message> </message>
<message> <message>
<source>GEOM_POLYGON</source> <source>GEOM_POLYGON</source>

View File

@ -29,6 +29,7 @@
// OCCT Includes // OCCT Includes
#include <BRepBuilderAPI_MakePolygon.hxx> #include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
@ -73,18 +74,25 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
BRepBuilderAPI_MakePolygon aMakePoly; BRepBuilderAPI_MakePolygon aMakePoly;
int anArrayLength = aCoordsArray->Length(); int anArrayLength = aCoordsArray->Length();
double x, y, z; double x, y, z;
gp_Pnt aPnt;
for (int i = 0; i <=(anArrayLength - 3); i+=3) { for (int i = 0; i <=(anArrayLength - 3); i+=3) {
x = aCoordsArray->Value(i+1); x = aCoordsArray->Value(i+1);
y = aCoordsArray->Value(i+2); y = aCoordsArray->Value(i+2);
z = aCoordsArray->Value(i+3); z = aCoordsArray->Value(i+3);
gp_Pnt aPnt = gp_Pnt(x, y, z); aPnt = gp_Pnt(x, y, z);
aMakePoly.Add(aPnt); aMakePoly.Add(aPnt);
} }
if ( anArrayLength == 3) { // Only Start Point
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
aShape = mkVertex.Shape();
}
else { // Make Wire
if (aCoordsArray->Value(1) == x && aCoordsArray->Value(2) == y && aCoordsArray->Value(3) == z) if (aCoordsArray->Value(1) == x && aCoordsArray->Value(2) == y && aCoordsArray->Value(3) == z)
aMakePoly.Close(); aMakePoly.Close();
if (aMakePoly.IsDone()) if (aMakePoly.IsDone())
aShape = aMakePoly.Wire(); aShape = aMakePoly.Wire();
}
if (aShape.IsNull()) return 0; if (aShape.IsNull()) return 0;