Hide menu
Loading...
Searching...
No Matches
exploring/brepgeometry/main.cxx

Refer to the B-Rep Geometry Exploration Example.

base_explorer.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _BaseExplorer_HeaderFile
#define _BaseExplorer_HeaderFile
#include <cadex/ModelData_Axis2Placement2d.hxx>
#include <cadex/ModelData_Curve2d.hxx>
#include <cadex/ModelData_Direction.hxx>
#include <cadex/ModelData_Direction2d.hxx>
#include <cadex/ModelData_Point.hxx>
#include <cadex/ModelData_Point2d.hxx>
#include <cadex/ModelData_ShapeOrientation.hxx>
#include <cadex/ModelData_Surface.hxx>
#include <cadex/ModelData_XY.hxx>
#include <cadex/ModelData_XYZ.hxx>
#include <functional>
#include <iostream>
using namespace std;
using namespace cadex;
class BaseExplorer
{
public:
template <typename T>
static void PrintElementary (const T& theGeometry)
{
PrintDomain (theGeometry);
auto& aPosition = theGeometry.Position();
const ModelData_Point& aLoc = aPosition.Location();
const ModelData_Direction& anAxis = aPosition.Axis();
const ModelData_Direction& aXDir = aPosition.XDirection();
const ModelData_Direction& aYDir = aPosition.YDirection();
PrintParameter ("Location", aLoc.Coord());
PrintParameter ("Axis", anAxis.Coord());
PrintParameter ("X Direction", aXDir.Coord());
PrintParameter ("Y Direction", aYDir.Coord());
}
template <typename T>
static void PrintElementary2d (const T& theGeometry)
{
PrintDomain (theGeometry);
auto& aPosition = theGeometry.Position();
const ModelData_Point2d& aLoc = aPosition.Location();
const ModelData_Direction2d& aXDir = aPosition.XDirection();
const ModelData_Direction2d& aYDir = aPosition.YDirection();
PrintParameter ("Location", aLoc.Coord());
PrintParameter ("X Direction", aXDir.Coord());
PrintParameter ("Y Direction", aYDir.Coord());
}
static void PrintRange (const char* aName, double aFirstParameter, double aLastParameter)
{
cout << aName << " = [" << aFirstParameter << ", " << aLastParameter << "]; ";
}
static void PrintDomain (const ModelData_Curve& theCurve)
{
PrintRange ("Domain", theCurve.UMin(), theCurve.UMax());
}
static void PrintDomain (const ModelData_Curve2d& theCurve)
{
PrintRange ("Domain", theCurve.UMin(), theCurve.UMax());
}
static void PrintDomain (const ModelData_Surface& theSurface)
{
PrintRange ("Domain U", theSurface.UMin(), theSurface.UMax());
PrintRange ("V", theSurface.VMin(), theSurface.VMax());
}
static void PrintParameter (ModelData_XYZd thePoint)
{
cout << "(" << thePoint.X() << ", " << thePoint.Y() << ", " << thePoint.Z() << "); ";
}
static void PrintParameter (ModelData_XYd thePoint)
{
cout << "(" << thePoint.X() << ", " << thePoint.Y() << "); ";
}
static void PrintParameter (double theValue)
{
cout << theValue << "; ";
}
template <typename T>
static void PrintParameter (const char* theName, T theValue)
{
cout << theName << " = ";
PrintParameter (theValue);
}
static void PrintName (const char* theName)
{
cout << theName << ": ";
}
static void PrintCollection (const char* theName,
int theFinalIndex,
std::function <void (int)> thePrintElement)
{
if (theName) {
cout << theName << " = ";
}
cout << "[";
for (int i = 1; i <= theFinalIndex; ++i)
{
if (i > 3) {
cout << "...";
break;
}
thePrintElement(i);
}
cout << "]; ";
}
static void PrintCollection (const char* theName,
int theFinalIndex1,
int theFinalIndex2,
std::function <void (int, int)> thePrintElement)
{
PrintCollection (theName, theFinalIndex1, [&](int i)
{
PrintCollection (nullptr, theFinalIndex2, [&](int j) {thePrintElement(i, j); });
});
}
static void PrintOrientation (const ModelData_ShapeOrientation& theOrientation)
{
cout << "Orientation = ";
switch (theOrientation) {
case ModelData_SO_Forward: cout << "Forward"; break;
case ModelData_SO_Reversed: cout << "Reversed"; break;
default:
cout << "Undefined";
break;
}
cout << "; ";
}
void PrintTabulation()
{
for (size_t i = 0; i < myNestingLevel; ++i) {
cout << "--- ";
}
}
size_t myNestingLevel = 0;
};
#endif
Base class for 2D curves.
Definition: ModelData_Curve2d.hxx:42
double UMin() const
Returns a minimum parameter of a definition domain.
Definition: ModelData_Curve2d.cxx:155
double UMax() const
Returns a maximum parameter of a definition domain.
Definition: ModelData_Curve2d.cxx:162
Base class for 3D curves.
Definition: ModelData_Curve.hxx:44
double UMin() const
Returns a minimum parameter of a definition domain.
Definition: ModelData_Curve.cxx:232
double UMax() const
Returns a maximum parameter of a definition domain.
Definition: ModelData_Curve.cxx:239
Defines a 2D direction.
Definition: ModelData_Direction2d.hxx:176
Defines a 3D direction.
Definition: ModelData_Direction.hxx:180
Defines a 2D point.
Definition: ModelData_Point2d.hxx:193
Defines a 3D point.
Definition: ModelData_Point.hxx:295
Base class for geometrical surfaces.
Definition: ModelData_Surface.hxx:44
double VMax() const
Returns a maximum parameter of a definition domain in V direction.
Definition: ModelData_Surface.cxx:262
double UMax() const
Returns a maximum parameter of a definition domain in U direction.
Definition: ModelData_Surface.cxx:242
double VMin() const
Returns a minimum parameter of a definition domain in V direction.
Definition: ModelData_Surface.cxx:252
double UMin() const
Returns a minimum parameter of a definition domain in U direction.
Definition: ModelData_Surface.cxx:233
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22
ModelData_ShapeOrientation
Defines shape orientation.
Definition: ModelData_ShapeOrientation.hxx:25

