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 \
<li> If <b>Reorder vertices taking into account distances</b> is
checked, the interpolation algorithm does not follow the order of
vertices but searches for the closest vertex.</li>
+<li><b>Tangents</b> 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.
+</li>
</ul>
\n <b>TUI Command:</b>
<em>geompy.MakeInterpol(ListOfShapes,isClosed,doReordering)</em>
+<em>geompy.MakeInterpolWithTangents(ListOfShapes,Vector1,Vector2)</em>
<b>Analytical Definition</b>
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.
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
- SelectionIntoArgument();
myEditCurrentArgument->setFocus();
globalSelection(); // close local contexts, if any
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
- displayPreview(true);
+ SelectionIntoArgument();
}
//=================================================================================
// 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
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
{
}
-
//=================================================================================
// function : Init()
// purpose :
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);
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()
//=================================================================================
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();
}
//=================================================================================
void BasicGUI_CurveDlg::CheckButtonToggled()
{
+ if (getConstructorId() == 2) { // Interpolation
+ bool disableTangents = (myGroupPoints->CheckButton1->isChecked() ||
+ myGroupPoints->CheckButton2->isChecked());
+ myGroupTangents->setEnabled(!disableTangents);
+ }
processPreview();
}
//=================================================================================
void BasicGUI_CurveDlg::ClickOnOk()
{
- setIsApplyAndClose( true );
- if ( ClickOnApply() )
+ setIsApplyAndClose(true);
+ if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
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<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right )
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+static void synchronize (QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right)
{
// 1. remove items from the "left" list that are not in the "right" list
- QMutableListIterator<GEOM::GeomObjPtr> it1( left );
- while ( it1.hasNext() ) {
+ QMutableListIterator<GEOM::GeomObjPtr> it1 (left);
+ while (it1.hasNext()) {
GEOM::GeomObjPtr o1 = it1.next();
bool found = false;
QMutableListIterator<GEOM::GeomObjPtr> it2( right );
}
}
-//=================================================================================
-// function : SelectionIntoArgument()
-// purpose : Called when selection as changed or other case
-//=================================================================================
void BasicGUI_CurveDlg::SelectionIntoArgument()
{
- QList<GEOM::GeomObjPtr> 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<GEOM::GeomObjPtr> 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<GEOM::GeomObjPtr> 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 :
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());
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
-void BasicGUI_CurveDlg::enterEvent( QEvent* )
+void BasicGUI_CurveDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
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;
}
}
// 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<<myParams->myPMin->text();
- aParameters<<myParams->myPMax->text();
- aParameters<<myParams->myPStep->text();
+ aParameters<<myGroupParams->myPMin->text();
+ aParameters<<myGroupParams->myPMax->text();
+ aParameters<<myGroupParams->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()
// 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();
}
// 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();
}
// 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
class DlgRef_1Sel3Check;
class QRadioButton;
+class QPushButton;
+class QLineEdit;
+class QGroupBox;
class BasicGUI_ParamCurveWidget;
//=================================================================================
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<GEOM::GeomObjPtr> 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<GEOM::GeomObjPtr> myPoints;
+ GEOM::GeomObjPtr myVec1, myVec2;
private slots:
void ClickOnOk();
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();
};
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix.cxx
+// Created: Tue Dec 7 11:59:05 2004
+// Author: Pavel DURANDIN
+
+#include <BlockFix.hxx>
+
+#include <BlockFix_SphereSpaceModifier.hxx>
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopLoc_Location.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <BRepAdaptor_Surface.hxx>
+
+#include <BRepTools.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <BRepTools_Substitution.hxx>
+
+#include <BRepOffsetAPI_MakeFilling.hxx>
+
+#include <ShapeFix.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+
+#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeAnalysis_Curve.hxx>
+#include <ShapeAnalysis_Surface.hxx>
+
+#include <ShapeCustom.hxx>
+
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+
+#include <ShapeFix_Wire.hxx>
+
+#include <Geom_Surface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_ToroidalSurface.hxx>
+
+#include <Geom2d_Curve.hxx>
+
+#include <TColgp_SequenceOfPnt2d.hxx>
+
+//=======================================================================
+//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; i<sewd->NbEdges();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;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_HeaderFile
+#define _BlockFix_HeaderFile
+
+#include <Standard_Real.hxx>
+
+class TopoDS_Shape;
+class BlockFix_SphereSpaceModifier;
+class BlockFix_UnionFaces;
+class BlockFix_UnionEdges;
+class BlockFix_BlockFixAPI;
+class BlockFix_PeriodicSurfaceModifier;
+class BlockFix_CheckTool;
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+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
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix_BlockFixAPI.cxx
+// Created: Tue Dec 7 11:59:05 2004
+// Author: Pavel DURANDIN
+
+#include <BlockFix_BlockFixAPI.hxx>
+
+#include <BlockFix.hxx>
+#include <BlockFix_UnionFaces.hxx>
+#include <BlockFix_UnionEdges.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <ShapeUpgrade_RemoveLocations.hxx>
+
+#include <Precision.hxx>
+
+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;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_BlockFixAPI_HeaderFile
+#define _BlockFix_BlockFixAPI_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+
+#include <Handle_ShapeBuild_ReShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Standard_Real.hxx>
+#include <MMgt_TShared.hxx>
+
+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
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix_CheckTool.cxx
+// Created: 17.12.04 11:15:25
+// Author: Sergey KUUL
+
+#include <BlockFix_CheckTool.hxx>
+
+#include <BRep_Tool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+//=======================================================================
+//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<faces.Length() && !HasFacesForUnification; i++) {
+ TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
+ TopTools_MapOfShape Edges;
+ for (TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
+ Edges.Add(expe.Current().Oriented(TopAbs_FORWARD));
+ TopLoc_Location L1;
+ Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
+ for(Standard_Integer j=i+1; j<=faces.Length() && !HasFacesForUnification; j++) {
+ TopoDS_Face F2 = TopoDS::Face(faces.Value(j));
+ TopLoc_Location L2;
+ Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
+ if( S1==S2 && L1==L2 ) {
+ // faces have equal based surface
+ // now check common edge
+ for(TopExp_Explorer expe2(F2,TopAbs_EDGE); expe2.More(); expe2.Next()) {
+ if(Edges.Contains(expe2.Current().Oriented(TopAbs_FORWARD))) {
+ HasFacesForUnification = Standard_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (HasFacesForUnification) {
+ MayBeUF=Standard_True;
+ }
+ }
+
+ Standard_Integer nbe=0;
+ TopTools_MapOfShape DegenEdges;
+ TopExp_Explorer expe (aSolid, TopAbs_EDGE);
+ TopTools_MapOfShape mapE;
+ for (; expe.More(); expe.Next()) {
+ TopoDS_Edge E = TopoDS::Edge(expe.Current());
+ if (!mapE.Add(E)) continue;
+ if (BRep_Tool::Degenerated(E)) {
+ DegenEdges.Add(E);
+ }
+ else {
+ nbe++;
+ }
+ }
+ if (nbe == 12 && DegenEdges.Extent() > 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!"<<endl;
+ else {
+ S<<"dump results of check:"<<endl;
+ S<<" total number of solids = "<<myNbSolids<<endl;
+ S<<" including: number of good blocks = "<<myNbBlocks<<endl;
+ S<<" number of possible blocks = "<<NbPossibleBlocks()<<endl;
+ S<<" including: need remove degenerative = "<<myNbDegen<<endl;
+ S<<" need unionfaces = "<<myNbUF<<endl;
+ S<<" need unionedges = "<<myNbUE<<endl;
+ S<<" need both unionfaces and unionedges = "<<myNbUFUE<<endl;
+ Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
+ S<<" number of impossible blocks = "<<nbtmp<<endl;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_CheckTool_HeaderFile
+#define _BlockFix_CheckTool_HeaderFile
+
+#include <TopoDS_Shape.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard_Integer.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+#include <Standard_OStream.hxx>
+
+class TopoDS_Shape;
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+class BlockFix_CheckTool {
+
+public:
+ Standard_EXPORT BlockFix_CheckTool();
+ Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ;
+ Standard_EXPORT void Perform() ;
+ Standard_EXPORT Standard_Integer NbPossibleBlocks() const;
+ Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const;
+ Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const;
+
+private:
+ TopoDS_Shape myShape;
+ Standard_Boolean myHasCheck;
+ Standard_Integer myNbSolids;
+ Standard_Integer myNbBlocks;
+ TopTools_SequenceOfShape myPossibleBlocks;
+ Standard_Integer myNbDegen;
+ Standard_Integer myNbUF;
+ Standard_Integer myNbUE;
+ Standard_Integer myNbUFUE;
+ Standard_Integer myBadRanges;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix_PeriodicSurfaceModifier.cxx
+// Created: 15.12.04 10:08:50
+// Author: Sergey KUUL
+
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+
+#include <ShapeFix_Edge.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <TopLoc_Location.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <BRepTools.hxx>
+
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Curve.hxx>
+
+#include <Geom2d_Curve.hxx>
+
+#include <gp_Pnt.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(BlockFix_PeriodicSurfaceModifier, BRepTools_Modification);
+IMPLEMENT_STANDARD_RTTIEXT(BlockFix_PeriodicSurfaceModifier, BRepTools_Modification);
+
+//=======================================================================
+//function : BlockFix_PeriodicSurfaceModifier()
+//purpose : Constructor
+//=======================================================================
+BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier()
+{
+ myMapOfFaces.Clear();
+ myMapOfSurfaces.Clear();
+}
+
+//=======================================================================
+//function : ~BlockFix_PeriodicSurfaceModifier()
+//purpose : Destructor
+//=======================================================================
+BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier()
+{
+}
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile
+#define _BlockFix_PeriodicSurfaceModifier_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+
+#include <Standard_Real.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TColStd_IndexedMapOfTransient.hxx>
+#include <BRepTools_Modification.hxx>
+#include <Standard_Boolean.hxx>
+#include <Handle_Geom_Surface.hxx>
+#include <Handle_Geom_Curve.hxx>
+#include <Handle_Geom2d_Curve.hxx>
+#include <GeomAbs_Shape.hxx>
+
+class TopoDS_Face;
+class Geom_Surface;
+class TopLoc_Location;
+class TopoDS_Edge;
+class Geom_Curve;
+class TopoDS_Vertex;
+class gp_Pnt;
+class Geom2d_Curve;
+
+DEFINE_STANDARD_HANDLE(BlockFix_PeriodicSurfaceModifier, BRepTools_Modification);
+
+class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification {
+
+public:
+ Standard_EXPORT BlockFix_PeriodicSurfaceModifier();
+ 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);
+
+ DEFINE_STANDARD_RTTI(BlockFix_PeriodicSurfaceModifier);
+
+private:
+ Standard_Real myTolerance;
+ TopTools_DataMapOfShapeInteger myMapOfFaces;
+ TColStd_IndexedMapOfTransient myMapOfSurfaces;
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix.cxx
+// Created: Tue Dec 7 11:59:05 2004
+// Author: Pavel DURANDIN
+
+#include <BlockFix_SphereSpaceModifier.hxx>
+
+#include <ShapeAnalysis.hxx>
+
+#include <ShapeFix_Edge.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopLoc_Location.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+#include <Geom2d_Curve.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_Sphere.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(BlockFix_SphereSpaceModifier, BRepTools_Modification);
+IMPLEMENT_STANDARD_RTTIEXT(BlockFix_SphereSpaceModifier, BRepTools_Modification);
+
+//=======================================================================
+//function : BlockFix_SphereSpaceModifier
+//purpose :
+//=======================================================================
+BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier()
+{
+ myMapOfFaces.Clear();
+ myMapOfSpheres.Clear();
+}
+
+//=======================================================================
+//function : ~BlockFix_SphereSpaceModifier
+//purpose :
+//=======================================================================
+BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {}
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_SphereSpaceModifier_HeaderFile
+#define _BlockFix_SphereSpaceModifier_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+
+#include <Standard_Real.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TColStd_IndexedMapOfTransient.hxx>
+#include <BRepTools_Modification.hxx>
+#include <Standard_Boolean.hxx>
+#include <Handle_Geom_Surface.hxx>
+#include <Handle_Geom_Curve.hxx>
+#include <Handle_Geom2d_Curve.hxx>
+#include <GeomAbs_Shape.hxx>
+
+class TopoDS_Face;
+class Geom_Surface;
+class TopLoc_Location;
+class TopoDS_Edge;
+class Geom_Curve;
+class TopoDS_Vertex;
+class gp_Pnt;
+class Geom2d_Curve;
+
+DEFINE_STANDARD_HANDLE(BlockFix_SphereSpaceModifier, BRepTools_Modification);
+
+class BlockFix_SphereSpaceModifier : public BRepTools_Modification {
+
+public:
+ Standard_EXPORT BlockFix_SphereSpaceModifier();
+ 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);
+
+ DEFINE_STANDARD_RTTI(BlockFix_SphereSpaceModifier);
+
+private:
+ Standard_Real myTolerance;
+ TopTools_DataMapOfShapeInteger myMapOfFaces;
+ TColStd_IndexedMapOfTransient myMapOfSpheres;
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix_UnionEdges.cxx
+// Created: 07.12.04 15:27:30
+// Author: Sergey KUUL
+
+#include <BlockFix_UnionEdges.hxx>
+
+#include <ShapeAnalysis_Edge.hxx>
+
+#include <ShapeBuild_ReShape.hxx>
+
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Shell.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_HCompCurve.hxx>
+#include <BRepLib.hxx>
+#include <BRepLib_MakeEdge.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <Approx_Curve3d.hxx>
+
+#include <GC_MakeCircle.hxx>
+
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomConvert.hxx>
+#include <GeomConvert_CompCurveToBSplineCurve.hxx>
+
+#include <Geom2dConvert.hxx>
+#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+
+#include <TColGeom_SequenceOfSurface.hxx>
+#include <TColGeom_Array1OfBSplineCurve.hxx>
+#include <TColGeom_HArray1OfBSplineCurve.hxx>
+#include <TColGeom2d_Array1OfBSplineCurve.hxx>
+#include <TColGeom2d_HArray1OfBSplineCurve.hxx>
+#include <TColGeom2d_SequenceOfBoundedCurve.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
+#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()<SeqEdges.Length()) {
+ MESSAGE ("can not create correct chain...");
+ return Standard_False;
+ }
+ // union edges in chain
+ // first step: union lines and circles
+ TopLoc_Location Loc;
+ Standard_Real fp1,lp1,fp2,lp2;
+ for(j=1; j<aChain.Length(); j++) {
+ TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j));
+ Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1);
+ if(c3d1.IsNull()) break;
+ while(c3d1->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;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_UnionEdges_HeaderFile
+#define _BlockFix_UnionEdges_HeaderFile
+
+#include <Standard_Real.hxx>
+
+#include <ShapeBuild_ReShape.hxx>
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+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
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File: BlockFix_UnionFaces.cxx
+// Created: Tue Dec 7 17:15:42 2004
+// Author: Pavel DURANDIN
+
+#include <BlockFix_UnionFaces.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <ShapeAnalysis_WireOrder.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+
+#include <ShapeExtend_WireData.hxx>
+#include <ShapeExtend_CompositeSurface.hxx>
+
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_ComposeShell.hxx>
+#include <ShapeFix_SequenceOfWireSegment.hxx>
+#include <ShapeFix_WireSegment.hxx>
+#include <ShapeFix_Wire.hxx>
+#include <ShapeFix_Edge.hxx>
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+#include <IntPatch_ImpImpIntersection.hxx>
+#else
+#include <IntPatch_TheIIIntOfIntersection.hxx>
+#endif
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <TColGeom_HArray2OfSurface.hxx>
+
+#include <GeomAdaptor_HSurface.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
+
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_OffsetSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Circle.hxx>
+
+#include <Geom2d_Line.hxx>
+
+#include <gp_XY.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Standard_Failure.hxx>
+#include <Standard_ErrorHandler.hxx> // 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);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _BlockFix_UnionFaces_HeaderFile
+#define _BlockFix_UnionFaces_HeaderFile
+
+#include <Standard_Real.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+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
--- /dev/null
+# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+# 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
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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;
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-
-// File: BlockFix.cxx
-// Created: Tue Dec 7 11:59:05 2004
-// Author: Pavel DURANDIN
-
-#include <BlockFix.hxx>
-
-#include <BlockFix_SphereSpaceModifier.hxx>
-#include <BlockFix_PeriodicSurfaceModifier.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <TopLoc_Location.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopoDS_Vertex.hxx>
-
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
-#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-
-#include <BRepAdaptor_Surface.hxx>
-
-#include <BRepTools.hxx>
-#include <BRepTools_Modifier.hxx>
-#include <BRepTools_Substitution.hxx>
-
-#include <BRepOffsetAPI_MakeFilling.hxx>
-
-#include <ShapeFix.hxx>
-#include <ShapeFix_Edge.hxx>
-#include <ShapeFix_Face.hxx>
-
-#include <ShapeAnalysis.hxx>
-#include <ShapeAnalysis_Edge.hxx>
-#include <ShapeAnalysis_Curve.hxx>
-#include <ShapeAnalysis_Surface.hxx>
-
-#include <ShapeCustom.hxx>
-
-#include <ShapeBuild_Edge.hxx>
-#include <ShapeBuild_ReShape.hxx>
-
-#include <ShapeFix_Wire.hxx>
-
-#include <Geom_Surface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_ConicalSurface.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <Geom_ToroidalSurface.hxx>
-
-#include <Geom2d_Curve.hxx>
-
-#include <TColgp_SequenceOfPnt2d.hxx>
-
-//=======================================================================
-//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; i<sewd->NbEdges();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;
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_HeaderFile
-#define _BlockFix_HeaderFile
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#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 <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix.jxx>
-
-
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _BlockFix_HeaderFile
-#include <BlockFix.hxx>
-#endif
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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;
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-
-// File: BlockFix_BlockFixAPI.cxx
-// Created: Tue Dec 7 11:59:05 2004
-// Author: Pavel DURANDIN
-
-#include <BlockFix_BlockFixAPI.ixx>
-
-#include <BlockFix.hxx>
-#include <BlockFix_UnionFaces.hxx>
-#include <BlockFix_UnionEdges.hxx>
-
-#include <Basics_OCCTVersion.hxx>
-
-#include <ShapeUpgrade_RemoveLocations.hxx>
-
-#include <Precision.hxx>
-
-//=======================================================================
-//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;
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_BlockFixAPI_HeaderFile
-#define _BlockFix_BlockFixAPI_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile
-#include <Handle_BlockFix_BlockFixAPI.hxx>
-#endif
-
-#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
-#include <Handle_ShapeBuild_ReShape.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _MMgt_TShared_HeaderFile
-#include <MMgt_TShared.hxx>
-#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 <BlockFix_BlockFixAPI.lxx>
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_BlockFixAPI.jxx>
-
-#ifndef _Standard_TypeMismatch_HeaderFile
-#include <Standard_TypeMismatch.hxx>
-#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() {}
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _ShapeBuild_ReShape_HeaderFile
-#include <ShapeBuild_ReShape.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _BlockFix_BlockFixAPI_HeaderFile
-#include <BlockFix_BlockFixAPI.hxx>
-#endif
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_BlockFixAPI.hxx>
-
-//=======================================================================
-//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;
-}
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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;
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: BlockFix_CheckTool.cxx
-// Created: 17.12.04 11:15:25
-// Author: Sergey KUUL
-//
-#include <BlockFix_CheckTool.ixx>
-
-//#include <BlockFix_UnionEdges.hxx>
-//#include <BlockFix_UnionFaces.hxx>
-
-#include <BRep_Tool.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-
-//=======================================================================
-//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<faces.Length() && !HasFacesForUnification; i++) {
- TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
- TopTools_MapOfShape Edges;
- for (TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
- Edges.Add(expe.Current().Oriented(TopAbs_FORWARD));
- TopLoc_Location L1;
- Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
- for(Standard_Integer j=i+1; j<=faces.Length() && !HasFacesForUnification; j++) {
- TopoDS_Face F2 = TopoDS::Face(faces.Value(j));
- TopLoc_Location L2;
- Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
- if( S1==S2 && L1==L2 ) {
- // faces have equal based surface
- // now check common edge
- for(TopExp_Explorer expe2(F2,TopAbs_EDGE); expe2.More(); expe2.Next()) {
- if(Edges.Contains(expe2.Current().Oriented(TopAbs_FORWARD))) {
- HasFacesForUnification = Standard_True;
- break;
- }
- }
- }
- }
- }
- if (HasFacesForUnification) {
- MayBeUF=Standard_True;
- }
- }
-
- Standard_Integer nbe=0;
- TopTools_MapOfShape DegenEdges;
- TopExp_Explorer expe (aSolid, TopAbs_EDGE);
- TopTools_MapOfShape mapE;
- for (; expe.More(); expe.Next()) {
- TopoDS_Edge E = TopoDS::Edge(expe.Current());
- if (!mapE.Add(E)) continue;
- if (BRep_Tool::Degenerated(E)) {
- DegenEdges.Add(E);
- }
- else {
- nbe++;
- }
- }
- if (nbe == 12 && DegenEdges.Extent() > 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!"<<endl;
- else {
- S<<"dump results of check:"<<endl;
- S<<" total number of solids = "<<myNbSolids<<endl;
- S<<" including: number of good blocks = "<<myNbBlocks<<endl;
- S<<" number of possible blocks = "<<NbPossibleBlocks()<<endl;
- S<<" including: need remove degenerative = "<<myNbDegen<<endl;
- S<<" need unionfaces = "<<myNbUF<<endl;
- S<<" need unionedges = "<<myNbUE<<endl;
- S<<" need both unionfaces and unionedges = "<<myNbUFUE<<endl;
- Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
- S<<" number of impossible blocks = "<<nbtmp<<endl;
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_CheckTool_HeaderFile
-#define _BlockFix_CheckTool_HeaderFile
-
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TopTools_SequenceOfShape_HeaderFile
-#include <TopTools_SequenceOfShape.hxx>
-#endif
-#ifndef _Standard_OStream_HeaderFile
-#include <Standard_OStream.hxx>
-#endif
-class TopoDS_Shape;
-
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-class BlockFix_CheckTool {
-
-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_CheckTool();
-Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ;
-Standard_EXPORT void Perform() ;
-Standard_EXPORT Standard_Integer NbPossibleBlocks() const;
-Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const;
-Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const;
-
-
-
-
-
-protected:
-
- // Methods PROTECTED
- //
-
-
- // Fields PROTECTED
- //
-
-
-private:
-
- // Methods PRIVATE
- //
-
-
- // Fields PRIVATE
- //
-TopoDS_Shape myShape;
-Standard_Boolean myHasCheck;
-Standard_Integer myNbSolids;
-Standard_Integer myNbBlocks;
-TopTools_SequenceOfShape myPossibleBlocks;
-Standard_Integer myNbDegen;
-Standard_Integer myNbUF;
-Standard_Integer myNbUE;
-Standard_Integer myNbUFUE;
-Standard_Integer myBadRanges;
-
-
-};
-
-
-
-
-
-// other Inline functions and methods (like "C++: function call" methods)
-//
-
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_CheckTool.jxx>
-
-
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _BlockFix_CheckTool_HeaderFile
-#include <BlockFix_CheckTool.hxx>
-#endif
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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 <F> has been
- -- modified. In this case, <S> is the new geometric
- -- support of the face, <L> the new location, <Tol>
- -- the new tolerance. Otherwise, returns
- -- Standard_False, and <S>, <L>, <Tol> 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 <E> has been
- -- modified. In this case, <C> is the new geometric
- -- support of the edge, <L> the new location, <Tol>
- -- the new tolerance. Otherwise, returns
- -- Standard_False, and <C>, <L>, <Tol> 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 <V> has been
- -- modified. In this case, <P> is the new geometric
- -- support of the vertex, <Tol> the new tolerance.
- -- Otherwise, returns Standard_False, and <P>, <Tol>
- -- 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 <E> has a new
- -- curve on surface on the face <F>.In this case, <C>
- -- is the new geometric support of the edge, <L> the
- -- new location, <Tol> the new tolerance.
- --
- -- Otherwise, returns Standard_False, and <C>, <L>,
- -- <Tol> are not significant.
- --
- -- <NewE> is the new edge created from <E>. <NewF>
- -- is the new face created from <F>. 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 <V> has a new
- -- parameter on the edge <E>. In this case, <P> is
- -- the parameter, <Tol> the new tolerance.
- -- Otherwise, returns Standard_False, and <P>, <Tol>
- -- 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 <NewE> between <NewF1>
- -- and <NewF2>.
- --
- -- <NewE> is the new edge created from <E>. <NewF1>
- -- (resp. <NewF2>) is the new face created from <F1>
- -- (resp. <F2>).
-
-
-fields
-
- myTolerance : Real;
- myMapOfFaces : DataMapOfShapeInteger from TopTools;
- myMapOfSurfaces: IndexedMapOfTransient from TColStd;
-
-end PeriodicSurfaceModifier;
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: BlockFix_PeriodicSurfaceModifier.cxx
-// Created: 15.12.04 10:08:50
-// Author: Sergey KUUL
-
-#include <BlockFix_PeriodicSurfaceModifier.ixx>
-
-#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepTools.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <ShapeFix_Edge.hxx>
-#include <TopExp.hxx>
-
-
-//=======================================================================
-//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);
-}
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile
-#define _BlockFix_PeriodicSurfaceModifier_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile
-#include <Handle_BlockFix_PeriodicSurfaceModifier.hxx>
-#endif
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
-#include <TopTools_DataMapOfShapeInteger.hxx>
-#endif
-#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
-#include <TColStd_IndexedMapOfTransient.hxx>
-#endif
-#ifndef _BRepTools_Modification_HeaderFile
-#include <BRepTools_Modification.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Handle_Geom_Surface_HeaderFile
-#include <Handle_Geom_Surface.hxx>
-#endif
-#ifndef _Handle_Geom_Curve_HeaderFile
-#include <Handle_Geom_Curve.hxx>
-#endif
-#ifndef _Handle_Geom2d_Curve_HeaderFile
-#include <Handle_Geom2d_Curve.hxx>
-#endif
-#ifndef _GeomAbs_Shape_HeaderFile
-#include <GeomAbs_Shape.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_PeriodicSurfaceModifier.jxx>
-
-#ifndef _Standard_TypeMismatch_HeaderFile
-#include <Standard_TypeMismatch.hxx>
-#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() {}
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _TopoDS_Face_HeaderFile
-#include <TopoDS_Face.hxx>
-#endif
-#ifndef _Geom_Surface_HeaderFile
-#include <Geom_Surface.hxx>
-#endif
-#ifndef _TopLoc_Location_HeaderFile
-#include <TopLoc_Location.hxx>
-#endif
-#ifndef _TopoDS_Edge_HeaderFile
-#include <TopoDS_Edge.hxx>
-#endif
-#ifndef _Geom_Curve_HeaderFile
-#include <Geom_Curve.hxx>
-#endif
-#ifndef _TopoDS_Vertex_HeaderFile
-#include <TopoDS_Vertex.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
-#include <gp_Pnt.hxx>
-#endif
-#ifndef _Geom2d_Curve_HeaderFile
-#include <Geom2d_Curve.hxx>
-#endif
-#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile
-#include <BlockFix_PeriodicSurfaceModifier.hxx>
-#endif
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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 <F> has been
- -- modified. In this case, <S> is the new geometric
- -- support of the face, <L> the new location, <Tol>
- -- the new tolerance. Otherwise, returns
- -- Standard_False, and <S>, <L>, <Tol> 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 <E> has been
- -- modified. In this case, <C> is the new geometric
- -- support of the edge, <L> the new location, <Tol>
- -- the new tolerance. Otherwise, returns
- -- Standard_False, and <C>, <L>, <Tol> 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 <V> has been
- -- modified. In this case, <P> is the new geometric
- -- support of the vertex, <Tol> the new tolerance.
- -- Otherwise, returns Standard_False, and <P>, <Tol>
- -- 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 <E> has a new
- -- curve on surface on the face <F>.In this case, <C>
- -- is the new geometric support of the edge, <L> the
- -- new location, <Tol> the new tolerance.
- --
- -- Otherwise, returns Standard_False, and <C>, <L>,
- -- <Tol> are not significant.
- --
- -- <NewE> is the new edge created from <E>. <NewF>
- -- is the new face created from <F>. 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 <V> has a new
- -- parameter on the edge <E>. In this case, <P> is
- -- the parameter, <Tol> the new tolerance.
- -- Otherwise, returns Standard_False, and <P>, <Tol>
- -- 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 <NewE> between <NewF1>
- -- and <NewF2>.
- --
- -- <NewE> is the new edge created from <E>. <NewF1>
- -- (resp. <NewF2>) is the new face created from <F1>
- -- (resp. <F2>).
-
- 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;
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: BlockFix.cxx
-// Created: Tue Dec 7 11:59:05 2004
-// Author: Pavel DURANDIN
-
-#include <BlockFix_SphereSpaceModifier.ixx>
-
-#include <TopLoc_Location.hxx>
-#include <BRep_Tool.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <ShapeAnalysis.hxx>
-#include <gp_Sphere.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopExp.hxx>
-#include <ShapeFix_Edge.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom2d_Curve.hxx>
-#include <GProp_GProps.hxx>
-#include <BRepGProp.hxx>
-
-
-//=======================================================================
-//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);
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_SphereSpaceModifier_HeaderFile
-#define _BlockFix_SphereSpaceModifier_HeaderFile
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile
-#include <Handle_BlockFix_SphereSpaceModifier.hxx>
-#endif
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
-#include <TopTools_DataMapOfShapeInteger.hxx>
-#endif
-#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
-#include <TColStd_IndexedMapOfTransient.hxx>
-#endif
-#ifndef _BRepTools_Modification_HeaderFile
-#include <BRepTools_Modification.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Handle_Geom_Surface_HeaderFile
-#include <Handle_Geom_Surface.hxx>
-#endif
-#ifndef _Handle_Geom_Curve_HeaderFile
-#include <Handle_Geom_Curve.hxx>
-#endif
-#ifndef _Handle_Geom2d_Curve_HeaderFile
-#include <Handle_Geom2d_Curve.hxx>
-#endif
-#ifndef _GeomAbs_Shape_HeaderFile
-#include <GeomAbs_Shape.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_SphereSpaceModifier.jxx>
-
-#ifndef _Standard_TypeMismatch_HeaderFile
-#include <Standard_TypeMismatch.hxx>
-#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() {}
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _TopoDS_Face_HeaderFile
-#include <TopoDS_Face.hxx>
-#endif
-#ifndef _Geom_Surface_HeaderFile
-#include <Geom_Surface.hxx>
-#endif
-#ifndef _TopLoc_Location_HeaderFile
-#include <TopLoc_Location.hxx>
-#endif
-#ifndef _TopoDS_Edge_HeaderFile
-#include <TopoDS_Edge.hxx>
-#endif
-#ifndef _Geom_Curve_HeaderFile
-#include <Geom_Curve.hxx>
-#endif
-#ifndef _TopoDS_Vertex_HeaderFile
-#include <TopoDS_Vertex.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
-#include <gp_Pnt.hxx>
-#endif
-#ifndef _Geom2d_Curve_HeaderFile
-#include <Geom2d_Curve.hxx>
-#endif
-#ifndef _BlockFix_SphereSpaceModifier_HeaderFile
-#include <BlockFix_SphereSpaceModifier.hxx>
-#endif
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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;
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-
-// File: BlockFix_UnionEdges.cxx
-// Created: 07.12.04 15:27:30
-// Author: Sergey KUUL
-
-#include <BlockFix_UnionEdges.ixx>
-
-#include <ShapeAnalysis_Edge.hxx>
-
-#include <ShapeFix_Edge.hxx>
-#include <ShapeFix_Face.hxx>
-#include <ShapeFix_Shell.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_HCompCurve.hxx>
-#include <BRepLib.hxx>
-#include <BRepLib_MakeEdge.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shell.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Iterator.hxx>
-
-#include <Approx_Curve3d.hxx>
-
-#include <GC_MakeCircle.hxx>
-
-#include <Geom_BSplineCurve.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <GeomConvert.hxx>
-#include <GeomConvert_CompCurveToBSplineCurve.hxx>
-
-#include <Geom2dConvert.hxx>
-#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-#include <TColGeom_SequenceOfSurface.hxx>
-#include <TColGeom_Array1OfBSplineCurve.hxx>
-#include <TColGeom_HArray1OfBSplineCurve.hxx>
-#include <TColGeom2d_Array1OfBSplineCurve.hxx>
-#include <TColGeom2d_HArray1OfBSplineCurve.hxx>
-#include <TColGeom2d_SequenceOfBoundedCurve.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_MapOfInteger.hxx>
-
-#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()<SeqEdges.Length()) {
- MESSAGE ("can not create correct chain...");
- return Standard_False;
- }
- // union edges in chain
- // first step: union lines and circles
- TopLoc_Location Loc;
- Standard_Real fp1,lp1,fp2,lp2;
- for(j=1; j<aChain.Length(); j++) {
- TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j));
- Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1);
- if(c3d1.IsNull()) break;
- while(c3d1->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;
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_UnionEdges_HeaderFile
-#define _BlockFix_UnionEdges_HeaderFile
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
-#include <Handle_ShapeBuild_ReShape.hxx>
-#endif
-class ShapeBuild_ReShape;
-class TopoDS_Shape;
-
-
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_UnionEdges.jxx>
-
-
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _ShapeBuild_ReShape_HeaderFile
-#include <ShapeBuild_ReShape.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _BlockFix_UnionEdges_HeaderFile
-#include <BlockFix_UnionEdges.hxx>
-#endif
+++ /dev/null
--- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
---
--- Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
--- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
---
--- This library is free software; you can redistribute it and/or
--- modify it under the terms of the GNU Lesser General Public
--- License as published by the Free Software Foundation; either
--- version 2.1 of the License.
---
--- This library is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--- Lesser General Public License for more details.
---
--- You should have received a copy of the GNU Lesser General Public
--- License along with this library; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
--- See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
---
-
--- File: 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;
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: BlockFix_UnionFaces.cxx
-// Created: Tue Dec 7 17:15:42 2004
-// Author: Pavel DURANDIN
-
-#include <BlockFix_UnionFaces.ixx>
-
-#include <Basics_OCCTVersion.hxx>
-
-#include <ShapeAnalysis_WireOrder.hxx>
-#include <ShapeAnalysis_Edge.hxx>
-
-#include <ShapeBuild_Edge.hxx>
-#include <ShapeBuild_ReShape.hxx>
-
-#include <ShapeExtend_WireData.hxx>
-#include <ShapeExtend_CompositeSurface.hxx>
-
-#include <ShapeFix_Face.hxx>
-#include <ShapeFix_ComposeShell.hxx>
-#include <ShapeFix_SequenceOfWireSegment.hxx>
-#include <ShapeFix_WireSegment.hxx>
-#include <ShapeFix_Wire.hxx>
-#include <ShapeFix_Edge.hxx>
-
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
-#include <IntPatch_ImpImpIntersection.hxx>
-#else
-#include <IntPatch_TheIIIntOfIntersection.hxx>
-#endif
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
-#include <BRepTopAdaptor_TopolTool.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <TopTools_SequenceOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_MapIteratorOfMapOfShape.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Shell.hxx>
-#include <TopoDS_Iterator.hxx>
-
-#include <TColGeom_HArray2OfSurface.hxx>
-
-#include <GeomAdaptor_HSurface.hxx>
-#include <GeomLib_IsPlanarSurface.hxx>
-
-#include <Geom_Surface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_OffsetSurface.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-
-#include <Geom_Curve.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Circle.hxx>
-
-#include <Geom2d_Line.hxx>
-
-#include <gp_XY.hxx>
-#include <gp_Pnt2d.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx> // 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);
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _BlockFix_UnionFaces_HeaderFile
-#define _BlockFix_UnionFaces_HeaderFile
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <BlockFix_UnionFaces.jxx>
-
-
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _TopoDS_Shape_HeaderFile
-#include <TopoDS_Shape.hxx>
-#endif
-#ifndef _TopoDS_Face_HeaderFile
-#include <TopoDS_Face.hxx>
-#endif
-#ifndef _BlockFix_UnionFaces_HeaderFile
-#include <BlockFix_UnionFaces.hxx>
-#endif
GEOMAlgo_IndexedDataMapOfShapeState.hxx
GEOMAlgo_IndexedDataMapOfIntegerShape.hxx
GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile
-#define _Handle_BlockFix_BlockFixAPI_HeaderFile
-
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-
-#ifndef _Handle_MMgt_TShared_HeaderFile
-#include <Handle_MMgt_TShared.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile
-#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile
-
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-
-#ifndef _Handle_BRepTools_Modification_HeaderFile
-#include <Handle_BRepTools_Modification.hxx>
-#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
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile
-#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile
-
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-
-#ifndef _Handle_BRepTools_Modification_HeaderFile
-#include <Handle_BRepTools_Modification.hxx>
-#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
# 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
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 \
# 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 \
$(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) \
<source>GEOM_IS_REORDER</source>
<translation>Reorder vertices taking into account distances</translation>
</message>
+ <message>
+ <source>GEOM_INTERPOL_TANGENTS</source>
+ <translation>Tangents</translation>
+ </message>
+ <message>
+ <source>GEOM_INTERPOL_FIRST_VEC</source>
+ <translation>First tangent vector</translation>
+ </message>
+ <message>
+ <source>GEOM_INTERPOL_LAST_VEC</source>
+ <translation>Last tangent vector</translation>
+ </message>
+ <message>
+ <source>GEOM_BOTH_TANGENTS_REQUIRED</source>
+ <translation>Both tangent vectors must be defined</translation>
+ </message>
<message>
<source>GEOM_CURVE_CRMODE</source>
<translation>Creation Mode</translation>
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <Standard_Stream.hxx>
#include <GEOMImpl_CircleDriver.hxx>
+
#include <GEOMImpl_ICircle.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
+
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRep_Tool.hxx>
+
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
//=======================================================================
//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);
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);
//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) {
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 {
}
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",
//=======================================================================
//function : DownCast
//purpose :
-//=======================================================================
+//=======================================================================
const Handle(GEOMImpl_CircleDriver) Handle(GEOMImpl_CircleDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMImpl_CircleDriver) _anOtherObject;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <Standard_Stream.hxx>
#include <GEOMImpl_FaceDriver.hxx>
+
#include <GEOMImpl_IFace.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMUtils.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
} 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();
}
#include <GEOMImpl_Fillet1d.hxx>
#include <GEOMImpl_IFillet1d.hxx>
#include <GEOMImpl_Types.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_HealingDriver.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
+
#include <ShapeFix_Wire.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_ConstructionError.hxx>
aListOfNewEdge.Append(anEdgeToEdgeMap.Find(anEdge));
}
- GEOMImpl_IShapesOperations::SortShapes(aListOfNewEdge);
+ GEOMUtils::SortShapes(aListOfNewEdge);
BRepBuilderAPI_MakeWire aWireTool;
aWireTool.Add(aListOfNewEdge);
#include <GEOMImpl_IBlockTrsf.hxx>
#include <GEOMImpl_CopyDriver.hxx>
#include <GEOMImpl_Block6Explorer.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
+
+#include <GEOMUtils.hxx>
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx>
} // 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);
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<Handle(GEOM_Object)>::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);
//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;
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<Handle(GEOM_Object)>::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);
return aSpline;
}
+
+//=============================================================================
+/*!
+ * MakeSplineInterpolWithTangents
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
+ (std::list<Handle(GEOM_Object)> 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<Handle(GEOM_Object)>::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
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;
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){
GEOMImpl_ISpline aCI (aFunction);
- aCI.SetLength(lsize);
aCI.SetConstructorType(COORD_CONSTRUCTOR);
aCI.SetIsClosed(false);
aCI.SetCoordinates(aCoordsArray);
GEOMImpl_ISpline aCI (aFunction);
aCI.SetConstructorType(COORD_CONSTRUCTOR);
- aCI.SetLength(lsize);
aCI.SetIsClosed(false);
aCI.SetDoReordering(false);
aCI.SetCoordinates(aCoordsArray);
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();
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,
bool theIsClosed = false,
bool theDoReordering = false);
+ Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolWithTangents
+ (std::list<Handle(GEOM_Object)> 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,
#include <GEOMImpl_IMeasure.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMUtils.hxx>
+
#include <GEOMAlgo_ShapeInfo.hxx>
#include <GEOMAlgo_ShapeInfoFiller.hxx>
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
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();
// 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_
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,
// 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 <TColStd_HSequenceOfTransient.hxx>
+
#ifndef _GEOMImpl_IPIPE_HXX_
#include "GEOMImpl_IPipe.hxx"
#endif
#include "GEOM_Function.hxx"
+#include <TColStd_HSequenceOfTransient.hxx>
+
class GEOMImpl_IPipePath
{
public:
// 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_
#include "GEOMImpl_IPipeDiffSect.hxx"
#endif
+#include <TColStd_HSequenceOfTransient.hxx>
+
#define PIPEDS_LIST_SUBBASES 6
#include "GEOM_ISubShape.hxx"
#include "GEOM_PythonDump.hxx"
+#include "GEOMUtils.hxx"
+
#include "GEOMAlgo_ClsfBox.hxx"
#include "GEOMAlgo_ClsfSolid.hxx"
#include "GEOMAlgo_CoupleOfShapes.hxx"
#include <BRepClass3d_SolidClassifier.hxx>
#include <Precision.hxx>
-#define STD_SORT_ALGO 1
-
//=============================================================================
/*!
* constructor:
}
// 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()) {
bool isOldSorting = false;
if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN)
isOldSorting = true;
- SortShapes(listShape, isOldSorting);
+ GEOMUtils::SortShapes(listShape, isOldSorting);
}
TopTools_IndexedMapOfShape anIndices;
bool isOldSorting = false;
if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN)
isOldSorting = true;
- SortShapes(listShape, isOldSorting);
+ GEOMUtils::SortShapes(listShape, isOldSorting);
}
TopTools_IndexedMapOfShape anIndices;
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;
}
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;
}
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;
}
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;
}
}
}
-//================================================================================
-/*!
- * \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:
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;
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;
return aResult;
}
-//=======================================================================
-//function : ShapeToDouble
-//purpose : used by CompareShapes::operator()
-//=======================================================================
-std::pair<double, double> 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<double, double> val1 = myMap.Find(theShape1);
- std::pair<double, double> 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<TopoDS_Shape> 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<TopoDS_Shape>::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))<< " > " <<MidXYZ(OrderInd(Index+1))
-// << " d: " << dMidXYZ << endl;
- exchange = Standard_True;
- }
- else if ( Abs(dMidXYZ) < tol && dLength >= tol ) {
-// cout << "Length: " << Length(OrderInd(Index))<< " > " <<Length(OrderInd(Index+1))
-// << " d: " << dLength << endl;
- exchange = Standard_True;
- }
- else if ( Abs(dMidXYZ) < tol && Abs(dLength) < tol &&
- aShapes(OrderInd(Index)).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( aShapes( OrderInd(Index) ), box1 );
- if ( box1.IsVoid() ) continue;
- BRepBndLib::Add( aShapes( OrderInd(Index+1) ), box2 );
- Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent();
- if ( dSquareExtent >= tol ) {
-// cout << "SquareExtent: " << box1.SquareExtent()<<" > "<<box2.SquareExtent() << endl;
- 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 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9;
- box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- val2 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9;
- //exchange = val1 > val2;
- if ((val1 - val2) >= tol) {
- exchange = Standard_True;
- }
- //cout << "box: " << val1<<" > "<<val2 << endl;
- }
- }
-
- if (exchange)
- {
-// cout << "exchange " << Index << " & " << Index+1 << endl;
- aTemp = OrderInd(Index);
- OrderInd(Index) = OrderInd(Index+1);
- OrderInd(Index+1) = aTemp;
- Sort = Standard_True;
- }
- }
- }
-
- for (Index=1; Index <= MaxShapes; Index++)
- SL.Append( aShapes( OrderInd(Index) ));
-#endif
-}
-
-//=======================================================================
-//function : CompsolidToCompound
-//purpose :
-//=======================================================================
-TopoDS_Shape GEOMImpl_IShapesOperations::CompsolidToCompound (const TopoDS_Shape& theCompsolid)
-{
- if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) {
- return theCompsolid;
- }
-
- TopoDS_Compound aCompound;
- BRep_Builder B;
- B.MakeCompound(aCompound);
-
- TopTools_MapOfShape mapShape;
- TopoDS_Iterator It (theCompsolid, Standard_True, Standard_True);
-
- for (; It.More(); It.Next()) {
- TopoDS_Shape aShape_i = It.Value();
- if (mapShape.Add(aShape_i)) {
- B.Add(aCompound, aShape_i);
- }
- }
-
- return aCompound;
-}
-
-//=======================================================================
-//function : CheckTriangulation
-//purpose :
-//=======================================================================
-bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
-{
- bool isTriangulation = true;
-
- TopExp_Explorer exp (aShape, TopAbs_FACE);
- if (exp.More())
- {
- TopLoc_Location aTopLoc;
- Handle(Poly_Triangulation) aTRF;
- aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
- if (aTRF.IsNull()) {
- isTriangulation = false;
- }
- }
- else // no faces, try edges
- {
- TopExp_Explorer expe (aShape, TopAbs_EDGE);
- if (!expe.More()) {
- return false;
- }
- TopLoc_Location aLoc;
- Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
- if (aPE.IsNull()) {
- isTriangulation = false;
- }
- }
-
- if (!isTriangulation) {
- // calculate deflection
- Standard_Real aDeviationCoefficient = 0.001;
-
- Bnd_Box B;
- BRepBndLib::Add(aShape, B);
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-
- Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
- Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
- Standard_Real aHLRAngle = 0.349066;
-
- BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle);
- }
-
- return true;
-}
-
#define MAX_TOLERANCE 1.e-7
//=======================================================================
class Handle(GEOM_Object);
class Handle(TColStd_HArray1OfInteger);
-inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2)
-{
- return S1.IsSame(S2);
-}
-
class GEOMImpl_IShapesOperations : public GEOM_IOperations
{
public:
const Standard_Integer theShapeType,
GEOMAlgo_State theState);
- public:
- /*!
- * \brief Sort shapes in the list by their coordinates.
- * \param SL The list of shapes to sort.
- */
- struct CompareShapes : public std::binary_function<TopoDS_Shape, TopoDS_Shape, bool>
- {
- CompareShapes (bool isOldSorting)
- : myIsOldSorting(isOldSorting) {}
-
- bool operator()(const TopoDS_Shape& lhs, const TopoDS_Shape& rhs);
-
- typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > 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<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType,
// 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 <TColStd_HArray1OfReal.hxx>
+#include <GEOM_Function.hxx>
-#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 <TColStd_HSequenceOfTransient.hxx>
+#include <TColStd_HArray1OfReal.hxx>
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:
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_MarkerDriver.hxx>
#include <GEOMImpl_IMarker.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
+
+#include <GEOMUtils.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
} 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;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_IMeasure.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
+
#include <BRep_Tool.hxx>
#include <BRepGProp.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
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();
}
}
else
{
- gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aFace);
+ gp_Ax3 aPos = GEOMUtils::GetPosition(aFace);
p1 = aPos.Location();
}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_PipeDriver.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IPipeDiffSect.hxx>
#include <GEOMImpl_IPipeShellSect.hxx>
#include <GEOMImpl_IPipeBiNormal.hxx>
#include <GEOMImpl_IPipePath.hxx>
#include <GEOMImpl_GlueDriver.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
+
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeFix_Face.hxx>
//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());
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <Standard_Stream.hxx>
#include <GEOMImpl_PipeTShapeDriver.hxx>
+
#include <GEOMImpl_IPipeTShape.hxx>
#include <GEOMImpl_Types.hxx>
-
#include <GEOMImpl_Block6Explorer.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOM_IOperations.hxx>
+
+#include <GEOMUtils.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
-#include "GEOMAlgo_FinderShapeOn1.hxx"
-#include "GEOMAlgo_FinderShapeOn2.hxx"
+#include <GEOMAlgo_FinderShapeOn1.hxx>
+#include <GEOMAlgo_FinderShapeOn2.hxx>
#include <GEOMAlgo_ClsfBox.hxx>
#include <TFunction_Logbook.hxx>
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;
}
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;
}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMUtils.hxx>
#include <Basics_OCCTVersion.hxx>
// 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();
}
TopoDS_Shape aRefShape = aRef->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE)
return 0;
- anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape);
+ anAx3 = GEOMUtils::GetPosition(aRefShape);
}
if ( anOrientation == 2)
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//#include <Standard_Stream.hxx>
-//
#include <GEOMImpl_PositionDriver.hxx>
+
#include <GEOMImpl_IPosition.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMUtils.hxx>
// OCCT Includes
#include <BRepBuilderAPI_Transform.hxx>
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);
gp_Ax3 aStartAx3, aDestAx3;
// End LCS
- aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS);
+ aDestAx3 = GEOMUtils::GetPosition(aShapeEndLCS);
// Set transformation
aTrsf.SetDisplacement(aStartAx3, aDestAx3);
// 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 <GEOMImpl_PrismDriver.hxx>
#include <GEOMImpl_IPrism.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
#include <GEOMImpl_GlueDriver.hxx>
#include <GEOMImpl_PipeDriver.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOM_Object.hxx>
+
+#include <GEOMUtils.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepFeat_MakeDPrism.hxx>
}
else
{
- TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+ TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
}
// 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();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_RevolutionDriver.hxx>
-#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IRevolution.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
+
#include <BRepPrimAPI_MakeRevol.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRep_Tool.hxx>
if (aShape.IsNull()) return 0;
- TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+ TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
log.SetTouched(Label());
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
-#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMUtils.hxx>
#include <Basics_Utils.hxx>
// 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);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <Standard_Stream.hxx>
#include <GEOMImpl_SplineDriver.hxx>
+
#include <GEOMImpl_ISpline.hxx>
#include <GEOMImpl_Types.hxx>
+
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
+#include <Standard_Stream.hxx>
+
+#include <Standard_NullObject.hxx>
+
//=======================================================================
//function : GetID
//purpose :
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()) {
}
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));
}
}
}
+
if (aType == SPLINE_BEZIER) {
if (!isSeveral) {
Standard_ConstructionError::Raise("Points for Bezier Curve are too close");
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++) {
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();
}
else {
}
-
+
if (aShape.IsNull()) return 0;
-
+
aFunction->SetValue(aShape);
-
+
log.SetTouched(Label());
-
+
return 1;
}
#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
-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 \
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include <Standard_Stream.hxx>
+
+#include <GEOMUtils.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <utilities.h>
+#include <OpUtil.hxx>
+#include <Utils_ExceptHandlers.hxx>
+
+// OCCT Includes
+#include <BRepMesh_IncrementalMesh.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepGProp.hxx>
+#include <BRepTools.hxx>
+
+#include <Bnd_Box.hxx>
+
+#include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+
+#include <GeomLProp_CLProps.hxx>
+#include <GeomLProp_SLProps.hxx>
+
+#include <GProp_GProps.hxx>
+#include <GProp_PrincipalProps.hxx>
+
+#include <gp_Pln.hxx>
+#include <gp_Lin.hxx>
+
+#include <vector>
+
+#include <Standard_Failure.hxx>
+#include <Standard_NullObject.hxx>
+#include <Standard_ErrorHandler.hxx> // 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<double, double> 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<double, double> val1 = myMap.Find(theShape1);
+ std::pair<double, double> 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<TopoDS_Shape> 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<TopoDS_Shape>::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))<< " > " <<MidXYZ(OrderInd(Index+1))
+// << " d: " << dMidXYZ << endl;
+ exchange = Standard_True;
+ }
+ else if ( Abs(dMidXYZ) < tol && dLength >= tol ) {
+// cout << "Length: " << Length(OrderInd(Index))<< " > " <<Length(OrderInd(Index+1))
+// << " d: " << dLength << endl;
+ exchange = Standard_True;
+ }
+ else if ( Abs(dMidXYZ) < tol && Abs(dLength) < tol &&
+ aShapes(OrderInd(Index)).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( aShapes( OrderInd(Index) ), box1 );
+ if ( box1.IsVoid() ) continue;
+ BRepBndLib::Add( aShapes( OrderInd(Index+1) ), box2 );
+ Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent();
+ if ( dSquareExtent >= tol ) {
+// cout << "SquareExtent: " << box1.SquareExtent()<<" > "<<box2.SquareExtent() << endl;
+ 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 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9;
+ box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+ val2 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9;
+ //exchange = val1 > val2;
+ if ((val1 - val2) >= tol) {
+ exchange = Standard_True;
+ }
+ //cout << "box: " << val1<<" > "<<val2 << endl;
+ }
+ }
+
+ if (exchange)
+ {
+// cout << "exchange " << Index << " & " << Index+1 << endl;
+ aTemp = OrderInd(Index);
+ OrderInd(Index) = OrderInd(Index+1);
+ OrderInd(Index+1) = aTemp;
+ Sort = Standard_True;
+ }
+ }
+ }
+
+ for (Index=1; Index <= MaxShapes; Index++)
+ SL.Append( aShapes( OrderInd(Index) ));
+#endif
+}
+
+//=======================================================================
+//function : CompsolidToCompound
+//purpose :
+//=======================================================================
+TopoDS_Shape GEOMUtils::CompsolidToCompound (const TopoDS_Shape& theCompsolid)
+{
+ if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) {
+ return theCompsolid;
+ }
+
+ TopoDS_Compound aCompound;
+ BRep_Builder B;
+ B.MakeCompound(aCompound);
+
+ TopTools_MapOfShape mapShape;
+ TopoDS_Iterator It (theCompsolid, Standard_True, Standard_True);
+
+ for (; It.More(); It.Next()) {
+ TopoDS_Shape aShape_i = It.Value();
+ if (mapShape.Add(aShape_i)) {
+ B.Add(aCompound, aShape_i);
+ }
+ }
+
+ return aCompound;
+}
+
+//=======================================================================
+//function : CheckTriangulation
+//purpose :
+//=======================================================================
+bool GEOMUtils::CheckTriangulation (const TopoDS_Shape& aShape)
+{
+ bool isTriangulation = true;
+
+ TopExp_Explorer exp (aShape, TopAbs_FACE);
+ if (exp.More())
+ {
+ TopLoc_Location aTopLoc;
+ Handle(Poly_Triangulation) aTRF;
+ aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
+ if (aTRF.IsNull()) {
+ isTriangulation = false;
+ }
+ }
+ else // no faces, try edges
+ {
+ TopExp_Explorer expe (aShape, TopAbs_EDGE);
+ if (!expe.More()) {
+ return false;
+ }
+ TopLoc_Location aLoc;
+ Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
+ if (aPE.IsNull()) {
+ isTriangulation = false;
+ }
+ }
+
+ if (!isTriangulation) {
+ // calculate deflection
+ Standard_Real aDeviationCoefficient = 0.001;
+
+ Bnd_Box B;
+ BRepBndLib::Add(aShape, B);
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+
+ Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
+ Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
+ Standard_Real aHLRAngle = 0.349066;
+
+ BRepMesh_IncrementalMesh Inc (aShape, aDeflection, Standard_False, aHLRAngle);
+ }
+
+ return true;
+}
+
+//=======================================================================
+//function : GetTypeOfSimplePart
+//purpose :
+//=======================================================================
+TopAbs_ShapeEnum GEOMUtils::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;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef _GEOMUtils_HXX_
+#define _GEOMUtils_HXX_
+
+#include <TopoDS_Shape.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+
+#include <TopAbs.hxx>
+
+#include <gp_Ax3.hxx>
+#include <gp_Vec.hxx>
+
+#include <NCollection_DataMap.hxx>
+
+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<TopoDS_Shape, TopoDS_Shape, bool>
+ {
+ CompareShapes (bool isOldSorting)
+ : myIsOldSorting(isOldSorting) {}
+
+ bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs);
+
+ typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > 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
--- /dev/null
+# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+# 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)
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<Handle(GEOM_Object)> 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
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,
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
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")
"""
# 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.
RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
anObj.SetParameters(Parameters)
return anObj
-
-
# end of l4_curves
## @}
# 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
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