Open CASCADE notes

A blog about the Open Source 3D modeling kernel: notes from its former developer and project manager

(continued...)

Pipe with constant radius
A particular case of a pipe with a constant section is a pipe with a constant radius. In ACIS such surfaces are called tubes.

Here is a sample screenshot:



Here is an example of creation:

GeomFill_Pipe aTube (thePath, theRadius);
aTube.Perform (aTol, Standard_False, (GeomAbs_Shape)Min (GeomAbs_C1, thePath->Continuity()), aMaxDeg, aMaxSeg);


Pipe with constant radius and two rail curves
As a convenience, the pipe algorithm allows to specify two rail curves. Rails are those which limit the cross section.
This algorithm flavor can be used to model so-called rolling ball surfaces. ACIS defines rolling-ball surfaces as if you have a ball of a constant radius that rolls along the path and always touches two limiting faces. The traces that the ball makes on those boundary faces are called spring or rail curves.

Open CASCADE algorithm accepts the radius, the path and two rail curves and creates a surface with limited circular sections. Each section is constructed by intersecting a plane at every path point and perpendicular to it with rail curves.

Here are sample screenshots of rolling ball surfaces:




On both images the pipes are shown in red and rail curves in blue. The 2nd screenshot also contains a full tube of which a fragment is constructed using 2 rail curves. This tube is a trace that a full rolling ball would make.

Important note to make is that Open CASCADE requires that rail curves follow the path parametrization. This means that the rail curves' ranges must be at least as big as the path's and be consistent between each other.


Pipe with variable radius
In addition to constant radius, you might want to create tubes (i.e. pipes with circular sections) with variable radii. For instance, like this:




Open CASCADE does not offer direct API to construct such surfaces but you can do these using lower level API it offers. For instance, here is my code excerpt:


/*! Set radius evolution function with SetEvol() before calling this method.

If \a theIsPolynomial is true tries to create polynomial B-Spline, otherwise - rational.

\sa Surface(), Error().
*/
void ACISGGeom_Pipe::Perform (const Standard_Real theTol,
const Standard_Boolean theIsPolynomial,
const GeomAbs_Shape theContinuity,
const Standard_Integer theMaxDegree,
const Standard_Integer theMaxSegment)
{
mySurface.Nullify();
myError = -1.;

if (myEvol.IsNull())
return;

//circular profile
Handle(Geom_Circle) aCirc = new Geom_Circle (gp::XOY(), 1.);
aCirc->Rotate (gp::OZ(), PI / 2.);

//code inspired by GeomFile_Pipe when using for constant radius and corrected
//trihedron orientation

//perpendicular section
Handle(GeomFill_SectionLaw) aSec = new GeomFill_EvolvedSection (aCirc, myEvol);
Handle(GeomFill_LocationLaw) aLoc = new GeomFill_CurveAndTrihedron (
new GeomFill_CorrectedFrenet);
aLoc->SetCurve (myPath);

GeomFill_Sweep Sweep (aLoc, myIsElem);
Sweep.SetTolerance (theTol);
Sweep.Build (aSec, GeomFill_Location, theContinuity, theMaxDegree, theMaxSegment);
if (Sweep.IsDone()) {
mySurface = Sweep.Surface();
myError = Sweep.ErrorOnSurface();
}
}

In this case myEval is Handle_Law_BSpFunc object constructed from 2D B-Spline which defines radius evolution:

/*! Creates an internal Law_BSpFunc object which represents an evolution function. Uses X
coordinates of the \a theEvol B-Spline curve.

\a theFirst and \a theLast are boundaries of the path curve.
*/
static Handle(Law_BSpFunc) CreateBsFunction (const Handle(Geom2d_BSplineCurve)& theEvol,
const Standard_Real theFirst,
const Standard_Real theLast)
{
//knots are recalculated from theEvol prorate to [theFirst, theLast] range
Standard_Integer i;
const Standard_Integer aNbP = theEvol->NbPoles();
TColgp_Array1OfPnt2d aPArrE (1, aNbP);
theEvol->Poles (aPArrE);
TColStd_Array1OfReal aPArr (1, aNbP);
for (i = 1; i <= aNbP; i++)
aPArr(i) = aPArrE(i).X();

const Standard_Integer aNbK = theEvol->NbKnots();
TColStd_Array1OfReal aKArrE (1, aNbK), aKArr (1, aNbK);
theEvol->Knots (aKArrE);
TColStd_Array1OfInteger aMArr (1, aNbK);
theEvol->Multiplicities (aMArr);

const Standard_Real aKF = aKArrE(1), aKL = aKArrE (aNbK);
const Standard_Real aKRatio = (theLast - theFirst) / (aKL - aKF);
for (i = 1; i <= aNbK; i++) {
aKArr(i) = theFirst + (aKArrE(i) - aKF) * aKRatio;
}

Handle(Law_BSpline) aBs;
if (theEvol->IsRational()) {
TColStd_Array1OfReal aWArrE (1, aNbP);
theEvol->Weights (aWArrE);
aBs = new Law_BSpline (aPArr, aWArrE, aKArr, aMArr, theEvol->Degree(),
theEvol->IsPeriodic());
} else {
aBs = new Law_BSpline (aPArr, aKArr, aMArr, theEvol->Degree(), theEvol->IsPeriodic());
}

Handle(Law_BSpFunc) aFunc = new Law_BSpFunc (aBs, theFirst, theLast);
return aFunc;
}