curve_explorer.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _CurveExplorer_HeaderFile
#define _CurveExplorer_HeaderFile
#include <cadex/ModelData_Axis2Placement.hxx>
#include <cadex/ModelData_BezierCurve.hxx>
#include <cadex/ModelData_BSplineCurve.hxx>
#include <cadex/ModelData_Circle.hxx>
#include <cadex/ModelData_Ellipse.hxx>
#include <cadex/ModelData_Hyperbola.hxx>
#include <cadex/ModelData_Line.hxx>
#include <cadex/ModelData_OffsetCurve.hxx>
#include <cadex/ModelData_Parabola.hxx>
#include <cadex/ModelData_TrimmedCurve.hxx>
#include <base_explorer.hxx>
using namespace std;
using namespace cadex;
class CurveExplorer : public BaseExplorer
{
public:
static void PrintCurveInfo (const ModelData_Curve& theCurve)
{
switch (theCurve.Type()) {
case ModelData_CT_Line:
PrintLine (static_cast <const ModelData_Line&> (theCurve));
break;
case ModelData_CT_Circle:
PrintCircle (static_cast <const ModelData_Circle&> (theCurve));
break;
case ModelData_CT_Ellipse:
PrintEllipse (static_cast <const ModelData_Ellipse&> (theCurve));
break;
case ModelData_CT_Hyperbola:
PrintHyperbola (static_cast <const ModelData_Hyperbola&> (theCurve));
break;
case ModelData_CT_Parabola:
PrintParabola (static_cast <const ModelData_Parabola&> (theCurve));
break;
case ModelData_CT_Bezier:
PrintBezierCurve (static_cast <const ModelData_BezierCurve&> (theCurve));
break;
case ModelData_CT_BSpline:
PrintBSplineCurve (static_cast <const ModelData_BSplineCurve&> (theCurve));
break;
case ModelData_CT_Offset:
PrintOffsetCurve (static_cast <const ModelData_OffsetCurve&> (theCurve));
break;
case ModelData_CT_Trimmed:
PrintTrimmedCurve (static_cast <const ModelData_TrimmedCurve&> (theCurve));
break;
default:
break;
}
}
static void PrintLine (const ModelData_Line& theLine)
{
PrintName ("Line");
const ModelData_Point& aLoc = theLine.Location();
const ModelData_Direction& aDir = theLine.Direction();
PrintDomain (theLine);
PrintParameter ("Location", aLoc.Coord());
PrintParameter ("Direction", aDir.Coord());
}
static void PrintCircle (const ModelData_Circle& theCircle)
{
PrintName ("Circle");
double aRadius = theCircle.Radius();
PrintElementary (theCircle);
PrintParameter ("Radius", aRadius);
}
static void PrintEllipse (const ModelData_Ellipse& theEllipse)
{
PrintName ("Ellipse");
double aMajorRadius = theEllipse.MajorRadius();
double aMinorRadius = theEllipse.MinorRadius();
PrintElementary (theEllipse);
PrintParameter ("Major Radius", aMajorRadius);
PrintParameter ("Minor Radius", aMinorRadius);
}
static void PrintHyperbola (const ModelData_Hyperbola& theHyperbola)
{
PrintName ("Hyperbola");
double aMajorRadius = theHyperbola.MajorRadius();
double aMinorRadius = theHyperbola.MinorRadius();
PrintElementary (theHyperbola);
PrintParameter ("Major Radius", aMajorRadius);
PrintParameter ("Minor Radius", aMinorRadius);
}
static void PrintParabola (const ModelData_Parabola& theParabola)
{
PrintName ("Parabola");
double aFocal = theParabola.Focal();
PrintElementary (theParabola);
PrintParameter ("Focal", aFocal);
}
static void PrintBezierCurve (const ModelData_BezierCurve& theBezier)
{
PrintName ("Bezier Curve");
int aDegree = theBezier.Degree();
int aNumberOfPoles = theBezier.NumberOfPoles();
PrintDomain (theBezier);
PrintParameter ("Degree", aDegree);
PrintParameter ("Number Of Poles", aNumberOfPoles);
PrintCollection ("Poles", aNumberOfPoles, [&](int i)
{
auto aPole = theBezier.Pole (i);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfPoles, [&](int i)
{
double aWeight = theBezier.Weight (i);
PrintParameter (aWeight);
});
}
static void PrintBSplineCurve (const ModelData_BSplineCurve& theBSpline)
{
PrintName ("BSpline Curve");
int aDegree = theBSpline.Degree();
int aNumberOfKnots = theBSpline.NumberOfKnots();
int aNumberOfPoles = theBSpline.NumberOfPoles();
PrintDomain (theBSpline);
PrintParameter ("Degree", aDegree);
PrintParameter ("Number Of Knots", aNumberOfKnots);
PrintParameter ("Number Of Poles", aNumberOfPoles);
PrintCollection ("Knots", aNumberOfKnots, [&](int i)
{
double aKnot = theBSpline.Knot (i);
PrintParameter (aKnot);
});
PrintCollection ("Multiplicities", aNumberOfKnots, [&](int i)
{
int aMultiplicity = theBSpline.Multiplicity (i);
PrintParameter (aMultiplicity);
});
PrintCollection ("Poles", aNumberOfPoles, [&](int i)
{
auto aPole = theBSpline.Pole (i);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfPoles, [&](int i)
{
double aWeight = theBSpline.Weight (i);
PrintParameter (aWeight);
});
}
static void PrintOffsetCurve (const ModelData_OffsetCurve& theOffset)
{
PrintName ("Offset Curve");
const ModelData_Direction& aDir = theOffset.Direction();
double anOffset = theOffset.Offset();
PrintDomain (theOffset);
PrintParameter ("Direction", aDir.Coord());
PrintParameter ("Offset", anOffset);
cout << "Basis Curve = ";
PrintCurveInfo (theOffset.BasisCurve());
}
static void PrintTrimmedCurve (const ModelData_TrimmedCurve& theTrimmed)
{
PrintName ("Trimmed Curve");
PrintDomain (theTrimmed);
cout << "Basis Curve = ";
PrintCurveInfo (theTrimmed.BasisCurve());
}
};
#endif
Defines 3D B-Spline curve.
Definition: ModelData_BSplineCurve.hxx:34
int NumberOfKnots() const
Returns number of unique knots.
Definition: ModelData_BSplineCurve.cxx:176
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition: ModelData_BSplineCurve.cxx:228
double Knot(int theIndex) const
Returns a knot value.
Definition: ModelData_BSplineCurve.cxx:195
double Weight(int theIndex) const
Returns a weight value.
Definition: ModelData_BSplineCurve.cxx:304
int Degree() const
Returns degree.
Definition: ModelData_BSplineCurve.cxx:168
ModelData_Point Pole(int theIndex) const
Returns a pole value.
Definition: ModelData_BSplineCurve.cxx:261
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BSplineCurve.cxx:184
Defines 3D Bezier curve.
Definition: ModelData_BezierCurve.hxx:36
double Weight(const int theIndex) const
Returns a weight value.
Definition: ModelData_BezierCurve.cxx:177
ModelData_Point Pole(const int theIndex) const
Returns a pole value.
Definition: ModelData_BezierCurve.cxx:143
int Degree() const
Returns degree.
Definition: ModelData_BezierCurve.cxx:124
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BezierCurve.cxx:132
Defines 3D circle.
Definition: ModelData_Circle.hxx:33
double Radius() const
Returns radius.
Definition: ModelData_Circle.cxx:68
ModelData_CurveType Type() const
Returns a curve type.
Definition: ModelData_Curve.cxx:205
Defines 3D ellipse.
Definition: ModelData_Ellipse.hxx:32
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Ellipse.cxx:83
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Ellipse.cxx:75
Defines 3D hyperbola.
Definition: ModelData_Hyperbola.hxx:32
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Hyperbola.cxx:80
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Hyperbola.cxx:72
Defines 3D line.
Definition: ModelData_Line.hxx:36
const ModelData_Direction & Direction() const
Returns a direction.
Definition: ModelData_Line.cxx:70
const ModelData_Point & Location() const
Returns an origin point.
Definition: ModelData_Line.cxx:60
Defines 3D offset curve.
Definition: ModelData_OffsetCurve.hxx:33
const ModelData_Direction & Direction() const
Returns reference direction.
Definition: ModelData_OffsetCurve.cxx:97
ModelData_Curve BasisCurve() const
Returns basis curve.
Definition: ModelData_OffsetCurve.cxx:90
double Offset() const
Returns offset value.
Definition: ModelData_OffsetCurve.cxx:104
Defines 3D parabola.
Definition: ModelData_Parabola.hxx:32
double Focal() const
Returns a focal.
Definition: ModelData_Parabola.cxx:70
Defines explicitly trimmed 3D curve.
Definition: ModelData_TrimmedCurve.hxx:32

pcurve_explorer.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _PCurveExplorer_HeaderFile
#define _PCurveExplorer_HeaderFile
#include <base_explorer.hxx>
#include <cadex/ModelData_Axis2Placement.hxx>
#include <cadex/ModelData_BezierCurve2d.hxx>
#include <cadex/ModelData_BSplineCurve2d.hxx>
#include <cadex/ModelData_Circle2d.hxx>
#include <cadex/ModelData_Ellipse2d.hxx>
#include <cadex/ModelData_Hyperbola2d.hxx>
#include <cadex/ModelData_Line2d.hxx>
#include <cadex/ModelData_OffsetCurve2d.hxx>
#include <cadex/ModelData_Parabola2d.hxx>
#include <cadex/ModelData_TrimmedCurve2d.hxx>
using namespace std;
using namespace cadex;
class PCurveExplorer : public BaseExplorer
{
public:
static void PrintPCurveInfo (const ModelData_Curve2d& theCurve)
{
switch (theCurve.Type()) {
case ModelData_CT_Line:
PrintLine (static_cast <const ModelData_Line2d&> (theCurve));
break;
case ModelData_CT_Circle:
PrintCircle (static_cast <const ModelData_Circle2d&> (theCurve));
break;
case ModelData_CT_Ellipse:
PrintEllipse (static_cast <const ModelData_Ellipse2d&> (theCurve));
break;
case ModelData_CT_Hyperbola:
PrintHyperbola (static_cast <const ModelData_Hyperbola2d&> (theCurve));
break;
case ModelData_CT_Parabola:
PrintParabola (static_cast <const ModelData_Parabola2d&> (theCurve));
break;
case ModelData_CT_Bezier:
PrintBezierCurve (static_cast <const ModelData_BezierCurve2d&> (theCurve));
break;
case ModelData_CT_BSpline:
PrintBSplineCurve (static_cast <const ModelData_BSplineCurve2d&> (theCurve));
break;
case ModelData_CT_Offset:
PrintOffsetCurve (static_cast <const ModelData_OffsetCurve2d&> (theCurve));
break;
case ModelData_CT_Trimmed:
PrintTrimmedCurve (static_cast <const ModelData_TrimmedCurve2d&> (theCurve));
break;
default:
break;
}
}
static void PrintLine (const ModelData_Line2d& theLine)
{
PrintName ("Line 2d");
const ModelData_Point2d& aLoc = theLine.Location();
const ModelData_Direction2d& aDir = theLine.Direction();
PrintDomain (theLine);
PrintParameter ("Location", aLoc.Coord());
PrintParameter ("Direction", aDir.Coord());
}
static void PrintCircle (const ModelData_Circle2d& theCircle)
{
PrintName ("Circle 2d");
double aRadius = theCircle.Radius();
PrintElementary2d (theCircle);
PrintParameter ("Radius", aRadius);
}
static void PrintEllipse (const ModelData_Ellipse2d& theEllipse)
{
PrintName ("Ellipse 2d");
double aMajorRadius = theEllipse.MajorRadius();
double aMinorRadius = theEllipse.MinorRadius();
PrintElementary2d (theEllipse);
PrintParameter ("Major Radius", aMajorRadius);
PrintParameter ("Minor Radius", aMinorRadius);
}
static void PrintHyperbola (const ModelData_Hyperbola2d& theHyperbola)
{
PrintName ("Hyperbola 2d");
double aMajorRadius = theHyperbola.MajorRadius();
double aMinorRadius = theHyperbola.MinorRadius();
PrintElementary2d (theHyperbola);
PrintParameter ("Major Radius", aMajorRadius);
PrintParameter ("Minor Radius", aMinorRadius);
}
static void PrintParabola (const ModelData_Parabola2d& theParabola)
{
PrintName ("Parabola 2d");
double aFocal = theParabola.Focal();
PrintElementary2d (theParabola);
PrintParameter ("Focal", aFocal);
}
static void PrintBezierCurve (const ModelData_BezierCurve2d& theBezier)
{
PrintName ("Bezier Curve 2d");
int aDegree = theBezier.Degree();
int aNumberOfPoles = theBezier.NumberOfPoles();
PrintDomain (theBezier);
PrintParameter ("Degree", aDegree);
PrintParameter ("Number Of Poles", aNumberOfPoles);
PrintCollection ("Poles", aNumberOfPoles, [&](int i)
{
auto aPole = theBezier.Pole (i);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfPoles, [&](int i)
{
double aWeight = theBezier.Weight (i);
PrintParameter (aWeight);
});
}
static void PrintBSplineCurve (const ModelData_BSplineCurve2d& theBSpline)
{
PrintName ("BSpline Curve 2d");
int aDegree = theBSpline.Degree();
int aNumberOfKnots = theBSpline.NumberOfKnots();
int aNumberOfPoles = theBSpline.NumberOfPoles();
PrintDomain (theBSpline);
PrintParameter ("Degree", aDegree);
PrintParameter ("Number Of Knots", aNumberOfKnots);
PrintParameter ("Number Of Poles", aNumberOfPoles);
PrintCollection ("Knots", aNumberOfKnots, [&](int i)
{
double aKnot = theBSpline.Knot (i);
PrintParameter (aKnot);
});
PrintCollection ("Multiplicities", aNumberOfKnots, [&](int i)
{
int aMultiplicity = theBSpline.Multiplicity (i);
PrintParameter (aMultiplicity);
});
PrintCollection ("Poles", aNumberOfPoles, [&](int i)
{
auto aPole = theBSpline.Pole (i);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfPoles, [&](int i)
{
double aWeight = theBSpline.Weight (i);
PrintParameter (aWeight);
});
}
static void PrintOffsetCurve (const ModelData_OffsetCurve2d& theOffset)
{
PrintName ("Offset Curve 2d");
double anOffset = theOffset.Offset();
PrintDomain (theOffset);
PrintParameter ("Offset", anOffset);
cout << "Basis Curve = ";
PrintPCurveInfo (theOffset.BasisCurve());
}
static void PrintTrimmedCurve (const ModelData_TrimmedCurve2d& theTrimmed)
{
PrintName ("Trimmed Curve 2d");
PrintDomain (theTrimmed);
cout << "Basis Curve = ";
PrintPCurveInfo (theTrimmed.BasisCurve());
}
};
#endif
Defines 2D B-Spline curve.
Definition: ModelData_BSplineCurve2d.hxx:34
double Knot(int theIndex) const
Returns a knot value.
Definition: ModelData_BSplineCurve2d.cxx:172
int NumberOfKnots() const
Returns number of unique knots.
Definition: ModelData_BSplineCurve2d.cxx:153
double Weight(int theIndex) const
Returns a weight value.
Definition: ModelData_BSplineCurve2d.cxx:281
ModelData_Point2d Pole(int theIndex) const
Returns a pole value.
Definition: ModelData_BSplineCurve2d.cxx:238
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition: ModelData_BSplineCurve2d.cxx:205
int Degree() const
Returns degree.
Definition: ModelData_BSplineCurve2d.cxx:145
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BSplineCurve2d.cxx:161
Defines 2D Bezier curve.
Definition: ModelData_BezierCurve2d.hxx:34
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BezierCurve2d.cxx:114
ModelData_Point2d Pole(const int theIndex) const
Returns a pole value.
Definition: ModelData_BezierCurve2d.cxx:125
int Degree() const
Returns degree.
Definition: ModelData_BezierCurve2d.cxx:106
double Weight(const int theIndex) const
Returns a weight value.
Definition: ModelData_BezierCurve2d.cxx:159
Defines 2D circle.
Definition: ModelData_Circle2d.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_Circle2d.cxx:59
ModelData_CurveType Type() const
Returns a curve type.
Definition: ModelData_Curve2d.cxx:128
Defines 2D ellipse.
Definition: ModelData_Ellipse2d.hxx:32
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Ellipse2d.cxx:62
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Ellipse2d.cxx:70
Defines 2D hyperbola.
Definition: ModelData_Hyperbola2d.hxx:32
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Hyperbola2d.cxx:62
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Hyperbola2d.cxx:70
Defines 2D line.
Definition: ModelData_Line2d.hxx:35
const ModelData_Point2d & Location() const
Returns an origin point.
Definition: ModelData_Line2d.cxx:53
const ModelData_Direction2d & Direction() const
Returns a direction.
Definition: ModelData_Line2d.cxx:63
Defines 2D offset curve.
Definition: ModelData_OffsetCurve2d.hxx:32
Defines 2D parabola.
Definition: ModelData_Parabola2d.hxx:32
double Focal() const
Returns a focal.
Definition: ModelData_Parabola2d.cxx:61
Defines explicitly trimmed 2D curve.
Definition: ModelData_TrimmedCurve2d.hxx:32

shape_explorer.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _ShapeExplorer_HeaderFile
#define _ShapeExplorer_HeaderFile
#include <curve_explorer.hxx>
#include <base_explorer.hxx>
#include <pcurve_explorer.hxx>
#include <surface_explorer.hxx>
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelData_BodyType.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Curve.hxx>
#include <cadex/ModelData_Curve2d.hxx>
#include <cadex/ModelData_Edge.hxx>
#include <cadex/ModelData_Face.hxx>
#include <cadex/ModelData_Model.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/ModelData_Surface.hxx>
#include <cadex/ModelData_Vertex.hxx>
#include <cadex/ModelData_Wire.hxx>
#include <array>
#include <functional>
#include <iostream>
#include <unordered_map>
using namespace std;
using namespace cadex;
// Visits directly each part and calls B-Rep representation exploring if a part has one
class ShapeExplorer : public ModelData_Model::VoidElementVisitor, public BaseExplorer
{
protected:
void operator() (const ModelData_Part& thePart) override
{
if (aBRep) {
cout << "Part = \"" << thePart.Name() << "\"" << endl;
ExploreBRep (aBRep);
}
}
private:
void ExploreBRep (const ModelData_BRepRepresentation& theBRep)
{
// Get() method retrieves bodies listed in B-Rep representation by calling data providers flushing
// Flushing isn't an elementary process so it can take a significant time (seconds, minutes depending on a model structure)
const ModelData_BodyList& aBodyList = theBRep.Get();
// Iterate over bodies
for (ModelData_BodyList::SizeType i = 0; i < aBodyList.Size(); ++i) {
const ModelData_Body& aBody = aBodyList[i];
cout << "Body " << i << ": " << BodyType (aBody) << endl;
ExploreShape (aBody);
}
}
// Recursive iterating over the Shape until reaching vertices
void ExploreShape (const ModelData_Shape& theShape)
{
if (theShape.Type() == ModelData_ST_Face) {
myCurrentFace = ModelData_Face::Cast (theShape);
}
++myNestingLevel;
ModelData_Shape::Iterator aShapeIt (theShape);
while (aShapeIt.HasNext()) {
const ModelData_Shape& aShape = aShapeIt.Next();
PrintShape (aShape);
ExploreShape (aShape);
}
if (theShape.Type() == ModelData_ST_Face) {
myCurrentFace = ModelData_Face();
}
--myNestingLevel;
}
// Returns body type name
const char* BodyType (const ModelData_Body& theBody)
{
switch (theBody.BodyType()) {
case ModelData_BT_Solid: return "Solid";
case ModelData_BT_Sheet: return "Sheet";
case ModelData_BT_Wireframe: return "Wireframe";
case ModelData_BT_Acorn: return "Acorn";
default:
break;
}
return "Undefined";
}
// Returns shape type name and prints shape info in some cases
void PrintShape (const ModelData_Shape& theShape)
{
PrintTabulation();
switch (theShape.Type()) {
case ModelData_ST_Solid: cout << "Solid"; break;
case ModelData_ST_Shell: PrintShell (ModelData_Shell::Cast (theShape)); break;
case ModelData_ST_Wire: PrintWire (ModelData_Wire::Cast (theShape)); break;
case ModelData_ST_Face: PrintFace (ModelData_Face::Cast (theShape)); break;
case ModelData_ST_Edge: PrintEdge (ModelData_Edge::Cast (theShape)); break;
case ModelData_ST_Vertex: PrintVertex (ModelData_Vertex::Cast (theShape)); break;
default:
cout << "Undefined"; break;
}
cout << endl;
}
void PrintShell (const ModelData_Shell& theWire)
{
PrintName ("Shell");
++myNestingLevel;
PrintOrientation (theWire.Orientation());
--myNestingLevel;
}
void PrintWire (const ModelData_Wire& theWire)
{
PrintName ("Wire");
++myNestingLevel;
PrintOrientation (theWire.Orientation());
--myNestingLevel;
}
void PrintFace (const ModelData_Face& theFace)
{
PrintName ("Face");
++myNestingLevel;
PrintOrientation (theFace.Orientation());
cout << endl;
ModelData_Surface aSurface = theFace.Surface();
PrintTabulation();
cout << "Surface: ";
SurfaceExplorer::PrintSurface (aSurface);
--myNestingLevel;
}
void PrintEdge (const ModelData_Edge& theEdge)
{
PrintName ("Edge");
++myNestingLevel;
if (theEdge.IsDegenerated()) {
cout << "Degenerated: ";
}
PrintOrientation (theEdge.Orientation());
PrintParameter ("Tolerance", theEdge.Tolerance());
if (!theEdge.IsDegenerated()) {
pair<double, double> aParameters;
ModelData_Curve aCurve = theEdge.Curve (aParameters.first, aParameters.second);
cout << endl;
PrintTabulation();
PrintName ("Curve");
PrintRange ("Edge Range", aParameters.first, aParameters.second);
CurveExplorer::PrintCurveInfo (aCurve);
}
if (myCurrentFace) {
pair<double, double> aParameters2d;
const ModelData_Curve2d& aPCurve = theEdge.PCurve (myCurrentFace,
aParameters2d.first,
aParameters2d.second);
cout << endl;
PrintTabulation();
PrintName ("PCurve");
PrintRange ("Edge Range", aParameters2d.first, aParameters2d.second);
PCurveExplorer::PrintPCurveInfo (aPCurve);
}
--myNestingLevel;
}
void PrintVertex (const ModelData_Vertex& theVertex)
{
PrintName ("Vertex");
ModelData_Point aLoc = theVertex.Point();
double aTolerance = theVertex.Tolerance();
PrintOrientation (theVertex.Orientation());
PrintParameter ("Tolerance", aTolerance);
PrintParameter ("Location", aLoc.Coord());
}
private:
ModelData_Face myCurrentFace;
};
#endif
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
ModelData_BodyType BodyType() const
Returns a body type.
Definition: ModelData_Body.cxx:139
Defines a list of bodies.
Definition: ModelData_BodyList.hxx:31
Defines an edge.
Definition: ModelData_Edge.hxx:36
ModelData_Curve2d PCurve(const ModelData_Face &theFace, double &theFirstParameter, double &theLastParameter) const
Returns edge p-curve on a face and its limits.
Definition: ModelData_Edge.cxx:643
bool IsDegenerated() const
Returns true if the edge is degenerated.
Definition: ModelData_Edge.cxx:671
double Tolerance() const
Returns edge tolerance.
Definition: ModelData_Edge.cxx:664
ModelData_Curve Curve(double &theFirstParameter, double &theLastParameter) const
Returns edge 3D curve and its limits.
Definition: ModelData_Edge.cxx:632
Defines a topological face.
Definition: ModelData_Face.hxx:32
ModelData_Surface Surface() const
Returns underlying surface.
Definition: ModelData_Face.cxx:253
Element visitor with empty implementation.
Definition: ModelData_Model.hxx:113
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
ModelData_ShapeType Type() const
Returns a shape type.
Definition: ModelData_Shape.cxx:358
ModelData_ShapeOrientation Orientation() const
Returns orientation flag.
Definition: ModelData_Shape.cxx:392
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines topological vertex.
Definition: ModelData_Vertex.hxx:31
ModelData_Point Point() const
Returns a 3D point this vertex resides at.
Definition: ModelData_Vertex.cxx:68
double Tolerance() const
Returns vertex tolerance.
Definition: ModelData_Vertex.cxx:89
Defines a connected set of edges.
Definition: ModelData_Wire.hxx:31

surface_explorer.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _SurfaceExplorer_HeaderFile
#define _SurfaceExplorer_HeaderFile
#include <base_explorer.hxx>
#include <cadex/ModelData_Axis3Placement.hxx>
#include <cadex/ModelData_BezierSurface.hxx>
#include <cadex/ModelData_BSplineSurface.hxx>
#include <cadex/ModelData_ConicalSurface.hxx>
#include <cadex/ModelData_CylindricalSurface.hxx>
#include <cadex/ModelData_OffsetSurface.hxx>
#include <cadex/ModelData_Plane.hxx>
#include <cadex/ModelData_RectangularTrimmedSurface.hxx>
#include <cadex/ModelData_SphericalSurface.hxx>
#include <cadex/ModelData_SurfaceOfLinearExtrusion.hxx>
#include <cadex/ModelData_SurfaceOfRevolution.hxx>
#include <cadex/ModelData_ToroidalSurface.hxx>
using namespace std;
using namespace cadex;
class SurfaceExplorer : public BaseExplorer
{
public:
static void PrintSurface (const ModelData_Surface& theSurface)
{
switch (theSurface.Type()) {
case ModelData_ST_Plane:
PrintPlane (static_cast <const ModelData_Plane&> (theSurface));
break;
case ModelData_ST_Cylinder:
PrintCylinder (static_cast <const ModelData_CylindricalSurface&> (theSurface));
break;
case ModelData_ST_Cone:
PrintCone (static_cast <const ModelData_ConicalSurface&> (theSurface));
break;
case ModelData_ST_Sphere:
PrintSphere (static_cast <const ModelData_SphericalSurface&> (theSurface));
break;
case ModelData_ST_Torus:
PrintTorus (static_cast <const ModelData_ToroidalSurface&> (theSurface));
break;
case ModelData_ST_LinearExtrusion:
PrintLinearExtrusion (static_cast <const ModelData_SurfaceOfLinearExtrusion&> (theSurface));
break;
case ModelData_ST_Revolution:
PrintRevolution (static_cast <const ModelData_SurfaceOfRevolution&> (theSurface));
break;
case ModelData_ST_Bezier:
PrintBezierSurface (static_cast <const ModelData_BezierSurface&> (theSurface));
break;
case ModelData_ST_BSpline:
PrintBSplineSurface (static_cast <const ModelData_BSplineSurface&> (theSurface));
break;
case ModelData_ST_Offset:
PrintOffsetSurface (static_cast <const ModelData_OffsetSurface&> (theSurface));
break;
case ModelData_ST_Trimmed:
PrintTrimmedSurface (static_cast <const ModelData_RectangularTrimmedSurface&> (theSurface));
break;
default:
break;
}
}
static void PrintPlane (const ModelData_Plane& thePlane)
{
PrintName ("Plane");
PrintElementary (thePlane);
}
static void PrintCylinder (const ModelData_CylindricalSurface& theCylinder)
{
PrintName ("Cylinder");
double aRadius = theCylinder.Radius();
PrintElementary (theCylinder);
PrintParameter ("Radius", aRadius);
}
static void PrintCone (const ModelData_ConicalSurface& theCone)
{
PrintName ("Cone");
double aRadius = theCone.Radius();
double aSemiAngle = theCone.SemiAngle();
PrintElementary (theCone);
PrintParameter ("Radius", aRadius);
PrintParameter ("Semi-Angle", aSemiAngle);
}
static void PrintSphere (const ModelData_SphericalSurface& theSphere)
{
PrintName ("Sphere");
double aRadius = theSphere.Radius();
PrintElementary (theSphere);
PrintParameter ("Radius", aRadius);
}
static void PrintTorus (const ModelData_ToroidalSurface& theTorus)
{
PrintName ("Torus");
double aMajorRadius = theTorus.MajorRadius();
double aMinorRadius = theTorus.MinorRadius();
PrintElementary (theTorus);
PrintParameter ("Major Radius", aMajorRadius);
PrintParameter ("Minor Radius", aMinorRadius);
}
static void PrintLinearExtrusion (const ModelData_SurfaceOfLinearExtrusion& theLinearExtrusion)
{
PrintName ("Linear Extrusion Surface");
const ModelData_Direction& aDir = theLinearExtrusion.Direction();
PrintDomain (theLinearExtrusion);
PrintParameter ("Direction", aDir.Coord());
cout << "Basis Curve = ";
CurveExplorer::PrintCurveInfo (theLinearExtrusion.BasisCurve());
}
static void PrintRevolution (const ModelData_SurfaceOfRevolution& theRevolution)
{
PrintName ("Revolution Surface");
const ModelData_Direction& aDir = theRevolution.Direction();
const ModelData_Point& aLoc = theRevolution.Location();
PrintDomain (theRevolution);
PrintParameter ("Location", aLoc.Coord());
PrintParameter ("Direction", aDir.Coord());
cout << "Basis Curve = ";
CurveExplorer::PrintCurveInfo (theRevolution.BasisCurve());
}
static void PrintBezierSurface (const ModelData_BezierSurface& theBezier)
{
PrintName ("Bezier Surface");
int aUDegree = theBezier.UDegree();
int aVDegree = theBezier.VDegree();
int aNumberOfUPoles = theBezier.NumberOfUPoles();
int aNumberOfVPoles = theBezier.NumberOfVPoles();
PrintDomain (theBezier);
PrintParameter ("U Degree", aUDegree);
PrintParameter ("V Degree", aVDegree);
PrintParameter ("Number Of U Poles", aNumberOfUPoles);
PrintParameter ("Number Of V Poles", aNumberOfVPoles);
PrintCollection ("Poles", aNumberOfUPoles, aNumberOfVPoles, [&](int i, int j)
{
auto aPole = theBezier.Pole (i, j);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfUPoles, aNumberOfVPoles, [&](int i, int j)
{
double aWeight = theBezier.Weight (i, j);
PrintParameter (aWeight);
});
}
static void PrintBSplineSurface (const ModelData_BSplineSurface& theBSpline)
{
PrintName ("BSpline Surface");
int aUDegree = theBSpline.UDegree();
int aVDegree = theBSpline.VDegree();
int aNumberOfUKnots = theBSpline.NumberOfUKnots();
int aNumberOfVKnots = theBSpline.NumberOfVKnots();
int aNumberOfUPoles = theBSpline.NumberOfUPoles();
int aNumberOfVPoles = theBSpline.NumberOfVPoles();
PrintDomain (theBSpline);
PrintParameter ("U Degree", aUDegree);
PrintParameter ("V Degree", aVDegree);
PrintParameter ("Number Of U Knots", aNumberOfUKnots);
PrintParameter ("Number Of V Knots", aNumberOfVKnots);
PrintParameter ("Number Of U Poles", aNumberOfUPoles);
PrintParameter ("Number Of V Poles", aNumberOfVPoles);
PrintCollection ("U Knots", aNumberOfUKnots, [&](int i)
{
double aKnot = theBSpline.UKnot (i);
PrintParameter (aKnot);
});
PrintCollection ("V Knots", aNumberOfVKnots, [&](int i)
{
double aKnot = theBSpline.VKnot (i);
PrintParameter (aKnot);
});
PrintCollection ("U Multiplicities", aNumberOfUKnots, [&](int i)
{
int aUMultiplicity = theBSpline.UMultiplicity (i);
PrintParameter (aUMultiplicity);
});
PrintCollection ("V Multiplicities", aNumberOfVKnots, [&](int i)
{
int aVMultiplicity = theBSpline.VMultiplicity (i);
PrintParameter (aVMultiplicity);
});
PrintCollection ("Poles", aNumberOfUPoles, aNumberOfVPoles, [&](int i, int j)
{
auto aPole = theBSpline.Pole (i, j);
PrintParameter (aPole.Coord());
});
PrintCollection ("Weights", aNumberOfUPoles, aNumberOfVPoles, [&](int i, int j)
{
double aWeight = theBSpline.Weight (i, j);
PrintParameter (aWeight);
});
}
static void PrintOffsetSurface (const ModelData_OffsetSurface& theOffset)
{
PrintName ("Offset Surface");
double anOffset = theOffset.Offset();
PrintDomain (theOffset);
PrintParameter ("Offset", anOffset);
cout << "Basis Surface = ";
PrintSurface (theOffset.BasisSurface());
}
static void PrintTrimmedSurface (const ModelData_RectangularTrimmedSurface& theTrimmed)
{
PrintName ("Trimmed Surface");
PrintDomain (theTrimmed);
cout << "Basis Surface = ";
PrintSurface (theTrimmed.BasisSurface());
}
};
#endif
Defines a B-Spline surface.
Definition: ModelData_BSplineSurface.hxx:34
ModelData_Point Pole(int theUIndex, int theVIndex) const
Returns a pole value.
Definition: ModelData_BSplineSurface.cxx:380
double UKnot(int theUIndex) const
Returns a U-knot value.
Definition: ModelData_BSplineSurface.cxx:250
double Weight(int theUIndex, int theVIndex) const
Returns a weight value.
Definition: ModelData_BSplineSurface.cxx:434
int UMultiplicity(int theUIndex) const
Returns a U knot multiplicity.
Definition: ModelData_BSplineSurface.cxx:314
int NumberOfUKnots() const
Returns number of unique U-knots.
Definition: ModelData_BSplineSurface.cxx:219
int VDegree() const
Returns V-degree.
Definition: ModelData_BSplineSurface.cxx:212
int UDegree() const
Returns U-degree.
Definition: ModelData_BSplineSurface.cxx:205
int NumberOfUPoles() const
Returns number of U-poles.
Definition: ModelData_BSplineSurface.cxx:233
double VKnot(int theVIndex) const
Returns a V-knot value.
Definition: ModelData_BSplineSurface.cxx:261
int NumberOfVKnots() const
Returns number of unique V-knots.
Definition: ModelData_BSplineSurface.cxx:226
int NumberOfVPoles() const
Returns number of V-poles.
Definition: ModelData_BSplineSurface.cxx:240
int VMultiplicity(int theVIndex) const
Returns a V knot multiplicity.
Definition: ModelData_BSplineSurface.cxx:326
Defines a Bezier surface.
Definition: ModelData_BezierSurface.hxx:34
int NumberOfVPoles() const
Returns number of V-poles.
Definition: ModelData_BezierSurface.cxx:154
ModelData_Point Pole(const int theUIndex, const int theVIndex) const
Returns a pole value.
Definition: ModelData_BezierSurface.cxx:165
int VDegree() const
Returns degree.
Definition: ModelData_BezierSurface.cxx:138
int NumberOfUPoles() const
Returns number of U-poles.
Definition: ModelData_BezierSurface.cxx:146
int UDegree() const
Returns degree.
Definition: ModelData_BezierSurface.cxx:130
double Weight(const int theUIndex, const int theVIndex) const
Returns a weight value.
Definition: ModelData_BezierSurface.cxx:203
Defines a conical surface.
Definition: ModelData_ConicalSurface.hxx:32
double Radius() const
Returns reference radius.
Definition: ModelData_ConicalSurface.cxx:108
double SemiAngle() const
Returns semi-angle.
Definition: ModelData_ConicalSurface.cxx:101
Defines a cylindrical surface.
Definition: ModelData_CylindricalSurface.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_CylindricalSurface.cxx:85
Defines an offset surface.
Definition: ModelData_OffsetSurface.hxx:32
double Offset() const
Returns offset value.
Definition: ModelData_OffsetSurface.cxx:106
ModelData_Surface BasisSurface() const
Returns basis surface.
Definition: ModelData_OffsetSurface.cxx:99
Defines a plane.
Definition: ModelData_Plane.hxx:32
Defines an explicitly trimmed surface.
Definition: ModelData_RectangularTrimmedSurface.hxx:32
ModelData_Surface BasisSurface() const
Returns basis surface.
Definition: ModelData_RectangularTrimmedSurface.cxx:88
Defines a spherical surface.
Definition: ModelData_SphericalSurface.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_SphericalSurface.cxx:89
ModelData_SurfaceType Type() const
Returns a surface type.
Definition: ModelData_Surface.cxx:195
Defines a surface of linear extrusion.
Definition: ModelData_SurfaceOfLinearExtrusion.hxx:34
Defines a surface of revolution.
Definition: ModelData_SurfaceOfRevolution.hxx:35
const ModelData_Point & Location() const
Returns an origin point of a rotation axis.
Definition: ModelData_SurfaceOfRevolution.cxx:103
Defines a toroidal surface.
Definition: ModelData_ToroidalSurface.hxx:32
double MinorRadius() const
Returns minor radius.
Definition: ModelData_ToroidalSurface.cxx:99
double MajorRadius() const
Returns major radius.
Definition: ModelData_ToroidalSurface.cxx:90

main.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include <shape_explorer.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/LicenseManager_Activate.h>
#include "../../cadex_license.cxx"
int main (int argc, char* argv[])
{
auto aKey = LicenseKey::Value();
// Activate the license (aKey must be defined in cadex_license.cxx)
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
// Get the input
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the XML file to be read" << endl;
return 1;
}
const char* aSource = argv[1];
ModelData_Model aModel;
if (!ModelData_ModelReader().Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
// Explore B-Rep representation of model parts
ShapeExplorer aVisitor;
aModel.Accept (aVisitor);
return 0;
}