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
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.
\n <b>"Sketch Validation"</b> button applies the whole wire.
\n <b>"Sketch Closure"</b> button connects the first and the last points closing
the contour and applies the closed wire.
\n <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.
To make a closed wire using the TUI command, the first and the last point shoul
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>
</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>
\image html neo-scetcher1.png

View File

@ -67,8 +67,11 @@ private:
// TRUE to construct a modal dialog.
//=================================================================================
EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
bool modal, Qt::WindowFlags 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 image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
@ -169,6 +172,7 @@ void EntityGUI_3DSketcherDlg::Init()
initName( tr( "GEOM_3DSKETCHER" ) );
UpdateButtonsState();
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
//=================================================================================
@ -212,16 +216,14 @@ void EntityGUI_3DSketcherDlg::TypeClicked()
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
{
Locker lock( myOK );
double x, y, z;
GetCurrentPoints(x, y, z);
myPointsList.append(x);
myPointsList.append(y);
myPointsList.append(z);
/*if (myRedoList.size() >= 2) { // Remove this positions from Redo List
for (int i = 0; i <= 2; i++)
myRedoList.removeFirst();
}*/
myRedoList.clear();
if ( GroupType->RadioButton2->isChecked() ) {
@ -229,8 +231,8 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
Group3Spin->SpinBox_DY->setValue( 0.0 );
Group3Spin->SpinBox_DZ->setValue( 0.0 );
}
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
UpdateButtonsState();
displayPreview();
}
//=================================================================================
@ -263,7 +265,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
myPointsList.removeLast();
UpdateButtonsState();
displayPreview();
GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
}
}
@ -283,7 +285,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
myRedoList.removeLast();
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() ) );
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 )
{
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 )
{
int nbPoints = myPointsList.count()/3;
if ( myOK )
return nbPoints >= 2;
else
return nbPoints >= 1;
return true;
}
//=================================================================================
@ -428,10 +426,10 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
{
GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
if (myOK)
aCoordsArray->length(myPointsList.size());
else
if (!myOK || myPointsList.size() == 0)
aCoordsArray->length(myPointsList.size()+3);
else
aCoordsArray->length(myPointsList.size());
int i = 0;
QList<double>::const_iterator it;
@ -440,16 +438,15 @@ bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
i++;
}
if (!myOK) {
if (!myOK || myPointsList.size() == 0) {
double x, y, z;
GetCurrentPoints(x, y, z);
aCoordsArray[i] = x;
aCoordsArray[i+1] = y;
aCoordsArray[i+2] = z;
}
}
GEOM::GEOM_Object_var anObj =
GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->Make3DSketcher( aCoordsArray );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
@ -482,24 +479,6 @@ void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double 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()
// purpose :
@ -564,3 +543,87 @@ void EntityGUI_3DSketcherDlg::GetCurrentPoints(double& x, double& y, double& z)
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
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();
protected:
@ -64,7 +64,19 @@ protected:
private:
void Init();
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:
QList<double> myPointsList;
QList<double> myRedoList;
@ -73,6 +85,8 @@ private:
DlgRef_3Radio* GroupType;
bool myOK;
double myLineWidth;
GeometryGUI* myGeometryGUI;
private slots:
void ClickOnOk();

View File

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

View File

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