#include <AIS_RadiusDimension.hxx>
#include <AIS_Shape.hxx>
+const double tolerance = 1e-7;
+
const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
{
double aFlyout = 0;
if (theFlyoutPoint) {
- boost::shared_ptr<GeomAPI_Lin> aLine = boost::shared_ptr<GeomAPI_Lin>(
- new GeomAPI_Lin(theStartPoint, theEndPoint));
- double aDist = aLine->distance(theFlyoutPoint);
+ double aDist = 0.0;
+ if (theStartPoint->distance(theEndPoint) < tolerance)
+ aDist = theStartPoint->distance(theFlyoutPoint);
+ else {
+ boost::shared_ptr<GeomAPI_Lin> aLine = boost::shared_ptr<GeomAPI_Lin>(
+ new GeomAPI_Lin(theStartPoint, theEndPoint));
+ aDist = aLine->distance(theFlyoutPoint);
+ }
boost::shared_ptr<GeomAPI_XYZ> aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz());
boost::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <TopExp_Explorer.hxx>
+#include <BRep_Builder.hxx>
#include <Precision.hxx>
const double tolerance = Precision::Angular();
const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
TopExp_Explorer aFaceExp(aShape, TopAbs_FACE);
+ TopoDS_Compound aFaces; // use only faces from the shape: make compound for this
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aFaces);
for (; aFaceExp.More(); aFaceExp.Next()) {
const TopoDS_Face& aFace = (const TopoDS_Face&) aFaceExp.Current();
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aFace));
isFirstNorm = false;
} else if (!aShapeNormal.IsEqual(aNormal, tolerance)) // non-planar shapes is not supported for extrusion yet
return boost::shared_ptr<GeomAPI_Shape>();
+ aBuilder.Add(aFaces, aFace);
}
+ if (aFaces.IsNull())
+ return boost::shared_ptr<GeomAPI_Shape>();
boost::shared_ptr<GeomAPI_Dir> aDir(
new GeomAPI_Dir(aShapeNormal.X(), aShapeNormal.Y(), aShapeNormal.Z()));
- return GeomAlgoAPI_Extrusion::makeExtrusion(theShape, aDir, theSize);
+ boost::shared_ptr<GeomAPI_Shape> aFacesShape(new (GeomAPI_Shape));
+ aFacesShape->setImpl(new TopoDS_Shape(aFaces));
+ return GeomAlgoAPI_Extrusion::makeExtrusion(aFacesShape, aDir, theSize);
}
aProcEdges.pop_back();
} while (aCurVertex != aProcVertexes.back());
aCurDir = aCN.Reversed();
- aCurNorm = aNorm.Reversed();
+ //aCurNorm = aNorm.Reversed();
continue;
}
}
std::list<TopoDS_Edge>::iterator aCopyELoop = anEdgeIter;
removeWasteEdges(aVertIter, anEdgeIter, aProcVertexes.end(), aProcEdges.end(), aMapVE);
- // revert the list of remaining edges
- std::list<TopoDS_Vertex> aRemainVertexes;
- for (; aVertIter != aProcVertexes.end(); aVertIter++)
- aRemainVertexes.push_front(*aVertIter);
- std::list<TopoDS_Edge> aRemainEdges;
- for (; anEdgeIter != aProcEdges.end(); anEdgeIter++)
- aRemainEdges.push_front(*anEdgeIter);
- // remove edges and vertexes used in the loop and add remaining ones
- aProcVertexes.erase(aCopyVLoop, aProcVertexes.end());
- aProcVertexes.insert(aProcVertexes.end(), aRemainVertexes.begin(), aRemainVertexes.end());
- aProcEdges.erase(aCopyELoop, aProcEdges.end());
- aProcEdges.insert(aProcEdges.end(), aRemainEdges.begin(), aRemainEdges.end());
-
// Recalculate current vertex and current direction
- if (!aProcVertexes.empty()) {
- aNextVertex = aProcVertexes.back();
- if (!aProcEdges.empty())
- aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
- else
- aNextDir = aDirY;
+ aProcEdges.clear();
+ aProcVertexes.clear();
+ if (aMapVE.Extent() > 0)
+ {
+ aNextVertex = findStartVertex(aMapVE, aDirX, aDirY);
+ aProcVertexes.push_back(aNextVertex);
}
+ aNextDir = aDirY.Reversed();
+ aCurNorm = aNorm.Reversed();
}
// if next vertex connected only to alone edge, this is a part of wire (not a closed loop),
for (; aVert2.More(); aVert2.Next()) {
const TopoDS_Vertex& aV = (const TopoDS_Vertex&)aVert2.Current();
aClassifier.Perform(aF1, BRep_Tool::Pnt(aV), tolerance);
- if (aClassifier.State() != TopAbs_IN && aClassifier.State() != TopAbs_ON)
+ TopAbs_State aState = aClassifier.State();
+ if (aState != TopAbs_IN && aState != TopAbs_ON)
break;
}
if (aVert2.More()) { // second shape is not inside first, change the shapes order and repeat comparision
for (; aVert1.More(); aVert1.Next()) {
const TopoDS_Vertex& aV = (const TopoDS_Vertex&)aVert2.Current();
aClassifier.Perform(aF2, BRep_Tool::Pnt(aV), tolerance);
- if (aClassifier.State() != TopAbs_IN && aClassifier.State() != TopAbs_ON)
+ TopAbs_State aState = aClassifier.State();
+ if (aState != TopAbs_IN && aState != TopAbs_ON)
break;
}
if (!aVert1.More()) { // first shape should be cut from the second
BRepAlgoAPI_Cut aCut((*anIter2)->impl<TopoDS_Shape>(), (*anIter1)->impl<TopoDS_Shape>());
aCut.Build();
TopExp_Explorer anExp(aCut.Shape(), TopAbs_FACE);
- (*anIter2)->setImpl(new TopoDS_Shape(anExp.Current()));
+ bool isFirstFace = true;
for (anExp.Next(); anExp.More(); anExp.Next()) {
- boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
- aShape->setImpl(new TopoDS_Shape(anExp.Current()));
- theFaces.push_back(aShape);
+ if (anExp.Current().ShapeType() != TopAbs_FACE) continue;
+ if (isFirstFace) {
+ (*anIter2)->setImpl(new TopoDS_Shape(anExp.Current()));
+ isFirstFace = false;
+ } else {
+ boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ theFaces.push_back(aShape);
+ }
}
}
} else { // second shape should be cut from the first
BRepAlgoAPI_Cut aCut((*anIter1)->impl<TopoDS_Shape>(), (*anIter2)->impl<TopoDS_Shape>());
aCut.Build();
TopExp_Explorer anExp(aCut.Shape(), TopAbs_FACE);
- (*anIter1)->setImpl(new TopoDS_Shape(anExp.Current()));
+ bool isFirstFace = true;
for (anExp.Next(); anExp.More(); anExp.Next()) {
- boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
- aShape->setImpl(new TopoDS_Shape(anExp.Current()));
- theFaces.push_back(aShape);
+ if (anExp.Current().ShapeType() != TopAbs_FACE) continue;
+ if (isFirstFace) {
+ (*anIter1)->setImpl(new TopoDS_Shape(anExp.Current()));
+ isFirstFace = false;
+ } else {
+ boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ theFaces.push_back(aShape);
+ }
}
}
}
QApplication::restoreOverrideCursor();
}
+bool XGUI_Workshop::isActiveOperationAborted()
+{
+ if(!myOperationMgr->hasOperation())
+ return true;
+ return myOperationMgr->abortOperation();
+}
+
//******************************************************
void XGUI_Workshop::onExit()
{
//******************************************************
void XGUI_Workshop::onOpen()
{
- if(!myOperationMgr->abortOperation())
+ if(!isActiveOperationAborted())
return;
//save current file before close if modified
SessionPtr aSession = ModelAPI_Session::get();
myObjectBrowser->rebuildDataTree();
displayAllResults();
updateCommandStatus();
- myMainWindow->setCurrentDir(myCurrentDir);
QApplication::restoreOverrideCursor();
}
//******************************************************
bool XGUI_Workshop::onSave()
{
- if(!myOperationMgr->abortOperation())
+ if(!isActiveOperationAborted())
return false;
if (myCurrentDir.isEmpty()) {
return onSaveAs();
//******************************************************
bool XGUI_Workshop::onSaveAs()
{
- if(!myOperationMgr->abortOperation())
+ if(!isActiveOperationAborted())
return false;
QFileDialog dialog(mainWindow());
dialog.setWindowTitle(tr("Select directory to save files..."));
*/
void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
+ /*
+ * If there is an active (uncommited) operation shows a prompt to abort it
+ * and performs abortion if user agreed. Returns true if
+ * - operation aborted successfully
+ * - there is no active operation
+ */
+ bool isActiveOperationAborted();
+
signals:
void salomeViewerSelection();
void errorOccurred(const QString&);
void activateLastPart();
- /// Display all results of the current document
- void displayAllResults();
-
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
QList<QAction*> getModuleCommands() const;
+ void displayAllResults();
void displayDocumentResults(DocumentPtr theDoc);
void displayGroupResults(DocumentPtr theDoc, std::string theGroup);