/*! Uses X coordinates of the \a theEvol B-Spline curve to set evolution function.
*/
void ACISGGeom_Pipe::SetEvol (const Handle(Geom2d_BSplineCurve)& theEvol)
{
myEvol = ::CreateBsFunction (theEvol, myPath->FirstParameter(), myPath->LastParameter());
}


Below are examples of radius function (as 2D B-Spline) and resulting surface:





Common comments
Pipe surfaces are parametrized in U along the cross section and in V along the path. Surface parametrization inherits the path range and adjusts U to a section range. For instance, tubes are parametrized from 0 to 2*PI in U.

To be continued...
Share
Tweet
Pin
Share
8 comments
ACIS-SAT format support now available in CAD Exchanger and for any other Open CASCADE-based application

CAD Exchanger has been extended with support of ACIS-SAT import and export. After several months of hard work and thorough testing this new format is now available to our users.
CAD Exchanger supports ACIS from version R1.5 to the latest R20 released in 2009. The scope includes a full set of geometrical and topological objects.

For developers on Open CASCADE, the ACIS-SAT plugin can be delivered as SDK that can be directly integrated with Open CASCADE-based application using either TopoDS_Shape interface or a BRep file.

We have conducted thorough testing through the database of 1000+ models before this announcement, so you should not be annoyed by any severe bug. But there can be some corner cases which could potentially reveal some issues. So please let us know if you find anything. But if you just like the product and it works fine in our case please tell us this as well. We need your feedback !

To get immediate download access please email us at info@cadexchanger.com.

Public Beta will be made available early next year after addressing feedback from our most active users. Sign up now to get your voice heard !
Share
Tweet
Pin
Share
No comments
Sweep surfaces
Sweep surfaces are constructed using a spine and a profile that moves along it.
Here is a screenshots of a typical sweep surfaces:



The sweep surface is constructed using GeomFill_Pipe. Perhaps the name pipe stems from the fact that a particular case when the profile is closed produces a pipe-like surface.

GeomFill_Pipe Pipe;
GeomFill_Pipe aPipe (aPath, aProfile, GeomFill_IsFixed);
aPipe.GenerateParticularCase(Standard_True);
aPipe.Perform(aTol, Standard_False, GeomAbs_C1, BSplCLib::MaxDegree(), 1000);
const Handle(Geom_Surface)& aSurface = aPipe.Surface();

This code is an excerpt from the CAD Exchanger, the translation driver for ACIS sum_spl_sur, which is defined as a sum of two curves.

By default, the sweep surface is created as a B-Spline, either rational or polynomial – depending on the parameter in the Perform() method. If you want to generate elementary surface (torus, cylinder, sphere, etc) when curves configuration allows, then call GenerateParticularCase() with Standard_True.

The algorithm can also return an approximation error – use ErrorOnSurf() to get it.

Sweeping is constructed dragging a profile along the spine and modifying its orientation along the latter. This behavior is controlled by a parameter of the type GeomFill_Trihedron. The following images illustrate how resulting surface is different for the same spine and profile (semi-circles):


GeomFill_IsFixed


GeomFill_IsFrenet


GeomFill_IsConstantNormal

You can experiment in DRAW using the 'sweep' command and providing various options.

Pipes
GeomFill_Pipe offers a few pre-defined construction techniques to construct a sweep surface:
- a pipe with constant section;
- a circular section pipe with constant radius;
- a circular section pipe with constant radius with two rails.

Pipes with constant section has been considered above. Here are two more examples of such pipes:


To be continued...
Share
Tweet
Pin
Share
4 comments
Surface modeling is a fundamental feature of any 3D geometric modeler. As you know, Open CASCADE offers a set of elementary surfaces (planar, conical, spherical, etc), Bezier and B-Spline, revolved, extruded and offset surfaces. There is also a trimmed surface which trims an underlying surface in parameter space.

