diff --git a/TopologicCore/include/TopologicalQuery.h b/TopologicCore/include/TopologicalQuery.h index ed31195..8214e1c 100644 --- a/TopologicCore/include/TopologicalQuery.h +++ b/TopologicCore/include/TopologicalQuery.h @@ -32,7 +32,7 @@ namespace TopologicCore T* pSubclassTopology = dynamic_cast(kpTopologicalQuery); if (pSubclassTopology == nullptr) { - throw std::exception("Failed downcasting a topological query"); + throw std::runtime_error("Failed downcasting a topological query"); } return pSubclassTopology; } @@ -43,7 +43,7 @@ namespace TopologicCore T const * kpSubclassTopology = dynamic_cast(kpkTopologicalQuery); if (kpSubclassTopology == nullptr) { - throw std::exception("Failed downcasting topology"); + throw std::runtime_error("Failed downcasting topology"); } return kpSubclassTopology; } @@ -54,7 +54,7 @@ namespace TopologicCore std::shared_ptr pSubclassTopology = std::dynamic_pointer_cast(rTopologicalQuery); if (pSubclassTopology == nullptr) { - throw std::exception("Failed downcasting a topological query"); + throw std::runtime_error("Failed downcasting a topological query"); } return pSubclassTopology; } @@ -65,7 +65,7 @@ namespace TopologicCore const std::shared_ptr kSubclassTopology = std::dynamic_pointer_cast(rkTopologicalQuery); if (kSubclassTopology == nullptr) { - throw std::exception("Failed downcasting a topological query"); + throw std::runtime_error("Failed downcasting a topological query"); } return kSubclassTopology; } @@ -76,7 +76,7 @@ namespace TopologicCore std::shared_ptr pSuperClassTopology = std::dynamic_pointer_cast(rTopologicalQuery); if (pSuperClassTopology == nullptr) { - throw std::exception("Failed upcasting a topological query"); + throw std::runtime_error("Failed upcasting a topological query"); } return pSuperClassTopology; } @@ -87,7 +87,7 @@ namespace TopologicCore const std::shared_ptr pSuperClassTopology = std::dynamic_pointer_cast(rkTopologicalQuery); if (pSuperClassTopology == nullptr) { - throw std::exception("Failed upcasting a topological query"); + throw std::runtime_error("Failed upcasting a topological query"); } return pSuperClassTopology; } diff --git a/TopologicCore/include/Topology.h b/TopologicCore/include/Topology.h index 4e53f1f..3c5bbc7 100644 --- a/TopologicCore/include/Topology.h +++ b/TopologicCore/include/Topology.h @@ -909,7 +909,7 @@ namespace TopologicCore return TopAbs_COMPOUND; } - throw std::exception("Other subclasses are invalid."); + throw std::runtime_error("Other subclasses are invalid."); } /// diff --git a/TopologicCore/include/Vertex.h b/TopologicCore/include/Vertex.h index 6007de6..9be5747 100644 --- a/TopologicCore/include/Vertex.h +++ b/TopologicCore/include/Vertex.h @@ -111,7 +111,7 @@ namespace TopologicCore /// /// Return the corresponding point of this vertex. The output list only contains one vertex. /// - /// Null OCCT vertex + /// Null OCCT vertex /// The output parameter, containing only one point corresponding to this vertex. virtual void Geometry(std::list& rOcctGeometries) const; diff --git a/TopologicCore/src/Aperture.cpp b/TopologicCore/src/Aperture.cpp index 98ed00f..c09ba8f 100644 --- a/TopologicCore/src/Aperture.cpp +++ b/TopologicCore/src/Aperture.cpp @@ -102,7 +102,7 @@ namespace TopologicCore assert(m_pTopology != nullptr && "The underlying topology is null."); if (m_pTopology == nullptr) { - throw std::exception("The underlying topology is null."); + throw std::runtime_error("The underlying topology is null."); } return m_pTopology; } @@ -115,7 +115,7 @@ namespace TopologicCore RegisterFactory(GetClassGUID(), std::make_shared()); if (kpTopology == nullptr) { - throw std::exception("A null topology is passed."); + throw std::runtime_error("A null topology is passed."); } if (kpContext != nullptr) diff --git a/TopologicCore/src/Cell.cpp b/TopologicCore/src/Cell.cpp index fe39619..49b25b4 100644 --- a/TopologicCore/src/Cell.cpp +++ b/TopologicCore/src/Cell.cpp @@ -76,7 +76,7 @@ namespace TopologicCore catch (Standard_NoSuchObject) { assert("Cannot find a Face in the global Cluster."); - throw std::exception("Cannot find a Face in the global Cluster."); + throw std::runtime_error("Cannot find a Face in the global Cluster."); } } @@ -136,12 +136,12 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } if (rkFaces.empty()) { - throw std::exception("The input Face list is empty."); + throw std::runtime_error("The input Face list is empty."); } BOPAlgo_MakerVolume occtMakerVolume; @@ -160,7 +160,7 @@ namespace TopologicCore occtMakerVolume.Perform(); if (occtMakerVolume.HasErrors()) { - throw std::exception("The input Faces do not form a Cell."); + throw std::runtime_error("The input Faces do not form a Cell."); } const TopoDS_Shape& rkOcctResult = occtMakerVolume.Shape(); @@ -189,13 +189,13 @@ namespace TopologicCore } else { - throw std::exception("The input Faces do not form a Cell."); + throw std::runtime_error("The input Faces do not form a Cell."); } } if (occtShape.IsNull()) { - throw std::exception("The input Faces do not form a Cell."); + throw std::runtime_error("The input Faces do not form a Cell."); } else { @@ -229,7 +229,7 @@ namespace TopologicCore { if (!kpShell->IsClosed()) { - throw std::exception("The input Shell is open."); + throw std::runtime_error("The input Shell is open."); } BRepBuilderAPI_MakeSolid occtMakeSolid; @@ -238,7 +238,7 @@ namespace TopologicCore } catch (StdFail_NotDone&) { - throw std::exception("The input Shell does not form a valid Cell."); + throw std::runtime_error("The input Shell does not form a valid Cell."); } // Create a cell from the shell. The faces are the same and the contents @@ -374,7 +374,7 @@ namespace TopologicCore { // TODO: check for internal Faces // NOTE: it is not enough to check Edges bordering > 3 Faces - throw std::exception("Not implemented yet"); + throw std::runtime_error("Not implemented yet"); } TopoDS_Shape& Cell::GetOcctShape() @@ -392,7 +392,7 @@ namespace TopologicCore assert(!m_occtSolid.IsNull() && "Cell::m_occtSolid is null."); if (m_occtSolid.IsNull()) { - throw std::exception("A null Cell is encountered."); + throw std::runtime_error("A null Cell is encountered."); } return m_occtSolid; @@ -403,7 +403,7 @@ namespace TopologicCore assert(!m_occtSolid.IsNull() && "Cell::m_occtSolid is null."); if (m_occtSolid.IsNull()) { - throw std::exception("A null Cell is encountered."); + throw std::runtime_error("A null Cell is encountered."); } return m_occtSolid; diff --git a/TopologicCore/src/CellComplex.cpp b/TopologicCore/src/CellComplex.cpp index 11d85dc..bbadc8f 100644 --- a/TopologicCore/src/CellComplex.cpp +++ b/TopologicCore/src/CellComplex.cpp @@ -105,7 +105,7 @@ namespace TopologicCore { if (rkOcctSolids.IsEmpty()) { - throw std::exception("No cell is passed."); + throw std::runtime_error("No cell is passed."); } TopoDS_CompSolid occtCompSolid; @@ -123,11 +123,11 @@ namespace TopologicCore } catch (TopoDS_FrozenShape&) { - throw std::exception("The Cell is not free and cannot be modified."); + throw std::runtime_error("The Cell is not free and cannot be modified."); } catch (TopoDS_UnCompatibleShapes&) { - throw std::exception("The Cell and Face are not compatible."); + throw std::runtime_error("The Cell and Face are not compatible."); } pCellComplex = std::make_shared(occtCompSolid); @@ -148,7 +148,7 @@ namespace TopologicCore if (pMergeTopology->GetType() != TOPOLOGY_CELLCOMPLEX) { - throw std::exception("The input Cells do not form a CellComplex."); + throw std::runtime_error("The input Cells do not form a CellComplex."); } pCellComplex = TopologicalQuery::Downcast(pMergeTopology); @@ -176,10 +176,10 @@ namespace TopologicCore occtMakerVolume.SetFuzzyValue(kTolerance); occtMakerVolume.Perform(); if (occtMakerVolume.HasWarnings()) { - throw std::exception("Warnings."); + throw std::runtime_error("Warnings."); } if (occtMakerVolume.HasErrors()) { - throw std::exception("The input Faces do not form a CellComplex."); + throw std::runtime_error("The input Faces do not form a CellComplex."); } const TopoDS_Shape& rkOcctResult = occtMakerVolume.Shape(); @@ -249,7 +249,7 @@ namespace TopologicCore { std::ostringstream errorStream; occtCellsBuilder.DumpErrors(errorStream); - throw std::exception(errorStream.str().c_str()); + throw std::runtime_error(errorStream.str().c_str()); } TopTools_ListOfShape occtListToTake; @@ -319,7 +319,7 @@ namespace TopologicCore bool CellComplex::IsManifold() const { - throw std::exception("Not implemented yet"); + throw std::runtime_error("Not implemented yet"); } void CellComplex::NonManifoldFaces(std::list& rNonManifoldFaces) const @@ -351,7 +351,7 @@ namespace TopologicCore assert(!m_occtCompSolid.IsNull() && "CellComplex::m_occtCompSolid is null."); if (m_occtCompSolid.IsNull()) { - throw std::exception("A null CellComplex is encountered."); + throw std::runtime_error("A null CellComplex is encountered."); } return m_occtCompSolid; @@ -362,7 +362,7 @@ namespace TopologicCore assert(!m_occtCompSolid.IsNull() && "CellComplex::m_occtCompSolid is null."); if (m_occtCompSolid.IsNull()) { - throw std::exception("A null CellComplex is encountered."); + throw std::runtime_error("A null CellComplex is encountered."); } return m_occtCompSolid; diff --git a/TopologicCore/src/Cluster.cpp b/TopologicCore/src/Cluster.cpp index 35cc86c..9883a9f 100644 --- a/TopologicCore/src/Cluster.cpp +++ b/TopologicCore/src/Cluster.cpp @@ -81,11 +81,11 @@ namespace TopologicCore } catch (TopoDS_UnCompatibleShapes &) { - throw std::exception("Error making a OCCT compound."); + throw std::runtime_error("Error making a OCCT compound."); } catch (TopoDS_FrozenShape &) { - throw std::exception("Error making a OCCT compound."); + throw std::runtime_error("Error making a OCCT compound."); } } return occtCompound; @@ -143,7 +143,7 @@ namespace TopologicCore assert(!m_occtCompound.IsNull() && "Cluster::m_occtCompound is null."); if (m_occtCompound.IsNull()) { - throw std::exception("A null Cluster is encountered."); + throw std::runtime_error("A null Cluster is encountered."); } return m_occtCompound; @@ -154,7 +154,7 @@ namespace TopologicCore assert(!m_occtCompound.IsNull() && "Cluster::m_occtCompound is null."); if (m_occtCompound.IsNull()) { - throw std::exception("A null Cluster is encountered."); + throw std::runtime_error("A null Cluster is encountered."); } return m_occtCompound; @@ -172,7 +172,7 @@ namespace TopologicCore void Cluster::Geometry(std::list& rOcctGeometries) const { - throw std::exception("No implementation for Cluster entity"); + throw std::runtime_error("No implementation for Cluster entity"); } Cluster::Cluster(const TopoDS_Compound& rkOcctCompound, const std::string& rkGuid) @@ -252,7 +252,7 @@ namespace TopologicCore SubTopologies(rkOcctCompound, occtSubtopologies); if (occtSubtopologies.IsEmpty()) { - throw std::exception("The input Cluster is empty."); + throw std::runtime_error("The input Cluster is empty."); } double size = (double)occtSubtopologies.Size(); @@ -280,7 +280,7 @@ namespace TopologicCore bool Cluster::IsManifold() const { - throw std::exception("Not implemented yet"); + throw std::runtime_error("Not implemented yet"); } std::string Cluster::GetTypeAsString() const diff --git a/TopologicCore/src/Edge.cpp b/TopologicCore/src/Edge.cpp index 8e32be3..33c685d 100644 --- a/TopologicCore/src/Edge.cpp +++ b/TopologicCore/src/Edge.cpp @@ -133,7 +133,7 @@ namespace TopologicCore } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } // Done separately, because SetPeriod() does additional steps to adjust the poles, weights, etc. @@ -144,7 +144,7 @@ namespace TopologicCore } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } @@ -270,7 +270,7 @@ namespace TopologicCore assert(!m_occtEdge.IsNull() && "Edge::m_occtEdge is null."); if (m_occtEdge.IsNull()) { - throw std::exception("A null Edge is encountered."); + throw std::runtime_error("A null Edge is encountered."); } return m_occtEdge; @@ -281,7 +281,7 @@ namespace TopologicCore assert(!m_occtEdge.IsNull() && "Edge::m_occtEdge is null."); if (m_occtEdge.IsNull()) { - throw std::exception("A null Edge is encountered."); + throw std::runtime_error("A null Edge is encountered."); } return m_occtEdge; @@ -294,7 +294,7 @@ namespace TopologicCore } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } @@ -319,7 +319,7 @@ namespace TopologicCore double occtDParameter = kOcctLastParameter - kOcctFirstParameter; if (occtDParameter <= 0.0) { - throw std::exception("Negative range"); + throw std::runtime_error("Negative range"); } return (kNonNormalizedParameter - kOcctFirstParameter) / occtDParameter; @@ -361,22 +361,22 @@ namespace TopologicCore switch (occtEdgeError) { case BRepBuilderAPI_PointProjectionFailed: - throw std::exception("No parameters were given but the projection of the 3D points on the curve failed. This happens when the point distance to the curve is greater than the precision value."); + throw std::runtime_error("No parameters were given but the projection of the 3D points on the curve failed. This happens when the point distance to the curve is greater than the precision value."); case BRepBuilderAPI_ParameterOutOfRange: - throw std::exception("The given parameters are not in the parametric range."); + throw std::runtime_error("The given parameters are not in the parametric range."); case BRepBuilderAPI_DifferentPointsOnClosedCurve: - throw std::exception("The two vertices or points are the extremities of a closed curve but have different locations."); + throw std::runtime_error("The two vertices or points are the extremities of a closed curve but have different locations."); case BRepBuilderAPI_PointWithInfiniteParameter: - throw std::exception("A finite coordinate point was associated with an infinite parameter."); + throw std::runtime_error("A finite coordinate point was associated with an infinite parameter."); case BRepBuilderAPI_DifferentsPointAndParameter: - throw std::exception("The distance between the 3D point and the point evaluated on the curve with the parameter is greater than the precision."); + throw std::runtime_error("The distance between the 3D point and the point evaluated on the curve with the parameter is greater than the precision."); default: //case BRepBuilderAPI_LineThroughIdenticPoints: - throw std::exception("Two identical points were given to define a line (construction of an edge without curve)."); + throw std::runtime_error("Two identical points were given to define a line (construction of an edge without curve)."); } } diff --git a/TopologicCore/src/Face.cpp b/TopologicCore/src/Face.cpp index 40babc1..052f2d4 100644 --- a/TopologicCore/src/Face.cpp +++ b/TopologicCore/src/Face.cpp @@ -159,7 +159,7 @@ namespace TopologicCore { if (!pkExternalBoundary->IsClosed()) { - throw std::exception("The input Wire is open."); + throw std::runtime_error("The input Wire is open."); } TopoDS_Wire occtExternalBoundary = pkExternalBoundary->GetOcctWire(); BRepBuilderAPI_MakeFace occtMakeFace(occtExternalBoundary); @@ -234,7 +234,7 @@ namespace TopologicCore { if (rkEdges.size() < 3) { - throw std::exception("Fewer than 3 edges are passed."); + throw std::runtime_error("Fewer than 3 edges are passed."); } Wire::Ptr pWire = Wire::ByEdges(rkEdges); @@ -324,25 +324,25 @@ namespace TopologicCore { int occtMaxDegree = Geom_BSplineSurface::MaxDegree(); if (kUDegree < 1 || kUDegree > occtMaxDegree) { - throw std::exception(std::string("The curve's u degree must be between 1 and " + std::to_string(occtMaxDegree) + " (OCCT's max degree).").c_str()); + throw std::runtime_error(std::string("The curve's u degree must be between 1 and " + std::to_string(occtMaxDegree) + " (OCCT's max degree).").c_str()); } if (kVDegree < 1 || kVDegree > occtMaxDegree) { - throw std::exception(std::string("The curve's v degree must be between 1 and " + std::to_string(occtMaxDegree) + " (OCCT's max degree).").c_str()); + throw std::runtime_error(std::string("The curve's v degree must be between 1 and " + std::to_string(occtMaxDegree) + " (OCCT's max degree).").c_str()); } if (rkOcctPoles.ColLength() < 2 || rkOcctPoles.RowLength() < 2) { - throw std::exception("There must be more than one control points along each axis."); + throw std::runtime_error("There must be more than one control points along each axis."); } if (rkOcctPoles.ColLength() != rkOcctWeights.ColLength() || rkOcctPoles.RowLength() != rkOcctWeights.RowLength()) { - throw std::exception("The lists of control points and weights must have the same numbers of rows and columns."); + throw std::runtime_error("The lists of control points and weights must have the same numbers of rows and columns."); } if (rkOcctUKnots.Length() != rkOcctUMultiplicities.Length() || rkOcctVKnots.Length() != rkOcctVMultiplicities.Length()) { - throw std::exception("The lists of U and V knots and multiplicities must have the same length."); + throw std::runtime_error("The lists of U and V knots and multiplicities must have the same length."); } for (int i = rkOcctWeights.LowerRow(); i <= rkOcctWeights.UpperRow(); i++) @@ -351,7 +351,7 @@ namespace TopologicCore { if (rkOcctWeights(i, j) <= gp::Resolution()) { - throw std::exception(std::string("The (" + std::to_string(i) + ", " + std::to_string(j) + ")'s weight is smaller than OCCT's resolution (i.e. practically zero).").c_str()); + throw std::runtime_error(std::string("The (" + std::to_string(i) + ", " + std::to_string(j) + ")'s weight is smaller than OCCT's resolution (i.e. practically zero).").c_str()); } } } @@ -359,13 +359,13 @@ namespace TopologicCore for (int i = rkOcctUKnots.Lower(); i < rkOcctUKnots.Upper(); i++) { if (rkOcctUKnots(i + 1) - rkOcctUKnots(i) <= Epsilon(Abs(rkOcctUKnots(i)))) { - throw std::exception(std::string("The " + std::to_string(i + 1) + "'s U knot must be larger than the " + std::to_string(i) + "'s U knot.").c_str()); + throw std::runtime_error(std::string("The " + std::to_string(i + 1) + "'s U knot must be larger than the " + std::to_string(i) + "'s U knot.").c_str()); } } for (int i = rkOcctVKnots.Lower(); i < rkOcctVKnots.Upper(); i++) { if (rkOcctVKnots(i + 1) - rkOcctVKnots(i) <= Epsilon(Abs(rkOcctVKnots(i)))) { - throw std::exception(std::string("The " + std::to_string(i + 1) + "'s V knot must be larger than the " + std::to_string(i) + "'s V knot.").c_str()); + throw std::runtime_error(std::string("The " + std::to_string(i + 1) + "'s V knot must be larger than the " + std::to_string(i) + "'s V knot.").c_str()); } } @@ -374,22 +374,22 @@ namespace TopologicCore { if (kIsUPeriodic) { - throw std::exception("The curve is U periodic, so the number of poles must be equal to the sum of the U multiplicities."); + throw std::runtime_error("The curve is U periodic, so the number of poles must be equal to the sum of the U multiplicities."); } else { - throw std::exception("The curve is not U periodic, so the number of poles must be equal to the sum of the U multiplicities - U degree - 1, which must be larger than 1."); + throw std::runtime_error("The curve is not U periodic, so the number of poles must be equal to the sum of the U multiplicities - U degree - 1, which must be larger than 1."); } } if (rkOcctPoles.Length() != BSplCLib::NbPoles(kVDegree, kIsVPeriodic, rkOcctUMultiplicities)) { if (kIsVPeriodic) { - throw std::exception("The curve is V periodic, so the number of poles must be equal to the sum of the V multiplicities."); + throw std::runtime_error("The curve is V periodic, so the number of poles must be equal to the sum of the V multiplicities."); } else { - throw std::exception("The curve is not V periodic, so the number of poles must be equal to the sum of the V multiplicities - V degree - 1, which must be larger than 1."); + throw std::runtime_error("The curve is not V periodic, so the number of poles must be equal to the sum of the V multiplicities - V degree - 1, which must be larger than 1."); } } } @@ -585,7 +585,7 @@ namespace TopologicCore Handle(Poly_Triangulation) pOcctTriangulation = BRep_Tool::Triangulation(TopoDS::Face(occtFixFace.Result()), occtLocation); if (pOcctTriangulation.IsNull()) { - throw std::exception("No triangulation was produced."); + throw std::runtime_error("No triangulation was produced."); } int numOfTriangles = pOcctTriangulation->NbTriangles(); for (int i = 1; i <= numOfTriangles; ++i) @@ -666,7 +666,7 @@ namespace TopologicCore assert(!m_occtFace.IsNull() && "Face::m_occtFace is null."); if (m_occtFace.IsNull()) { - throw std::exception("A null Face is encountered."); + throw std::runtime_error("A null Face is encountered."); } return m_occtFace; @@ -677,7 +677,7 @@ namespace TopologicCore assert(!m_occtFace.IsNull() && "Face::m_occtFace is null."); if (m_occtFace.IsNull()) { - throw std::exception("A null Face is encountered."); + throw std::runtime_error("A null Face is encountered."); } return m_occtFace; @@ -724,16 +724,16 @@ namespace TopologicCore switch (rkOcctMakeFace.Error()) { case BRepBuilderAPI_NoFace: - throw std::exception("No initialization of the algorithm; only an empty constructor was used."); + throw std::runtime_error("No initialization of the algorithm; only an empty constructor was used."); case BRepBuilderAPI_NotPlanar: - throw std::exception("No surface was given and the wire was not planar."); + throw std::runtime_error("No surface was given and the wire was not planar."); case BRepBuilderAPI_CurveProjectionFailed: - throw std::exception("Curve projection failed."); + throw std::runtime_error("Curve projection failed."); case BRepBuilderAPI_ParametersOutOfRange: - throw std::exception("The parameters given to limit the surface are out of its bounds."); + throw std::runtime_error("The parameters given to limit the surface are out of its bounds."); //default: // i.e. BRepBuilderAPI_FaceDone, do nothing } diff --git a/TopologicCore/src/Graph.cpp b/TopologicCore/src/Graph.cpp index c8f72e3..6a06533 100644 --- a/TopologicCore/src/Graph.cpp +++ b/TopologicCore/src/Graph.cpp @@ -105,7 +105,7 @@ namespace TopologicCore kUseFaceInternalVertex, kTolerance); default: - throw std::exception("Fails to create a graph due to an unknown type of topology."); + throw std::runtime_error("Fails to create a graph due to an unknown type of topology."); } } @@ -319,7 +319,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } for (const Vertex::Ptr& kpVertex : rkVertices) @@ -335,7 +335,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } for (const Edge::Ptr& kpEdge : rkEdges) @@ -411,7 +411,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } std::list::const_iterator vertex1Iterator = rkVertices1.begin(); @@ -476,7 +476,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } TopoDS_Vertex occtStartCoincidentVertex = GetCoincidentVertex(rkVertex1, kTolerance); @@ -819,7 +819,7 @@ namespace TopologicCore { if (kTimeLimit <= 0.0) { - throw std::exception("The time limit must have a positive value."); + throw std::runtime_error("The time limit must have a positive value."); } auto startingTime = std::chrono::system_clock::now(); @@ -973,7 +973,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } // Use Breadth-First Search @@ -1147,7 +1147,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } for (const Edge::Ptr& kpEdge : rkEdges) @@ -1200,7 +1200,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } gp_Pnt occtQueryPoint(kX, kY, kZ); @@ -1250,7 +1250,7 @@ namespace TopologicCore { if (kTolerance <= 0.0) { - throw std::exception("The tolerance must have a positive value."); + throw std::runtime_error("The tolerance must have a positive value."); } TopoDS_Vertex occtQueryVertex1 = GetCoincidentVertex(kpVertex1->GetOcctVertex(), kTolerance); @@ -1816,7 +1816,7 @@ namespace TopologicCore catch (...) { assert(false); - throw std::exception("No Cell internal vertex pre-computed."); + throw std::runtime_error("No Cell internal vertex pre-computed."); } const TopTools_ListOfShape& rkOcctAdjacentCells = occtCellAdjacencyIterator.Value(); @@ -1834,7 +1834,7 @@ namespace TopologicCore catch (...) { assert(false); - throw std::exception("No Cell internal vertex pre-computed."); + throw std::runtime_error("No Cell internal vertex pre-computed."); } TopologicCore::Edge::Ptr pEdge = TopologicCore::Edge::ByStartVertexEndVertex( pCellInternalVertex, diff --git a/TopologicCore/src/PlanarSurface.cpp b/TopologicCore/src/PlanarSurface.cpp index 1b4cf6f..d9fcaef 100644 --- a/TopologicCore/src/PlanarSurface.cpp +++ b/TopologicCore/src/PlanarSurface.cpp @@ -80,7 +80,7 @@ namespace TopologicCore } catch (Standard_DomainError e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } } \ No newline at end of file diff --git a/TopologicCore/src/Shell.cpp b/TopologicCore/src/Shell.cpp index 0d8a3f6..1f54284 100644 --- a/TopologicCore/src/Shell.cpp +++ b/TopologicCore/src/Shell.cpp @@ -88,7 +88,7 @@ namespace TopologicCore { if (rkFaces.empty()) { - throw std::exception("No face is passed."); + throw std::runtime_error("No face is passed."); } TopTools_ListOfShape occtShapes; @@ -130,13 +130,13 @@ namespace TopologicCore } catch (Standard_TypeMismatch) { - throw std::exception("The set of faces does not create a valid shell."); + throw std::runtime_error("The set of faces does not create a valid shell."); } } bool Shell::IsManifold() const { - throw std::exception("Not implemented yet"); + throw std::runtime_error("Not implemented yet"); } TopoDS_Shape& Shell::GetOcctShape() @@ -154,7 +154,7 @@ namespace TopologicCore assert(!m_occtShell.IsNull() && "Shell::m_occtShell is null."); if (m_occtShell.IsNull()) { - throw std::exception("A null Shell is encountered."); + throw std::runtime_error("A null Shell is encountered."); } return m_occtShell; @@ -165,7 +165,7 @@ namespace TopologicCore assert(!m_occtShell.IsNull() && "Shell::m_occtShell is null."); if (m_occtShell.IsNull()) { - throw std::exception("A null Shell is encountered."); + throw std::runtime_error("A null Shell is encountered."); } return m_occtShell; diff --git a/TopologicCore/src/Topology.cpp b/TopologicCore/src/Topology.cpp index 033d7b8..2bc8381 100644 --- a/TopologicCore/src/Topology.cpp +++ b/TopologicCore/src/Topology.cpp @@ -266,7 +266,7 @@ namespace TopologicCore case TopAbs_COMPSOLID: return CellComplex::CenterOfMass(TopoDS::CompSolid(rkOcctShape)); case TopAbs_COMPOUND: return Cluster::CenterOfMass(TopoDS::Compound(rkOcctShape)); default: - throw std::exception("Unrecognised topology"); + throw std::runtime_error("Unrecognised topology"); } } @@ -283,7 +283,7 @@ namespace TopologicCore case TopAbs_COMPSOLID: return TOPOLOGY_CELLCOMPLEX; case TopAbs_COMPOUND: return TOPOLOGY_CLUSTER; default: - throw std::exception("Unrecognised topology"); + throw std::runtime_error("Unrecognised topology"); } } @@ -300,7 +300,7 @@ namespace TopologicCore case TOPOLOGY_CELLCOMPLEX: return TopAbs_COMPSOLID; case TOPOLOGY_CLUSTER: return TopAbs_COMPOUND; default: - throw std::exception("Unrecognised topology"); + throw std::runtime_error("Unrecognised topology"); } } @@ -371,11 +371,11 @@ namespace TopologicCore } catch (TopoDS_FrozenShape&) { - throw std::exception("The Cell is not free and cannot be modified."); + throw std::runtime_error("The Cell is not free and cannot be modified."); } catch (TopoDS_UnCompatibleShapes&) { - throw std::exception("The Cell and Face are not compatible."); + throw std::runtime_error("The Cell and Face are not compatible."); } } } @@ -887,12 +887,12 @@ namespace TopologicCore { if (rkSelectors.size() != rkDictionaries.size()) { - throw std::exception("The lists of selectors and dictionaries do not have the same length."); + throw std::runtime_error("The lists of selectors and dictionaries do not have the same length."); } if (rkSelectors.size() != rkTypeFilters.size()) { - throw std::exception("The lists of selectors and type filters do not have the same length."); + throw std::runtime_error("The lists of selectors and type filters do not have the same length."); } Topology::Ptr pCopyTopology = std::dynamic_pointer_cast(DeepCopy()); @@ -908,7 +908,7 @@ namespace TopologicCore const int kTypeFilter = *kTypeFilterIterator; if (kTypeFilter == 0) { - throw std::exception("No type filter specified."); + throw std::runtime_error("No type filter specified."); } Topology::Ptr selectedSubtopology = nullptr; @@ -920,7 +920,7 @@ namespace TopologicCore try { closestFace = TopologicalQuery::Downcast(closestFaceAsTopology); } - catch (const std::exception&) + catch (const std::runtime_error&) { } @@ -974,7 +974,7 @@ namespace TopologicCore { if (kpSelectedSubtopology != nullptr && kpSelectedSubtopology->IsSame(selectedSubtopology)) { - throw std::exception("Another selector has selected the same member of the input Topology."); + throw std::runtime_error("Another selector has selected the same member of the input Topology."); } } } @@ -1015,7 +1015,7 @@ namespace TopologicCore occtSewing.Perform(); if (occtSewing.SewedShape().IsNull()) { - throw std::exception("A null shape is created."); + throw std::runtime_error("A null shape is created."); } TopAbs_ShapeEnum type = occtSewing.SewedShape().ShapeType(); @@ -1061,7 +1061,7 @@ namespace TopologicCore TopoDS_Shape occtOriginShape; if (kpkOriginTopology1 == nullptr && kpkOriginTopology2 == nullptr) { - throw std::exception("Fails to transfer dictionari in a Boolean operation because the original Topologies are null."); + throw std::runtime_error("Fails to transfer dictionari in a Boolean operation because the original Topologies are null."); } else if (kpkOriginTopology1 == nullptr && kpkOriginTopology2 != nullptr) { @@ -1514,7 +1514,7 @@ namespace TopologicCore } catch (TopoDS_FrozenShape) { - throw std::exception("Topology is locked, cannot remove subtopology. Please contact the developer."); + throw std::runtime_error("Topology is locked, cannot remove subtopology. Please contact the developer."); } } @@ -1528,11 +1528,11 @@ namespace TopologicCore } catch (TopoDS_FrozenShape) { - throw std::exception("Topology is locked, cannot remove subtopology. Please contact the developer."); + throw std::runtime_error("Topology is locked, cannot remove subtopology. Please contact the developer."); } catch (TopoDS_UnCompatibleShapes) { - throw std::exception("Cannot add incompatible subtopology."); + throw std::runtime_error("Cannot add incompatible subtopology."); } } @@ -1600,7 +1600,7 @@ namespace TopologicCore } catch (TopoDS_FrozenShape) { - throw std::exception("Topology is locked, cannot remove subtopology. Please contact the developer."); + throw std::runtime_error("Topology is locked, cannot remove subtopology. Please contact the developer."); } } @@ -1631,7 +1631,7 @@ namespace TopologicCore const char* str = e.GetMessageString(); std::string stlStr(str); } - catch (std::exception& e) + catch (std::runtime_error& e) { const char* str = e.what(); std::string stlStr(str); @@ -1642,7 +1642,7 @@ namespace TopologicCore { std::ostringstream errorStream; rOcctCellsBuilder.DumpErrors(errorStream); - throw std::exception(errorStream.str().c_str()); + throw std::runtime_error(errorStream.str().c_str()); } } @@ -1674,7 +1674,7 @@ namespace TopologicCore catch (Standard_Failure&) { } - catch (std::exception&) + catch (std::runtime_error&) { } @@ -1682,7 +1682,7 @@ namespace TopologicCore { std::ostringstream errorStream; rOcctCellsBuilder.DumpErrors(errorStream); - throw std::exception(errorStream.str().c_str()); + throw std::runtime_error(errorStream.str().c_str()); } } @@ -2231,7 +2231,7 @@ namespace TopologicCore const char* str = e.GetMessageString(); std::string stlStr(str); } - catch (std::exception& e) + catch (std::runtime_error& e) { const char* str = e.what(); std::string stlStr(str); @@ -2358,7 +2358,7 @@ namespace TopologicCore const char* str = e.GetMessageString(); std::string stlStr(str); } - catch (std::exception& e) + catch (std::runtime_error& e) { const char* str = e.what(); std::string stlStr(str); @@ -2368,7 +2368,7 @@ namespace TopologicCore { std::ostringstream errorStream; occtCellsBuilder2.DumpErrors(errorStream); - throw std::exception(errorStream.str().c_str()); + throw std::runtime_error(errorStream.str().c_str()); } occtCellsBuilder2.AddAllToResult(); @@ -2842,7 +2842,7 @@ namespace TopologicCore Topology::Ptr Topology::IntersectFaceFace(const Topology::Ptr kpMergeTopology, Face const* const kpkFace, Face const* const kpkOtherFace) { // OCCT does not seem to have a robust Face-Face - throw std::exception("Not yet implemented"); + throw std::runtime_error("Not yet implemented"); } void Topology::AddBooleanOperands( diff --git a/TopologicCore/src/TopologyFactoryManager.cpp b/TopologicCore/src/TopologyFactoryManager.cpp index 0904e11..90c91fc 100644 --- a/TopologicCore/src/TopologyFactoryManager.cpp +++ b/TopologicCore/src/TopologyFactoryManager.cpp @@ -59,7 +59,7 @@ namespace TopologicCore case TopAbs_EDGE: return std::make_shared(); case TopAbs_VERTEX: return std::make_shared(); default: - throw std::exception("Topology::ByOcctShape: unknown topology."); + throw std::runtime_error("Topology::ByOcctShape: unknown topology."); } } } \ No newline at end of file diff --git a/TopologicCore/src/Utilities.cpp b/TopologicCore/src/Utilities.cpp index 2a436ec..489eb16 100644 --- a/TopologicCore/src/Utilities.cpp +++ b/TopologicCore/src/Utilities.cpp @@ -29,7 +29,7 @@ namespace TopologicCore { case TOPOLOGY_CELL: return TopAbs_SOLID; case TOPOLOGY_CELLCOMPLEX: return TopAbs_COMPSOLID; case TOPOLOGY_CLUSTER: return TopAbs_COMPOUND; - default: throw std::exception("No OCCT counterpart is found from this topology."); + default: throw std::runtime_error("No OCCT counterpart is found from this topology."); } } } \ No newline at end of file diff --git a/TopologicCore/src/Utilities/CellUtility.cpp b/TopologicCore/src/Utilities/CellUtility.cpp index 2270298..255ae6f 100644 --- a/TopologicCore/src/Utilities/CellUtility.cpp +++ b/TopologicCore/src/Utilities/CellUtility.cpp @@ -52,7 +52,7 @@ namespace TopologicUtilities } catch (...) { - throw std::exception("Loft error"); + throw std::runtime_error("Loft error"); } TopologicCore::Cell::Ptr pCell = std::make_shared(TopoDS::Solid(occtLoft.Shape())); TopologicCore::GlobalCluster::GetInstance().AddTopology(pCell->GetOcctShape()); @@ -201,7 +201,7 @@ namespace TopologicUtilities if (closestVertex == nullptr) { - throw std::exception("Ray casting fails to identify the closest vertex from a random point."); + throw std::runtime_error("Ray casting fails to identify the closest vertex from a random point."); } // Create a line between the closest vertex and vertex in Face, then get the midpoint (center of mass) diff --git a/TopologicCore/src/Utilities/EdgeUtility.cpp b/TopologicCore/src/Utilities/EdgeUtility.cpp index 80c370e..95b86de 100644 --- a/TopologicCore/src/Utilities/EdgeUtility.cpp +++ b/TopologicCore/src/Utilities/EdgeUtility.cpp @@ -42,7 +42,7 @@ namespace TopologicUtilities TopologicCore::Edge::Ptr pEdge = nullptr; if (numberOfVertices < 2) { - throw std::exception("Too few vertices to create an edge."); + throw std::runtime_error("Too few vertices to create an edge."); } else if (numberOfVertices == 2) // a line { @@ -67,7 +67,7 @@ namespace TopologicUtilities occtInterpolate.Perform(); if (!occtInterpolate.IsDone()) { - throw std::exception("Line interpolation error in Edge::ByVertices()"); + throw std::runtime_error("Line interpolation error in Edge::ByVertices()"); } Handle(Geom_Curve) pOcctCurveOnTargetSurface = occtInterpolate.Curve(); BRepBuilderAPI_MakeEdge occtMakeEdge(pOcctCurveOnTargetSurface); @@ -80,7 +80,7 @@ namespace TopologicUtilities } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } @@ -207,7 +207,7 @@ namespace TopologicUtilities bool isOnCurve = GeomLib_Tool::Parameter(pOcctCurve, pOcctPoint->Pnt(), Precision::Confusion(), occtParameter); if (!isOnCurve) { - throw std::exception("Point not on curve"); + throw std::runtime_error("Point not on curve"); } // Parameter may be non-normalized, so normalize it diff --git a/TopologicCore/src/Utilities/FaceUtility.cpp b/TopologicCore/src/Utilities/FaceUtility.cpp index 9a18921..3224821 100644 --- a/TopologicCore/src/Utilities/FaceUtility.cpp +++ b/TopologicCore/src/Utilities/FaceUtility.cpp @@ -82,7 +82,7 @@ namespace TopologicUtilities { if (rowLength != rkVerticesRow.size()) { - throw std::exception("Rows have inequal lengths"); + throw std::runtime_error("Rows have inequal lengths"); } } } @@ -106,7 +106,7 @@ namespace TopologicUtilities } catch (...) { - throw std::exception("Fails to create a face by vertices"); + throw std::runtime_error("Fails to create a face by vertices"); } } @@ -352,7 +352,7 @@ namespace TopologicUtilities Handle(Poly_Triangulation) pOcctTriangulation = BRep_Tool::Triangulation(occtFace, occtLocation); if (pOcctTriangulation.IsNull()) { - throw std::exception("No triangulation was produced."); + throw std::runtime_error("No triangulation was produced."); } int numOfTriangles = pOcctTriangulation->NbTriangles(); for (int i = 1; i <= numOfTriangles; ++i) @@ -390,7 +390,7 @@ namespace TopologicUtilities double occtDV = occtVMax - occtVMin; if (occtDU <= 0.0 || occtDV <= 0.0) { - throw std::exception("Negative range"); + throw std::runtime_error("Negative range"); } rNormalizedU = (kNonNormalizedU - occtUMin) / occtDU; @@ -601,7 +601,7 @@ namespace TopologicUtilities } catch (const Standard_ConstructionError& occtError) { - throw std::exception(occtError.GetMessageString()); + throw std::runtime_error(occtError.GetMessageString()); } } } @@ -615,7 +615,7 @@ namespace TopologicUtilities GeomAPI_ProjectPointOnSurf occtProjectToSurface(kpVertex->Point()->Pnt(), kpFace->Surface()); if (!occtProjectToSurface.IsDone()) { - throw std::exception("Fails to project a Vertex to a Face."); + throw std::runtime_error("Fails to project a Vertex to a Face."); } gp_Pnt occtProjectedPoint = occtProjectToSurface.NearestPoint(); return TopologicCore::Vertex::ByPoint(new Geom_CartesianPoint(occtProjectedPoint)); diff --git a/TopologicCore/src/Utilities/ShellUtility.cpp b/TopologicCore/src/Utilities/ShellUtility.cpp index 737f7fc..4f8693d 100644 --- a/TopologicCore/src/Utilities/ShellUtility.cpp +++ b/TopologicCore/src/Utilities/ShellUtility.cpp @@ -69,7 +69,7 @@ namespace TopologicUtilities } catch (...) { - throw std::exception("Loft error"); + throw std::runtime_error("Loft error"); } TopologicCore::Shell::Ptr pShell = std::make_shared(TopoDS::Shell(occtLoft.Shape())); TopologicCore::Shell::Ptr pCopyShell = std::dynamic_pointer_cast(pShell->DeepCopy()); diff --git a/TopologicCore/src/Utilities/TopologyUtility.cpp b/TopologicCore/src/Utilities/TopologyUtility.cpp index c4df1d9..ab7d22e 100644 --- a/TopologicCore/src/Utilities/TopologyUtility.cpp +++ b/TopologicCore/src/Utilities/TopologyUtility.cpp @@ -232,7 +232,7 @@ namespace TopologicUtilities kpCoreTopology->GetType() == TopologicCore::Cluster::Type()) { std::string errorMessage = "Does not accept an input Topology of type " + kpCoreTopology->GetTypeAsString(); - throw std::exception(errorMessage.c_str()); + throw std::runtime_error(errorMessage.c_str()); } kpCoreTopology->UpwardNavigation(kpCoreTopology->GetOcctShape(), kTypeFilter, rCoreAdjacentTopologies); diff --git a/TopologicCore/src/Utilities/VertexUtility.cpp b/TopologicCore/src/Utilities/VertexUtility.cpp index 1dab71c..61d03fe 100644 --- a/TopologicCore/src/Utilities/VertexUtility.cpp +++ b/TopologicCore/src/Utilities/VertexUtility.cpp @@ -121,7 +121,7 @@ namespace TopologicUtilities return occtDistance.Value(); } } - catch (const std::exception&) + catch (const std::runtime_error&) { return std::numeric_limits::max(); } @@ -267,7 +267,7 @@ namespace TopologicUtilities ); default: - throw std::exception("An unknown Topology is detected."); + throw std::runtime_error("An unknown Topology is detected."); } } } \ No newline at end of file diff --git a/TopologicCore/src/Utilities/WireUtility.cpp b/TopologicCore/src/Utilities/WireUtility.cpp index 5a11d91..e76d511 100644 --- a/TopologicCore/src/Utilities/WireUtility.cpp +++ b/TopologicCore/src/Utilities/WireUtility.cpp @@ -55,7 +55,7 @@ namespace TopologicUtilities { if (kpWire->NumberOfBranches() > 0) { - throw std::exception("This method currently only supportes straight, manifold wires with no branches."); + throw std::runtime_error("This method currently only supportes straight, manifold wires with no branches."); } TopologicCore::Wire::Ptr pCopyWire = std::dynamic_pointer_cast(kpWire->DeepCopy()); diff --git a/TopologicCore/src/Vertex.cpp b/TopologicCore/src/Vertex.cpp index eef2bc4..e8ede53 100644 --- a/TopologicCore/src/Vertex.cpp +++ b/TopologicCore/src/Vertex.cpp @@ -66,7 +66,7 @@ namespace TopologicCore bool Vertex::IsManifold() const { - throw std::exception("Not implemented yet"); + throw std::runtime_error("Not implemented yet"); } void Vertex::Geometry(std::list& rOcctGeometries) const @@ -86,7 +86,7 @@ namespace TopologicCore } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } @@ -100,7 +100,7 @@ namespace TopologicCore assert(!m_occtVertex.IsNull() && "Vertex::m_occtVertex is null."); if (m_occtVertex.IsNull()) { - throw std::exception("A null Vertex is encountered."); + throw std::runtime_error("A null Vertex is encountered."); } return m_occtVertex; @@ -116,7 +116,7 @@ namespace TopologicCore assert(!m_occtVertex.IsNull() && "Vertex::m_occtVertex is null."); if (m_occtVertex.IsNull()) { - throw std::exception("A null Vertex is encountered."); + throw std::runtime_error("A null Vertex is encountered."); } return m_occtVertex; diff --git a/TopologicCore/src/Wire.cpp b/TopologicCore/src/Wire.cpp index 52a9e2c..30761f8 100644 --- a/TopologicCore/src/Wire.cpp +++ b/TopologicCore/src/Wire.cpp @@ -87,7 +87,7 @@ namespace TopologicCore if (startingVertex == nullptr) { - throw std::exception("This Wire is closed, but is identified as an open Wire."); + throw std::runtime_error("This Wire is closed, but is identified as an open Wire."); } } @@ -300,7 +300,7 @@ namespace TopologicCore } catch (Standard_Failure e) { - throw std::exception(e.GetMessageString()); + throw std::runtime_error(e.GetMessageString()); } } @@ -314,7 +314,7 @@ namespace TopologicCore assert(!m_occtWire.IsNull() && "Wire::m_occtWire is null."); if (m_occtWire.IsNull()) { - throw std::exception("A null Wire is encountered."); + throw std::runtime_error("A null Wire is encountered."); } return m_occtWire; @@ -325,7 +325,7 @@ namespace TopologicCore assert(!m_occtWire.IsNull() && "Wire::m_occtWire is null."); if (m_occtWire.IsNull()) { - throw std::exception("A null Wire is encountered."); + throw std::runtime_error("A null Wire is encountered."); } return m_occtWire; @@ -339,13 +339,13 @@ namespace TopologicCore switch (rkOcctMakeWire.Error()) { case BRepBuilderAPI_EmptyWire: - throw std::exception("No initialization of the algorithm. Only an empty constructor was used."); + throw std::runtime_error("No initialization of the algorithm. Only an empty constructor was used."); case BRepBuilderAPI_DisconnectedWire: - throw std::exception("The last edge which you attempted to add was not connected to the wire."); + throw std::runtime_error("The last edge which you attempted to add was not connected to the wire."); case BRepBuilderAPI_NonManifoldWire: - throw std::exception("The wire has some singularity."); + throw std::runtime_error("The wire has some singularity."); //default: // i.e. BRepBuilderAPI_WireDone, do nothing }