How to differentiate between a circle and an arc

bioan

CAD practitioner
How can I differentiate between an full circle and an arc of the same support circle?
I'm trying to cycle through the elements of a TopoDS_Shape of type TopAbs_COMPOUND.
Everything just work fine using the below code:

Code:
double u0, u1;
Handle(Geom_Curve) Curve;
TopoDS_Edge Edge;
Curve = BRep_Tool::Curve(Edge, u0, u1);

GeomAdaptor_Curve brepCurveAdaptor(Curve);
GeomAbs_CurveType curveType = brepCurveAdaptor.GetType();
switch (curveType)
{
   case GeomAbs_Circle:
   {
      if (Curve->IsClosed())
      {
      // here the code always runs no matter is an arc or a circle
      }
   }
}

I can use u0 and u1 values to decide it. If 0 to 2*PI - is a circle, otherwise if 0 to <2*PI is an arc.
My question is whether there is a more elegant method (as it should have been IsClosed() ) than the raw checking of the values of the parameters u0 and u1.
Thank you!
 
Last edited:

Jonathan

CAD community veteran
Standard_Boolean Geom_Circle::IsClosed () const { return Standard_True; } :D

I am not sure but wouldn't an arc be a Geom_TrimmedCurve?
 

bioan

CAD practitioner
Standard_Boolean Geom_Circle::IsClosed () const { return Standard_True; } :D

I am not sure but wouldn't an arc be a Geom_TrimmedCurve?
Hi Jonathan! All I have as input data is an array of Geom_Curve. I do not know when or if I need to check these Geom_Curve if some of them are of Geom_TrimmedCurve type. I assumed that IsClosed () might help, but unfortunately, regardless of whether it is a arc or a circle, this function returns true all the time.
 

Quaoar

Administrator
Staff member
I assumed that IsClosed () might help, but unfortunately, regardless of whether it is a arc or a circle, this function returns true all the time.
I would assume it's a purely geometric check. What you could also try is ShapeAnalysis_Edge::IsClosed3d(). It has an early exit condition on !IsClosed() and then checks the vertices. For a closed arc (and any closed edge), there should presumably be a shared vertex.
 

bioan

CAD practitioner
I would assume it's a purely geometric check. What you could also try is ShapeAnalysis_Edge::IsClosed3d(). It has an early exit condition on !IsClosed() and then checks the vertices. For a closed arc (and any closed edge), there should presumably be a shared vertex.
Excellent info!!
Yes, the verification is purely geometric. I managed to differentiate using the parameter values u0 and u1. It seems to work just perfectly!
Thank you very much!!
All the best!
Ioan
 

blobfish

CAD community veteran
Excellent info!!
Yes, the verification is purely geometric. I managed to differentiate using the parameter values u0 and u1. It seems to work just perfectly!
Thank you very much!!
All the best!
Ioan
The parameter range will describe a circle not necessarily (0, 2*PI) parameters. Something like this is legit.
Code:
BRepBuilderAPI_MakeEdge em(gp_Circ(gp_Ax2(), 1.0), M_PI, 3.0 * M_PI);
assert(em.IsDone());
TopoDS_Edge anEdge = em;
assert(BRep_Tool::IsClosed(anEdge));
In addition with parameters, you need to compensate for numerical error. So you get into something like std::fabs(lastParameter - firstParameter - 2*M_PI) <= Precision:: PConfusion. And that doesn't consider any vertex tolerances. My point: Use TopoDS_Shape and relative algos whenever possible and let occt take care of the minutia underneath.
 

bioan

CAD practitioner
The parameter range will describe a circle not necessarily (0, 2*PI) parameters. Something like this is legit.
Code:
BRepBuilderAPI_MakeEdge em(gp_Circ(gp_Ax2(), 1.0), M_PI, 3.0 * M_PI);
assert(em.IsDone());
TopoDS_Edge anEdge = em;
assert(BRep_Tool::IsClosed(anEdge));
In addition with parameters, you need to compensate for numerical error. So you get into something like std::fabs(lastParameter - firstParameter - 2*M_PI) <= Precision:: PConfusion. And that doesn't consider any vertex tolerances. My point: Use TopoDS_Shape and relative algos whenever possible and let occt take care of the minutia underneath.
Thank you very much for your observations!!
 
Top