AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
An Iges File Reading and Writing Example

Overview

This tutorial introduces the basic usage of the AMCAX IGES module.

Iges example 1

Import the header files

#include <iges/IgesIO.hpp>
Class of IgesIO.

Read TopoShape from iges/igs file

AMCAX::IGES::IgesIO::Read(ts, "./iges/test.igs");
static AMCAX_API bool Read(TopoShape &s, const std::string &file)
Read a shape from a file.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15

Write TopoShape to iges/igs file

AMCAX::IGES::IgesIO::Write(ts, "./iges/test1.igs");
static AMCAX_API bool Write(const TopoShape &s, const std::string &file, int format=0)
Write a file from TopoShape.

Appendix

The complete code of this sample is listed here:

#include <iges/IgesIO.hpp>
void test_all()
{
if (AMCAX::IGES::IgesIO::Read(ts, "./iges/test.igs"))
if (!ts.IsNull())
AMCAX::IGES::IgesIO::Write(ts, "./iges/test1.igs");
}
int main()
{
test_all();
}
AMCAX_API bool IsNull() const noexcept
Is the shape null.

Iges example 2

Import the header files

#include <iges/IgesIO.hpp>

Read Label from iges/igs file

Currently only supports parsing Name attributes with length <= 8 bytes. Any excess portion will be truncated.

AMCAX::IGES::IgesIO::Read(lb, "./data/test.igs");
The class of Label.
Definition Label.hpp:27

Also supports input data streams.

std::ifstream file("./iges/test.igs");

Appendix

The complete code of this sample is listed here:

#include <iges/IgesIO.hpp>
void demo1()
{
bool ret = AMCAX::IGES::IgesIO::Read(lb, "./iges/test.igs");
if (!ret || lb.IsNull())
{
std::cout << "File reading failed or the label is null" << std::endl;
}
}
void demo2(std::istream& ist)
{
bool ret = AMCAX::IGES::IgesIO::Read(lb, ist);
//then the label is the model read from the iStream
if (!ret || lb.IsNull())
{
std::cout << "File reading failed or the label is null" << std::endl;
}
}
int main()
{
demo1();
std::ifstream file("./iges/test.igs");
demo2(file);
}
AMCAX_API bool IsNull() const noexcept
Check if the label is null.