Open CASCADE implements a subset of STEP (ISO standard 10303, part 42) for geometrical and topological entities, though with some minor deviations.

The surface object only contains a final geometrical representation and does not provide any information on how it was created. This differentiates it, for instance, from ACIS which uses a notion of so called procedural surfaces which may contain both a construction technique and an optional final approximation. For instance, a skin surface comes with description of a set of section curves the surface was 'skinned' through and resulting NURBS approximation. This leads to increase in number of entity types to be supported by the modeler and likely complexity of modeling algorithms that use them. (This also makes me suffer developing extra classes to represent all this variety in the CAD Exchanger translator and to translate them into Open CASCADE. I can successfully re-import all SAT files exported from Open CASCADE but not all possible SAT types yet). By the way, if there are readers who are familiar with ACIS their comments would be valuable to check how OCC capabilities compare with those of ACIS.

Open CASCADE favors different approach where knowledge of the performed modeling algorithms is stored elsewhere (e.g. in OCAF using function drivers). The B-Rep model only contains a result of an operation and thus is more compact.

Another point to make is that OCC offers algorithms both at geometry level (dealing with Geom_Surface and/or Geom_Curve objects) and topology level (TopoDS_Shape subclasses). The latter may use the former but this dual API is not always provided. Some algorithms are only available at the geometry level and some are only at topology. (If you are not certain about this distinction please make sure you re-read a series of posts earlier this year).

Let's see what modeling techniques you can use with Open CASCADE. I bet there is no point in going through description of construction techniques of elementary surfaces. Documentation and header files are just enough for that. Let's rather check what kind of advanced stuff OCC has.

Ruled surfaces
Ruled surface is constructed by connecting two curves (i.e. points along them) with lines. Particular case of a ruled surface is plane (as it can be built on two parallel lines). If you take two parallel circles then a ruled surface will be a cylinder or a cone.

Here is how it may look in general case:



Last spring, when we were in Spain and visiting Sagrada Familia in Barcelona (the central city cathedral, which is an on-going construction for several decades), there was an exhibition of Antoni Gaudi's construction techniques. Gaudi was an architect and he reused many techniques from nature. Among those there was a use of ruled surfaces – see some photos here or even read a paper 'Gaudi and CAD'.


You can create a ruled surface at geometry level as follows:
Handle(Geom_Curve) aCrv1 = ...;
Handle(Geom_Curve) aCrv2 = ...;
Handle(Geom_Surface) aSurf = GeomFill::Surface (aCrv1, aCrv2);

If you dealing at topology level you can create either a face using two edges or a shell using two wires. You need to use BRepFill:
TopoDS_Edge anEdge1 = ...;
TopoDS_Edge anEdge2 = ...;
TopoDS_Face aFace = BRepFill::Face (anEdge1, anEdge2);

TopoDS_Wire aWire1 = ...;
TopoDS_Wire aWire2 = ...;
TopoDS_Face aShell = BRepFill::Shell (aWire1, aWire2);

Here is a shell of two faces lying on ruled surfaces:



When using BRepFill::Shell(), wires must contain the same number of edges. If not you may need to re-approximate the edges. For instance you can reuse ShapeAlgo_Container::HomoWires() or create some similar algorithm, or re-approximate a wire using BRepAdaptor_CompCurve adaptor and Approx_Curve3d. The latter will produce a single B-Spline curve from a wire, which you can later use with GeomFill or create a TopoDS_Edge from of it to use BRepFill.

To be continued...
Share
Tweet
Pin
Share
5 comments
Newer Posts
Older Posts

Subscribe for the new posts

Blog Archive

  • August 2015 (2)
  • May 2014 (1)
  • November 2013 (1)
  • June 2013 (1)
  • May 2013 (1)
  • November 2012 (2)
  • November 2011 (1)
  • June 2011 (3)
  • May 2011 (2)
  • March 2011 (1)
  • February 2011 (1)
  • November 2010 (2)
  • October 2010 (2)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • June 2010 (1)
  • May 2010 (1)
  • April 2010 (2)
  • March 2010 (2)
  • January 2010 (2)
  • December 2009 (1)
  • November 2009 (2)
  • October 2009 (3)
  • August 2009 (2)
  • July 2009 (3)
  • June 2009 (4)
  • May 2009 (3)
  • April 2009 (2)
  • March 2009 (5)
  • February 2009 (5)
  • January 2009 (5)
  • December 2008 (11)
  • November 2008 (8)

Loading...

Followers

Created by ThemeXpose