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.

Import Section

Import TopoShape

Include header file

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

Read file/data stream

Read from iges/igs file

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

Read from data stream

std::ifstream ist("./data/test.iges");

Import Label

Include header file

#include <iges/IgesIO.hpp>

Read file/data stream

Read from iges/igs file

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

Read from data stream

std::ifstream ist("./data/test.iges");

Export Section

Before introducing export functions, first explain the configuration parameters.

Configuration 1:

  • FACE_MODE: Scattered face mode 【format=0】
  • BREP_MODE: Brep mode 【format=1】

Configuration 2: WriteAF (export Label) attribute delegation strategy 【Only effective when Configuration 1 is FACE_MODE】

  • WRITE_ATTR_DEFAULT: Default strategy configuration (currently equivalent to WRITE_ATTR_SELF_HIGH_PRI)
  • WRITE_ATTR_NOT_INHERIT: Parent topology attributes do not affect child topology
  • WRITE_ATTR_SELF_HIGH_PRI: Child topology high priority 【Prefer to use own attributes】
  • WRITE_ATTR_SELF_LOW_PRI: Parent topology high priority 【Prefer to use parent topology attributes】

Note:

  • WRITE_ATTR_SELF_HIGH_PRI and WRITE_ATTR_SELF_LOW_PRI configurations only take effect when attribute delegation conflicts occur; when there is no conflict, they automatically inherit parent topology attributes.
  • Bitwise OR is only used for behaviors between different configurations, such as: FACE_MODE | WRITE_ATTR_NOT_INHERIT

Export TopoShape

Include header file

#include <iges/IgesIO.hpp>
#include<iostream>

Export to file/data stream

Export to iges/igs file

// Make a box
AMCAX::Point3 p1(0., 0., 0.);
AMCAX::Point3 p2(2., 2., 2.);
// Set output path
std::string filePath = "./iges/Outpute_TopoToFile.iges";
// Write a TopoShape to file
//【default format config = FACE_MODE】
bool ret = AMCAX::IGES::IgesIO::Write(ts, filePath);
if (!ret)
{
std::cout << "error" << std::endl;
}
//【BREP_MODE】
if (!ret)
{
std::cout << "error" << std::endl;
}
#define BREP_MODE
The BREP_MODE macro is only applicable to the IGES::IgesIO::Write interface. It uses the 186 entities...
Definition IGESConfig.hpp:20
static AMCAX_API bool Write(const TopoShape &s, const std::string &file, int format=FACE_MODE|WRITE_ATTR_DEFAULT)
Write a TopoShape to file.
Class of making a box.
Definition MakeBox.hpp:20
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Export to data stream

// Make a box
AMCAX::Point3 p1(0., 0., 0.);
AMCAX::Point3 p2(2., 2., 2.);
// Write a TopoShape to ostream
std::ostringstream os_t;
//【default format config = FACE_MODE】
bool ret = AMCAX::IGES::IgesIO::Write(ts, os_t);
if (!ret)
{
std::cout << "error" << std::endl;
}
//【BREP_MODE】
if (!ret)
{
std::cout << "error" << std::endl;
}

Export Label

Include header file

#include <iges/IgesIO.hpp>
#include<iostream>
The classes of WithAttrModeling.

Export to file/data stream

Export to file

// Create box label
auto makeBox = WithAttr<MakeBox>(1.0, 1.0, 1.0);
makeBox.Build();
AMCAX::Label lb = makeBox.GetResultLabel();
// Set output path
std::string filePath = "./iges/Outpute_LabelToFile.iges";
// Write a Label to file
//【default format config = FACE_MODE | WRITE_ATTR_DEFAULT】
bool ret = AMCAX::IGES::IgesIO::Write(lb, filePath);
if (!ret)
{
std::cout << "error" << std::endl;
}
//【WRITE_ATTR_NOT_INHERIT Mode】
if (!ret)
{
std::cout << "error" << std::endl;
}
//【WRITE_ATTR_SELF_LOW_PRI Mode】
if (!ret)
{
std::cout << "error" << std::endl;
}
#define FACE_MODE
The FACE_MODE macro is only applicable to the IGES::IgesIO::Write interface. and BREP_MODE represent ...
Definition IGESConfig.hpp:14
#define WRITE_ATTR_SELF_LOW_PRI
This configurations are only applicable to IGES::IgesIO::Write(Label&, Face_Mode| XXXX) form,...
Definition IGESConfig.hpp:48
#define WRITE_ATTR_NOT_INHERIT
This configurations are only applicable to IGES::IgesIO::Write(Label&, Face_Mode| XXXX) form,...
Definition IGESConfig.hpp:34

Export to data stream

// Create box label
auto makeBox = WithAttr<MakeBox>(1.0, 1.0, 1.0);
makeBox.Build();
AMCAX::Label lb = makeBox.GetResultLabel();
// Write a Label to ostream
std::ostringstream os_l;
//【default format config = FACE_MODE | WRITE_ATTR_DEFAULT】
bool ret = AMCAX::IGES::IgesIO::Write(lb, os_l);
if (!ret)
{
std::cout << "error" << std::endl;
}
//【WRITE_ATTR_NOT_INHERIT Mode】
if (!ret)
{
std::cout << "error" << std::endl;
}
//【WRITE_ATTR_SELF_LOW_PRI Mode】
if (!ret)
{
std::cout << "error" << std::endl;
}