From: jfa Date: Fri, 14 Dec 2012 12:14:31 +0000 (+0000) Subject: Mantis issue 0021865: Adding tangency in Spline creation + Small repackaging X-Git-Tag: V6_main_FINAL~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e75612208c5c7308084985a0c3675ed2a0cdd7a;p=modules%2Fgeom.git Mantis issue 0021865: Adding tangency in Spline creation + Small repackaging --- diff --git a/configure.ac b/configure.ac index dcc973832..e249b1f5d 100644 --- a/configure.ac +++ b/configure.ac @@ -499,12 +499,14 @@ AC_OUTPUT([ \ src/DlgRef/Makefile \ src/EntityGUI/Makefile \ src/GEOM/Makefile \ + src/BlockFix/Makefile \ src/GEOMAlgo/Makefile \ src/GEOMBase/Makefile \ src/GEOMClient/Makefile \ src/GEOMFiltersSelection/Makefile \ src/Material/Makefile \ src/GEOMGUI/Makefile \ + src/GEOMUtils/Makefile \ src/GEOMImpl/Makefile \ src/GEOMToolsGUI/Makefile \ src/GEOM_I/Makefile \ diff --git a/doc/salome/gui/GEOM/images/curve4.png b/doc/salome/gui/GEOM/images/curve4.png index cbb60924d..2fe0db0ae 100644 Binary files a/doc/salome/gui/GEOM/images/curve4.png and b/doc/salome/gui/GEOM/images/curve4.png differ diff --git a/doc/salome/gui/GEOM/input/creating_curve.doc b/doc/salome/gui/GEOM/input/creating_curve.doc index 9c3371826..e70a6279c 100644 --- a/doc/salome/gui/GEOM/input/creating_curve.doc +++ b/doc/salome/gui/GEOM/input/creating_curve.doc @@ -70,10 +70,15 @@ closed edge.
  • If Reorder vertices taking into account distances is checked, the interpolation algorithm does not follow the order of vertices but searches for the closest vertex.
  • +
  • Tangents are two vectors, defining direction of curve at +its ends. Both or none vectors must be set. This option available only +if two above check boxes are not checked. +
  • \n TUI Command: geompy.MakeInterpol(ListOfShapes,isClosed,doReordering) +geompy.MakeInterpolWithTangents(ListOfShapes,Vector1,Vector2) Analytical Definition diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index f35c7935e..de18e7ee1 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2804,6 +2804,17 @@ module GEOM in boolean theIsClosed, in boolean theDoReordering); + /*! + * \brief Create B-Spline curve on the set of points. + * \param thePoints Sequence of points for the B-Spline curve. + * \param theFirstVec Vector object, defining the curve direction at its first point. + * \param theLastVec Vector object, defining the curve direction at its last point. + * \return New GEOM_Object, containing the created B-Spline curve. + */ + GEOM_Object MakeSplineInterpolWithTangents (in ListOfGO thePoints, + in GEOM_Object theFirstVec, + in GEOM_Object theLastVec); + /*! * \brief Creates a curve using the parametric definition of the basic points. * \param thexExpr parametric equation of the coordinates X. diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index b69c3660c..90488fa74 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -280,7 +280,6 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) qApp->processEvents(); updateGeometry(); resize( minimumSizeHint() ); - SelectionIntoArgument(); myEditCurrentArgument->setFocus(); globalSelection(); // close local contexts, if any @@ -289,7 +288,7 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - displayPreview(true); + SelectionIntoArgument(); } //================================================================================= diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index c964983ae..ffb3f7ebf 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_CurveDlg.cxx @@ -59,66 +58,101 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare bool modal, Qt::WindowFlags fl ) : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POLYLINE" ) ) ); - QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SPLINE" ) ) ); - QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BEZIER" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_POLYLINE"))); + QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SPLINE"))); + QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BEZIER"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle( tr( "GEOM_CURVE_TITLE" ) ); + setWindowTitle(tr("GEOM_CURVE_TITLE")); /***************************************************************/ - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image3 ); - mainFrame()->RadioButton3->setIcon( image2 ); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setIcon(image3); + mainFrame()->RadioButton3->setIcon(image2); - QGroupBox* creationModeCroup = new QGroupBox(this); - QButtonGroup* bg = new QButtonGroup(this); + // Creation mode + QGroupBox* creationModeGroup = new QGroupBox (this); + QButtonGroup* bg = new QButtonGroup (this); - creationModeCroup->setTitle( tr( "GEOM_CURVE_CRMODE" ) ); - QHBoxLayout * creationModeLayout = new QHBoxLayout(creationModeCroup); - myBySelectionBtn = new QRadioButton( tr( "GEOM_CURVE_SELECTION" ) ,creationModeCroup ); - myAnaliticalBtn = new QRadioButton( tr( "GEOM_CURVE_ANALITICAL" ) ,creationModeCroup ); + creationModeGroup->setTitle(tr("GEOM_CURVE_CRMODE")); + QHBoxLayout * creationModeLayout = new QHBoxLayout (creationModeGroup); + myBySelectionBtn = new QRadioButton (tr("GEOM_CURVE_SELECTION") ,creationModeGroup); + myAnaliticalBtn = new QRadioButton (tr("GEOM_CURVE_ANALITICAL") ,creationModeGroup); bg->addButton(myBySelectionBtn); bg->addButton(myAnaliticalBtn); - + creationModeLayout->addWidget(myBySelectionBtn); creationModeLayout->addWidget(myAnaliticalBtn); - GroupPoints = new DlgRef_1Sel3Check( centralWidget() ); - - GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) ); - GroupPoints->TextLabel1->setText( tr( "GEOM_POINTS" ) ); - GroupPoints->PushButton1->setIcon( image1 ); - GroupPoints->PushButton1->setDown( true ); - - GroupPoints->LineEdit1->setReadOnly( true ); - - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton1->setChecked(false); - //GroupPoints->CheckButton1->hide(); - - GroupPoints->CheckButton2->setText( tr( "GEOM_IS_REORDER" ) ); - GroupPoints->CheckButton2->setChecked(false); - GroupPoints->CheckButton2->hide(); - - GroupPoints->CheckButton3->hide(); - - myParams = new BasicGUI_ParamCurveWidget( centralWidget() ); - - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( creationModeCroup ); - layout->addWidget( GroupPoints ); - layout->addWidget( myParams ); + // Points and flags + myGroupPoints = new DlgRef_1Sel3Check (centralWidget()); + + myGroupPoints->GroupBox1->setTitle(tr("GEOM_NODES")); + myGroupPoints->TextLabel1->setText(tr("GEOM_POINTS")); + myGroupPoints->PushButton1->setIcon(image1); + myGroupPoints->PushButton1->setDown(true); + + myGroupPoints->LineEdit1->setReadOnly( true ); + + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton1->setChecked(false); + //myGroupPoints->CheckButton1->hide(); + + myGroupPoints->CheckButton2->setText( tr( "GEOM_IS_REORDER" ) ); + myGroupPoints->CheckButton2->setChecked(false); + myGroupPoints->CheckButton2->hide(); + + myGroupPoints->CheckButton3->hide(); + + // Parametrical mode + myGroupParams = new BasicGUI_ParamCurveWidget( centralWidget() ); + + // Tangents (only for Interpolation constructor and only not closed and no reordering) + myGroupTangents = new QGroupBox (this); + myGroupTangents->setCheckable(true); + myGroupTangents->setChecked(false); + myGroupTangents->setTitle(tr("GEOM_INTERPOL_TANGENTS")); + + QGridLayout* tangentsLayout = new QGridLayout (myGroupTangents); + + myPushBtnV1 = new QPushButton (myGroupTangents); + myPushBtnV2 = new QPushButton (myGroupTangents); + myPushBtnV1->setIcon(image1); + myPushBtnV2->setIcon(image1); + + myLineEditV1 = new QLineEdit (myGroupTangents); + myLineEditV2 = new QLineEdit (myGroupTangents); + myLineEditV1->setReadOnly(true); + myLineEditV2->setReadOnly(true); + + QLabel* aTextLabelV1 = new QLabel (myGroupTangents); + QLabel* aTextLabelV2 = new QLabel (myGroupTangents); + aTextLabelV1->setText(tr("GEOM_INTERPOL_FIRST_VEC")); + aTextLabelV2->setText(tr("GEOM_INTERPOL_LAST_VEC")); + + tangentsLayout->addWidget(aTextLabelV1, 0, 0); + tangentsLayout->addWidget(myPushBtnV1 , 0, 1); + tangentsLayout->addWidget(myLineEditV1, 0, 2); + tangentsLayout->addWidget(aTextLabelV2, 1, 0); + tangentsLayout->addWidget(myPushBtnV2 , 1, 1); + tangentsLayout->addWidget(myLineEditV2, 1, 2); + + // Layout + QVBoxLayout* layout = new QVBoxLayout (centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(creationModeGroup); + layout->addWidget(myGroupPoints); + layout->addWidget(myGroupParams); + layout->addWidget(myGroupTangents); /***************************************************************/ - setHelpFileName( "create_curve_page.html" ); + setHelpFileName("create_curve_page.html"); Init(); } - //================================================================================= // function : ~BasicGUI_CurveDlg() // purpose : Destroys the object and frees any allocated resources @@ -127,7 +161,6 @@ BasicGUI_CurveDlg::~BasicGUI_CurveDlg() { } - //================================================================================= // function : Init() // purpose : @@ -135,13 +168,6 @@ BasicGUI_CurveDlg::~BasicGUI_CurveDlg() void BasicGUI_CurveDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoints.clear(); - - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - showOnlyPreviewControl(); myBySelectionBtn->setChecked(true); @@ -152,87 +178,94 @@ void BasicGUI_CurveDlg::Init() double aMax( 100. ), aMin( 0.0 ); /* min, max, step and decimals for spin boxes & initial values */ - initSpinBox( myParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( myParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" ); - myParams->myPStep->setValue( 10 ); - myParams->myPStep->setMaximum( 999 ); - myParams->myPStep->setSingleStep( 10 ); - myParams->myPMin->setValue( aMin ); - myParams->myPMax->setValue( aMax ); - myParams->myPStep->setValue( step ); - myParams->myXExpr->setText("t"); - myParams->myYExpr->setText("t"); - myParams->myZExpr->setText("t"); - - myParams->hide(); + initSpinBox( myGroupParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( myGroupParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" ); + myGroupParams->myPStep->setValue( 10 ); + myGroupParams->myPStep->setMaximum( 999 ); + myGroupParams->myPStep->setSingleStep( 10 ); + myGroupParams->myPMin->setValue( aMin ); + myGroupParams->myPMax->setValue( aMax ); + myGroupParams->myPStep->setValue( step ); + myGroupParams->myXExpr->setText("t"); + myGroupParams->myYExpr->setText("t"); + myGroupParams->myZExpr->setText("t"); + + myGroupParams->hide(); /* signals and slots connections */ - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect(myGroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myPushBtnV1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myPushBtnV2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( GroupPoints->CheckButton1, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); - connect( GroupPoints->CheckButton2, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); + connect(myGroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CheckButtonToggled())); + connect(myGroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(CheckButtonToggled())); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - connect( myBySelectionBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) ); - connect( myAnaliticalBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) ); + connect(myBySelectionBtn, SIGNAL(clicked()), this, SLOT(CreationModeChanged())); + connect(myAnaliticalBtn, SIGNAL(clicked()), this, SLOT(CreationModeChanged())); - connect(myParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myParams->myPStep, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); + connect(myGroupParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGroupParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGroupParams->myPStep, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); - connect(myParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - connect(myParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - connect(myParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - initName( tr( "GEOM_CURVE" ) ); - resize(100,100); - ConstructorsClicked( 0 ); + initName(tr("GEOM_CURVE")); + //resize(100, 100); + ConstructorsClicked(0); } //================================================================================= // function : ConstructorsClicked() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ConstructorsClicked( int id ) +void BasicGUI_CurveDlg::ConstructorsClicked (int id) { - QString aTitle = tr( id == 0 ? "GEOM_POLYLINE" : id == 1 ? "GEOM_BEZIER" : "GEOM_INTERPOL" ); - mainFrame()->GroupConstructors->setTitle( aTitle ); + QString aTitle = tr(id == 0 ? "GEOM_POLYLINE" : id == 1 ? "GEOM_BEZIER" : "GEOM_INTERPOL"); + mainFrame()->GroupConstructors->setTitle(aTitle); if (id == 0) { // polyline (wire) - //GroupPoints->CheckButton1->hide(); - GroupPoints->CheckButton1->setText( tr( "GEOM_BUILD_CLOSED_WIRE" ) ); - GroupPoints->CheckButton2->hide(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_BUILD_CLOSED_WIRE" ) ); + myGroupPoints->CheckButton2->hide(); + myGroupTangents->hide(); } else if (id == 1) { // bezier - //GroupPoints->CheckButton1->hide(); - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton2->hide(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton2->hide(); + myGroupTangents->hide(); } else { // b-spline - //GroupPoints->CheckButton1->show(); - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton2->show(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton2->show(); + myGroupTangents->setVisible(myBySelectionBtn->isChecked()); } myPoints.clear(); + myVec1.nullify(); + myVec2.nullify(); + + myGroupPoints->LineEdit1->setText(""); + myLineEditV1->setText(""); + myLineEditV2->setText(""); - myEditCurrentArgument->setText( "" ); qApp->processEvents(); updateGeometry(); - resize( minimumSizeHint() ); - SelectionIntoArgument(); -} + resize(minimumSizeHint()); + myGroupPoints->PushButton1->click(); +} //================================================================================= // function : SetEditCurrentArgument() @@ -240,9 +273,28 @@ void BasicGUI_CurveDlg::ConstructorsClicked( int id ) //================================================================================= void BasicGUI_CurveDlg::SetEditCurrentArgument() { - if ( sender() == GroupPoints->PushButton1 ) - myEditCurrentArgument = GroupPoints->LineEdit1; + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + + globalSelection(); // close local contexts, if any + + if (sender() == myGroupPoints->PushButton1) { + myEditCurrentArgument = myGroupPoints->LineEdit1; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + } + else if (sender() == myPushBtnV1) { + myEditCurrentArgument = myLineEditV1; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else if (sender() == myPushBtnV2) { + myEditCurrentArgument = myLineEditV2; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + myEditCurrentArgument->setFocus(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } @@ -252,6 +304,11 @@ void BasicGUI_CurveDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_CurveDlg::CheckButtonToggled() { + if (getConstructorId() == 2) { // Interpolation + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + myGroupTangents->setEnabled(!disableTangents); + } processPreview(); } @@ -261,8 +318,8 @@ void BasicGUI_CurveDlg::CheckButtonToggled() //================================================================================= void BasicGUI_CurveDlg::ClickOnOk() { - setIsApplyAndClose( true ); - if ( ClickOnApply() ) + setIsApplyAndClose(true); + if (ClickOnApply()) ClickOnCancel(); } @@ -272,20 +329,23 @@ void BasicGUI_CurveDlg::ClickOnOk() //================================================================================= bool BasicGUI_CurveDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + ConstructorsClicked(getConstructorId()); return true; } -static void synchronize( QList& left, QList& right ) +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +static void synchronize (QList& left, QList& right) { // 1. remove items from the "left" list that are not in the "right" list - QMutableListIterator it1( left ); - while ( it1.hasNext() ) { + QMutableListIterator it1 (left); + while (it1.hasNext()) { GEOM::GeomObjPtr o1 = it1.next(); bool found = false; QMutableListIterator it2( right ); @@ -307,22 +367,38 @@ static void synchronize( QList& left, QList& } } -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= void BasicGUI_CurveDlg::SelectionIntoArgument() { - QList points = getSelected( TopAbs_VERTEX, -1 ); - synchronize( myPoints, points ); - if ( !myPoints.isEmpty() ) - GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); - else - GroupPoints->LineEdit1->setText( "" ); + myEditCurrentArgument->setText(""); + + if (myEditCurrentArgument == myGroupPoints->LineEdit1) { + QList points = getSelected(TopAbs_VERTEX, -1); + synchronize(myPoints, points); + if (!myPoints.isEmpty()) + myGroupPoints->LineEdit1->setText(QString::number(myPoints.count()) + "_" + + tr("GEOM_POINT") + tr("_S_")); + } + else { + QList vecs = getSelected(TopAbs_EDGE, -1); + if (vecs.count() != 1) { + if (myEditCurrentArgument == myLineEditV1) myVec1.nullify(); + else if (myEditCurrentArgument == myLineEditV2) myVec2.nullify(); + } + else { + if (myEditCurrentArgument == myLineEditV1) { + myVec1 = vecs.first(); + } + else if (myEditCurrentArgument == myLineEditV2) { + myVec2 = vecs.first(); + } + QString aName = GEOMBase::GetName(vecs.first().get()); + myEditCurrentArgument->setText(aName); + } + } + processPreview(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -330,13 +406,11 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() void BasicGUI_CurveDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -353,9 +427,9 @@ void BasicGUI_CurveDlg::DeactivateActiveDialog() // function : enterEvent() // purpose : //================================================================================= -void BasicGUI_CurveDlg::enterEvent( QEvent* ) +void BasicGUI_CurveDlg::enterEvent (QEvent*) { - if ( !mainFrame()->GroupConstructors->isEnabled() ) + if (!mainFrame()->GroupConstructors->isEnabled()) ActivateThisDialog(); } @@ -365,24 +439,34 @@ void BasicGUI_CurveDlg::enterEvent( QEvent* ) //================================================================================= GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation() { - return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); + return myGeomGUI->GetGeomGen()->GetICurvesOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool BasicGUI_CurveDlg::isValid( QString& msg ) +bool BasicGUI_CurveDlg::isValid (QString& msg) { - if( myBySelectionBtn->isChecked() ) - return myPoints.count() > 1; + if (myBySelectionBtn->isChecked()) { + bool ok = true; + if (getConstructorId() == 2) { // Interpolation + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + if (!disableTangents && myGroupTangents->isChecked()) { + ok = (myVec1 && myVec2); + if (!ok) msg = tr("GEOM_BOTH_TANGENTS_REQUIRED"); + } + } + return ok && myPoints.count() > 1; + } else { - bool ok = myParams->myPMin->isValid( msg, !IsPreview() ) && - myParams->myPMax->isValid( msg, !IsPreview() ) && - myParams->myPStep->isValid( msg, !IsPreview() ); - ok &= !myParams->myXExpr->text().isEmpty(); - ok &= !myParams->myYExpr->text().isEmpty(); - ok &= !myParams->myZExpr->text().isEmpty(); + bool ok = myGroupParams->myPMin->isValid( msg, !IsPreview() ) && + myGroupParams->myPMax->isValid( msg, !IsPreview() ) && + myGroupParams->myPStep->isValid( msg, !IsPreview() ); + ok &= !myGroupParams->myXExpr->text().isEmpty(); + ok &= !myGroupParams->myYExpr->text().isEmpty(); + ok &= !myGroupParams->myZExpr->text().isEmpty(); return ok; } } @@ -391,79 +475,85 @@ bool BasicGUI_CurveDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool BasicGUI_CurveDlg::execute( ObjectList& objects ) +bool BasicGUI_CurveDlg::execute (ObjectList& objects) { bool res = false; GEOM::GEOM_Object_var anObj; - GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); + GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); GEOM::ListOfGO_var points = new GEOM::ListOfGO(); - points->length( myPoints.count() ); - for ( int i = 0; i < myPoints.count(); i++ ) + points->length(myPoints.count()); + for (int i = 0; i < myPoints.count(); i++) points[i] = myPoints[i].copy(); - switch ( getConstructorId() ) { + switch (getConstructorId()) { case 0 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() ); + if (myBySelectionBtn->isChecked()) + anObj = anOper->MakePolyline(points.in(), myGroupPoints->CheckButton1->isChecked()); else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Polyline); + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Polyline); res = true; break; case 1 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() ); + if (myBySelectionBtn->isChecked()) + anObj = anOper->MakeSplineBezier(points.in(), myGroupPoints->CheckButton1->isChecked()); else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Bezier); - + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Bezier); res = true; break; case 2 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(), - GroupPoints->CheckButton2->isChecked() ); + if (myBySelectionBtn->isChecked()) { + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + if (!disableTangents && myGroupTangents->isChecked()) { + anObj = anOper->MakeSplineInterpolWithTangents(points.in(), myVec1.get(), myVec2.get()); + } + else + anObj = anOper->MakeSplineInterpolation(points.in(), myGroupPoints->CheckButton1->isChecked(), + myGroupPoints->CheckButton2->isChecked()); + } else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Interpolation); + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Interpolation); res = true; break; } - if ( !anObj->_is_nil() ) { - if(myAnaliticalBtn->isChecked() && !IsPreview()) { + if (!anObj->_is_nil()) { + if (myAnaliticalBtn->isChecked() && !IsPreview()) { QStringList aParameters; - aParameters<myPMin->text(); - aParameters<myPMax->text(); - aParameters<myPStep->text(); + aParameters<myPMin->text(); + aParameters<myPMax->text(); + aParameters<myPStep->text(); anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } - objects.push_back( anObj._retn() ); + objects.push_back(anObj._retn()); } - + return res; } //================================================================================= -// function : addSubshapeToStudy +// function : addSubshapesToStudy // purpose : virtual method to add new SubObjects if local selection //================================================================================= void BasicGUI_CurveDlg::addSubshapesToStudy() @@ -476,19 +566,20 @@ void BasicGUI_CurveDlg::addSubshapesToStudy() // function : CreationModeChanged // purpose : //================================================================================= -void BasicGUI_CurveDlg::CreationModeChanged() { +void BasicGUI_CurveDlg::CreationModeChanged() +{ const QObject* s = sender(); - GroupPoints->setVisible(myBySelectionBtn == s); - myParams->setVisible(myBySelectionBtn != s); - - ConstructorsClicked( getConstructorId() ); + myGroupPoints->setVisible(myBySelectionBtn == s); + myGroupParams->setVisible(myBySelectionBtn != s); + + ConstructorsClicked(getConstructorId()); } //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/) +void BasicGUI_CurveDlg::ValueChangedInSpinBox (double/*theValue*/) { processPreview(); } @@ -497,15 +588,16 @@ void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ValueChangedInSpinBox(int/*theValue*/) +void BasicGUI_CurveDlg::ValueChangedInSpinBox (int/*theValue*/) { processPreview(); } //================================================================================= -// function : ValueChangedInSpinBox() +// function : OnEditingFinished() // purpose : //================================================================================= -void BasicGUI_CurveDlg::OnEditingFinished() { +void BasicGUI_CurveDlg::OnEditingFinished() +{ processPreview(); } diff --git a/src/BasicGUI/BasicGUI_CurveDlg.h b/src/BasicGUI/BasicGUI_CurveDlg.h index ce9a6a9e7..8d6751b5e 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.h +++ b/src/BasicGUI/BasicGUI_CurveDlg.h @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_CurveDlg.h @@ -34,6 +33,9 @@ class DlgRef_1Sel3Check; class QRadioButton; +class QPushButton; +class QLineEdit; +class QGroupBox; class BasicGUI_ParamCurveWidget; //================================================================================= @@ -45,26 +47,34 @@ class BasicGUI_CurveDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_CurveDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 ); + BasicGUI_CurveDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0); ~BasicGUI_CurveDlg(); protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); virtual void addSubshapesToStudy(); private: void Init(); - void enterEvent( QEvent* ); + void enterEvent (QEvent*); private: - DlgRef_1Sel3Check* GroupPoints; - QList myPoints; QRadioButton* myAnaliticalBtn; QRadioButton* myBySelectionBtn; - BasicGUI_ParamCurveWidget* myParams; + DlgRef_1Sel3Check* myGroupPoints; + BasicGUI_ParamCurveWidget* myGroupParams; + QGroupBox* myGroupTangents; + + QPushButton* myPushBtnV1; + QPushButton* myPushBtnV2; + QLineEdit* myLineEditV1; + QLineEdit* myLineEditV2; + + QList myPoints; + GEOM::GeomObjPtr myVec1, myVec2; private slots: void ClickOnOk(); @@ -73,13 +83,13 @@ private slots: void ActivateThisDialog(); void DeactivateActiveDialog(); - void ConstructorsClicked( int ); + void ConstructorsClicked (int); void CheckButtonToggled(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void CreationModeChanged(); - void ValueChangedInSpinBox(double/*theValue*/); - void ValueChangedInSpinBox(int /*theValue*/); + void ValueChangedInSpinBox (double/*theValue*/); + void ValueChangedInSpinBox (int /*theValue*/); void OnEditingFinished(); }; diff --git a/src/BlockFix/BlockFix.cxx b/src/BlockFix/BlockFix.cxx new file mode 100644 index 000000000..0e4f9bb21 --- /dev/null +++ b/src/BlockFix/BlockFix.cxx @@ -0,0 +1,344 @@ +// 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: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN + +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +//======================================================================= +//function : FixResult +//purpose : auxilary +//======================================================================= +static void FixResult(const TopoDS_Shape& result, + Handle(ShapeBuild_ReShape)& Context, + const Standard_Real Tol) +{ + for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { + TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); + // face coud not be dropped or splitted on this step + TopoDS_Face aFace = TopoDS::Face(aShape); + TopLoc_Location L; + Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); + + if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) { + + Standard_Integer nbWires = 0; + for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { + nbWires++; + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), + aFace, + Precision::Confusion()); + sfw->FixReorder(); + if(sfw->StatusReorder ( ShapeExtend_FAIL )) + continue; + + sfw->SetPrecision(2.*Tol); + sfw->FixShifted(); + + Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); + isDone |= sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + Standard_Integer i; + for( i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { + sewd->Remove(i); + isDone = Standard_True; + i--; + } + } + + //isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395) + + // remove neighbour seam edges + if(isDone) { + for( i = 1; iNbEdges();i++) { + if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { + isDone = Standard_True; + sewd->Remove(i); + sewd->Remove(i); + i--; + } + } + if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { + sewd->Remove(1); + sewd->Remove(sewd->NbEdges()); + } + } + + if(isDone) { + TopoDS_Wire ResWire = sfw->Wire(); + Context->Replace(ex_w.Current(), ResWire); + }; + } + // Implement fix orientation in case of several wires + if(nbWires > 1) { + TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); + if(sff->FixOrientation()) + Context->Replace(aFixedFace,sff->Face()); + } + } + } +} + +//======================================================================= +//function : RotateSphereSpace +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + return result; +} + +//======================================================================= +//function : RefillProblemFaces +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::RefillProblemFaces (const TopoDS_Shape& aShape) +{ + Standard_Integer NbSamples = 10; + + TopTools_ListOfShape theFaces; + + TopExp_Explorer Explo(aShape, TopAbs_FACE); + for (; Explo.More(); Explo.Next()) + { + TopoDS_Face aFace = TopoDS::Face(Explo.Current()); + BRepAdaptor_Surface BAsurf(aFace); + GeomAbs_SurfaceType SurfType = BAsurf.GetType(); + if (SurfType >= GeomAbs_BezierSurface) + { + TopExp_Explorer fexp(aFace, TopAbs_EDGE); + for (; fexp.More(); fexp.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(fexp.Current()); + if (BRep_Tool::Degenerated(anEdge)) + { + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2); + if (V1.IsSame(V2)) + { + gp_Pnt aPnt = BRep_Tool::Pnt(V1); + Standard_Real TolV = BRep_Tool::Tolerance(V1); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + Handle(ShapeAnalysis_Surface) Analyser = new ShapeAnalysis_Surface(aSurf); + if (Analyser->IsDegenerated(aPnt, TolV)) + { + theFaces.Append(aFace); + break; + } + } + } + } + } + } + + //Now all problem faces are collected in the list "theFaces" + BRepTools_Substitution aSubst; + TopTools_ListIteratorOfListOfShape itl(theFaces); + for (; itl.More(); itl.Next()) + { + const TopoDS_Face& aFace = TopoDS::Face(itl.Value()); + BRepOffsetAPI_MakeFilling Filler; + for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + if (!BRep_Tool::Degenerated(anEdge)) + Filler.Add(anEdge, GeomAbs_C0); + } + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + //Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + Standard_Integer i, j; + for (i = 1; i < NbSamples; i++) + for (j = 1; j < NbSamples; j++) { + /* + gp_Pnt aPoint = aSurf->Value(Umin + i*(Umax-Umin)/NbSamples, + Vmin + j*(Vmax-Vmin)/NbSamples); + Filler.Add(aPoint); + */ + Filler.Add(Umin + i*(Umax-Umin)/NbSamples, + Vmin + j*(Vmax-Vmin)/NbSamples, + aFace, GeomAbs_G1); + } + + Filler.Build(); + if (Filler.IsDone()) + { + for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + TopTools_ListOfShape Ledge; + if (!BRep_Tool::Degenerated(anEdge)) + { + const TopTools_ListOfShape& Ledges = Filler.Generated(anEdge); + if (!Ledges.IsEmpty()) { + TopoDS_Shape NewEdge = Ledges.First(); + Ledge.Append(NewEdge.Oriented(TopAbs_FORWARD)); + } + } + aSubst.Substitute(anEdge, Ledge); + } + TopTools_ListOfShape Lface; + TopoDS_Face NewFace = TopoDS::Face(Filler.Shape()); + NewFace.Orientation(TopAbs_FORWARD); + BRepAdaptor_Surface NewBAsurf(NewFace); + gp_Pnt MidPnt; + gp_Vec D1U, D1V, Normal, NewNormal; + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + aSurf->D1((Umin+Umax)*0.5, (Vmin+Vmax)*0.5, MidPnt, D1U, D1V); + Normal = D1U ^ D1V; + NewBAsurf.D1((NewBAsurf.FirstUParameter() + NewBAsurf.LastUParameter())*0.5, + (NewBAsurf.FirstVParameter() + NewBAsurf.LastVParameter())*0.5, + MidPnt, D1U, D1V); + NewNormal = D1U ^ D1V; + if (Normal * NewNormal < 0.) + NewFace.Reverse(); + Lface.Append(NewFace); + aSubst.Substitute(aFace, Lface); + } + } + aSubst.Build(aShape); + + TopoDS_Shape Result = aShape; + if (aSubst.IsCopied(aShape)) + Result = aSubst.Copy(aShape).First(); + + BRepTools::RemoveUnusedPCurves(Result); + + return Result; +} + +//======================================================================= +//function : FixRanges +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + + return result; +} diff --git a/src/BlockFix/BlockFix.hxx b/src/BlockFix/BlockFix.hxx new file mode 100644 index 000000000..70d37df65 --- /dev/null +++ b/src/BlockFix/BlockFix.hxx @@ -0,0 +1,56 @@ +// 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 + +#ifndef _BlockFix_HeaderFile +#define _BlockFix_HeaderFile + +#include + +class TopoDS_Shape; +class BlockFix_SphereSpaceModifier; +class BlockFix_UnionFaces; +class BlockFix_UnionEdges; +class BlockFix_BlockFixAPI; +class BlockFix_PeriodicSurfaceModifier; +class BlockFix_CheckTool; + +#include +#include + +class BlockFix { + +public: + Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol); + Standard_EXPORT static TopoDS_Shape RefillProblemFaces(const TopoDS_Shape& S); + Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol); + +private: + +friend class BlockFix_SphereSpaceModifier; +friend class BlockFix_UnionFaces; +friend class BlockFix_UnionEdges; +friend class BlockFix_BlockFixAPI; +friend class BlockFix_PeriodicSurfaceModifier; +friend class BlockFix_CheckTool; + +}; + +#endif diff --git a/src/BlockFix/BlockFix_BlockFixAPI.cxx b/src/BlockFix/BlockFix_BlockFixAPI.cxx new file mode 100644 index 000000000..376632b4f --- /dev/null +++ b/src/BlockFix/BlockFix_BlockFixAPI.cxx @@ -0,0 +1,89 @@ +// 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: BlockFix_BlockFixAPI.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN + +#include + +#include +#include +#include + +#include + +#include + +#include + +IMPLEMENT_STANDARD_HANDLE(BlockFix_BlockFixAPI, MMgt_TShared); +IMPLEMENT_STANDARD_RTTIEXT(BlockFix_BlockFixAPI, MMgt_TShared); + +//======================================================================= +//function : BlockFix_BlockFixAPI +//purpose : +//======================================================================= +BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() +{ + myTolerance = Precision::Confusion(); + myOptimumNbFaces = 6; +} + +//======================================================================= +//function : ~BlockFix_BlockFixAPI +//purpose : +//======================================================================= +BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void BlockFix_BlockFixAPI::Perform() +{ + // processing spheres with degenerativities + TopoDS_Shape aShape = Shape(); + myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); + + // try to approximate non-canonic surfaces + // with singularities on boundaries by filling + myShape = BlockFix::RefillProblemFaces(myShape); + + // faces unification + BlockFix_UnionFaces aFaceUnifier; + aFaceUnifier.GetTolerance() = myTolerance; + aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; + TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); + + // avoid problem with degenerated edges appearance + // due to shape quality regress + ShapeUpgrade_RemoveLocations RemLoc; + RemLoc.Remove(aResult); + aResult = RemLoc.GetResult(); + + // edges unification + BlockFix_UnionEdges anEdgeUnifier; + myShape = anEdgeUnifier.Perform(aResult,myTolerance); + + TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); + myShape = aRes; +} diff --git a/src/BlockFix/BlockFix_BlockFixAPI.hxx b/src/BlockFix/BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..84140aff5 --- /dev/null +++ b/src/BlockFix/BlockFix_BlockFixAPI.hxx @@ -0,0 +1,102 @@ +// 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 + +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#define _BlockFix_BlockFixAPI_HeaderFile + +#include +#include + +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(BlockFix_BlockFixAPI, MMgt_TShared); + +class BlockFix_BlockFixAPI : public MMgt_TShared +{ +public: + Standard_EXPORT BlockFix_BlockFixAPI(); + Standard_EXPORT ~BlockFix_BlockFixAPI(); + + void SetShape(const TopoDS_Shape& Shape); + TopoDS_Shape Shape() const; + Handle_ShapeBuild_ReShape& Context(); + Standard_Real& Tolerance(); + Standard_Integer& OptimumNbFaces(); + Standard_EXPORT void Perform(); + + DEFINE_STANDARD_RTTI(BlockFix_BlockFixAPI); + +private: + Handle_ShapeBuild_ReShape myContext; + TopoDS_Shape myShape; + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= +inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) +{ + myShape = Shape; +} + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= +inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const +{ + return myShape; +} + +//======================================================================= +//function : Context +//purpose : +//======================================================================= +inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() +{ + return myContext; +} + +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= +inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() +{ + return myTolerance; +} + +//======================================================================= +//function : OptimumNbFaces +//purpose : +//======================================================================= +inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces() +{ + return myOptimumNbFaces; +} + +#endif diff --git a/src/BlockFix/BlockFix_CheckTool.cxx b/src/BlockFix/BlockFix_CheckTool.cxx new file mode 100644 index 000000000..ba1c5c6af --- /dev/null +++ b/src/BlockFix/BlockFix_CheckTool.cxx @@ -0,0 +1,266 @@ +// 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: BlockFix_CheckTool.cxx +// Created: 17.12.04 11:15:25 +// Author: Sergey KUUL + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +//======================================================================= +//function : BlockFix_CheckTool() +//purpose : Constructor +//======================================================================= +BlockFix_CheckTool::BlockFix_CheckTool( ) +{ + myHasCheck = Standard_False; + myPossibleBlocks.Clear(); +} + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= +void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) +{ + myHasCheck = Standard_False; + myShape = aShape; + myPossibleBlocks.Clear(); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void BlockFix_CheckTool::Perform() +{ + myNbSolids=0; + myNbBlocks=0; + myNbDegen=0; + myNbUF=0; + myNbUE=0; + myNbUFUE=0; + + TopExp_Explorer exps (myShape, TopAbs_SOLID); + TopTools_MapOfShape mapS; + for (; exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + if (!mapS.Add(aSolid)) continue; + myNbSolids++; + Standard_Boolean IsBlock=Standard_True; + Standard_Boolean MayBeUF=Standard_False; + Standard_Boolean MayBeUE=Standard_False; + Standard_Integer nf=0; + TopExp_Explorer expf (aSolid, TopAbs_FACE); + TopTools_MapOfShape mapF; + for (; expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) + nf++; + } + + if (nf < 6) { + IsBlock = Standard_False; + } + else if (nf > 6) { + IsBlock = Standard_False; + // check faces unification + TopTools_SequenceOfShape faces; + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + faces.Append(aFace); + } + } + Standard_Boolean HasFacesForUnification = Standard_False; + for (Standard_Integer i=1; i 0) { + IsBlock = Standard_False; + myNbDegen++; + myPossibleBlocks.Append(aSolid); + continue; + } + if (nbe < 12) + IsBlock = Standard_False; + if (nbe > 12) { + IsBlock = Standard_False; + // check edges unification + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + if (!mapF.Add(aFace)) continue; + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + TopTools_MapOfShape mapEe; + for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!mapEe.Add(edge)) continue; + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter (aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + if (face.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + Standard_Integer i = 1; + for (; i <= aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + if (ListEdges.Extent() > 1) break; + } + if (i <= aMapFacesEdges.Extent()) { + MayBeUE = Standard_True; + break; + } + } + } + + if (IsBlock) + myNbBlocks++; + else { + if (MayBeUF) { + myPossibleBlocks.Append(aSolid); + if (MayBeUE) + myNbUFUE++; + else + myNbUF++; + } + else if (MayBeUE) { + myNbUE++; + myPossibleBlocks.Append(aSolid); + } + } + } + + myHasCheck = Standard_True; +} + +//======================================================================= +//function : NbPossibleBlocks +//purpose : +//======================================================================= +Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const +{ + return myPossibleBlocks.Length(); +} + +//======================================================================= +//function : PossibleBlock +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const +{ + TopoDS_Shape res; + if( num>0 && num<=myPossibleBlocks.Length() ) + res = myPossibleBlocks.Value(num); + return res; +} + +//======================================================================= +//function : DumpCheckResult +//purpose : +//======================================================================= +void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const +{ + if(!myHasCheck) + S<<"Check not performed!"<Curves() ); + for (; itr.More(); itr.Next()) + { + Handle(BRep_CurveRepresentation) CurveRep = itr.Value(); + if (CurveRep->IsCurveOnSurface()) + { + //PCurveSeq.Append(CurveRep->PCurve()); + SurfSeq.Append(CurveRep->Surface()); + /* + TopoDS_Shape aLocShape; + aLocShape.Location(CurveRep->Location()); + LocSeq.Append(aLocShape); + */ + } + } + + Standard_Real fpar, lpar; + BRep_Tool::Range(FirstEdge, fpar, lpar); + TopoDS_Edge PrevEdge = FirstEdge; + TopoDS_Vertex CV; + Standard_Real MaxTol = 0.; + + TopoDS_Edge ResEdge; + BRep_Builder BB; + + Standard_Integer nb_curve = aChain.Length(); //number of curves + TColGeom_Array1OfBSplineCurve tab_c3d(0,nb_curve-1); //array of the curves + TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances + + TopoDS_Vertex PrevVertex = FirstVertex; + for (i = 1; i <= nb_curve; i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); + TopoDS_Vertex VF, VL; + TopExp::Vertices(anEdge, VF, VL); + Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); + + Standard_Real Tol1 = BRep_Tool::Tolerance(VF); + Standard_Real Tol2 = BRep_Tool::Tolerance(VL); + if (Tol1 > MaxTol) + MaxTol = Tol1; + if (Tol2 > MaxTol) + MaxTol = Tol2; + + if (i > 1) + { + TopExp::CommonVertex(PrevEdge, anEdge, CV); + Standard_Real Tol = BRep_Tool::Tolerance(CV); + tabtolvertex(i-2) = Tol; + } + + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); + Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, fpar, lpar); + tab_c3d(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve); + GeomConvert::C0BSplineToC1BSplineCurve(tab_c3d(i-1), Precision::Confusion()); + if (ToReverse) + tab_c3d(i-1)->Reverse(); + PrevVertex = (ToReverse)? VF : VL; + PrevEdge = anEdge; + } + Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves + Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex + GeomConvert::ConcatC1(tab_c3d, + tabtolvertex, + ArrayOfIndices, + concatcurve, + Standard_False, + Precision::Confusion()); //C1 concatenation + + if (concatcurve->Length() > 1) + { + GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); + + for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++) + Concat.Add( concatcurve->Value(i), MaxTol, Standard_True ); + + concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); + } + Handle(Geom_BSplineCurve) ResCurve = concatcurve->Value(concatcurve->Lower()); + + TColGeom2d_SequenceOfBoundedCurve ResPCurves; + TopLoc_Location aLoc; + for (j = 1; j <= SurfSeq.Length(); j++) + { + TColGeom2d_Array1OfBSplineCurve tab_c2d(0,nb_curve-1); //array of the pcurves + + PrevVertex = FirstVertex; + PrevEdge = FirstEdge; + //TopLoc_Location theLoc = LocSeq(j).Location(); + for (i = 1; i <= nb_curve; i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); + TopoDS_Vertex VF, VL; + TopExp::Vertices(anEdge, VF, VL); + Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); + + /* + Handle(Geom2d_Curve) aPCurve = + BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), anEdge.Location()*theLoc, fpar, lpar); + */ + Handle(Geom2d_Curve) aPCurve = + BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), aLoc, fpar, lpar); + Handle(Geom2d_TrimmedCurve) aTrPCurve = new Geom2d_TrimmedCurve(aPCurve, fpar, lpar); + tab_c2d(i-1) = Geom2dConvert::CurveToBSplineCurve(aTrPCurve); + Geom2dConvert::C0BSplineToC1BSplineCurve(tab_c2d(i-1), Precision::Confusion()); + if (ToReverse) + tab_c2d(i-1)->Reverse(); + PrevVertex = (ToReverse)? VF : VL; + PrevEdge = anEdge; + } + Handle(TColGeom2d_HArray1OfBSplineCurve) concatc2d; //array of the concatenated curves + Handle(TColStd_HArray1OfInteger) ArrayOfInd2d; //array of the remining Vertex + Geom2dConvert::ConcatC1(tab_c2d, + tabtolvertex, + ArrayOfInd2d, + concatc2d, + Standard_False, + Precision::Confusion()); //C1 concatenation + + if (concatc2d->Length() > 1) + { + Geom2dConvert_CompCurveToBSplineCurve Concat2d(concatc2d->Value(concatc2d->Lower())); + + for (i = concatc2d->Lower()+1; i <= concatc2d->Upper(); i++) + Concat2d.Add( concatc2d->Value(i), MaxTol, Standard_True ); + + concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve()); + } + Handle(Geom2d_BSplineCurve) aResPCurve = concatc2d->Value(concatc2d->Lower()); + ResPCurves.Append(aResPCurve); + } + + ResEdge = BRepLib_MakeEdge(ResCurve, + FirstVertex, LastVertex, + ResCurve->FirstParameter(), ResCurve->LastParameter()); + BB.SameRange(ResEdge, Standard_False); + BB.SameParameter(ResEdge, Standard_False); + for (j = 1; j <= ResPCurves.Length(); j++) + { + BB.UpdateEdge(ResEdge, ResPCurves(j), SurfSeq(j), aLoc, MaxTol); + BB.Range(ResEdge, SurfSeq(j), aLoc, ResPCurves(j)->FirstParameter(), ResPCurves(j)->LastParameter()); + } + + BRepLib::SameParameter(ResEdge, MaxTol, Standard_True); + + return ResEdge; +} + +//======================================================================= +//function : MergeEdges +//purpose : auxilary +//======================================================================= +static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, + const TopoDS_Face& aFace, + const Standard_Real Tol, + TopoDS_Edge& anEdge) +{ + // make chain for union + BRep_Builder B; + ShapeAnalysis_Edge sae; + TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); + TopoDS_Edge LastE = FirstE; + TopoDS_Vertex VF = sae.FirstVertex(FirstE); + TopoDS_Vertex VL = sae.LastVertex(LastE); + TopTools_SequenceOfShape aChain; + aChain.Append(FirstE); + TColStd_MapOfInteger IndUsedEdges; + IndUsedEdges.Add(1); + Standard_Integer j; + for(j=2; j<=SeqEdges.Length(); j++) { + for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { + if(IndUsedEdges.Contains(k)) continue; + TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); + TopoDS_Vertex VF2 = sae.FirstVertex(edge); + TopoDS_Vertex VL2 = sae.LastVertex(edge); + if(sae.FirstVertex(edge).IsSame(VL)) { + aChain.Append(edge); + LastE = edge; + VL = sae.LastVertex(LastE); + IndUsedEdges.Add(k); + } + else if(sae.LastVertex(edge).IsSame(VF)) { + aChain.Prepend(edge); + FirstE = edge; + VF = sae.FirstVertex(FirstE); + IndUsedEdges.Add(k); + } + } + } + if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d1); + c3d1 = tc->BasisCurve(); + } + TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); + Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); + if(c3d2.IsNull()) break; + while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d2); + c3d2 = tc->BasisCurve(); + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { + // union lines + Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); + Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); + gp_Dir Dir1 = L1->Position().Direction(); + gp_Dir Dir2 = L2->Position().Direction(); + //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { + //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { + if(!Dir1.IsParallel(Dir2,Tol)) { + continue; + } + // can union lines => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + gp_Vec Vec(PV1,PV2); + Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); + Standard_Real dist = PV1.Distance(PV2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); + TopoDS_Edge E; + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add (E,V1); B.Add (E,V2); + B.UpdateVertex(V1, 0., E, 0.); + B.UpdateVertex(V2, dist, E, 0.); + //ShapeFix_Edge sfe; + //sfe.FixAddPCurve(E,aFace,Standard_False); + //sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { + // union circles + Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); + Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); + gp_Pnt P01 = C1->Location(); + gp_Pnt P02 = C2->Location(); + if (P01.Distance(P02) > Precision::Confusion()) continue; + // can union circles => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + TopoDS_Vertex VM = sae.LastVertex(edge1); + gp_Pnt PVM = BRep_Tool::Pnt(VM); + GC_MakeCircle MC (PV1,PVM,PV2); + Handle(Geom_Circle) C = MC.Value(); + TopoDS_Edge E; + if (!MC.IsDone() || C.IsNull()) { + // jfa for Mantis issue 0020228 + if (PV1.Distance(PV2) > Precision::Confusion()) continue; + // closed chain + C = C1; + B.MakeEdge (E,C,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + } + else { + gp_Pnt P0 = C->Location(); + gp_Dir D1(gp_Vec(P0,PV1)); + gp_Dir D2(gp_Vec(P0,PV2)); + Standard_Real fpar = C->XAxis().Direction().Angle(D1); + if(fabs(fpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D1); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + fpar = -fpar; + } + } + Standard_Real lpar = C->XAxis().Direction().Angle(D2); + if(fabs(lpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D2); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + lpar = -lpar; + } + } + if (lpar < fpar) lpar += 2*M_PI; + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + B.UpdateVertex(V1, fpar, E, 0.); + B.UpdateVertex(V2, lpar, E, 0.); + } + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + } + if (j < aChain.Length()) { + MESSAGE ("null curve3d in edge..."); + return Standard_False; + } + if (aChain.Length() > 1) { + // second step: union edges with various curves + // skl for bug 0020052 from Mantis: perform such unions + // only if curves are bspline or bezier + bool NeedUnion = true; + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); + if(c3d.IsNull()) continue; + while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d); + c3d = tc->BasisCurve(); + } + if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; + NeedUnion = false; + break; + } + if(NeedUnion) { + MESSAGE ("can not make analitical union => make approximation"); + TopoDS_Edge E = GlueEdgesWithPCurves(aChain, VF, VL); + /* + TopoDS_Wire W; + B.MakeWire(W); + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + B.Add(W,edge); + } + Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); + Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); + Handle(Geom_BSplineCurve) bc = Conv.Curve(); + TopoDS_Edge E; + B.MakeEdge (E,bc,Precision::Confusion()); + B.Add (E,VF); + B.Add (E,VL); + */ + aChain.SetValue(1,E); + } + else { + MESSAGE ("can not make approximation for such types of curves"); + return Standard_False; + } + } + + anEdge = TopoDS::Edge(aChain.Value(1)); + return Standard_True; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, + const Standard_Real Tol) +{ + myContext = new ShapeBuild_ReShape; + myTolerance = Tol; + TopoDS_Shape aResult = myContext->Apply(Shape); + + // processing each solid + TopAbs_ShapeEnum aType = TopAbs_SOLID; + TopExp_Explorer exps (Shape, aType); + if (!exps.More()) { + aType = TopAbs_SHELL; + exps.Init(Shape, aType); + } + for (; exps.More(); exps.Next()) { + //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + TopoDS_Shape aSolid = exps.Current(); + + TopTools_IndexedMapOfShape ChangedFaces; + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + TopoDS_Shape aRes = aSolid; + aRes = aContext->Apply(aSolid); + + // processing each face + TopExp_Explorer exp; + for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = + TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for ( ; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); + if (face1.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + + for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + TopTools_SequenceOfShape SeqEdges; + TopTools_ListIteratorOfListOfShape anIter(ListEdges); + for ( ; anIter.More(); anIter.Next()) { + SeqEdges.Append(anIter.Value()); + } + if (SeqEdges.Length()==1) continue; + TopoDS_Edge E; + if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { + // now we have only one edge - aChain.Value(1) + // we have to replace old ListEdges with this new edge + aContext->Replace(SeqEdges(1),E); + for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { + aContext->Remove(SeqEdges(j)); + } + TopoDS_Face tmpF = TopoDS::Face(exp.Current()); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + } + } + + } // end processing each face + + // fix changed faces and replace them in the local context + for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { + TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); + sff->SetContext(myContext); + sff->SetPrecision(myTolerance); + sff->SetMinTolerance(myTolerance); + sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sff->Perform(); + aContext->Replace(aFace,sff->Face()); + } + + if (ChangedFaces.Extent() > 0) { + // fix changed shell and replace it in the local context + TopoDS_Shape aRes1 = aContext->Apply(aRes); + TopExp_Explorer expsh; + for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { + TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); + Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; + sfsh->FixFaceOrientation(aShell); + aContext->Replace(aShell,sfsh->Shell()); + } + TopoDS_Shape aRes2 = aContext->Apply(aRes1); + // put new solid into global context + myContext->Replace(aSolid,aRes2); + } + + } // end processing each solid + + aResult = myContext->Apply(Shape); + return aResult; +} diff --git a/src/BlockFix/BlockFix_UnionEdges.hxx b/src/BlockFix/BlockFix_UnionEdges.hxx new file mode 100644 index 000000000..b63f5c7e2 --- /dev/null +++ b/src/BlockFix/BlockFix_UnionEdges.hxx @@ -0,0 +1,47 @@ +// 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 + +#ifndef _BlockFix_UnionEdges_HeaderFile +#define _BlockFix_UnionEdges_HeaderFile + +#include + +#include + +#include +#include + +class TopoDS_Shape; + +class BlockFix_UnionEdges { + +public: + Standard_EXPORT BlockFix_UnionEdges(); + + Standard_EXPORT TopoDS_Shape Perform (const TopoDS_Shape& Shape,const Standard_Real Tol); + +private: + Standard_Real myTolerance; + Handle_ShapeBuild_ReShape myContext; + +}; + +#endif diff --git a/src/BlockFix/BlockFix_UnionFaces.cxx b/src/BlockFix/BlockFix_UnionFaces.cxx new file mode 100644 index 000000000..aae28cab6 --- /dev/null +++ b/src/BlockFix/BlockFix_UnionFaces.cxx @@ -0,0 +1,709 @@ +// 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: BlockFix_UnionFaces.cxx +// Created: Tue Dec 7 17:15:42 2004 +// Author: Pavel DURANDIN + +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 +#include +#else +#include +#endif + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//======================================================================= +//function : BlockFix_UnionFaces +//purpose : +//======================================================================= +BlockFix_UnionFaces::BlockFix_UnionFaces() + : myTolerance(Precision::Confusion()), + myOptimumNbFaces(6) +{ +} + +//======================================================================= +//function : GetTolerance +//purpose : +//======================================================================= +Standard_Real& BlockFix_UnionFaces::GetTolerance() +{ + return myTolerance; +} + +//======================================================================= +//function : GetOptimumNbFaces +//purpose : +//======================================================================= +Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces() +{ + return myOptimumNbFaces; +} + +//======================================================================= +//function : AddOrdinaryEdges +//purpose : auxilary +// adds edges from the shape to the sequence +// seams and equal edges are dropped +// Returns true if one of original edges dropped +//======================================================================= +static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, + const TopoDS_Shape aShape, + Standard_Integer& anIndex) +{ + //map of edges + TopTools_MapOfShape aNewEdges; + //add edges without seams + for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Shape edge = exp.Current(); + if(aNewEdges.Contains(edge)) + aNewEdges.Remove(edge); + else + aNewEdges.Add(edge); + } + + Standard_Boolean isDropped = Standard_False; + //merge edges and drop seams + for(Standard_Integer i = 1; i <= edges.Length(); i++) { + TopoDS_Shape current = edges(i); + if(aNewEdges.Contains(current)) { + + aNewEdges.Remove(current); + edges.Remove(i); + i--; + + if(!isDropped) { + isDropped = Standard_True; + anIndex = i; + } + } + } + + //add edges to the sequemce + for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) + edges.Append(anIter.Key()); + + return isDropped; +} + +//======================================================================= +//function : ClearRts +//purpose : auxilary +//======================================================================= +static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) +{ + if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) rts = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); + return rts->BasisSurface(); + } + return aSurface; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) +{ + Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; + TopoDS_Shape aResShape = myContext->Apply(Shape); + + // processing each solid + TopExp_Explorer exps; + for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // map of processed shapes + TopTools_MapOfShape aProcessed; + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + + Standard_Integer NbModif = 0; + Standard_Boolean hasFailed = Standard_False; + Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); + + // count faces + int nbf = 0; + TopExp_Explorer exp; + TopTools_MapOfShape mapF; + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + if (mapF.Add(exp.Current())) + nbf++; + } + + bool doUnion = ((myOptimumNbFaces == 0) || + ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces))); + + // processing each face + mapF.Clear(); + for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + + if (aProcessed.Contains(aFace)) + continue; + + Standard_Integer dummy; + TopTools_SequenceOfShape edges; + AddOrdinaryEdges(edges,aFace,dummy); + + TopTools_SequenceOfShape faces; + faces.Append(aFace); + + //surface and location to construct result + TopLoc_Location aBaseLocation; + Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); + aBaseSurface = ClearRts(aBaseSurface); + + // find adjacent faces to union + Standard_Integer i; + for (i = 1; i <= edges.Length(); i++) { + TopoDS_Edge edge = TopoDS::Edge(edges(i)); + if (BRep_Tool::Degenerated(edge)) + continue; + + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); + if (anCheckedFace.IsSame(aFace)) + continue; + + if (aProcessed.Contains(anCheckedFace)) + continue; + + if (IsSameDomain(aFace,anCheckedFace)) { + + if (aList.Extent() != 2) { + // non mainfold case is not processed + continue; + } + + // replacing pcurves + TopoDS_Face aMockUpFace; + BRep_Builder B; + B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); + MovePCurves(aMockUpFace,anCheckedFace); + + if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { + // sequence edges is modified + i = dummy; + } + + faces.Append(anCheckedFace); + aProcessed.Add(anCheckedFace); + break; + } + } + } + + // all faces collected in the sequence. Perform union of faces + if (faces.Length() > 1) { + NbModif++; + TopoDS_Face aResult; + BRep_Builder B; + B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); + Standard_Integer nbWires = 0; + + // connecting wires + while (edges.Length()>0) { + + Standard_Boolean isEdge3d = Standard_False; + nbWires++; + TopTools_MapOfShape aVertices; + TopoDS_Wire aWire; + B.MakeWire(aWire); + + TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); + edges.Remove(1); + + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + B.Add(aWire,anEdge); + TopoDS_Vertex V1,V2; + TopExp::Vertices(anEdge,V1,V2); + aVertices.Add(V1); + aVertices.Add(V2); + + Standard_Boolean isNewFound = Standard_False; + do { + isNewFound = Standard_False; + for(Standard_Integer j = 1; j <= edges.Length(); j++) { + anEdge = TopoDS::Edge(edges(j)); + TopExp::Vertices(anEdge,V1,V2); + if(aVertices.Contains(V1) || aVertices.Contains(V2)) { + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + aVertices.Add(V1); + aVertices.Add(V2); + B.Add(aWire,anEdge); + edges.Remove(j); + j--; + isNewFound = Standard_True; + } + } + } while (isNewFound); + + // sorting any type of edges + aWire = TopoDS::Wire(aContext->Apply(aWire)); + + TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isDegRemoved = Standard_False; + if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { + // clear degenerated edges if at least one with 3d curve exist + if(isEdge3d) { + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { + TopoDS_Edge E = sewd->Edge(j); + if(BRep_Tool::Degenerated(E)) { + sewd->Remove(j); + isDegRemoved = Standard_True; + j--; + } + } + } + sfw->FixShifted(); + if(isDegRemoved) + sfw->FixDegenerated(); + } + TopoDS_Wire aWireFixed = sfw->Wire(); + aContext->Replace(aWire,aWireFixed); + // add resulting wire + if(isEdge3d) { + B.Add(aResult,aWireFixed); + } + else { + // sorting edges + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Standard_Integer nbEdges = sbwd->NbEdges(); + // sort degenerated edges and create one edge instead of several ones + ShapeAnalysis_WireOrder sawo(Standard_False, 0); + ShapeAnalysis_Edge sae; + Standard_Integer aLastEdge = nbEdges; + for(Standard_Integer j = 1; j <= nbEdges; j++) { + Standard_Real f,l; + //smh protection on NULL pcurve + Handle(Geom2d_Curve) c2d; + if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { + aLastEdge--; + continue; + } + sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); + } + sawo.Perform(); + + // constructind one degenerative edge + gp_XY aStart, anEnd, tmp; + Standard_Integer nbFirst = sawo.Ordered(1); + TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); + ShapeBuild_Edge sbe; + TopoDS_Vertex aDummyV; + TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); + sawo.XY(nbFirst,aStart,tmp); + sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); + + gp_XY aVec = anEnd-aStart; + Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); + + B.UpdateEdge(E,aLine,tmpF,0.); + B.Range(E,tmpF,0.,aVec.Modulus()); + Handle(Geom_Curve) C3d; + B.UpdateEdge(E,C3d,0.); + B.Degenerated(E,Standard_True); + TopoDS_Wire aW; + B.MakeWire(aW); + B.Add(aW,E); + B.Add(aResult,aW); + } + } + + // perform substitution of face + aContext->Replace(aContext->Apply(aFace),aResult); + + ShapeFix_Face sff (aResult); + //Intializing by tolerances + sff.SetPrecision(myTolerance); + sff.SetMinTolerance(tol); + sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); + //Setting modes + sff.FixOrientationMode() = 0; + //sff.FixWireMode() = 0; + sff.SetContext(aContext); + // Applying the fixes + sff.Perform(); + if(sff.Status(ShapeExtend_FAIL)) + hasFailed = Standard_True; + + // breaking down to several faces + TopoDS_Shape theResult = aContext->Apply(aResult); + for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { + TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); + Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); + grid->SetValue ( 1, 1, aBaseSurface ); + Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); + ShapeFix_ComposeShell CompShell; + CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision + CompShell.SetContext( aContext ); + + TopTools_SequenceOfShape parts; + ShapeFix_SequenceOfWireSegment wires; + for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { + Handle(ShapeExtend_WireData) sbwd = + new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); + ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); + wires.Append(seg); + } + + CompShell.DispatchWires ( parts,wires ); + for (Standard_Integer j=1; j <= parts.Length(); j++ ) { + ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); + aFixOrient.SetContext(aContext); + aFixOrient.FixOrientation(); + } + + TopoDS_Shape CompRes; + if ( faces.Length() !=1 ) { + TopoDS_Shell S; + B.MakeShell ( S ); + for ( i=1; i <= parts.Length(); i++ ) + B.Add ( S, parts(i) ); + CompRes = S; + } + else CompRes = parts(1); + + aContext->Replace(aCurrent,CompRes); + } + + // remove the remaining faces + for(i = 2; i <= faces.Length(); i++) + aContext->Remove(faces(i)); + } + } // end processing each face + + //TopoDS_Shape aResult = Shape; + if (NbModif > 0 && !hasFailed) { + TopoDS_Shape aResult = aContext->Apply(aSolid); + + ShapeFix_Edge sfe; + for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + // ptv add fix same parameter + sfe.FixSameParameter(E, myTolerance); + } + + myContext->Replace(aSolid, aResult); + } + //else + { + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(myContext); + sfw->SetPrecision(myTolerance); + sfw->SetMinTolerance(myTolerance); + sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sfw->SetFace(aFace); + for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { + TopoDS_Wire wire = TopoDS::Wire(iter.Value()); + sfw->Load(wire); + sfw->FixReorder(); + sfw->FixShifted(); + } + } + } + } // end processing each solid + + aResShape = myContext->Apply(Shape); + return aResShape; +} + +//======================================================================= +//function : IsSameDomain +//purpose : +//======================================================================= +bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder) +{ + bool isCylinder = false; + + if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface); + + theOutCylinder = aGC->Cylinder(); + isCylinder = true; + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { + Handle(Geom_SurfaceOfRevolution) aRS = + Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aRS->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) { + Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis); + gp_Dir aDir = aRS->Direction(); + gp_Dir aBasisDir = aBasisLine->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis line is parallel to the revolution axis: it is a cylinder + gp_Pnt aLoc = aRS->Location(); + Standard_Real aR = aBasisLine->Lin().Distance(aLoc); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { + Handle(Geom_SurfaceOfLinearExtrusion) aLES = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aLES->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) { + Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis); + gp_Dir aDir = aLES->Direction(); + gp_Dir aBasisDir = aBasisCircle->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis circle is normal to the extrusion axis: it is a cylinder + gp_Pnt aLoc = aBasisCircle->Location(); + Standard_Real aR = aBasisCircle->Radius(); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else { + } + + return isCylinder; +} + +Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aCheckedFace) const +{ + //checking the same handles + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1, S2; + + S1 = BRep_Tool::Surface(aFace,L1); + S2 = BRep_Tool::Surface(aCheckedFace,L2); + + if (S1 == S2 && L1 == L2) + return true; + + // planar and cylindrical cases (IMP 20052) + Standard_Real aPrec = Precision::Confusion(); + + S1 = BRep_Tool::Surface(aFace); + S2 = BRep_Tool::Surface(aCheckedFace); + + S1 = ClearRts(S1); + S2 = ClearRts(S2); + + //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2; + //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1); + //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2); + //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface(); + //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface(); + + // case of two elementary surfaces: use OCCT tool + // elementary surfaces: ConicalSurface, CylindricalSurface, + // Plane, SphericalSurface and ToroidalSurface + if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && + S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { + Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1); + Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2); + + Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); + Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 + IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#else + IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#endif + if (!anIIInt.IsDone() || anIIInt.IsEmpty()) + return false; + + return anIIInt.TangentFaces(); + } + catch (Standard_Failure) { + return false; + } + } + + // case of two planar surfaces: + // all kinds of surfaces checked, including b-spline and bezier + GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec); + if (aPlanarityChecker1.IsPlanar()) { + GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec); + if (aPlanarityChecker2.IsPlanar()) { + gp_Pln aPln1 = aPlanarityChecker1.Plan(); + gp_Pln aPln2 = aPlanarityChecker2.Plan(); + + if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) && + aPln1.Distance(aPln2) < aPrec) { + return true; + } + } + } + + // case of two cylindrical surfaces, at least one of which is a swept surface + // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution + if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && + (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S2->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) + { + gp_Cylinder aCyl1, aCyl2; + if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) { + if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) { + gp_Dir aDir1 = aCyl1.Position().Direction(); + gp_Dir aDir2 = aCyl2.Position().Direction(); + if (aDir1.IsParallel(aDir2, aPrec)) { + gp_Pnt aLoc1 = aCyl1.Location(); + gp_Pnt aLoc2 = aCyl2.Location(); + gp_Vec aVec12 (aLoc1, aLoc2); + if (aVec12.SquareMagnitude() < aPrec*aPrec || + aVec12.IsParallel(aDir1, aPrec)) { + return true; + } + } + } + } + } + + return false; +} + +//======================================================================= +//function : MovePCurves +//purpose : +//======================================================================= +void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const +{ + BRep_Builder B; + for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), + aTarget, Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); + sfw->FixEdgeCurves(); + if(isReoredFailed) + continue; + + sfw->FixShifted(); + sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { + sewd->Remove(i); + i--; + } + } + + TopoDS_Wire ResWire = sfw->Wire(); + B.Add(aTarget,ResWire); + } +} diff --git a/src/BlockFix/BlockFix_UnionFaces.hxx b/src/BlockFix/BlockFix_UnionFaces.hxx new file mode 100644 index 000000000..83140b08b --- /dev/null +++ b/src/BlockFix/BlockFix_UnionFaces.hxx @@ -0,0 +1,65 @@ +// 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 + +#ifndef _BlockFix_UnionFaces_HeaderFile +#define _BlockFix_UnionFaces_HeaderFile + +#include +#include +#include +#include + +class TopoDS_Shape; +class TopoDS_Face; + +class BlockFix_UnionFaces +{ +public: + Standard_EXPORT BlockFix_UnionFaces(); + + Standard_EXPORT Standard_Real& GetTolerance(); + + /* \brief To get/set the OptimumNbFaces parameter + * + * If a being processed solid has less than OptimumNbFaces + * faces, no union will be performed. + * By default this parameter is set to 6 (to correctly + * process blocks - hexahedral solids) + * Special values: 0 - do all possible unions, regardless the faces quantity, + * negative - do not perform any unions, regardless the faces quantity. + * + */ + Standard_EXPORT Standard_Integer& GetOptimumNbFaces(); + + Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape); + + Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aChekedFace) const; + + Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const; + +private: + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +#endif diff --git a/src/BlockFix/Makefile.am b/src/BlockFix/Makefile.am new file mode 100644 index 000000000..a3b37223d --- /dev/null +++ b/src/BlockFix/Makefile.am @@ -0,0 +1,55 @@ +# 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 + +# GEOM BlockFix : tools for Blocks algorithms +# File : Makefile.am +# Author : Julia DOROVSKIKH +# Module : GEOM + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# Libraries targets +lib_LTLIBRARIES = libBlockFix.la + +dist_libBlockFix_la_SOURCES = \ + BlockFix_BlockFixAPI.cxx \ + BlockFix_CheckTool.cxx \ + BlockFix.cxx \ + BlockFix_PeriodicSurfaceModifier.cxx \ + BlockFix_SphereSpaceModifier.cxx \ + BlockFix_UnionEdges.cxx \ + BlockFix_UnionFaces.cxx + +# header files +salomeinclude_HEADERS = \ + BlockFix.hxx \ + BlockFix_BlockFixAPI.hxx \ + BlockFix_CheckTool.hxx \ + BlockFix_PeriodicSurfaceModifier.hxx \ + BlockFix_SphereSpaceModifier.hxx \ + BlockFix_UnionEdges.hxx \ + BlockFix_UnionFaces.hxx + +libBlockFix_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) + +libBlockFix_la_LDFLAGS = \ + $(STDLIB) \ + $(CAS_LDPATH) -lTKBO -lTKShHealing -lTKBool -lTKMesh -lTKOffset \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace diff --git a/src/GEOMAlgo/BlockFix.cdl b/src/GEOMAlgo/BlockFix.cdl deleted file mode 100644 index 961af6625..000000000 --- a/src/GEOMAlgo/BlockFix.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- 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: BlockFix.cdl --- Created: Tue Dec 7 11:59:05 2004 --- Author: Pavel Durandin --- -package BlockFix - -uses - - TColStd, - gp, - Geom, - Geom2d, - GeomAbs, - TopLoc, - TopoDS, - BRepTools, - TopTools, - ShapeBuild - -is - - class SphereSpaceModifier; - - class UnionFaces; - - class UnionEdges; - - class BlockFixAPI; - ---Purpose: API class to perform the fixing of the - -- block - - class PeriodicSurfaceModifier; - - class CheckTool; - - RotateSphereSpace (S: Shape from TopoDS; Tol: Real) - returns Shape from TopoDS; - - FixRanges (S: Shape from TopoDS; Tol: Real) - returns Shape from TopoDS; - ---Purpose: checking and fixing cases where parametric - -- boundaries of face based on periodic surface are not - -- contained in the range of this surface. - -end BlockFix; diff --git a/src/GEOMAlgo/BlockFix.cxx b/src/GEOMAlgo/BlockFix.cxx deleted file mode 100644 index 0e4f9bb21..000000000 --- a/src/GEOMAlgo/BlockFix.cxx +++ /dev/null @@ -1,344 +0,0 @@ -// 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: BlockFix.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -//======================================================================= -//function : FixResult -//purpose : auxilary -//======================================================================= -static void FixResult(const TopoDS_Shape& result, - Handle(ShapeBuild_ReShape)& Context, - const Standard_Real Tol) -{ - for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { - TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); - // face coud not be dropped or splitted on this step - TopoDS_Face aFace = TopoDS::Face(aShape); - TopLoc_Location L; - Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); - - if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || - Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) { - - Standard_Integer nbWires = 0; - for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { - nbWires++; - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), - aFace, - Precision::Confusion()); - sfw->FixReorder(); - if(sfw->StatusReorder ( ShapeExtend_FAIL )) - continue; - - sfw->SetPrecision(2.*Tol); - sfw->FixShifted(); - - Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); - isDone |= sfw->FixDegenerated(); - - // remove degenerated edges from not degenerated points - ShapeAnalysis_Edge sae; - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - Standard_Integer i; - for( i = 1; i<=sewd->NbEdges();i++) { - TopoDS_Edge E = sewd->Edge(i); - if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { - sewd->Remove(i); - isDone = Standard_True; - i--; - } - } - - //isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395) - - // remove neighbour seam edges - if(isDone) { - for( i = 1; iNbEdges();i++) { - if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { - isDone = Standard_True; - sewd->Remove(i); - sewd->Remove(i); - i--; - } - } - if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { - sewd->Remove(1); - sewd->Remove(sewd->NbEdges()); - } - } - - if(isDone) { - TopoDS_Wire ResWire = sfw->Wire(); - Context->Replace(ex_w.Current(), ResWire); - }; - } - // Implement fix orientation in case of several wires - if(nbWires > 1) { - TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); - Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); - if(sff->FixOrientation()) - Context->Replace(aFixedFace,sff->Face()); - } - } - } -} - -//======================================================================= -//function : RotateSphereSpace -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, - const Standard_Real Tol) -{ - // Create a modification description - Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; - SR->SetTolerance(Tol); - - TopTools_DataMapOfShapeShape context; - BRepTools_Modifier MD; - TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); - - Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; - FixResult(result,RS,Tol); - result = RS->Apply(result); - - ShapeFix_Edge sfe; - for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - } - - ShapeFix::SameParameter(result,Standard_False); - return result; -} - -//======================================================================= -//function : RefillProblemFaces -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::RefillProblemFaces (const TopoDS_Shape& aShape) -{ - Standard_Integer NbSamples = 10; - - TopTools_ListOfShape theFaces; - - TopExp_Explorer Explo(aShape, TopAbs_FACE); - for (; Explo.More(); Explo.Next()) - { - TopoDS_Face aFace = TopoDS::Face(Explo.Current()); - BRepAdaptor_Surface BAsurf(aFace); - GeomAbs_SurfaceType SurfType = BAsurf.GetType(); - if (SurfType >= GeomAbs_BezierSurface) - { - TopExp_Explorer fexp(aFace, TopAbs_EDGE); - for (; fexp.More(); fexp.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(fexp.Current()); - if (BRep_Tool::Degenerated(anEdge)) - { - TopoDS_Vertex V1, V2; - TopExp::Vertices(anEdge, V1, V2); - if (V1.IsSame(V2)) - { - gp_Pnt aPnt = BRep_Tool::Pnt(V1); - Standard_Real TolV = BRep_Tool::Tolerance(V1); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - Handle(ShapeAnalysis_Surface) Analyser = new ShapeAnalysis_Surface(aSurf); - if (Analyser->IsDegenerated(aPnt, TolV)) - { - theFaces.Append(aFace); - break; - } - } - } - } - } - } - - //Now all problem faces are collected in the list "theFaces" - BRepTools_Substitution aSubst; - TopTools_ListIteratorOfListOfShape itl(theFaces); - for (; itl.More(); itl.Next()) - { - const TopoDS_Face& aFace = TopoDS::Face(itl.Value()); - BRepOffsetAPI_MakeFilling Filler; - for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); - if (!BRep_Tool::Degenerated(anEdge)) - Filler.Add(anEdge, GeomAbs_C0); - } - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - //Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - Standard_Integer i, j; - for (i = 1; i < NbSamples; i++) - for (j = 1; j < NbSamples; j++) { - /* - gp_Pnt aPoint = aSurf->Value(Umin + i*(Umax-Umin)/NbSamples, - Vmin + j*(Vmax-Vmin)/NbSamples); - Filler.Add(aPoint); - */ - Filler.Add(Umin + i*(Umax-Umin)/NbSamples, - Vmin + j*(Vmax-Vmin)/NbSamples, - aFace, GeomAbs_G1); - } - - Filler.Build(); - if (Filler.IsDone()) - { - for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); - TopTools_ListOfShape Ledge; - if (!BRep_Tool::Degenerated(anEdge)) - { - const TopTools_ListOfShape& Ledges = Filler.Generated(anEdge); - if (!Ledges.IsEmpty()) { - TopoDS_Shape NewEdge = Ledges.First(); - Ledge.Append(NewEdge.Oriented(TopAbs_FORWARD)); - } - } - aSubst.Substitute(anEdge, Ledge); - } - TopTools_ListOfShape Lface; - TopoDS_Face NewFace = TopoDS::Face(Filler.Shape()); - NewFace.Orientation(TopAbs_FORWARD); - BRepAdaptor_Surface NewBAsurf(NewFace); - gp_Pnt MidPnt; - gp_Vec D1U, D1V, Normal, NewNormal; - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - aSurf->D1((Umin+Umax)*0.5, (Vmin+Vmax)*0.5, MidPnt, D1U, D1V); - Normal = D1U ^ D1V; - NewBAsurf.D1((NewBAsurf.FirstUParameter() + NewBAsurf.LastUParameter())*0.5, - (NewBAsurf.FirstVParameter() + NewBAsurf.LastVParameter())*0.5, - MidPnt, D1U, D1V); - NewNormal = D1U ^ D1V; - if (Normal * NewNormal < 0.) - NewFace.Reverse(); - Lface.Append(NewFace); - aSubst.Substitute(aFace, Lface); - } - } - aSubst.Build(aShape); - - TopoDS_Shape Result = aShape; - if (aSubst.IsCopied(aShape)) - Result = aSubst.Copy(aShape).First(); - - BRepTools::RemoveUnusedPCurves(Result); - - return Result; -} - -//======================================================================= -//function : FixRanges -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, - const Standard_Real Tol) -{ - // Create a modification description - Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; - SR->SetTolerance(Tol); - - TopTools_DataMapOfShapeShape context; - BRepTools_Modifier MD; - TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); - - Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; - FixResult(result,RS,Tol); - result = RS->Apply(result); - - ShapeFix_Edge sfe; - for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - } - - ShapeFix::SameParameter(result,Standard_False); - - return result; -} diff --git a/src/GEOMAlgo/BlockFix.hxx b/src/GEOMAlgo/BlockFix.hxx deleted file mode 100644 index 34007be5c..000000000 --- a/src/GEOMAlgo/BlockFix.hxx +++ /dev/null @@ -1,81 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_HeaderFile -#define _BlockFix_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif - -class TopoDS_Shape; -class BlockFix_SphereSpaceModifier; -class BlockFix_UnionFaces; -class BlockFix_UnionEdges; -class BlockFix_BlockFixAPI; -class BlockFix_PeriodicSurfaceModifier; -class BlockFix_CheckTool; - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class BlockFix { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol); - Standard_EXPORT static TopoDS_Shape RefillProblemFaces(const TopoDS_Shape& S); - Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol); - -protected: - -private: - -friend class BlockFix_SphereSpaceModifier; -friend class BlockFix_UnionFaces; -friend class BlockFix_UnionEdges; -friend class BlockFix_BlockFixAPI; -friend class BlockFix_PeriodicSurfaceModifier; -friend class BlockFix_CheckTool; - -}; - -// other Inline functions and methods (like "C++: function call" methods) - -#endif diff --git a/src/GEOMAlgo/BlockFix.ixx b/src/GEOMAlgo/BlockFix.ixx deleted file mode 100644 index 2ea228ff7..000000000 --- a/src/GEOMAlgo/BlockFix.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// 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 - - - - diff --git a/src/GEOMAlgo/BlockFix.jxx b/src/GEOMAlgo/BlockFix.jxx deleted file mode 100644 index 8649f8895..000000000 --- a/src/GEOMAlgo/BlockFix.jxx +++ /dev/null @@ -1,28 +0,0 @@ -// 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 -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl deleted file mode 100644 index 8cb4c49ce..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl +++ /dev/null @@ -1,68 +0,0 @@ --- 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: BlockFix_BlockFixAPI.cdl --- Created: Tue Dec 7 17:56:09 2004 --- Author: Pavel Durandin --- -class BlockFixAPI from BlockFix inherits TShared from MMgt - - ---Purpose: - -uses - - Shape from TopoDS, - ReShape from ShapeBuild - -is - Create returns BlockFixAPI from BlockFix; - ---Purpose: Empty constructor - - SetShape(me: mutable; Shape: Shape from TopoDS); - ---Purpose: Sets the shape to be operated on - ---C++: inline - - Perform(me: mutable); - ---Purpose: - - Shape(me) returns Shape from TopoDS; - ---Purpose: Returns resulting shape. - ---C++: inline - - Context(me:mutable) returns ReShape from ShapeBuild; - ---Purpose: Returns modifiable context for storing the - -- mofifications - ---C++: inline - ---C++: return & - - Tolerance (me:mutable) returns Real; - ---Purpose: Returns modifiable tolerance of recognition - ---C++: inline - ---C++: return & - -fields - - myContext : ReShape from ShapeBuild; - myShape : Shape from TopoDS; - myTolerance : Real from Standard; - -end BlockFixAPI from BlockFix; diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx deleted file mode 100644 index 3c82e4a84..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// 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: BlockFix_BlockFixAPI.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include -#include - -#include - -#include - -#include - -//======================================================================= -//function : ShapeConvert_CanonicAPI -//purpose : -//======================================================================= - -BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() -{ - myTolerance = Precision::Confusion(); - myOptimumNbFaces = 6; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void BlockFix_BlockFixAPI::Perform() -{ - // processing spheres with degenerativities - TopoDS_Shape aShape = Shape(); - myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); - - // try to approximate non-canonic surfaces - // with singularities on boundaries by filling - myShape = BlockFix::RefillProblemFaces(myShape); - - // faces unification - BlockFix_UnionFaces aFaceUnifier; - aFaceUnifier.GetTolerance() = myTolerance; - aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; - TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); - - // avoid problem with degenerated edges appearance - // due to shape quality regress - ShapeUpgrade_RemoveLocations RemLoc; - RemLoc.Remove(aResult); - aResult = RemLoc.GetResult(); - - // edges unification - BlockFix_UnionEdges anEdgeUnifier; - myShape = anEdgeUnifier.Perform(aResult,myTolerance); - - TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); - myShape = aRes; -} diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx deleted file mode 100644 index 7be25cc57..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_BlockFixAPI_HeaderFile -#define _BlockFix_BlockFixAPI_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile -#include -#endif - -#ifndef _Handle_ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif - -class ShapeBuild_ReShape; -class TopoDS_Shape; - - -class BlockFix_BlockFixAPI : public MMgt_TShared -{ -public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - // Methods PUBLIC - // - Standard_EXPORT BlockFix_BlockFixAPI(); - void SetShape(const TopoDS_Shape& Shape); - Standard_EXPORT void Perform(); - TopoDS_Shape Shape() const; - Handle_ShapeBuild_ReShape& Context(); - Standard_Real& Tolerance(); - Standard_Integer& OptimumNbFaces(); - Standard_EXPORT ~BlockFix_BlockFixAPI(); - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -private: - // Fields PRIVATE - // - Handle_ShapeBuild_ReShape myContext; - TopoDS_Shape myShape; - Standard_Real myTolerance; - Standard_Integer myOptimumNbFaces; -}; - -#include - -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx deleted file mode 100644 index 4d06a875e..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx +++ /dev/null @@ -1,77 +0,0 @@ -// 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 - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_BlockFixAPI_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("BlockFix_BlockFixAPI", - sizeof(BlockFix_BlockFixAPI), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_BlockFixAPI) Handle(BlockFix_BlockFixAPI)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_BlockFixAPI) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_BlockFixAPI))) { - _anOtherObject = Handle(BlockFix_BlockFixAPI)((Handle(BlockFix_BlockFixAPI)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_BlockFixAPI::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_BlockFixAPI) ; -} -Standard_Boolean BlockFix_BlockFixAPI::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_BlockFixAPI) == AType || MMgt_TShared::IsKind(AType)); -} -Handle_BlockFix_BlockFixAPI::~Handle_BlockFix_BlockFixAPI() {} - diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx deleted file mode 100644 index 945a6ed88..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -// - -#ifndef _ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_BlockFixAPI_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx deleted file mode 100644 index 5992e1794..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx +++ /dev/null @@ -1,73 +0,0 @@ -// 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 - -//======================================================================= -//function : SetShape -//purpose : -//======================================================================= - -inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) -{ - myShape = Shape; -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - -inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const -{ - return myShape; -} - -//======================================================================= -//function : Context -//purpose : -//======================================================================= - -inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() -{ - return myContext; -} - -//======================================================================= -//function : Tolerance -//purpose : -//======================================================================= - -inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() -{ - return myTolerance; -} - -//======================================================================= -//function : OptimumNbFaces -//purpose : -//======================================================================= - -inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces() -{ - return myOptimumNbFaces; -} diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cdl b/src/GEOMAlgo/BlockFix_CheckTool.cdl deleted file mode 100644 index c5423377f..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- 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: BlockFix_CheckTool.cdl --- Created: Fri Dec 17 10:36:58 2004 --- Author: Sergey KUUL --- -class CheckTool from BlockFix - - ---Purpose: - -uses - - Shape from TopoDS, - SequenceOfShape from TopTools - -is - - Create returns CheckTool from BlockFix; - ---Purpose: Empty constructor - - SetShape(me: in out; aShape: Shape from TopoDS); - - Perform(me: in out); - ---Purpose: - - NbPossibleBlocks(me) returns Integer; - - PossibleBlock(me; num: Integer) returns Shape from TopoDS; - - DumpCheckResult(me; S : in out OStream); - ---Purpose: Dumps results of checking - - -fields - - myShape : Shape from TopoDS; - myHasCheck : Boolean; - myNbSolids : Integer; - myNbBlocks : Integer; - myPossibleBlocks : SequenceOfShape from TopTools; - myNbDegen : Integer; - myNbUF : Integer; - myNbUE : Integer; - myNbUFUE : Integer; - myBadRanges : Integer; - -end CheckTool; diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cxx b/src/GEOMAlgo/BlockFix_CheckTool.cxx deleted file mode 100644 index 674ef69dd..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.cxx +++ /dev/null @@ -1,279 +0,0 @@ -// 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: BlockFix_CheckTool.cxx -// Created: 17.12.04 11:15:25 -// Author: Sergey KUUL -// -#include - -//#include -//#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_CheckTool() -//purpose : Constructor -//======================================================================= - -BlockFix_CheckTool::BlockFix_CheckTool( ) -{ - myHasCheck = Standard_False; - myPossibleBlocks.Clear(); -} - - -//======================================================================= -//function : SetShape -//purpose : -//======================================================================= - -void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) -{ - myHasCheck = Standard_False; - myShape = aShape; - myPossibleBlocks.Clear(); -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void BlockFix_CheckTool::Perform() -{ - myNbSolids=0; - myNbBlocks=0; - myNbDegen=0; - myNbUF=0; - myNbUE=0; - myNbUFUE=0; - - TopExp_Explorer exps (myShape, TopAbs_SOLID); - TopTools_MapOfShape mapS; - for (; exps.More(); exps.Next()) { - TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - if (!mapS.Add(aSolid)) continue; - myNbSolids++; - Standard_Boolean IsBlock=Standard_True; - Standard_Boolean MayBeUF=Standard_False; - Standard_Boolean MayBeUE=Standard_False; - Standard_Integer nf=0; - TopExp_Explorer expf (aSolid, TopAbs_FACE); - TopTools_MapOfShape mapF; - for (; expf.More(); expf.Next()) { - if (mapF.Add(expf.Current())) - nf++; - } - - if (nf < 6) { - IsBlock = Standard_False; - } - else if (nf > 6) { - IsBlock = Standard_False; - // check faces unification - TopTools_SequenceOfShape faces; - mapF.Clear(); - for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { - if (mapF.Add(expf.Current())) { - TopoDS_Face aFace = TopoDS::Face(expf.Current()); - faces.Append(aFace); - } - } - Standard_Boolean HasFacesForUnification = Standard_False; - for (Standard_Integer i=1; i 0) { - IsBlock = Standard_False; - myNbDegen++; - myPossibleBlocks.Append(aSolid); - continue; - } - if (nbe < 12) - IsBlock = Standard_False; - if (nbe > 12) { - IsBlock = Standard_False; - // check edges unification - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - mapF.Clear(); - for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { - TopoDS_Face aFace = TopoDS::Face(expf.Current()); - if (!mapF.Add(aFace)) continue; - TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; - - TopTools_MapOfShape mapEe; - for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { - TopoDS_Edge edge = TopoDS::Edge(expe.Current()); - if (!mapEe.Add(edge)) continue; - if (!aMapEdgeFaces.Contains(edge)) continue; - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter (aList); - for (; anIter.More(); anIter.Next()) { - TopoDS_Face face = TopoDS::Face(anIter.Value()); - if (face.IsSame(aFace)) continue; - if (aMapFacesEdges.Contains(face)) { - aMapFacesEdges.ChangeFromKey(face).Append(edge); - } - else { - TopTools_ListOfShape ListEdges; - ListEdges.Append(edge); - aMapFacesEdges.Add(face,ListEdges); - } - } - } - Standard_Integer i = 1; - for (; i <= aMapFacesEdges.Extent(); i++) { - const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); - if (ListEdges.Extent() > 1) break; - } - if (i <= aMapFacesEdges.Extent()) { - MayBeUE = Standard_True; - break; - } - } - } - - if (IsBlock) - myNbBlocks++; - else { - if (MayBeUF) { - myPossibleBlocks.Append(aSolid); - if (MayBeUE) - myNbUFUE++; - else - myNbUF++; - } - else if (MayBeUE) { - myNbUE++; - myPossibleBlocks.Append(aSolid); - } - } - } - - myHasCheck = Standard_True; -} - - -//======================================================================= -//function : NbPossibleBlocks -//purpose : -//======================================================================= - -Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const -{ - return myPossibleBlocks.Length(); -} - - -//======================================================================= -//function : PossibleBlock -//purpose : -//======================================================================= - -TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const -{ - TopoDS_Shape res; - if( num>0 && num<=myPossibleBlocks.Length() ) - res = myPossibleBlocks.Value(num); - return res; -} - - -//======================================================================= -//function : DumpCheckResult -//purpose : -//======================================================================= - -void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const -{ - if(!myHasCheck) - S<<"Check not performed!"< - - - - diff --git a/src/GEOMAlgo/BlockFix_CheckTool.jxx b/src/GEOMAlgo/BlockFix_CheckTool.jxx deleted file mode 100644 index 7574af057..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.jxx +++ /dev/null @@ -1,28 +0,0 @@ -// 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 -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_CheckTool_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl deleted file mode 100644 index 374af919c..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl +++ /dev/null @@ -1,135 +0,0 @@ --- 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: BlockFix_PeriodicSurfaceModifier.cdl --- Created: Wed Dec 15 10:03:50 2004 --- Author: Sergey KUUL --- -class PeriodicSurfaceModifier from BlockFix inherits Modification from BRepTools - - ---Purpose: - -uses - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Location from TopLoc, - Shape from GeomAbs, - Pnt from gp, - Curve from Geom, - Curve from Geom2d, - Surface from Geom, - IndexedMapOfTransient from TColStd, - DataMapOfShapeInteger from TopTools - -is - - Create returns mutable PeriodicSurfaceModifier from BlockFix; - - SetTolerance(me: mutable; Toler: Real); - ---Purpose: Sets the tolerance for recognition of geometry - - NewSurface(me: mutable; F : Face from TopoDS; - S : out Surface from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard; - RevWires : out Boolean from Standard; - RevFace : out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the face has been - -- modified. In this case, is the new geometric - -- support of the face, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewCurve(me: mutable; E : Edge from TopoDS; - C : out Curve from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has been - -- modified. In this case, is the new geometric - -- support of the edge, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewPoint(me: mutable; V : Vertex from TopoDS; - P : out Pnt from gp; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the vertex has been - -- modified. In this case,

    is the new geometric - -- support of the vertex, the new tolerance. - -- Otherwise, returns Standard_False, and

    , - -- are not significant. - - NewCurve2d(me: mutable; E : Edge from TopoDS; - F : Face from TopoDS; - NewE : Edge from TopoDS; - NewF : Face from TopoDS; - C : out Curve from Geom2d; - Tol : out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has a new - -- curve on surface on the face .In this case, - -- is the new geometric support of the edge, the - -- new location, the new tolerance. - -- - -- Otherwise, returns Standard_False, and , , - -- are not significant. - -- - -- is the new edge created from . - -- is the new face created from . They may be usefull. - - NewParameter(me: mutable; V : Vertex from TopoDS; - E : Edge from TopoDS; - P : out Real from Standard; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the Vertex has a new - -- parameter on the edge . In this case,

    is - -- the parameter, the new tolerance. - -- Otherwise, returns Standard_False, and

    , - -- are not significant. - - Continuity(me: mutable; E : Edge from TopoDS; - F1,F2 : Face from TopoDS; - NewE : Edge from TopoDS; - NewF1,NewF2: Face from TopoDS) - returns Shape from GeomAbs; - ---Purpose: Returns the continuity of between - -- and . - -- - -- is the new edge created from . - -- (resp. ) is the new face created from - -- (resp. ). - - -fields - - myTolerance : Real; - myMapOfFaces : DataMapOfShapeInteger from TopTools; - myMapOfSurfaces: IndexedMapOfTransient from TColStd; - -end PeriodicSurfaceModifier; diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx deleted file mode 100644 index 1e9f33ca0..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx +++ /dev/null @@ -1,251 +0,0 @@ -// 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: BlockFix_PeriodicSurfaceModifier.cxx -// Created: 15.12.04 10:08:50 -// Author: Sergey KUUL - -#include - -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_PeriodicSurfaceModifier() -//purpose : Constructor -//======================================================================= - -BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier ( ) -{ - myMapOfFaces.Clear(); - myMapOfSurfaces.Clear(); -} - - -//======================================================================= -//function : SetTolerance -//purpose : -//======================================================================= - -void BlockFix_PeriodicSurfaceModifier::SetTolerance(const Standard_Real Tol) -{ - myTolerance = Tol; -} - - -//======================================================================= -//function : ModifySurface -//purpose : auxilary -//======================================================================= - -static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, - const Handle(Geom_Surface)& aSurface, - Handle(Geom_Surface)& aNewSurface) -{ - Handle(Geom_Surface) S = aSurface; - - if(S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { - Handle(Geom_CylindricalSurface) aCyl = - Handle(Geom_CylindricalSurface)::DownCast(S); - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { - gp_Ax3 ax3 = aCyl->Position(); - gp_Ax1 NDir = ax3.Axis(); - gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); - Handle(Geom_CylindricalSurface) aNewCyl = - new Geom_CylindricalSurface(newax3,aCyl->Radius()); - aNewSurface = aNewCyl; - return Standard_True; - } - } - - if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { - Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { - gp_Ax3 ax3 = aSphere->Position(); - gp_Ax1 NDir = ax3.Axis(); - gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(newax3,aSphere->Radius()); - aNewSurface = aNewSphere; - return Standard_True; - } - } - - return Standard_False; -} - - -//======================================================================= -//function : NewSurface -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewSurface(const TopoDS_Face& F, - Handle(Geom_Surface)& S, - TopLoc_Location& L,Standard_Real& Tol, - Standard_Boolean& RevWires, - Standard_Boolean& RevFace) -{ - TopLoc_Location LS; - Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); - - if(ModifySurface(F, SIni, S)) { - - RevWires = Standard_False; - RevFace = Standard_False; - - L = LS; - Tol = BRep_Tool::Tolerance(F); - - Standard_Integer anIndex = myMapOfSurfaces.Add(S); - myMapOfFaces.Bind(F,anIndex); - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewCurve -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve(const TopoDS_Edge& /*E*/, - Handle(Geom_Curve)& /*C*/, - TopLoc_Location& /*L*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : NewPoint -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, - gp_Pnt& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : NewCurve2d -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve2d(const TopoDS_Edge& E, - const TopoDS_Face& F, - const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF*/, - Handle(Geom2d_Curve)& C, - Standard_Real& Tol) -{ - //check if undelying surface of the face was modified - if(myMapOfFaces.IsBound(F)) { - Standard_Integer anIndex = myMapOfFaces.Find(F); - - Handle(Geom_Surface) aNewSurf = Handle(Geom_Surface)::DownCast(myMapOfSurfaces.FindKey(anIndex)); - - Standard_Real f,l; - TopLoc_Location LC, LS; - Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); - Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); - - //taking into accound the orientation of the seam - C = BRep_Tool::CurveOnSurface(E,F,f,l); - Tol = BRep_Tool::Tolerance(E); - - BRep_Builder B; - TopoDS_Edge TempE; - B.MakeEdge(TempE); - B.Add(TempE, TopExp::FirstVertex(E)); - B.Add(TempE, TopExp::LastVertex(E)); - - if(!C3d.IsNull()) - B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); - B.Range(TempE, f, l); - - Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; - Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(LS.Transformation())); - TopLoc_Location LTemp; - LTemp.Identity(); - - Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); - Standard_Real aWorkTol = 2*myTolerance+Tol; - sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); - sfe->FixSameParameter(TempE); - - //keep the orientation of original edge - TempE.Orientation(E.Orientation()); - C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); - - //surface was modified - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewParameter -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewParameter(const TopoDS_Vertex& /*V*/, - const TopoDS_Edge& /*E*/, - Standard_Real& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : Continuity -//purpose : -//======================================================================= - -GeomAbs_Shape BlockFix_PeriodicSurfaceModifier::Continuity(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF1*/, - const TopoDS_Face& /*NewF2*/) -{ - return BRep_Tool::Continuity(E,F1,F2); -} - diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx deleted file mode 100644 index 39d2062ea..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile -#define _BlockFix_PeriodicSurfaceModifier_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile -#include -#endif - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _TColStd_IndexedMapOfTransient_HeaderFile -#include -#endif -#ifndef _BRepTools_Modification_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Surface_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Curve_HeaderFile -#include -#endif -#ifndef _Handle_Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _GeomAbs_Shape_HeaderFile -#include -#endif -class TopoDS_Face; -class Geom_Surface; -class TopLoc_Location; -class TopoDS_Edge; -class Geom_Curve; -class TopoDS_Vertex; -class gp_Pnt; -class Geom2d_Curve; - - -class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_PeriodicSurfaceModifier(); -Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; -Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; -Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; -Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; -Standard_EXPORT ~BlockFix_PeriodicSurfaceModifier(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -TopTools_DataMapOfShapeInteger myMapOfFaces; -TColStd_IndexedMapOfTransient myMapOfSurfaces; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx deleted file mode 100644 index da3bdc95e..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx +++ /dev/null @@ -1,79 +0,0 @@ -// 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 - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); - 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("BlockFix_PeriodicSurfaceModifier", - sizeof(BlockFix_PeriodicSurfaceModifier), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_PeriodicSurfaceModifier) Handle(BlockFix_PeriodicSurfaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_PeriodicSurfaceModifier) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier))) { - _anOtherObject = Handle(BlockFix_PeriodicSurfaceModifier)((Handle(BlockFix_PeriodicSurfaceModifier)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_PeriodicSurfaceModifier::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) ; -} -Standard_Boolean BlockFix_PeriodicSurfaceModifier::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) == AType || BRepTools_Modification::IsKind(AType)); -} -Handle_BlockFix_PeriodicSurfaceModifier::~Handle_BlockFix_PeriodicSurfaceModifier() {} - diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx deleted file mode 100644 index 29c1c1e34..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx +++ /dev/null @@ -1,49 +0,0 @@ -// 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 -// - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _Geom_Surface_HeaderFile -#include -#endif -#ifndef _TopLoc_Location_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Geom_Curve_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _gp_Pnt_HeaderFile -#include -#endif -#ifndef _Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl deleted file mode 100644 index da614611b..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl +++ /dev/null @@ -1,139 +0,0 @@ --- 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: BlockFix_SphereSpaceModifier.cdl --- Created: Tue Dec 7 12:01:49 2004 --- Author: Pavel Durandin --- -class SphereSpaceModifier from BlockFix inherits Modification from BRepTools - - ---Purpose: Rotation of the parametric space of the sphere in order - -- to avoid the seam and degenerared edge within it - -uses - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Location from TopLoc, - Shape from GeomAbs, - Pnt from gp, - Curve from Geom, - Curve from Geom2d, - Surface from Geom, - IndexedMapOfTransient from TColStd, - DataMapOfShapeInteger from TopTools - -is - - Create returns mutable SphereSpaceModifier from BlockFix; - - SetTolerance(me: mutable; Toler: Real); - ---Purpose: Sets the tolerance for recognition of geometry - - NewSurface(me: mutable; F : Face from TopoDS; - S : out Surface from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard; - RevWires : out Boolean from Standard; - RevFace : out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the face has been - -- modified. In this case, is the new geometric - -- support of the face, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewCurve(me: mutable; E : Edge from TopoDS; - C : out Curve from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has been - -- modified. In this case, is the new geometric - -- support of the edge, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewPoint(me: mutable; V : Vertex from TopoDS; - P : out Pnt from gp; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the vertex has been - -- modified. In this case,

    is the new geometric - -- support of the vertex, the new tolerance. - -- Otherwise, returns Standard_False, and

    , - -- are not significant. - - NewCurve2d(me: mutable; E : Edge from TopoDS; - F : Face from TopoDS; - NewE : Edge from TopoDS; - NewF : Face from TopoDS; - C : out Curve from Geom2d; - Tol : out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has a new - -- curve on surface on the face .In this case, - -- is the new geometric support of the edge, the - -- new location, the new tolerance. - -- - -- Otherwise, returns Standard_False, and , , - -- are not significant. - -- - -- is the new edge created from . - -- is the new face created from . They may be usefull. - - NewParameter(me: mutable; V : Vertex from TopoDS; - E : Edge from TopoDS; - P : out Real from Standard; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the Vertex has a new - -- parameter on the edge . In this case,

    is - -- the parameter, the new tolerance. - -- Otherwise, returns Standard_False, and

    , - -- are not significant. - - Continuity(me: mutable; E : Edge from TopoDS; - F1,F2 : Face from TopoDS; - NewE : Edge from TopoDS; - NewF1,NewF2: Face from TopoDS) - returns Shape from GeomAbs; - ---Purpose: Returns the continuity of between - -- and . - -- - -- is the new edge created from . - -- (resp. ) is the new face created from - -- (resp. ). - - ForRotation(me: mutable; F: Face from TopoDS) returns Boolean; - -fields - - myTolerance : Real; - myMapOfFaces : DataMapOfShapeInteger from TopTools; - myMapOfSpheres: IndexedMapOfTransient from TColStd; - --myMapOfGeom: MapOfShapeTransient from TColStd; - -end SphereSpaceModifier; - diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx deleted file mode 100644 index 2abc08316..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx +++ /dev/null @@ -1,275 +0,0 @@ -// 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: BlockFix.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_SphereSpaceModifier -//purpose : -//======================================================================= - -BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier() -{ - myMapOfFaces.Clear(); - myMapOfSpheres.Clear(); -} - -//======================================================================= -//function : SetTolerance -//purpose : -//======================================================================= - -void BlockFix_SphereSpaceModifier::SetTolerance(const Standard_Real Tol) -{ - myTolerance = Tol; -} - - -//======================================================================= -//function : NewSurface -//purpose : -//======================================================================= - - -static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, - const Handle(Geom_Surface)& aSurface, - Handle(Geom_Surface)& aNewSurface) -{ - Handle(Geom_Surface) S = aSurface; - if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(S); - S = RTS->BasisSurface(); - } - - if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { - Standard_Real Umin, Umax, Vmin, Vmax; - ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax); - Standard_Real PI2 = M_PI/2.; - if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { - Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); - gp_Sphere sp = aSphere->Sphere(); - //modified by jgv, 12.11.2012 for issue 21777// - Standard_Real Radius = sp.Radius(); - Standard_Real HalfArea = 2.*M_PI*Radius*Radius; - GProp_GProps Properties; - BRepGProp::SurfaceProperties(aFace, Properties); - Standard_Real anArea = Properties.Mass(); - Standard_Real AreaTol = Radius*Radius*1.e-6; - if (anArea > HalfArea - AreaTol) //no chance to avoid singularity - return Standard_False; - /////////////////////////////////////////////// - gp_Ax3 ax3 = sp.Position(); - if(Abs(Vmax-Vmin) < PI2) { - gp_Ax3 axnew3(ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(),ax3.XDirection()); - sp.SetPosition(axnew3); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); - aNewSurface = aNewSphere; - return Standard_True; - } - else { - gp_Pnt PC = ax3.Location(); - Standard_Real Vpar; - if(fabs(PI2-Vmax)>fabs(-PI2-Vmin)) - Vpar = (PI2+Vmax)/2.; - else - Vpar = (-PI2+Vmin)/2.; - Standard_Real Upar = (Umin+Umax)/2.;; - gp_Pnt PN,PX; - S->D0(Upar,Vpar,PN); - S->D0(Upar+PI2,0.,PX); - gp_Dir newNorm(gp_Vec(PC,PN)); - gp_Dir newDirX(gp_Vec(PC,PX)); - gp_Ax3 axnew3(ax3.Axis().Location(), newNorm, newDirX); - sp.SetPosition(axnew3); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); - aNewSurface = aNewSphere; - return Standard_True; - } - } - } - return Standard_False; -} - - -Standard_Boolean BlockFix_SphereSpaceModifier::NewSurface(const TopoDS_Face& F, - Handle(Geom_Surface)& S, - TopLoc_Location& L,Standard_Real& Tol, - Standard_Boolean& RevWires, - Standard_Boolean& RevFace) -{ - TopLoc_Location LS; - Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); - - //check if pole of the sphere in the parametric space - if(ModifySurface(F, SIni, S)) { - - RevWires = Standard_False; - RevFace = Standard_False; - - L = LS; - Tol = BRep_Tool::Tolerance(F); - - Standard_Integer anIndex = myMapOfSpheres.Add(S); - myMapOfFaces.Bind(F,anIndex); - return Standard_True; - } - - return Standard_False; -} - -//======================================================================= -//function : NewCurve -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve(const TopoDS_Edge& /*E*/,Handle(Geom_Curve)& /*C*/, - TopLoc_Location& /*L*/,Standard_Real& /*Tol*/) -{ - return Standard_False; -} - -//======================================================================= -//function : NewPoint -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, - gp_Pnt& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - -//======================================================================= -//function : NewCurve2d -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F, - const TopoDS_Edge& /*NewE*/,const TopoDS_Face& /*NewF*/, - Handle(Geom2d_Curve)& C,Standard_Real& Tol) -{ - //check if undelying surface of the face was modified - if(myMapOfFaces.IsBound(F)) { - Standard_Integer anIndex = myMapOfFaces.Find(F); - - Handle(Geom_Surface) aNewSphere = Handle(Geom_Surface)::DownCast(myMapOfSpheres.FindKey(anIndex)); - - Standard_Real f,l; - TopLoc_Location LC, LS; - Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); - Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); - - //taking into accound the orientation of the seam - C = BRep_Tool::CurveOnSurface(E,F,f,l); - Tol = BRep_Tool::Tolerance(E); - - BRep_Builder B; - TopoDS_Edge TempE; - B.MakeEdge(TempE); - B.Add(TempE, TopExp::FirstVertex(E)); - B.Add(TempE, TopExp::LastVertex(E)); - - if(!C3d.IsNull()) - B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); - B.Range(TempE, f, l); - - Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; - Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSphere->Transformed(LS.Transformation())); - TopLoc_Location LTemp; - LTemp.Identity(); - - Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); - Standard_Real aWorkTol = 2*myTolerance+Tol; - sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); - sfe->FixSameParameter(TempE); - - //keep the orientation of original edge - TempE.Orientation(E.Orientation()); - C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); - - // shifting seam of sphere - if(isClosed && !C.IsNull()) { - Standard_Real f2,l2; - Handle(Geom2d_Curve) c22 = - BRep_Tool::CurveOnSurface(TopoDS::Edge(TempE.Reversed()),STemp, LTemp,f2,l2); - Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion(); - if((C->Value(f).SquareDistance(c22->Value(f2)) < dPreci) - ||(C->Value(l).SquareDistance(c22->Value(l2)) < dPreci)) { - gp_Vec2d shift(S->UPeriod(),0.); - C->Translate(shift); - } - } - //sphere was modified - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewParameter -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,const TopoDS_Edge& /*E*/, - Standard_Real& /*P*/,Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : Continuity -//purpose : -//======================================================================= - -GeomAbs_Shape BlockFix_SphereSpaceModifier::Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1, - const TopoDS_Face& F2,const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF1*/,const TopoDS_Face& /*NewF2*/) -{ - return BRep_Tool::Continuity(E,F1,F2); -} diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx deleted file mode 100644 index fb11fdbae..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx +++ /dev/null @@ -1,141 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_SphereSpaceModifier_HeaderFile -#define _BlockFix_SphereSpaceModifier_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile -#include -#endif - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _TColStd_IndexedMapOfTransient_HeaderFile -#include -#endif -#ifndef _BRepTools_Modification_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Surface_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Curve_HeaderFile -#include -#endif -#ifndef _Handle_Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _GeomAbs_Shape_HeaderFile -#include -#endif -class TopoDS_Face; -class Geom_Surface; -class TopLoc_Location; -class TopoDS_Edge; -class Geom_Curve; -class TopoDS_Vertex; -class gp_Pnt; -class Geom2d_Curve; - - -class BlockFix_SphereSpaceModifier : public BRepTools_Modification { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_SphereSpaceModifier(); -Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; -Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; -Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; -Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; -Standard_EXPORT Standard_Boolean ForRotation(const TopoDS_Face& F) ; -Standard_EXPORT ~BlockFix_SphereSpaceModifier(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -TopTools_DataMapOfShapeInteger myMapOfFaces; -TColStd_IndexedMapOfTransient myMapOfSpheres; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx deleted file mode 100644 index 482241f6d..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx +++ /dev/null @@ -1,79 +0,0 @@ -// 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 - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); - 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("BlockFix_SphereSpaceModifier", - sizeof(BlockFix_SphereSpaceModifier), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_SphereSpaceModifier) Handle(BlockFix_SphereSpaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_SphereSpaceModifier) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_SphereSpaceModifier))) { - _anOtherObject = Handle(BlockFix_SphereSpaceModifier)((Handle(BlockFix_SphereSpaceModifier)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_SphereSpaceModifier::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_SphereSpaceModifier) ; -} -Standard_Boolean BlockFix_SphereSpaceModifier::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_SphereSpaceModifier) == AType || BRepTools_Modification::IsKind(AType)); -} -Handle_BlockFix_SphereSpaceModifier::~Handle_BlockFix_SphereSpaceModifier() {} - diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx deleted file mode 100644 index 050734179..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx +++ /dev/null @@ -1,49 +0,0 @@ -// 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 -// - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _Geom_Surface_HeaderFile -#include -#endif -#ifndef _TopLoc_Location_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Geom_Curve_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _gp_Pnt_HeaderFile -#include -#endif -#ifndef _Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _BlockFix_SphereSpaceModifier_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cdl b/src/GEOMAlgo/BlockFix_UnionEdges.cdl deleted file mode 100644 index 05a9f3870..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cdl +++ /dev/null @@ -1,49 +0,0 @@ --- 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: BlockFix_UnionEdges.cdl --- Created: Tue Dec 7 15:24:51 2004 --- Author: Sergey KUUL --- -class UnionEdges from BlockFix - - ---Purpose: - -uses - - Shape from TopoDS, - ReShape from ShapeBuild - -is - - Create returns UnionEdges from BlockFix; - - Perform(me: in out; Shape: Shape from TopoDS; - Tol : Real) - returns Shape from TopoDS; - -fields - - myTolerance : Real; - myContext : ReShape from ShapeBuild; - -end UnionEdges; diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx deleted file mode 100644 index 95a1a713e..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cxx +++ /dev/null @@ -1,589 +0,0 @@ -// 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: BlockFix_UnionEdges.cxx -// Created: 07.12.04 15:27:30 -// Author: Sergey KUUL - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utilities.h" - -//======================================================================= -//function : BlockFix_UnionEdges() -//purpose : Constructor -//======================================================================= -BlockFix_UnionEdges::BlockFix_UnionEdges ( ) -{ -} - -//======================================================================= -//function : GlueEdgesWithPCurves -//purpose : Glues the pcurves of the sequence of edges -// and glues their 3d curves -//======================================================================= -static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain, - const TopoDS_Vertex& FirstVertex, - const TopoDS_Vertex& LastVertex) -{ - Standard_Integer i, j; - - TopoDS_Edge FirstEdge = TopoDS::Edge(aChain(1)); - //TColGeom2d_SequenceOfCurve PCurveSeq; - TColGeom_SequenceOfSurface SurfSeq; - //TopTools_SequenceOfShape LocSeq; - - BRep_ListIteratorOfListOfCurveRepresentation itr( (Handle(BRep_TEdge)::DownCast(FirstEdge.TShape()))->Curves() ); - for (; itr.More(); itr.Next()) - { - Handle(BRep_CurveRepresentation) CurveRep = itr.Value(); - if (CurveRep->IsCurveOnSurface()) - { - //PCurveSeq.Append(CurveRep->PCurve()); - SurfSeq.Append(CurveRep->Surface()); - /* - TopoDS_Shape aLocShape; - aLocShape.Location(CurveRep->Location()); - LocSeq.Append(aLocShape); - */ - } - } - - Standard_Real fpar, lpar; - BRep_Tool::Range(FirstEdge, fpar, lpar); - TopoDS_Edge PrevEdge = FirstEdge; - TopoDS_Vertex CV; - Standard_Real MaxTol = 0.; - - TopoDS_Edge ResEdge; - BRep_Builder BB; - - Standard_Integer nb_curve = aChain.Length(); //number of curves - TColGeom_Array1OfBSplineCurve tab_c3d(0,nb_curve-1); //array of the curves - TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances - - TopoDS_Vertex PrevVertex = FirstVertex; - for (i = 1; i <= nb_curve; i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); - TopoDS_Vertex VF, VL; - TopExp::Vertices(anEdge, VF, VL); - Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); - - Standard_Real Tol1 = BRep_Tool::Tolerance(VF); - Standard_Real Tol2 = BRep_Tool::Tolerance(VL); - if (Tol1 > MaxTol) - MaxTol = Tol1; - if (Tol2 > MaxTol) - MaxTol = Tol2; - - if (i > 1) - { - TopExp::CommonVertex(PrevEdge, anEdge, CV); - Standard_Real Tol = BRep_Tool::Tolerance(CV); - tabtolvertex(i-2) = Tol; - } - - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); - Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, fpar, lpar); - tab_c3d(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve); - GeomConvert::C0BSplineToC1BSplineCurve(tab_c3d(i-1), Precision::Confusion()); - if (ToReverse) - tab_c3d(i-1)->Reverse(); - PrevVertex = (ToReverse)? VF : VL; - PrevEdge = anEdge; - } - Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves - Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex - GeomConvert::ConcatC1(tab_c3d, - tabtolvertex, - ArrayOfIndices, - concatcurve, - Standard_False, - Precision::Confusion()); //C1 concatenation - - if (concatcurve->Length() > 1) - { - GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); - - for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++) - Concat.Add( concatcurve->Value(i), MaxTol, Standard_True ); - - concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); - } - Handle(Geom_BSplineCurve) ResCurve = concatcurve->Value(concatcurve->Lower()); - - TColGeom2d_SequenceOfBoundedCurve ResPCurves; - TopLoc_Location aLoc; - for (j = 1; j <= SurfSeq.Length(); j++) - { - TColGeom2d_Array1OfBSplineCurve tab_c2d(0,nb_curve-1); //array of the pcurves - - PrevVertex = FirstVertex; - PrevEdge = FirstEdge; - //TopLoc_Location theLoc = LocSeq(j).Location(); - for (i = 1; i <= nb_curve; i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); - TopoDS_Vertex VF, VL; - TopExp::Vertices(anEdge, VF, VL); - Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); - - /* - Handle(Geom2d_Curve) aPCurve = - BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), anEdge.Location()*theLoc, fpar, lpar); - */ - Handle(Geom2d_Curve) aPCurve = - BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), aLoc, fpar, lpar); - Handle(Geom2d_TrimmedCurve) aTrPCurve = new Geom2d_TrimmedCurve(aPCurve, fpar, lpar); - tab_c2d(i-1) = Geom2dConvert::CurveToBSplineCurve(aTrPCurve); - Geom2dConvert::C0BSplineToC1BSplineCurve(tab_c2d(i-1), Precision::Confusion()); - if (ToReverse) - tab_c2d(i-1)->Reverse(); - PrevVertex = (ToReverse)? VF : VL; - PrevEdge = anEdge; - } - Handle(TColGeom2d_HArray1OfBSplineCurve) concatc2d; //array of the concatenated curves - Handle(TColStd_HArray1OfInteger) ArrayOfInd2d; //array of the remining Vertex - Geom2dConvert::ConcatC1(tab_c2d, - tabtolvertex, - ArrayOfInd2d, - concatc2d, - Standard_False, - Precision::Confusion()); //C1 concatenation - - if (concatc2d->Length() > 1) - { - Geom2dConvert_CompCurveToBSplineCurve Concat2d(concatc2d->Value(concatc2d->Lower())); - - for (i = concatc2d->Lower()+1; i <= concatc2d->Upper(); i++) - Concat2d.Add( concatc2d->Value(i), MaxTol, Standard_True ); - - concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve()); - } - Handle(Geom2d_BSplineCurve) aResPCurve = concatc2d->Value(concatc2d->Lower()); - ResPCurves.Append(aResPCurve); - } - - ResEdge = BRepLib_MakeEdge(ResCurve, - FirstVertex, LastVertex, - ResCurve->FirstParameter(), ResCurve->LastParameter()); - BB.SameRange(ResEdge, Standard_False); - BB.SameParameter(ResEdge, Standard_False); - for (j = 1; j <= ResPCurves.Length(); j++) - { - BB.UpdateEdge(ResEdge, ResPCurves(j), SurfSeq(j), aLoc, MaxTol); - BB.Range(ResEdge, SurfSeq(j), aLoc, ResPCurves(j)->FirstParameter(), ResPCurves(j)->LastParameter()); - } - - BRepLib::SameParameter(ResEdge, MaxTol, Standard_True); - - return ResEdge; -} - -//======================================================================= -//function : MergeEdges -//purpose : auxilary -//======================================================================= -static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, - const TopoDS_Face& aFace, - const Standard_Real Tol, - TopoDS_Edge& anEdge) -{ - // make chain for union - BRep_Builder B; - ShapeAnalysis_Edge sae; - TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); - TopoDS_Edge LastE = FirstE; - TopoDS_Vertex VF = sae.FirstVertex(FirstE); - TopoDS_Vertex VL = sae.LastVertex(LastE); - TopTools_SequenceOfShape aChain; - aChain.Append(FirstE); - TColStd_MapOfInteger IndUsedEdges; - IndUsedEdges.Add(1); - Standard_Integer j; - for(j=2; j<=SeqEdges.Length(); j++) { - for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { - if(IndUsedEdges.Contains(k)) continue; - TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); - TopoDS_Vertex VF2 = sae.FirstVertex(edge); - TopoDS_Vertex VL2 = sae.LastVertex(edge); - if(sae.FirstVertex(edge).IsSame(VL)) { - aChain.Append(edge); - LastE = edge; - VL = sae.LastVertex(LastE); - IndUsedEdges.Add(k); - } - else if(sae.LastVertex(edge).IsSame(VF)) { - aChain.Prepend(edge); - FirstE = edge; - VF = sae.FirstVertex(FirstE); - IndUsedEdges.Add(k); - } - } - } - if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d1); - c3d1 = tc->BasisCurve(); - } - TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); - Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); - if(c3d2.IsNull()) break; - while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d2); - c3d2 = tc->BasisCurve(); - } - if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { - // union lines - Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); - Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); - gp_Dir Dir1 = L1->Position().Direction(); - gp_Dir Dir2 = L2->Position().Direction(); - //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { - //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { - if(!Dir1.IsParallel(Dir2,Tol)) { - continue; - } - // can union lines => create new edge - TopoDS_Vertex V1 = sae.FirstVertex(edge1); - gp_Pnt PV1 = BRep_Tool::Pnt(V1); - TopoDS_Vertex V2 = sae.LastVertex(edge2); - gp_Pnt PV2 = BRep_Tool::Pnt(V2); - gp_Vec Vec(PV1,PV2); - Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); - Standard_Real dist = PV1.Distance(PV2); - Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); - TopoDS_Edge E; - B.MakeEdge (E,tc,Precision::Confusion()); - B.Add (E,V1); B.Add (E,V2); - B.UpdateVertex(V1, 0., E, 0.); - B.UpdateVertex(V2, dist, E, 0.); - //ShapeFix_Edge sfe; - //sfe.FixAddPCurve(E,aFace,Standard_False); - //sfe.FixSameParameter(E); - aChain.Remove(j); - aChain.SetValue(j,E); - j--; - } - if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { - // union circles - Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); - Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); - gp_Pnt P01 = C1->Location(); - gp_Pnt P02 = C2->Location(); - if (P01.Distance(P02) > Precision::Confusion()) continue; - // can union circles => create new edge - TopoDS_Vertex V1 = sae.FirstVertex(edge1); - gp_Pnt PV1 = BRep_Tool::Pnt(V1); - TopoDS_Vertex V2 = sae.LastVertex(edge2); - gp_Pnt PV2 = BRep_Tool::Pnt(V2); - TopoDS_Vertex VM = sae.LastVertex(edge1); - gp_Pnt PVM = BRep_Tool::Pnt(VM); - GC_MakeCircle MC (PV1,PVM,PV2); - Handle(Geom_Circle) C = MC.Value(); - TopoDS_Edge E; - if (!MC.IsDone() || C.IsNull()) { - // jfa for Mantis issue 0020228 - if (PV1.Distance(PV2) > Precision::Confusion()) continue; - // closed chain - C = C1; - B.MakeEdge (E,C,Precision::Confusion()); - B.Add(E,V1); - B.Add(E,V2); - } - else { - gp_Pnt P0 = C->Location(); - gp_Dir D1(gp_Vec(P0,PV1)); - gp_Dir D2(gp_Vec(P0,PV2)); - Standard_Real fpar = C->XAxis().Direction().Angle(D1); - if(fabs(fpar)>Precision::Confusion()) { - // check orientation - gp_Dir ND = C->XAxis().Direction().Crossed(D1); - if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { - fpar = -fpar; - } - } - Standard_Real lpar = C->XAxis().Direction().Angle(D2); - if(fabs(lpar)>Precision::Confusion()) { - // check orientation - gp_Dir ND = C->XAxis().Direction().Crossed(D2); - if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { - lpar = -lpar; - } - } - if (lpar < fpar) lpar += 2*M_PI; - Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); - B.MakeEdge (E,tc,Precision::Confusion()); - B.Add(E,V1); - B.Add(E,V2); - B.UpdateVertex(V1, fpar, E, 0.); - B.UpdateVertex(V2, lpar, E, 0.); - } - aChain.Remove(j); - aChain.SetValue(j,E); - j--; - } - } - if (j < aChain.Length()) { - MESSAGE ("null curve3d in edge..."); - return Standard_False; - } - if (aChain.Length() > 1) { - // second step: union edges with various curves - // skl for bug 0020052 from Mantis: perform such unions - // only if curves are bspline or bezier - bool NeedUnion = true; - for(j=1; j<=aChain.Length(); j++) { - TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); - if(c3d.IsNull()) continue; - while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d); - c3d = tc->BasisCurve(); - } - if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || - c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; - NeedUnion = false; - break; - } - if(NeedUnion) { - MESSAGE ("can not make analitical union => make approximation"); - TopoDS_Edge E = GlueEdgesWithPCurves(aChain, VF, VL); - /* - TopoDS_Wire W; - B.MakeWire(W); - for(j=1; j<=aChain.Length(); j++) { - TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - B.Add(W,edge); - } - Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); - Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); - Handle(Geom_BSplineCurve) bc = Conv.Curve(); - TopoDS_Edge E; - B.MakeEdge (E,bc,Precision::Confusion()); - B.Add (E,VF); - B.Add (E,VL); - */ - aChain.SetValue(1,E); - } - else { - MESSAGE ("can not make approximation for such types of curves"); - return Standard_False; - } - } - - anEdge = TopoDS::Edge(aChain.Value(1)); - return Standard_True; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, - const Standard_Real Tol) -{ - myContext = new ShapeBuild_ReShape; - myTolerance = Tol; - TopoDS_Shape aResult = myContext->Apply(Shape); - - // processing each solid - TopAbs_ShapeEnum aType = TopAbs_SOLID; - TopExp_Explorer exps (Shape, aType); - if (!exps.More()) { - aType = TopAbs_SHELL; - exps.Init(Shape, aType); - } - for (; exps.More(); exps.Next()) { - //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - TopoDS_Shape aSolid = exps.Current(); - - TopTools_IndexedMapOfShape ChangedFaces; - - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - TopoDS_Shape aRes = aSolid; - aRes = aContext->Apply(aSolid); - - // processing each face - TopExp_Explorer exp; - for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = - TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); - TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; - - for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { - TopoDS_Edge edge = TopoDS::Edge(expe.Current()); - if (!aMapEdgeFaces.Contains(edge)) continue; - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter(aList); - for ( ; anIter.More(); anIter.Next()) { - TopoDS_Face face = TopoDS::Face(anIter.Value()); - TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); - if (face1.IsSame(aFace)) continue; - if (aMapFacesEdges.Contains(face)) { - aMapFacesEdges.ChangeFromKey(face).Append(edge); - } - else { - TopTools_ListOfShape ListEdges; - ListEdges.Append(edge); - aMapFacesEdges.Add(face,ListEdges); - } - } - } - - for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { - const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); - TopTools_SequenceOfShape SeqEdges; - TopTools_ListIteratorOfListOfShape anIter(ListEdges); - for ( ; anIter.More(); anIter.Next()) { - SeqEdges.Append(anIter.Value()); - } - if (SeqEdges.Length()==1) continue; - TopoDS_Edge E; - if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { - // now we have only one edge - aChain.Value(1) - // we have to replace old ListEdges with this new edge - aContext->Replace(SeqEdges(1),E); - for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { - aContext->Remove(SeqEdges(j)); - } - TopoDS_Face tmpF = TopoDS::Face(exp.Current()); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - } - } - - } // end processing each face - - // fix changed faces and replace them in the local context - for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { - TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); - Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); - sff->SetContext(myContext); - sff->SetPrecision(myTolerance); - sff->SetMinTolerance(myTolerance); - sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sff->Perform(); - aContext->Replace(aFace,sff->Face()); - } - - if (ChangedFaces.Extent() > 0) { - // fix changed shell and replace it in the local context - TopoDS_Shape aRes1 = aContext->Apply(aRes); - TopExp_Explorer expsh; - for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { - TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); - Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; - sfsh->FixFaceOrientation(aShell); - aContext->Replace(aShell,sfsh->Shell()); - } - TopoDS_Shape aRes2 = aContext->Apply(aRes1); - // put new solid into global context - myContext->Replace(aSolid,aRes2); - } - - } // end processing each solid - - aResult = myContext->Apply(Shape); - return aResult; -} diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.hxx b/src/GEOMAlgo/BlockFix_UnionEdges.hxx deleted file mode 100644 index b38e941fb..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_UnionEdges_HeaderFile -#define _BlockFix_UnionEdges_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Handle_ShapeBuild_ReShape_HeaderFile -#include -#endif -class ShapeBuild_ReShape; -class TopoDS_Shape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class BlockFix_UnionEdges { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_UnionEdges(); -Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape,const Standard_Real Tol) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -Handle_ShapeBuild_ReShape myContext; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.ixx b/src/GEOMAlgo/BlockFix_UnionEdges.ixx deleted file mode 100644 index 27e87ac6c..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// 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 - - - - diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.jxx b/src/GEOMAlgo/BlockFix_UnionEdges.jxx deleted file mode 100644 index 558e8d82b..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -// - -#ifndef _ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_UnionEdges_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cdl b/src/GEOMAlgo/BlockFix_UnionFaces.cdl deleted file mode 100644 index 371cb25ea..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.cdl +++ /dev/null @@ -1,65 +0,0 @@ --- 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: BlockFix_UnionFaces.cdl --- Created: Tue Dec 7 17:15:42 2004 --- Author: Pavel Durandin --- -class UnionFaces from BlockFix - -uses - - Face from TopoDS, - Shape from TopoDS - -is - - Create returns UnionFaces from BlockFix; - ---Purpose: Empty constructor - - GetTolerance(me: in out) returns Real; - ---Purpose: Returns modifiable tolerance - ---C++: return& - - Perform (me: in out; Shape: Shape from TopoDS) returns Shape from TopoDS; - ---Purpose: Performs the unification of the fsces - -- whith the same geometry - - IsSameDomain(me; aFace : Face from TopoDS; - aChekedFace: Face from TopoDS) - returns Boolean is virtual; - ---Purpose: Returns true is surfaces have same geometrically domain - -- with given tolerance - - MovePCurves(me; aTarget: in out Face from TopoDS; - aSource: Face from TopoDS) - is virtual; - ---Purpose: Creates pcurves on aTarget face for each edge from - -- aSource one. - -fields - - myTolerance: Real; - -end; - - diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cxx b/src/GEOMAlgo/BlockFix_UnionFaces.cxx deleted file mode 100644 index c800fd421..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.cxx +++ /dev/null @@ -1,722 +0,0 @@ -// 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: BlockFix_UnionFaces.cxx -// Created: Tue Dec 7 17:15:42 2004 -// Author: Pavel DURANDIN - -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 -#include -#else -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -//======================================================================= -//function : BlockFix_UnionFaces -//purpose : -//======================================================================= - -BlockFix_UnionFaces::BlockFix_UnionFaces() - : myTolerance(Precision::Confusion()), - myOptimumNbFaces(6) -{ -} - - -//======================================================================= -//function : GetTolerance -//purpose : -//======================================================================= - -Standard_Real& BlockFix_UnionFaces::GetTolerance() -{ - return myTolerance; -} - - -//======================================================================= -//function : GetOptimumNbFaces -//purpose : -//======================================================================= - -Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces() -{ - return myOptimumNbFaces; -} - - -//======================================================================= -//function : AddOrdinaryEdges -//purpose : auxilary -//======================================================================= -// adds edges from the shape to the sequence -// seams and equal edges are dropped -// Returns true if one of original edges dropped -static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, - const TopoDS_Shape aShape, - Standard_Integer& anIndex) -{ - //map of edges - TopTools_MapOfShape aNewEdges; - //add edges without seams - for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Shape edge = exp.Current(); - if(aNewEdges.Contains(edge)) - aNewEdges.Remove(edge); - else - aNewEdges.Add(edge); - } - - Standard_Boolean isDropped = Standard_False; - //merge edges and drop seams - for(Standard_Integer i = 1; i <= edges.Length(); i++) { - TopoDS_Shape current = edges(i); - if(aNewEdges.Contains(current)) { - - aNewEdges.Remove(current); - edges.Remove(i); - i--; - - if(!isDropped) { - isDropped = Standard_True; - anIndex = i; - } - } - } - - //add edges to the sequemce - for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) - edges.Append(anIter.Key()); - - return isDropped; -} - - -//======================================================================= -//function : ClearRts -//purpose : auxilary -//======================================================================= -static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) -{ - if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - Handle(Geom_RectangularTrimmedSurface) rts = - Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); - return rts->BasisSurface(); - } - return aSurface; -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) -{ - Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; - TopoDS_Shape aResShape = myContext->Apply(Shape); - - // processing each solid - TopExp_Explorer exps; - for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { - TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - // map of processed shapes - TopTools_MapOfShape aProcessed; - - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - - Standard_Integer NbModif = 0; - Standard_Boolean hasFailed = Standard_False; - Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); - - // count faces - int nbf = 0; - TopExp_Explorer exp; - TopTools_MapOfShape mapF; - for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { - if (mapF.Add(exp.Current())) - nbf++; - } - - bool doUnion = ((myOptimumNbFaces == 0) || - ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces))); - - // processing each face - mapF.Clear(); - for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { - TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - - if (aProcessed.Contains(aFace)) - continue; - - Standard_Integer dummy; - TopTools_SequenceOfShape edges; - AddOrdinaryEdges(edges,aFace,dummy); - - TopTools_SequenceOfShape faces; - faces.Append(aFace); - - //surface and location to construct result - TopLoc_Location aBaseLocation; - Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); - aBaseSurface = ClearRts(aBaseSurface); - - // find adjacent faces to union - Standard_Integer i; - for (i = 1; i <= edges.Length(); i++) { - TopoDS_Edge edge = TopoDS::Edge(edges(i)); - if (BRep_Tool::Degenerated(edge)) - continue; - - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter(aList); - for (; anIter.More(); anIter.Next()) { - TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); - if (anCheckedFace.IsSame(aFace)) - continue; - - if (aProcessed.Contains(anCheckedFace)) - continue; - - if (IsSameDomain(aFace,anCheckedFace)) { - - if (aList.Extent() != 2) { - // non mainfold case is not processed - continue; - } - - // replacing pcurves - TopoDS_Face aMockUpFace; - BRep_Builder B; - B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); - MovePCurves(aMockUpFace,anCheckedFace); - - if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { - // sequence edges is modified - i = dummy; - } - - faces.Append(anCheckedFace); - aProcessed.Add(anCheckedFace); - break; - } - } - } - - // all faces collected in the sequence. Perform union of faces - if (faces.Length() > 1) { - NbModif++; - TopoDS_Face aResult; - BRep_Builder B; - B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); - Standard_Integer nbWires = 0; - - // connecting wires - while (edges.Length()>0) { - - Standard_Boolean isEdge3d = Standard_False; - nbWires++; - TopTools_MapOfShape aVertices; - TopoDS_Wire aWire; - B.MakeWire(aWire); - - TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); - edges.Remove(1); - - isEdge3d |= !BRep_Tool::Degenerated(anEdge); - B.Add(aWire,anEdge); - TopoDS_Vertex V1,V2; - TopExp::Vertices(anEdge,V1,V2); - aVertices.Add(V1); - aVertices.Add(V2); - - Standard_Boolean isNewFound = Standard_False; - do { - isNewFound = Standard_False; - for(Standard_Integer j = 1; j <= edges.Length(); j++) { - anEdge = TopoDS::Edge(edges(j)); - TopExp::Vertices(anEdge,V1,V2); - if(aVertices.Contains(V1) || aVertices.Contains(V2)) { - isEdge3d |= !BRep_Tool::Degenerated(anEdge); - aVertices.Add(V1); - aVertices.Add(V2); - B.Add(aWire,anEdge); - edges.Remove(j); - j--; - isNewFound = Standard_True; - } - } - } while (isNewFound); - - // sorting any type of edges - aWire = TopoDS::Wire(aContext->Apply(aWire)); - - TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); - sfw->FixReorder(); - Standard_Boolean isDegRemoved = Standard_False; - if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { - // clear degenerated edges if at least one with 3d curve exist - if(isEdge3d) { - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { - TopoDS_Edge E = sewd->Edge(j); - if(BRep_Tool::Degenerated(E)) { - sewd->Remove(j); - isDegRemoved = Standard_True; - j--; - } - } - } - sfw->FixShifted(); - if(isDegRemoved) - sfw->FixDegenerated(); - } - TopoDS_Wire aWireFixed = sfw->Wire(); - aContext->Replace(aWire,aWireFixed); - // add resulting wire - if(isEdge3d) { - B.Add(aResult,aWireFixed); - } - else { - // sorting edges - Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); - Standard_Integer nbEdges = sbwd->NbEdges(); - // sort degenerated edges and create one edge instead of several ones - ShapeAnalysis_WireOrder sawo(Standard_False, 0); - ShapeAnalysis_Edge sae; - Standard_Integer aLastEdge = nbEdges; - for(Standard_Integer j = 1; j <= nbEdges; j++) { - Standard_Real f,l; - //smh protection on NULL pcurve - Handle(Geom2d_Curve) c2d; - if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { - aLastEdge--; - continue; - } - sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); - } - sawo.Perform(); - - // constructind one degenerative edge - gp_XY aStart, anEnd, tmp; - Standard_Integer nbFirst = sawo.Ordered(1); - TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); - ShapeBuild_Edge sbe; - TopoDS_Vertex aDummyV; - TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); - sawo.XY(nbFirst,aStart,tmp); - sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); - - gp_XY aVec = anEnd-aStart; - Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); - - B.UpdateEdge(E,aLine,tmpF,0.); - B.Range(E,tmpF,0.,aVec.Modulus()); - Handle(Geom_Curve) C3d; - B.UpdateEdge(E,C3d,0.); - B.Degenerated(E,Standard_True); - TopoDS_Wire aW; - B.MakeWire(aW); - B.Add(aW,E); - B.Add(aResult,aW); - } - } - - // perform substitution of face - aContext->Replace(aContext->Apply(aFace),aResult); - - ShapeFix_Face sff (aResult); - //Intializing by tolerances - sff.SetPrecision(myTolerance); - sff.SetMinTolerance(tol); - sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); - //Setting modes - sff.FixOrientationMode() = 0; - //sff.FixWireMode() = 0; - sff.SetContext(aContext); - // Applying the fixes - sff.Perform(); - if(sff.Status(ShapeExtend_FAIL)) - hasFailed = Standard_True; - - // breaking down to several faces - TopoDS_Shape theResult = aContext->Apply(aResult); - for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { - TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); - Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); - grid->SetValue ( 1, 1, aBaseSurface ); - Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); - ShapeFix_ComposeShell CompShell; - CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision - CompShell.SetContext( aContext ); - - TopTools_SequenceOfShape parts; - ShapeFix_SequenceOfWireSegment wires; - for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { - Handle(ShapeExtend_WireData) sbwd = - new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); - ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); - wires.Append(seg); - } - - CompShell.DispatchWires ( parts,wires ); - for (Standard_Integer j=1; j <= parts.Length(); j++ ) { - ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); - aFixOrient.SetContext(aContext); - aFixOrient.FixOrientation(); - } - - TopoDS_Shape CompRes; - if ( faces.Length() !=1 ) { - TopoDS_Shell S; - B.MakeShell ( S ); - for ( i=1; i <= parts.Length(); i++ ) - B.Add ( S, parts(i) ); - CompRes = S; - } - else CompRes = parts(1); - - aContext->Replace(aCurrent,CompRes); - } - - // remove the remaining faces - for(i = 2; i <= faces.Length(); i++) - aContext->Remove(faces(i)); - } - } // end processing each face - - //TopoDS_Shape aResult = Shape; - if (NbModif > 0 && !hasFailed) { - TopoDS_Shape aResult = aContext->Apply(aSolid); - - ShapeFix_Edge sfe; - for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - // ptv add fix same parameter - sfe.FixSameParameter(E, myTolerance); - } - - myContext->Replace(aSolid, aResult); - } - //else - { - for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; - sfw->SetContext(myContext); - sfw->SetPrecision(myTolerance); - sfw->SetMinTolerance(myTolerance); - sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sfw->SetFace(aFace); - for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { - TopoDS_Wire wire = TopoDS::Wire(iter.Value()); - sfw->Load(wire); - sfw->FixReorder(); - sfw->FixShifted(); - } - } - } - } // end processing each solid - - aResShape = myContext->Apply(Shape); - return aResShape; -} - - -//======================================================================= -//function : IsSameDomain -//purpose : -//======================================================================= - -bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder) -{ - bool isCylinder = false; - - if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { - Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface); - - theOutCylinder = aGC->Cylinder(); - isCylinder = true; - } - else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { - Handle(Geom_SurfaceOfRevolution) aRS = - Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface); - Handle(Geom_Curve) aBasis = aRS->BasisCurve(); - if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) { - Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis); - gp_Dir aDir = aRS->Direction(); - gp_Dir aBasisDir = aBasisLine->Position().Direction(); - if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { - // basis line is parallel to the revolution axis: it is a cylinder - gp_Pnt aLoc = aRS->Location(); - Standard_Real aR = aBasisLine->Lin().Distance(aLoc); - gp_Ax3 aCylAx (aLoc, aDir); - - theOutCylinder = gp_Cylinder(aCylAx, aR); - isCylinder = true; - } - } - } - else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { - Handle(Geom_SurfaceOfLinearExtrusion) aLES = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface); - Handle(Geom_Curve) aBasis = aLES->BasisCurve(); - if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) { - Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis); - gp_Dir aDir = aLES->Direction(); - gp_Dir aBasisDir = aBasisCircle->Position().Direction(); - if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { - // basis circle is normal to the extrusion axis: it is a cylinder - gp_Pnt aLoc = aBasisCircle->Location(); - Standard_Real aR = aBasisCircle->Radius(); - gp_Ax3 aCylAx (aLoc, aDir); - - theOutCylinder = gp_Cylinder(aCylAx, aR); - isCylinder = true; - } - } - } - else { - } - - return isCylinder; -} - -Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, - const TopoDS_Face& aCheckedFace) const -{ - //checking the same handles - TopLoc_Location L1, L2; - Handle(Geom_Surface) S1, S2; - - S1 = BRep_Tool::Surface(aFace,L1); - S2 = BRep_Tool::Surface(aCheckedFace,L2); - - if (S1 == S2 && L1 == L2) - return true; - - // planar and cylindrical cases (IMP 20052) - Standard_Real aPrec = Precision::Confusion(); - - S1 = BRep_Tool::Surface(aFace); - S2 = BRep_Tool::Surface(aCheckedFace); - - S1 = ClearRts(S1); - S2 = ClearRts(S2); - - //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2; - //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1); - //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2); - //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface(); - //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface(); - - // case of two elementary surfaces: use OCCT tool - // elementary surfaces: ConicalSurface, CylindricalSurface, - // Plane, SphericalSurface and ToroidalSurface - if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && - S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) - { - Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1); - Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2); - - Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); - Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#else - IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#endif - if (!anIIInt.IsDone() || anIIInt.IsEmpty()) - return false; - - return anIIInt.TangentFaces(); - } - catch (Standard_Failure) { - return false; - } - } - - // case of two planar surfaces: - // all kinds of surfaces checked, including b-spline and bezier - GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec); - if (aPlanarityChecker1.IsPlanar()) { - GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec); - if (aPlanarityChecker2.IsPlanar()) { - gp_Pln aPln1 = aPlanarityChecker1.Plan(); - gp_Pln aPln2 = aPlanarityChecker2.Plan(); - - if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) && - aPln1.Distance(aPln2) < aPrec) { - return true; - } - } - } - - // case of two cylindrical surfaces, at least one of which is a swept surface - // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution - if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || - S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && - (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || - S2->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) - { - gp_Cylinder aCyl1, aCyl2; - if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) { - if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) { - gp_Dir aDir1 = aCyl1.Position().Direction(); - gp_Dir aDir2 = aCyl2.Position().Direction(); - if (aDir1.IsParallel(aDir2, aPrec)) { - gp_Pnt aLoc1 = aCyl1.Location(); - gp_Pnt aLoc2 = aCyl2.Location(); - gp_Vec aVec12 (aLoc1, aLoc2); - if (aVec12.SquareMagnitude() < aPrec*aPrec || - aVec12.IsParallel(aDir1, aPrec)) { - return true; - } - } - } - } - } - - return false; -} - - -//======================================================================= -//function : MovePCurves -//purpose : -//======================================================================= - -void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, - const TopoDS_Face& aSource) const -{ - BRep_Builder B; - for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), - aTarget, Precision::Confusion()); - sfw->FixReorder(); - Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); - sfw->FixEdgeCurves(); - if(isReoredFailed) - continue; - - sfw->FixShifted(); - sfw->FixDegenerated(); - - // remove degenerated edges from not degenerated points - ShapeAnalysis_Edge sae; - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { - TopoDS_Edge E = sewd->Edge(i); - if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { - sewd->Remove(i); - i--; - } - } - - TopoDS_Wire ResWire = sfw->Wire(); - B.Add(aTarget,ResWire); - } -} diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.hxx b/src/GEOMAlgo/BlockFix_UnionFaces.hxx deleted file mode 100644 index f676d5bcf..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.hxx +++ /dev/null @@ -1,90 +0,0 @@ -// 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 -// - -#ifndef _BlockFix_UnionFaces_HeaderFile -#define _BlockFix_UnionFaces_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class TopoDS_Shape; -class TopoDS_Face; - -class BlockFix_UnionFaces -{ -public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - // Methods PUBLIC - // - Standard_EXPORT BlockFix_UnionFaces(); - - Standard_EXPORT Standard_Real& GetTolerance(); - - /* \brief To get/set the OptimumNbFaces parameter - * - * If a being processed solid has less than OptimumNbFaces - * faces, no union will be performed. - * By default this parameter is set to 6 (to correctly - * process blocks - hexahedral solids) - * Special values: 0 - do all possible unions, regardless the faces quantity, - * negative - do not perform any unions, regardless the faces quantity. - * - */ - Standard_EXPORT Standard_Integer& GetOptimumNbFaces(); - - Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape); - - Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace, - const TopoDS_Face& aChekedFace) const; - Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget, - const TopoDS_Face& aSource) const; - -private: - // Fields PRIVATE - // - Standard_Real myTolerance; - Standard_Integer myOptimumNbFaces; -}; - -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.ixx b/src/GEOMAlgo/BlockFix_UnionFaces.ixx deleted file mode 100644 index c5299ca40..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// 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 - - - - diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.jxx b/src/GEOMAlgo/BlockFix_UnionFaces.jxx deleted file mode 100644 index c89fc31fb..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _BlockFix_UnionFaces_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/FILES b/src/GEOMAlgo/FILES index 44aeb0c17..102101794 100644 --- a/src/GEOMAlgo/FILES +++ b/src/GEOMAlgo/FILES @@ -140,30 +140,3 @@ GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx GEOMAlgo_IndexedDataMapOfShapeState.hxx GEOMAlgo_IndexedDataMapOfIntegerShape.hxx GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx deleted file mode 100644 index 3fce5be46..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// 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 -// - -#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile -#define _Handle_BlockFix_BlockFixAPI_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_MMgt_TShared_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(MMgt_TShared); -class BlockFix_BlockFixAPI; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_BlockFixAPI); - -class Handle(BlockFix_BlockFixAPI) : public Handle(MMgt_TShared) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_BlockFixAPI)():Handle(MMgt_TShared)() {} - Handle(BlockFix_BlockFixAPI)(const Handle(BlockFix_BlockFixAPI)& aHandle) : Handle(MMgt_TShared)(aHandle) - { - } - - Handle(BlockFix_BlockFixAPI)(const BlockFix_BlockFixAPI* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) - { - } - - Handle(BlockFix_BlockFixAPI)& operator=(const Handle(BlockFix_BlockFixAPI)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_BlockFixAPI)& operator=(const BlockFix_BlockFixAPI* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_BlockFixAPI* operator->() - { - return (BlockFix_BlockFixAPI *)ControlAccess(); - } - - BlockFix_BlockFixAPI* operator->() const - { - return (BlockFix_BlockFixAPI *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_BlockFixAPI)(); - - Standard_EXPORT static const Handle(BlockFix_BlockFixAPI) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx deleted file mode 100644 index 1cb29e022..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// 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 -// - -#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile -#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_BRepTools_Modification_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(BRepTools_Modification); -class BlockFix_PeriodicSurfaceModifier; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier); - -class Handle(BlockFix_PeriodicSurfaceModifier) : public Handle(BRepTools_Modification) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_PeriodicSurfaceModifier)():Handle(BRepTools_Modification)() {} - Handle(BlockFix_PeriodicSurfaceModifier)(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) - { - } - - Handle(BlockFix_PeriodicSurfaceModifier)(const BlockFix_PeriodicSurfaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) - { - } - - Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const BlockFix_PeriodicSurfaceModifier* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_PeriodicSurfaceModifier* operator->() - { - return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); - } - - BlockFix_PeriodicSurfaceModifier* operator->() const - { - return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_PeriodicSurfaceModifier)(); - - Standard_EXPORT static const Handle(BlockFix_PeriodicSurfaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx deleted file mode 100644 index 33dc8a198..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// 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 -// - -#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile -#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_BRepTools_Modification_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(BRepTools_Modification); -class BlockFix_SphereSpaceModifier; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_SphereSpaceModifier); - -class Handle(BlockFix_SphereSpaceModifier) : public Handle(BRepTools_Modification) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_SphereSpaceModifier)():Handle(BRepTools_Modification)() {} - Handle(BlockFix_SphereSpaceModifier)(const Handle(BlockFix_SphereSpaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) - { - } - - Handle(BlockFix_SphereSpaceModifier)(const BlockFix_SphereSpaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) - { - } - - Handle(BlockFix_SphereSpaceModifier)& operator=(const Handle(BlockFix_SphereSpaceModifier)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_SphereSpaceModifier)& operator=(const BlockFix_SphereSpaceModifier* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_SphereSpaceModifier* operator->() - { - return (BlockFix_SphereSpaceModifier *)ControlAccess(); - } - - BlockFix_SphereSpaceModifier* operator->() const - { - return (BlockFix_SphereSpaceModifier *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_SphereSpaceModifier)(); - - Standard_EXPORT static const Handle(BlockFix_SphereSpaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Makefile.am b/src/GEOMAlgo/Makefile.am index dacba0542..f54398d11 100644 --- a/src/GEOMAlgo/Makefile.am +++ b/src/GEOMAlgo/Makefile.am @@ -15,7 +15,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # GEOM GEOMAlgo : tools for Glue Faces algorithm # File : Makefile.am @@ -28,13 +27,6 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libGEOMAlgo.la dist_libGEOMAlgo_la_SOURCES = \ - BlockFix_BlockFixAPI.cxx \ - BlockFix_CheckTool.cxx \ - BlockFix.cxx \ - BlockFix_PeriodicSurfaceModifier.cxx \ - BlockFix_SphereSpaceModifier.cxx \ - BlockFix_UnionEdges.cxx \ - BlockFix_UnionFaces.cxx \ GEOMAlgo_Algo.cxx \ GEOMAlgo_Builder_0.cxx \ GEOMAlgo_Builder_1.cxx \ @@ -96,31 +88,6 @@ dist_libGEOMAlgo_la_SOURCES = \ # header files salomeinclude_HEADERS = \ - BlockFix.hxx \ - BlockFix.ixx \ - BlockFix.jxx \ - BlockFix_BlockFixAPI.hxx \ - BlockFix_BlockFixAPI.ixx \ - BlockFix_BlockFixAPI.jxx \ - BlockFix_BlockFixAPI.lxx \ - BlockFix_CheckTool.hxx \ - BlockFix_CheckTool.ixx \ - BlockFix_CheckTool.jxx \ - BlockFix_PeriodicSurfaceModifier.hxx \ - BlockFix_PeriodicSurfaceModifier.ixx \ - BlockFix_PeriodicSurfaceModifier.jxx \ - BlockFix_SphereSpaceModifier.hxx \ - BlockFix_SphereSpaceModifier.ixx \ - BlockFix_SphereSpaceModifier.jxx \ - BlockFix_UnionEdges.hxx \ - BlockFix_UnionEdges.ixx \ - BlockFix_UnionEdges.jxx \ - BlockFix_UnionFaces.hxx \ - BlockFix_UnionFaces.ixx \ - BlockFix_UnionFaces.jxx \ - Handle_BlockFix_BlockFixAPI.hxx \ - Handle_BlockFix_SphereSpaceModifier.hxx \ - Handle_BlockFix_PeriodicSurfaceModifier.hxx \ GEOMAlgo_Algo.hxx \ GEOMAlgo_BuilderArea.hxx \ GEOMAlgo_BuilderFace.hxx \ @@ -211,15 +178,7 @@ libGEOMAlgo_la_LDFLAGS = \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace # extra distributed files -CDL_FILES = \ - BlockFix.cdl \ - BlockFix_BlockFixAPI.cdl \ - BlockFix_CheckTool.cdl \ - BlockFix_PeriodicSurfaceModifier.cdl \ - BlockFix_SphereSpaceModifier.cdl \ - BlockFix_UnionEdges.cdl \ - BlockFix_UnionFaces.cdl \ - GEOMAlgo.cdl +CDL_FILES = GEOMAlgo.cdl EXTRA_DIST += \ $(CDL_FILES) \ diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index ed57921e0..4b0d81c5c 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -4871,6 +4871,22 @@ be specified in meters). GEOM_IS_REORDER Reorder vertices taking into account distances + + GEOM_INTERPOL_TANGENTS + Tangents + + + GEOM_INTERPOL_FIRST_VEC + First tangent vector + + + GEOM_INTERPOL_LAST_VEC + Last tangent vector + + + GEOM_BOTH_TANGENTS_REQUIRED + Both tangent vectors must be defined + GEOM_CURVE_CRMODE Creation Mode diff --git a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx index b26507e88..e0c33a478 100644 --- a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx @@ -18,17 +18,19 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include +#include + #include #include + #include #include #include @@ -48,29 +50,29 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_CircleDriver::GetID() { static Standard_GUID aCircleDriver("FF1BBB32-5D14-4df2-980B-3A668264EA16"); - return aCircleDriver; + return aCircleDriver; } //======================================================================= //function : GEOMImpl_CircleDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_CircleDriver::GEOMImpl_CircleDriver() +GEOMImpl_CircleDriver::GEOMImpl_CircleDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const { - if (Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_ICircle aCI (aFunction); @@ -95,20 +97,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aRefVector = aCI.GetVector(); if (!aRefVector.IsNull()) { TopoDS_Shape aShapeVec = aRefVector->GetValue(); - if (aShapeVec.ShapeType() != TopAbs_EDGE) { - Standard_ConstructionError::Raise - ("Circle creation aborted: invalid vector argument, must be a vector or an edge"); - } - TopoDS_Edge anE = TopoDS::Edge(aShapeVec); - TopoDS_Vertex V1, V2; - TopExp::Vertices(anE, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) { - aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - if (aV.Magnitude() < gp::Resolution()) { - Standard_ConstructionError::Raise - ("Circle creation aborted: vector of zero length is given"); - } - } + aV = GEOMUtils::GetVector(aShapeVec); } // Axes gp_Ax2 anAxes (aP, aV); @@ -163,7 +152,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const //Make Circle gp_Ax2 anAxes (aP1, aDir); gp_Circ aCirc (anAxes, aRadius); - aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); } } else if (aType == CIRCLE_THREE_PNT) { @@ -187,7 +176,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line"); Handle(Geom_Circle) aCirc = GC_MakeCircle(aP1, aP2, aP3).Value(); aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); - } + } } else { } @@ -196,26 +185,26 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); - return 1; + return 1; } //======================================================================= //function : GEOMImpl_CircleDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_CircleDriver_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); + 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_CircleDriver", @@ -230,7 +219,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_CircleDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOMImpl_CircleDriver) Handle(GEOMImpl_CircleDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_CircleDriver) _anOtherObject; diff --git a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx index 4aafb7114..708f8f450 100755 --- a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx @@ -15,16 +15,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include -#include +#include #include #include @@ -89,7 +88,7 @@ Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const } else if (aRefShape.ShapeType() == TopAbs_FACE) { double aH = aFI.GetH() / 2.0; double aW = aFI.GetW() / 2.0; - gp_Ax3 anAx = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Ax3 anAx = GEOMUtils::GetPosition(aRefShape); gp_Pln aPln (anAx); aShape = BRepBuilderAPI_MakeFace(aPln, -aH, +aH, -aW, +aW).Shape(); } diff --git a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx index f781f228e..38a0ba318 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx @@ -23,10 +23,12 @@ #include #include #include -#include #include + #include +#include + #include #include #include @@ -352,7 +354,7 @@ bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire, aListOfNewEdge.Append(anEdgeToEdgeMap.Find(anEdge)); } - GEOMImpl_IShapesOperations::SortShapes(aListOfNewEdge); + GEOMUtils::SortShapes(aListOfNewEdge); BRepBuilderAPI_MakeWire aWireTool; aWireTool.Add(aListOfNewEdge); diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index efb69f42c..65b2ea018 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -34,7 +34,8 @@ #include #include #include -#include + +#include #include #include @@ -3492,13 +3493,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate } // while (listPrevEdges.Extent() > 0) // Sort shapes in current chain (Mantis issue 21053) - GEOMImpl_IShapesOperations::SortShapes(currentChain, Standard_False); + GEOMUtils::SortShapes(currentChain, Standard_False); aFirstInChains.Append(currentChain.First()); aMapChains.Bind(currentChain.First(), currentChain); } // Sort chains (Mantis issue 21053) - GEOMImpl_IShapesOperations::SortShapes(aFirstInChains, Standard_False); + GEOMUtils::SortShapes(aFirstInChains, Standard_False); // Store sorted chains in the document TopTools_ListIteratorOfListOfShape aChainsIt (aFirstInChains); diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 22237b786..60983a177 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -736,19 +736,19 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier GEOMImpl_ISpline aCI (aFunction); - int aLen = thePoints.size(); - aCI.SetLength(aLen); aCI.SetConstructorType(POINT_CONSTRUCTOR); - int ind = 1; + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; std::list::iterator it = thePoints.begin(); - for (; it != thePoints.end(); it++, ind++) { + for (; it != thePoints.end(); it++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - - if (aRefPnt.IsNull()) return NULL; - - aCI.SetPoint(ind, aRefPnt); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Besier curve"); + return NULL; + } + aPoints->Append(aRefPnt); } + aCI.SetPoints(aPoints); aCI.SetIsClosed(theIsClosed); @@ -798,7 +798,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation //Add a new Spline object Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE); - //Add a new Spline function for creation a bezier curve relatively to points set + //Add a new Spline function for interpolation type Handle(GEOM_Function) aFunction = aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION); if (aFunction.IsNull()) return NULL; @@ -808,19 +808,18 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation GEOMImpl_ISpline aCI (aFunction); - int aLen = thePoints.size(); aCI.SetConstructorType(POINT_CONSTRUCTOR); - aCI.SetLength(aLen); - int ind = 1; + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; std::list::iterator it = thePoints.begin(); - for (; it != thePoints.end(); it++, ind++) { + for (; it != thePoints.end(); it++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - - if (aRefPnt.IsNull()) return NULL; - - aCI.SetPoint(ind, aRefPnt); + if (aRefPnt.IsNull()) { + return NULL; + } + aPoints->Append(aRefPnt); } + aCI.SetPoints(aPoints); aCI.SetIsClosed(theIsClosed); aCI.SetDoReordering(theDoReordering); @@ -856,6 +855,85 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation return aSpline; } + +//============================================================================= +/*! + * MakeSplineInterpolWithTangents + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents + (std::list thePoints, + Handle(GEOM_Object) theFirstVec, + Handle(GEOM_Object) theLastVec) +{ + SetErrorCode(KO); + + //Add a new Spline object + Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE); + + //Add a new Spline function for interpolation type + Handle(GEOM_Function) aFunction = + aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL; + + GEOMImpl_ISpline aCI (aFunction); + + aCI.SetConstructorType(POINT_CONSTRUCTOR); + + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; + std::list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Interpolation"); + return NULL; + } + aPoints->Append(aRefPnt); + } + aCI.SetPoints(aPoints); + + Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction(); + Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction(); + + if (aVec1.IsNull() || aVec2.IsNull()) return NULL; + + aCI.SetFirstVector(aVec1); + aCI.SetLastVector(aVec2); + + //Compute the Spline value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Spline 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 pd (aFunction); + pd << aSpline << " = geompy.MakeInterpolWithTangents(["; + + it = thePoints.begin(); + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); + } + pd << "], " << theFirstVec << ", " << theLastVec << ")"; + + SetErrorCode(OK); + return aSpline; +} + //============================================================================= /*! * MakeCurveParametric @@ -864,7 +942,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric (const char* thexExpr, const char* theyExpr, const char* thezExpr, double theParamMin, double theParamMax, double theParamStep, - CurveType theCurveType, + CurveType theCurveType, int theParamNbStep, bool theNewMethod) { TCollection_AsciiString aPyScript; @@ -958,7 +1036,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep ); else coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep ); - + PyObject* new_stderr = NULL; if (coords == NULL){ @@ -1038,7 +1116,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric GEOMImpl_ISpline aCI (aFunction); - aCI.SetLength(lsize); aCI.SetConstructorType(COORD_CONSTRUCTOR); aCI.SetIsClosed(false); aCI.SetCoordinates(aCoordsArray); @@ -1058,7 +1135,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric GEOMImpl_ISpline aCI (aFunction); aCI.SetConstructorType(COORD_CONSTRUCTOR); - aCI.SetLength(lsize); aCI.SetIsClosed(false); aCI.SetDoReordering(false); aCI.SetCoordinates(aCoordsArray); diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 829f9cc5d..f3e93170d 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -32,11 +32,11 @@ class GEOM_Engine; class Handle(GEOM_Object); class GEOMImpl_ICurvesOperations : public GEOM_IOperations { - + public: enum CurveType { Polyline, Bezier, Interpolation }; - + Standard_EXPORT GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT ~GEOMImpl_ICurvesOperations(); @@ -57,7 +57,7 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3); - + Standard_EXPORT Handle(GEOM_Object) MakeArcCenter (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3, @@ -77,9 +77,14 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { bool theIsClosed = false, bool theDoReordering = false); + Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolWithTangents + (std::list thePoints, + Handle(GEOM_Object) theFirstVec, + Handle(GEOM_Object) theLastVec); + Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric - (const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, double theParamStep, + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, double theParamStep, CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false); Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index df3a87a49..0d08e6dcd 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -28,6 +28,8 @@ #include #include +#include + #include #include @@ -765,69 +767,6 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape return aKind; } -//============================================================================= -/*! Get LCS, corresponding to the given shape. - * Origin of the LCS is situated at the shape's center of mass. - * Axes of the LCS are obtained from shape's location or, - * if the shape is a planar face, from position of its plane. - */ -//============================================================================= -gp_Ax3 GEOMImpl_IMeasureOperations::GetPosition (const TopoDS_Shape& theShape) -{ - gp_Ax3 aResult; - - if (theShape.IsNull()) - return aResult; - - // Axes - aResult.Transform(theShape.Location().Transformation()); - if (theShape.ShapeType() == TopAbs_FACE) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape)); - if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); - gp_Pln aPln = aGPlane->Pln(); - aResult = aPln.Position(); - // In case of reverse orinetation of the face invert the plane normal - // (the face's normal does not mathc the plane's normal in this case) - if(theShape.Orientation() == TopAbs_REVERSED) - { - gp_Dir Vx = aResult.XDirection(); - gp_Dir N = aResult.Direction().Mirrored(Vx); - gp_Pnt P = aResult.Location(); - aResult = gp_Ax3(P, N, Vx); - } - } - } - - // Origin - gp_Pnt aPnt; - - TopAbs_ShapeEnum aShType = theShape.ShapeType(); - - if (aShType == TopAbs_VERTEX) { - aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); - } - else { - if (aShType == TopAbs_COMPOUND) { - aShType = GEOMImpl_IShapesOperations::GetTypeOfSimplePart(theShape); - } - - GProp_GProps aSystem; - if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE) - BRepGProp::LinearProperties(theShape, aSystem); - else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL) - BRepGProp::SurfaceProperties(theShape, aSystem); - else - BRepGProp::VolumeProperties(theShape, aSystem); - - aPnt = aSystem.CentreOfMass(); - } - - aResult.SetLocation(aPnt); - - return aResult; -} - //============================================================================= /*! * GetPosition @@ -861,7 +800,7 @@ void GEOMImpl_IMeasureOperations::GetPosition OCC_CATCH_SIGNALS; #endif - gp_Ax3 anAx3 = GetPosition(aShape); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aShape); gp_Pnt anOri = anAx3.Location(); gp_Dir aDirZ = anAx3.Direction(); diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index d84b8743c..fbcdcfa9e 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_IMeasureOperations_HXX_ #define _GEOMImpl_IMeasureOperations_HXX_ @@ -168,9 +167,6 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_EXPORT Standard_Real MinSurfaceCurvatureByPoint (Handle(GEOM_Object) theSurf, Handle(GEOM_Object) thePoint); - public: - Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); - private: void StructuralDump (const BRepCheck_Analyzer& theAna, const TopoDS_Shape& theShape, diff --git a/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx b/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx index dbdb52601..393e65a47 100644 --- a/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx @@ -18,15 +18,16 @@ // 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 intreface to a function for the Pipe creation. -// + #ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_ #define _GEOMImpl_IPIPEDIFFSECT_HXX_ #include "GEOM_Function.hxx" +#include + #ifndef _GEOMImpl_IPIPE_HXX_ #include "GEOMImpl_IPipe.hxx" #endif diff --git a/src/GEOMImpl/GEOMImpl_IPipePath.hxx b/src/GEOMImpl/GEOMImpl_IPipePath.hxx index 028ab2f53..7b2ccd40a 100644 --- a/src/GEOMImpl/GEOMImpl_IPipePath.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipePath.hxx @@ -23,6 +23,8 @@ #include "GEOM_Function.hxx" +#include + class GEOMImpl_IPipePath { public: diff --git a/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx b/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx index 0b3f35fd4..3061153f0 100644 --- a/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx @@ -15,10 +15,9 @@ // 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 intreface to a function for the Pipe creation. -// + #ifndef _GEOMImpl_IPIPESHELLSECT_HXX_ #define _GEOMImpl_IPIPESHELLSECT_HXX_ @@ -28,6 +27,8 @@ #include "GEOMImpl_IPipeDiffSect.hxx" #endif +#include + #define PIPEDS_LIST_SUBBASES 6 diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 682311302..eb8ec50fc 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -48,6 +48,8 @@ #include "GEOM_ISubShape.hxx" #include "GEOM_PythonDump.hxx" +#include "GEOMUtils.hxx" + #include "GEOMAlgo_ClsfBox.hxx" #include "GEOMAlgo_ClsfSolid.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx" @@ -141,8 +143,6 @@ #include #include -#define STD_SORT_ALGO 1 - //============================================================================= /*! * constructor: @@ -1023,7 +1023,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes } // for stable order of returned entities - GEOMImpl_IShapesOperations::SortShapes(listOnePerSet, Standard_False); + GEOMUtils::SortShapes(listOnePerSet, Standard_False); TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet); for (; aListIt.More(); aListIt.Next()) { @@ -1267,7 +1267,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode bool isOldSorting = false; if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN) isOldSorting = true; - SortShapes(listShape, isOldSorting); + GEOMUtils::SortShapes(listShape, isOldSorting); } TopTools_IndexedMapOfShape anIndices; @@ -1391,7 +1391,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs bool isOldSorting = false; if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN) isOldSorting = true; - SortShapes(listShape, isOldSorting); + GEOMUtils::SortShapes(listShape, isOldSorting); } TopTools_IndexedMapOfShape anIndices; @@ -2217,7 +2217,7 @@ Handle(TColStd_HSequenceOfInteger) TopoDS_Shape aShape = theShape->GetValue(); // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -2384,7 +2384,7 @@ Handle(TColStd_HSequenceOfInteger) TopTools_ListOfShape res; // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -2604,7 +2604,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!CheckTriangulation(theShape)) { + if (!GEOMUtils::CheckTriangulation(theShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -3385,7 +3385,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -3776,28 +3776,6 @@ namespace { } } -//================================================================================ -/*! - * \brief Return type of shape for explode. In case of compound it will be a type of sub-shape. - */ -//================================================================================ -TopAbs_ShapeEnum GEOMImpl_IShapesOperations::GetTypeOfSimplePart (const TopoDS_Shape& theShape) -{ - TopAbs_ShapeEnum aType = theShape.ShapeType(); - if (aType == TopAbs_VERTEX) return TopAbs_VERTEX; - else if (aType == TopAbs_EDGE || aType == TopAbs_WIRE) return TopAbs_EDGE; - else if (aType == TopAbs_FACE || aType == TopAbs_SHELL) return TopAbs_FACE; - else if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) return TopAbs_SOLID; - else if (aType == TopAbs_COMPOUND) { - // Only the iType of the first shape in the compound is taken into account - TopoDS_Iterator It (theShape, Standard_False, Standard_False); - if (It.More()) { - return GetTypeOfSimplePart(It.Value()); - } - } - return TopAbs_SHAPE; -} - //============================================================================= /*! * case GetInPlace: @@ -3839,7 +3817,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) GProp_GProps aProps; // Find the iType of the aWhat shape - iType = GetTypeOfSimplePart(aWhat); + iType = GEOMUtils::GetTypeOfSimplePart(aWhat); if (iType == TopAbs_SHAPE) { SetErrorCode("Error: An attempt to extract a shape of not supported type."); return NULL; @@ -4041,7 +4019,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec return NULL; } */ - iType = GetTypeOfSimplePart(aWhat); + iType = GEOMUtils::GetTypeOfSimplePart(aWhat); if (iType == TopAbs_SHAPE) { SetErrorCode("Error: An attempt to extract a shape of not supported type."); return NULL; @@ -4266,321 +4244,6 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory return aResult; } -//======================================================================= -//function : ShapeToDouble -//purpose : used by CompareShapes::operator() -//======================================================================= -std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) -{ - // Computing of CentreOfMass - gp_Pnt GPoint; - double Len; - - if (S.ShapeType() == TopAbs_VERTEX) { - GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); - Len = (double)S.Orientation(); - } - else { - GProp_GProps GPr; - // BEGIN: fix for Mantis issue 0020842 - if (isOldSorting) { - BRepGProp::LinearProperties(S, GPr); - } - else { - if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(S, GPr); - } - else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(S, GPr); - } - else { - BRepGProp::VolumeProperties(S, GPr); - } - } - // END: fix for Mantis issue 0020842 - GPoint = GPr.CentreOfMass(); - Len = GPr.Mass(); - } - - double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; - return std::make_pair(dMidXYZ, Len); -} - -//======================================================================= -//function : CompareShapes::operator() -//purpose : used by std::sort(), called from SortShapes() -//======================================================================= -bool GEOMImpl_IShapesOperations::CompareShapes::operator()(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2) -{ - if (!myMap.IsBound(theShape1)) { - myMap.Bind(theShape1, ShapeToDouble(theShape1, myIsOldSorting)); - } - - if (!myMap.IsBound(theShape2)) { - myMap.Bind(theShape2, ShapeToDouble(theShape2, myIsOldSorting)); - } - - std::pair val1 = myMap.Find(theShape1); - std::pair val2 = myMap.Find(theShape2); - - double tol = Precision::Confusion(); - bool exchange = Standard_False; - - double dMidXYZ = val1.first - val2.first; - if (dMidXYZ >= tol) { - exchange = Standard_True; - } - else if (Abs(dMidXYZ) < tol) { - double dLength = val1.second - val2.second; - if (dLength >= tol) { - exchange = Standard_True; - } - else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { - // PAL17233 - // equal values possible on shapes such as two halves of a sphere and - // a membrane inside the sphere - Bnd_Box box1,box2; - BRepBndLib::Add(theShape1, box1); - if (!box1.IsVoid()) { - BRepBndLib::Add(theShape2, box2); - Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); - if (dSquareExtent >= tol) { - exchange = Standard_True; - } - else if (Abs(dSquareExtent) < tol) { - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; - box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; - box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; - if ((val1 - val2) >= tol) { - exchange = Standard_True; - } - } - } - } - } - - //return val1 < val2; - return !exchange; -} - -//======================================================================= -//function : SortShapes -//purpose : -//======================================================================= -void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting) -{ -#ifdef STD_SORT_ALGO - std::vector aShapesVec; - aShapesVec.reserve(SL.Extent()); - - TopTools_ListIteratorOfListOfShape it (SL); - for (; it.More(); it.Next()) { - aShapesVec.push_back(it.Value()); - } - SL.Clear(); - - CompareShapes shComp (isOldSorting); - std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); - //std::sort(aShapesVec.begin(), aShapesVec.end(), shComp); - - std::vector::const_iterator anIter = aShapesVec.begin(); - for (; anIter != aShapesVec.end(); ++anIter) { - SL.Append(*anIter); - } -#else - // old implementation - Standard_Integer MaxShapes = SL.Extent(); - TopTools_Array1OfShape aShapes (1,MaxShapes); - TColStd_Array1OfInteger OrderInd(1,MaxShapes); - TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z; - TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z; - - // Computing of CentreOfMass - Standard_Integer Index; - GProp_GProps GPr; - gp_Pnt GPoint; - TopTools_ListIteratorOfListOfShape it(SL); - for (Index=1; it.More(); Index++) - { - TopoDS_Shape S = it.Value(); - SL.Remove( it ); // == it.Next() - aShapes(Index) = S; - OrderInd.SetValue (Index, Index); - if (S.ShapeType() == TopAbs_VERTEX) { - GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S )); - Length.SetValue( Index, (Standard_Real) S.Orientation()); - } - else { - // BEGIN: fix for Mantis issue 0020842 - if (isOldSorting) { - BRepGProp::LinearProperties (S, GPr); - } - else { - if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties (S, GPr); - } - else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(S, GPr); - } - else { - BRepGProp::VolumeProperties(S, GPr); - } - } - // END: fix for Mantis issue 0020842 - GPoint = GPr.CentreOfMass(); - Length.SetValue(Index, GPr.Mass()); - } - MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9); - //cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl; - } - - // Sorting - Standard_Integer aTemp; - Standard_Boolean exchange, Sort = Standard_True; - Standard_Real tol = Precision::Confusion(); - while (Sort) - { - Sort = Standard_False; - for (Index=1; Index < MaxShapes; Index++) - { - exchange = Standard_False; - Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); - Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); - if ( dMidXYZ >= tol ) { -// cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <= tol ) { -// cout << "Length: " << Length(OrderInd(Index))<< " > " <= tol ) { -// cout << "SquareExtent: " << box1.SquareExtent()<<" > "< val2; - if ((val1 - val2) >= tol) { - exchange = Standard_True; - } - //cout << "box: " << val1<<" > "< - { - CompareShapes (bool isOldSorting) - : myIsOldSorting(isOldSorting) {} - - bool operator()(const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); - - typedef NCollection_DataMap > NCollection_DataMapOfShapeDouble; - NCollection_DataMapOfShapeDouble myMap; - bool myIsOldSorting; - }; - - Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting = Standard_True); - - /*! - * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. - * - * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is. - * - * \param theCompsolid The compsolid to be converted. - * \retval TopoDS_Shape Returns the resulting compound. - */ - Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); - - /*! - * \brief Build a triangulation on \a theShape if it is absent. - * \param theShape The shape to check/build triangulation on. - * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. - */ - Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape); - - /*! - * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. - * \param theShape The shape to get type of. - * \retval TopAbs_ShapeEnum Return type of shape for explode. - */ - Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); - private: Handle(GEOM_Object) MakeShape (std::list theShapes, const Standard_Integer theObjectType, diff --git a/src/GEOMImpl/GEOMImpl_ISpline.hxx b/src/GEOMImpl/GEOMImpl_ISpline.hxx index b20a7e6dc..e7f8b076a 100644 --- a/src/GEOMImpl/GEOMImpl_ISpline.hxx +++ b/src/GEOMImpl/GEOMImpl_ISpline.hxx @@ -18,53 +18,84 @@ // 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 a function for the Spline creation. -#include "GEOM_Function.hxx" -#include +#include -#define SPL_ARG_LENG 1 -#define SPL_ARG_CLOS 2 -#define SPL_ARG_REOR 3 -#define SPL_ARG_LAST 2 - -#define SPL_CONSTRUCTOR 4 -#define SPL_ARG_ARRAY 5 +#include +#include class GEOMImpl_ISpline { public: + enum { + ARG_POINTS = 1, + ARG_CLOSED = 2, + ARG_REORDER = 3, + CONSTRUCTOR = 4, + ARG_ARRAY = 5, + ARG_VEC_1 = 6, + ARG_VEC_2 = 7 + }; + GEOMImpl_ISpline(Handle(GEOM_Function) theFunction): _func(theFunction) {} - void SetLength(int theLen) { _func->SetInteger(SPL_ARG_LENG, theLen); } + // Set - void SetIsClosed(bool theIsClosed) { _func->SetInteger(SPL_ARG_CLOS, (int)theIsClosed); } + void SetPoints (const Handle(TColStd_HSequenceOfTransient)& thePoints) + { _func->SetReferenceList(ARG_POINTS, thePoints); } - void SetDoReordering(bool theDoReordering) { _func->SetInteger(SPL_ARG_REOR, (int)theDoReordering); } + void SetIsClosed (bool theIsClosed) { _func->SetInteger(ARG_CLOSED, (int)theIsClosed); } + void SetDoReordering (bool theDoReordering) { _func->SetInteger(ARG_REORDER, (int)theDoReordering); } - void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SPL_ARG_LAST + theId, theP); } + void SetConstructorType (int theConstructor) { _func->SetInteger(CONSTRUCTOR, theConstructor); } - int GetLength() { return _func->GetInteger(SPL_ARG_LENG); } + void SetCoordinates (const Handle(TColStd_HArray1OfReal)& theValue) + { _func->SetRealArray(ARG_ARRAY, theValue); } - bool GetIsClosed() { return (bool)_func->GetInteger(SPL_ARG_CLOS); } + void SetFirstVector (Handle(GEOM_Function) theVec) { _func->SetReference(ARG_VEC_1, theVec); } + void SetLastVector (Handle(GEOM_Function) theVec) { _func->SetReference(ARG_VEC_2, theVec); } - bool GetDoReordering() { return (bool)_func->GetInteger(SPL_ARG_REOR); } + // Get - Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } + Handle(TColStd_HSequenceOfTransient) GetPoints() { return _func->GetReferenceList(ARG_POINTS); } + bool GetIsClosed() { return (bool)_func->GetInteger(ARG_CLOSED); } + bool GetDoReordering() { return (bool)_func->GetInteger(ARG_REORDER); } - void SetConstructorType(int theConstructor) {_func->SetInteger(SPL_CONSTRUCTOR,theConstructor); } + int GetConstructorType() { return _func->GetInteger(CONSTRUCTOR); } - int GetConstructorType() { return _func->GetInteger(SPL_CONSTRUCTOR); } + Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(ARG_ARRAY); } + Handle(GEOM_Function) GetFirstVector () { return _func->GetReference(ARG_VEC_1); } + Handle(GEOM_Function) GetLastVector () { return _func->GetReference(ARG_VEC_2); } + + /* Old implementation (Salome 6.6.0 and earlier) +#define SPL_ARG_LENG 1 +#define SPL_ARG_CLOS 2 +#define SPL_ARG_REOR 3 +#define SPL_ARG_LAST 2 + +#define SPL_CONSTRUCTOR 4 +#define SPL_ARG_ARRAY 5 + + void SetLength(int theLen) { _func->SetInteger(SPL_ARG_LENG, theLen); } + void SetIsClosed(bool theIsClosed) { _func->SetInteger(SPL_ARG_CLOS, (int)theIsClosed); } + void SetDoReordering(bool theDoReordering) { _func->SetInteger(SPL_ARG_REOR, (int)theDoReordering); } + void SetConstructorType(int theConstructor) {_func->SetInteger(SPL_CONSTRUCTOR,theConstructor); } + void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SPL_ARG_LAST + theId, theP); } void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue) { _func->SetRealArray(SPL_ARG_ARRAY, theValue); } - + int GetLength() { return _func->GetInteger(SPL_ARG_LENG); } + bool GetIsClosed() { return (bool)_func->GetInteger(SPL_ARG_CLOS); } + bool GetDoReordering() { return (bool)_func->GetInteger(SPL_ARG_REOR); } + int GetConstructorType() { return _func->GetInteger(SPL_CONSTRUCTOR); } + Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SPL_ARG_ARRAY); } + */ private: diff --git a/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx b/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx index 25f22d214..604d65da1 100644 --- a/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx @@ -18,15 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include #include #include + #include -#include + +#include #include #include @@ -109,7 +110,7 @@ Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const } else if (aType == MARKER_SHAPE) { Handle(GEOM_Function) aRefShape = aPI.GetShape(); TopoDS_Shape aSh = aRefShape->GetValue(); - gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aSh); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aSh); gp_Pln aPln (anAx3); double aTrimSize = 100.0; diff --git a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx index 5e014b4eb..7aa6fb5f8 100644 --- a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx @@ -18,16 +18,17 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include #include -#include #include + #include +#include + #include #include #include @@ -96,7 +97,7 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(TFunction_Logbook& log) const Standard_NullObject::Raise("Shape for centre of mass calculation is null"); } - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aShapeBase); + gp_Ax3 aPos = GEOMUtils::GetPosition(aShapeBase); gp_Pnt aCenterMass = aPos.Location(); aShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape(); } @@ -189,7 +190,7 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(TFunction_Logbook& log) const } else { - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aFace); + gp_Ax3 aPos = GEOMUtils::GetPosition(aFace); p1 = aPos.Location(); } diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 400c2a03c..530d38012 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -19,11 +19,8 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -#include - #include -#include #include #include #include @@ -31,8 +28,11 @@ #include #include #include + #include +#include + #include #include #include @@ -2491,7 +2491,7 @@ Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const //aShape = GEOMImpl_GlueDriver::GlueFaces(aShape, Precision::Confusion(), Standard_True); } - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); log.SetTouched(Label()); diff --git a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx index 025042282..f28ff1f27 100644 --- a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx @@ -15,20 +15,20 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include - #include + #include +#include + +#include -#include -#include "GEOMAlgo_FinderShapeOn1.hxx" -#include "GEOMAlgo_FinderShapeOn2.hxx" +#include +#include #include #include @@ -106,7 +106,7 @@ GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!GEOMImpl_IShapesOperations::CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { StdFail_NotDone::Raise("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -179,7 +179,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!GEOMImpl_IShapesOperations::CheckTriangulation(theShape)) { + if (!GEOMUtils::CheckTriangulation(theShape)) { StdFail_NotDone::Raise("Cannot build triangulation on the shape"); return aSeqOfIDs; } diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index e1968567b..8fc83e24e 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -27,7 +26,7 @@ #include #include -#include +#include #include @@ -142,7 +141,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const // Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); //} //aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); - gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aRefShape); gp_Pln aPln (anAx3); aShape = BRepBuilderAPI_MakeFace(aPln, -aSize, +aSize, -aSize, +aSize).Shape(); } @@ -223,7 +222,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aRefShape = aRef->GetValue(); if (aRefShape.ShapeType() != TopAbs_FACE) return 0; - anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + anAx3 = GEOMUtils::GetPosition(aRefShape); } if ( anOrientation == 2) diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx index be11e7dbb..73aed0fa2 100644 --- a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx @@ -18,16 +18,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//#include -// #include + #include #include + #include -#include +#include // OCCT Includes #include @@ -117,10 +116,10 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const gp_Ax3 aStartAx3, aDestAx3; // End LCS - aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + aDestAx3 = GEOMUtils::GetPosition(aShapeEndLCS); // Start LCS - aStartAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeStartLCS); + aStartAx3 = GEOMUtils::GetPosition(aShapeStartLCS); // Set transformation aTrsf.SetDisplacement(aStartAx3, aDestAx3); @@ -145,7 +144,7 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const gp_Ax3 aStartAx3, aDestAx3; // End LCS - aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + aDestAx3 = GEOMUtils::GetPosition(aShapeEndLCS); // Set transformation aTrsf.SetDisplacement(aStartAx3, aDestAx3); diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index 87b18275d..ae25ae0b8 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -18,17 +18,18 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include -#include -#include #include #include #include + #include +#include + +#include #include #include @@ -249,7 +250,7 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const } else { - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); } @@ -275,7 +276,7 @@ TopoDS_Shape GEOMImpl_PrismDriver::MakeScaledPrism (const TopoDS_Shape& theShape // 1. aCDG = geompy.MakeCDG(theBase) gp_Pnt aCDG = theCDG; if (!isCDG) { - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(theShapeBase); + gp_Ax3 aPos = GEOMUtils::GetPosition(theShapeBase); aCDG = aPos.Location(); } TopoDS_Shape aShapeCDG_1 = BRepBuilderAPI_MakeVertex(aCDG).Shape(); diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx index ea72dd7c3..44e68d973 100644 --- a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx @@ -18,17 +18,18 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include -#include #include #include + #include +#include + #include #include #include @@ -128,7 +129,7 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons if (aShape.IsNull()) return 0; - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); log.SetTouched(Label()); diff --git a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx index 70e627719..0ebe757d0 100644 --- a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -27,7 +26,7 @@ #include #include -#include +#include #include @@ -117,7 +116,7 @@ Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const // return 0; //Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); //aWPlane = aGPlane->Pln().Position(); - aWPlane = GEOMImpl_IMeasureOperations::GetPosition(aShape); + aWPlane = GEOMUtils::GetPosition(aShape); } gp_Trsf aTrans; aTrans.SetTransformation(aWPlane); diff --git a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx index c87cdbc09..a94f0a279 100644 --- a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx @@ -18,14 +18,14 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include +#include #include #include @@ -49,6 +49,10 @@ #include #include +#include + +#include + //======================================================================= //function : GetID //purpose : @@ -82,54 +86,73 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; - if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) { + if (aType == SPLINE_BEZIER || + aType == SPLINE_INTERPOLATION || + aType == SPLINE_INTERPOL_TANGENTS) { bool useCoords = aCI.GetConstructorType() == COORD_CONSTRUCTOR; - TColgp_Array1OfPnt points(1, (useCoords ? aCI.GetLength() : 1) ); - if(useCoords) { - Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); + + Handle(TColStd_HArray1OfReal) aCoordsArray; // parametric case + Handle(TColStd_HSequenceOfTransient) aPoints; // points case + + int aLen = 0; + if (useCoords) { + aCoordsArray = aCI.GetCoordinates(); + aLen = aCoordsArray->Length() / 3; + } + else { + aPoints = aCI.GetPoints(); + aLen = aPoints->Length(); + } + + if (aLen < 2) return 0; + + TColgp_Array1OfPnt points (1, (useCoords ? aLen : 1)); + if (useCoords) { int anArrayLength = aCoordsArray->Length(); for (int i = 0, j = 1; i <= (anArrayLength-3); i += 3) { gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3)); - points.SetValue(j,aPnt); + points.SetValue(j, aPnt); j++; - } + } } - - int ind, aLen = aCI.GetLength(); - if (aLen < 2) return 0; - Standard_Boolean isSeveral = Standard_False; - gp_Pnt aPrevP; int aRealLen = aLen; + if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) { TopoDS_Vertex aV1; - if(useCoords) { + if (useCoords) { aV1 = BRepBuilderAPI_MakeVertex(points.Value(1)); - } else { - Handle(GEOM_Function) aFPoint = aCI.GetPoint(1); + } + else { + Handle(GEOM_Function) aFPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(1)); TopoDS_Shape aFirstPnt = aFPoint->GetValue(); aV1 = TopoDS::Vertex(aFirstPnt); } TopoDS_Vertex aV2; - if(useCoords) { + if (useCoords) { aV2 = BRepBuilderAPI_MakeVertex(points.Value(aLen)); - } else { - Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen); + } + else { + Handle(GEOM_Function) aLPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(aLen)); TopoDS_Shape aLastPnt = aLPoint->GetValue(); aV2 = TopoDS::Vertex(aLastPnt); } - + if (!aV1.IsNull() && !aV2.IsNull() && !aV1.IsSame(aV2)) { aRealLen++; } } - + + int ind; + Standard_Boolean isSeveral = Standard_False; + gp_Pnt aPrevP; + TColgp_Array1OfPnt CurvePoints (1, aRealLen); for (ind = 1; ind <= aLen; ind++) { gp_Pnt aP; - if( useCoords ) { + if (useCoords) { aP = points.Value(ind); if (!isSeveral && ind > 1) { if (aP.Distance(aPrevP) > Precision::Confusion()) { @@ -138,8 +161,9 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } CurvePoints.SetValue(ind, aP); aPrevP = aP; - } else { - Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); + } + else { + Handle(GEOM_Function) aRefPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(ind)); TopoDS_Shape aShapePnt = aRefPoint->GetValue(); if (aShapePnt.ShapeType() == TopAbs_VERTEX) { aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); @@ -153,6 +177,7 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } } } + if (aType == SPLINE_BEZIER) { if (!isSeveral) { Standard_ConstructionError::Raise("Points for Bezier Curve are too close"); @@ -160,13 +185,12 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const if (aRealLen > aLen) { // set last point equal to first for the closed curve CurvePoints.SetValue(aRealLen, CurvePoints.Value(1)); } - Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints); + Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve (CurvePoints); aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); - } else { + } + else { //GeomAPI_PointsToBSpline GBC (CurvePoints); //aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); - - Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen); if (aCI.GetDoReordering()) { for (int curInd = 1; curInd < aLen - 1; curInd++) { @@ -194,18 +218,35 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const CurvePoints.SetValue(curInd + 1, nearPnt); } } - for (ind = 1; ind <= aLen; ind++) { - aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); - } } - else { - for (ind = 1; ind <= aLen; ind++) { - aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); - } + + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen); + for (ind = 1; ind <= aLen; ind++) { + aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); } - - bool isClosed = aCI.GetIsClosed(); + + bool isClosed = Standard_False; + if (aType == SPLINE_INTERPOLATION) + isClosed = aCI.GetIsClosed(); + GeomAPI_Interpolate GBC (aHCurvePoints, isClosed, gp::Resolution()); + + if (aType == SPLINE_INTERPOL_TANGENTS) { + Handle(GEOM_Function) aVec1Ref = aCI.GetFirstVector(); + Handle(GEOM_Function) aVec2Ref = aCI.GetLastVector(); + + if (aVec1Ref.IsNull() || aVec2Ref.IsNull()) + Standard_NullObject::Raise("Null object is given for a vector"); + + TopoDS_Shape aVec1Sh = aVec1Ref->GetValue(); + TopoDS_Shape aVec2Sh = aVec2Ref->GetValue(); + + gp_Vec aV1 = GEOMUtils::GetVector(aVec1Sh); + gp_Vec aV2 = GEOMUtils::GetVector(aVec2Sh); + + GBC.Load(aV1, aV2, /*Scale*/Standard_True); + } + GBC.Perform(); if (GBC.IsDone()) aShape = BRepBuilderAPI_MakeEdge(GBC.Curve()).Edge(); @@ -215,13 +256,13 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } else { } - + if (aShape.IsNull()) return 0; - + aFunction->SetValue(aShape); - + log.SetTouched(Label()); - + return 1; } diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 4aeed6398..659158e28 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -234,8 +234,9 @@ #define POLYLINE_POINTS 1 -#define SPLINE_BEZIER 1 -#define SPLINE_INTERPOLATION 2 +#define SPLINE_BEZIER 1 +#define SPLINE_INTERPOLATION 2 +#define SPLINE_INTERPOL_TANGENTS 3 #define CIRCLE_THREE_PNT 1 #define CIRCLE_PNT_VEC_R 2 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 8ce12ca2e..f456551ce 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -238,14 +238,18 @@ libGEOMimpl_la_CPPFLAGS = \ -I$(srcdir)/../NMTDS \ -I$(srcdir)/../NMTTools \ -I$(srcdir)/../GEOM \ + -I$(srcdir)/../BlockFix \ -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../GEOMUtils \ -I$(srcdir)/../SKETCHER \ -I$(srcdir)/../ARCHIMEDE \ -I$(top_builddir)/idl libGEOMimpl_la_LDFLAGS = \ ../GEOM/libGEOMbasic.la \ + ../BlockFix/libBlockFix.la \ ../GEOMAlgo/libGEOMAlgo.la \ + ../GEOMUtils/libGEOMUtils.la \ ../ShHealOper/libShHealOper.la \ ../ARCHIMEDE/libGEOMArchimede.la \ ../SKETCHER/libGEOMSketcher.la \ diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx new file mode 100644 index 000000000..292ab5c44 --- /dev/null +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -0,0 +1,499 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#include + +#include + +#include + +#include +#include +#include + +// OCCT Includes +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +#define STD_SORT_ALGO 1 + +//======================================================================= +//function : GetPosition +//purpose : +//======================================================================= +gp_Ax3 GEOMUtils::GetPosition (const TopoDS_Shape& theShape) +{ + gp_Ax3 aResult; + + if (theShape.IsNull()) + return aResult; + + // Axes + aResult.Transform(theShape.Location().Transformation()); + if (theShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape)); + if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); + gp_Pln aPln = aGPlane->Pln(); + aResult = aPln.Position(); + // In case of reverse orinetation of the face invert the plane normal + // (the face's normal does not mathc the plane's normal in this case) + if(theShape.Orientation() == TopAbs_REVERSED) + { + gp_Dir Vx = aResult.XDirection(); + gp_Dir N = aResult.Direction().Mirrored(Vx); + gp_Pnt P = aResult.Location(); + aResult = gp_Ax3(P, N, Vx); + } + } + } + + // Origin + gp_Pnt aPnt; + + TopAbs_ShapeEnum aShType = theShape.ShapeType(); + + if (aShType == TopAbs_VERTEX) { + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); + } + else { + if (aShType == TopAbs_COMPOUND) { + aShType = GetTypeOfSimplePart(theShape); + } + + GProp_GProps aSystem; + if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE) + BRepGProp::LinearProperties(theShape, aSystem); + else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL) + BRepGProp::SurfaceProperties(theShape, aSystem); + else + BRepGProp::VolumeProperties(theShape, aSystem); + + aPnt = aSystem.CentreOfMass(); + } + + aResult.SetLocation(aPnt); + + return aResult; +} + +//======================================================================= +//function : GetVector +//purpose : +//======================================================================= +gp_Vec GEOMUtils::GetVector (const TopoDS_Shape& theShape) +{ + if (theShape.IsNull()) + Standard_NullObject::Raise("Null shape is given for a vector"); + + if (theShape.ShapeType() != TopAbs_EDGE) + Standard_TypeMismatch::Raise("Invalid shape is given, must be a vector or an edge"); + + TopoDS_Edge anE = TopoDS::Edge(theShape); + + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + + if (V1.IsNull() || V2.IsNull()) + Standard_NullObject::Raise("Invalid edge is given, it must have two points"); + + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (aV.Magnitude() < gp::Resolution()) { + Standard_ConstructionError::Raise("Vector of zero length is given"); + } + + return aV; +} + +//======================================================================= +//function : ShapeToDouble +//purpose : used by CompareShapes::operator() +//======================================================================= +std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) +{ + // Computing of CentreOfMass + gp_Pnt GPoint; + double Len; + + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); + Len = (double)S.Orientation(); + } + else { + GProp_GProps GPr; + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties(S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 + GPoint = GPr.CentreOfMass(); + Len = GPr.Mass(); + } + + double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; + return std::make_pair(dMidXYZ, Len); +} + +//======================================================================= +//function : CompareShapes::operator() +//purpose : used by std::sort(), called from SortShapes() +//======================================================================= +bool GEOMUtils::CompareShapes::operator() (const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2) +{ + if (!myMap.IsBound(theShape1)) { + myMap.Bind(theShape1, ShapeToDouble(theShape1, myIsOldSorting)); + } + + if (!myMap.IsBound(theShape2)) { + myMap.Bind(theShape2, ShapeToDouble(theShape2, myIsOldSorting)); + } + + std::pair val1 = myMap.Find(theShape1); + std::pair val2 = myMap.Find(theShape2); + + double tol = Precision::Confusion(); + bool exchange = Standard_False; + + double dMidXYZ = val1.first - val2.first; + if (dMidXYZ >= tol) { + exchange = Standard_True; + } + else if (Abs(dMidXYZ) < tol) { + double dLength = val1.second - val2.second; + if (dLength >= tol) { + exchange = Standard_True; + } + else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { + // PAL17233 + // equal values possible on shapes such as two halves of a sphere and + // a membrane inside the sphere + Bnd_Box box1,box2; + BRepBndLib::Add(theShape1, box1); + if (!box1.IsVoid()) { + BRepBndLib::Add(theShape2, box2); + Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); + if (dSquareExtent >= tol) { + exchange = Standard_True; + } + else if (Abs(dSquareExtent) < tol) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; + box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + } + } + } + } + + //return val1 < val2; + return !exchange; +} + +//======================================================================= +//function : SortShapes +//purpose : +//======================================================================= +void GEOMUtils::SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting) +{ +#ifdef STD_SORT_ALGO + std::vector aShapesVec; + aShapesVec.reserve(SL.Extent()); + + TopTools_ListIteratorOfListOfShape it (SL); + for (; it.More(); it.Next()) { + aShapesVec.push_back(it.Value()); + } + SL.Clear(); + + CompareShapes shComp (isOldSorting); + std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); + //std::sort(aShapesVec.begin(), aShapesVec.end(), shComp); + + std::vector::const_iterator anIter = aShapesVec.begin(); + for (; anIter != aShapesVec.end(); ++anIter) { + SL.Append(*anIter); + } +#else + // old implementation + Standard_Integer MaxShapes = SL.Extent(); + TopTools_Array1OfShape aShapes (1,MaxShapes); + TColStd_Array1OfInteger OrderInd(1,MaxShapes); + TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z; + TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z; + + // Computing of CentreOfMass + Standard_Integer Index; + GProp_GProps GPr; + gp_Pnt GPoint; + TopTools_ListIteratorOfListOfShape it(SL); + for (Index=1; it.More(); Index++) + { + TopoDS_Shape S = it.Value(); + SL.Remove( it ); // == it.Next() + aShapes(Index) = S; + OrderInd.SetValue (Index, Index); + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S )); + Length.SetValue( Index, (Standard_Real) S.Orientation()); + } + else { + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties (S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties (S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 + GPoint = GPr.CentreOfMass(); + Length.SetValue(Index, GPr.Mass()); + } + MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9); + //cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl; + } + + // Sorting + Standard_Integer aTemp; + Standard_Boolean exchange, Sort = Standard_True; + Standard_Real tol = Precision::Confusion(); + while (Sort) + { + Sort = Standard_False; + for (Index=1; Index < MaxShapes; Index++) + { + exchange = Standard_False; + Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); + Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); + if ( dMidXYZ >= tol ) { +// cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <= tol ) { +// cout << "Length: " << Length(OrderInd(Index))<< " > " <= tol ) { +// cout << "SquareExtent: " << box1.SquareExtent()<<" > "< val2; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + //cout << "box: " << val1<<" > "< + +#include + +#include + +#include +#include + +#include + +inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) +{ + return S1.IsSame(S2); +} + +class GEOMUtils { + + public: + /*! + * \brief Get Local Coordinate System, corresponding to the given shape. + * + * Origin of the LCS is situated at the shape's center of mass. + * Axes of the LCS are obtained from shape's location or, + * if the shape is a planar face, from position of its plane. + */ + Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); + + /*! + * \brief Get vector, defined by the given edge. + */ + Standard_EXPORT static gp_Vec GetVector (const TopoDS_Shape& theShape); + + /*! + * \brief Sort shapes in the list by their coordinates. + * \param SL The list of shapes to sort. + */ + struct CompareShapes : public std::binary_function + { + CompareShapes (bool isOldSorting) + : myIsOldSorting(isOldSorting) {} + + bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); + + typedef NCollection_DataMap > GEOMUtils_DataMapOfShapeDouble; + GEOMUtils_DataMapOfShapeDouble myMap; + bool myIsOldSorting; + }; + + /*! + * \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9 + */ + Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting = Standard_True); + + /*! + * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. + * + * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is. + * + * \param theCompsolid The compsolid to be converted. + * \retval TopoDS_Shape Returns the resulting compound. + */ + Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); + + /*! + * \brief Build a triangulation on \a theShape if it is absent. + * \param theShape The shape to check/build triangulation on. + * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. + */ + Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape); + + /*! + * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. + * \param theShape The shape to get type of. + * \retval TopAbs_ShapeEnum Return type of shape for explode. + */ + Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); + +}; + +#endif diff --git a/src/GEOMUtils/Makefile.am b/src/GEOMUtils/Makefile.am new file mode 100644 index 000000000..844ac94f2 --- /dev/null +++ b/src/GEOMUtils/Makefile.am @@ -0,0 +1,57 @@ +# 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 + +# GEOMUtils : implementaion of some common methods for GEOMImpl package +# File : Makefile.am +# Author : Julia DOROVSKIKH + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# Libraries targets +lib_LTLIBRARIES = libGEOMUtils.la + +# header files +salomeinclude_HEADERS = \ + GEOMUtils.hxx + +dist_libGEOMUtils_la_SOURCES = \ + GEOMUtils.cxx + +# additional information to compile and link file + +libGEOMUtils_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + $(BOOST_CPPFLAGS) \ + -I$(srcdir)/../ShHealOper \ + -I$(srcdir)/../NMTDS \ + -I$(srcdir)/../NMTTools \ + -I$(srcdir)/../BlockFix \ + -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../SKETCHER \ + -I$(srcdir)/../ARCHIMEDE + +libGEOMUtils_la_LDFLAGS = \ + ../BlockFix/libBlockFix.la \ + ../GEOMAlgo/libGEOMAlgo.la \ + ../ShHealOper/libShHealOper.la \ + ../ARCHIMEDE/libGEOMArchimede.la \ + ../SKETCHER/libGEOMSketcher.la \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \ + $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \ + $(STDLIB) diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index 3f1a67800..88e381681 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -427,6 +427,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation return GetObject(anObject); } +//============================================================================= +/*! + * MakeSplineInterpolWithTangents + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolWithTangents + (const GEOM::ListOfGO& thePoints, + GEOM::GEOM_Object_ptr theFirstVec, + GEOM::GEOM_Object_ptr theLastVec) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference points + int ind = 0; + int aLen = thePoints.length(); + std::list aPoints; + for (; ind < aLen; ind++) { + Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]); + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + + //Get the reference vectors + Handle(GEOM_Object) aVec1 = GetObjectImpl(theFirstVec); + Handle(GEOM_Object) aVec2 = GetObjectImpl(theLastVec); + + if (aVec1.IsNull() || aVec2.IsNull()) return aGEOMObject._retn(); + + // Make Polyline + Handle(GEOM_Object) anObject = + GetOperations()->MakeSplineInterpolWithTangents(aPoints, aVec1, aVec2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeCurveParametric diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index e50ab2111..07f4ce2a0 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -85,6 +85,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : CORBA::Boolean theIsClosed, CORBA::Boolean theDoReordering); + GEOM::GEOM_Object_ptr MakeSplineInterpolWithTangents (const GEOM::ListOfGO& thePoints, + GEOM::GEOM_Object_ptr theFirstVec, + GEOM::GEOM_Object_ptr theLastVec); + GEOM::GEOM_Object_ptr MakeCurveParametric (const char* thexExpr, const char* theyExpr, const char* thezExpr, double theParamMin, double theParamMax, double theParamStep, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 3b9381772..4eb309e4c 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -102,6 +102,8 @@ def TestAll (geompy, math): Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object)->GEOM_Object Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object)->GEOM_Object Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->GEOM_Object + InterpT1 = geompy.MakeInterpolWithTangents([px, py, pxyz], vx, vz) #(List of GO, GO, GO)->GEOM_Object + InterpT2 = geompy.MakeInterpolWithTangents([px, py, pxyz], vxy, vxyz) #(List of GO, GO, GO)->GEOM_Object Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW", [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object @@ -343,6 +345,8 @@ def TestAll (geompy, math): id_Polyline = geompy.addToStudy(Polyline, "Polyline") id_Bezier = geompy.addToStudy(Bezier, "Bezier") id_Interpol = geompy.addToStudy(Interpol, "Interpol") + id_InterpT1 = geompy.addToStudy(InterpT1, "InterpT1") + id_InterpT2 = geompy.addToStudy(InterpT2, "InterpT2") id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") id_Sketcher3d_1 = geompy.addToStudy(Sketcher3d_1, "Sketcher 3D by interface") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 40a7dd53a..f5ad127fc 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -1579,9 +1579,32 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeSplineInterpolation(thePoints, theIsClosed, theDoReordering) - RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) + RaiseIfFailed("MakeInterpol", self.CurvesOp) return anObj + ## Create B-Spline curve on the set of points. + # @param thePoints Sequence of points for the B-Spline curve. + # @param theFirstVec Vector object, defining the curve direction at its first point. + # @param theLastVec Vector object, defining the curve direction at its last point. + # @return New GEOM.GEOM_Object, containing the created B-Spline curve. + # + # @ref tui_creation_curve "Example" + def MakeInterpolWithTangents(self, thePoints, theFirstVec, theLastVec): + """ + Create B-Spline curve on the set of points. + + Parameters: + thePoints Sequence of points for the B-Spline curve. + theFirstVec Vector object, defining the curve direction at its first point. + theLastVec Vector object, defining the curve direction at its last point. + + Returns: + New GEOM.GEOM_Object, containing the created B-Spline curve. + """ + # Example: see GEOM_TestAll.py + anObj = self.CurvesOp.MakeSplineInterpolWithTangents(thePoints, theFirstVec, theLastVec) + RaiseIfFailed("MakeInterpolWithTangents", self.CurvesOp) + return anObj ## Creates a curve using the parametric definition of the basic points. # @param thexExpr parametric equation of the coordinates X. @@ -1622,8 +1645,6 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) anObj.SetParameters(Parameters) return anObj - - # end of l4_curves ## @} diff --git a/src/Makefile.am b/src/Makefile.am index 862b90287..e81e3bfd9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,15 +15,14 @@ # 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 : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : src (source files directory) -SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM \ - BREPExport BREPImport IGESExport IGESImport STEPExport \ - STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \ +SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER OCC2VTK GEOM \ + BREPExport BREPImport IGESExport IGESImport STEPExport STEPImport \ + STLExport VTKExport ShHealOper GEOMUtils GEOMImpl GEOM_I \ GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY if WITH_OPENCV @@ -31,18 +30,18 @@ if WITH_OPENCV endif if GEOM_ENABLE_GUI - SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase GEOMToolsGUI \ - DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI \ - BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI \ - GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM + SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ + GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ + EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM endif -DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ - SKETCHER OCC2VTK GEOM BREPExport \ - BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \ - VTKExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \ - GEOM_SWIG OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ +DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER \ + OCC2VTK GEOM BREPExport BREPImport IGESExport IGESImport \ + STEPExport STEPImport STLExport VTKExport ShHealOper GEOMUtils \ + GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG OBJECT \ + DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition