AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Data Exchange

Currently, Jiushao Kernel supports import/export of BREP files, mesh file reading/writing (OBJ, STL), import/export of IGES/IGS files, and import/export of STEP files.

BREP File Import/Export

Import

AMCAX::OCCTIO::OCCTTool::Read provides the functionality to import BREP files.

AMCAX::OCCTIO::OCCTTool::Read(shape, "./data/box.brep");
static AMCAX_API bool Read(TopoShape &s, std::istream &is)
Read a shape from a stream.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15

Export

AMCAX::OCCTIO::OCCTTool::Write provides the functionality to export BREP files.

// Construct a box
AMCAX::Point3 p1(-5.0, -5.0, 0.0);// diagonal corner points
AMCAX::Point3 p2(5.0, 5.0, 3.0);// diagonal corner points
// Write a shape to a file
AMCAX::OCCTIO::OCCTTool::Write(box, "./box.brep");
Class of making a box.
Definition MakeBox.hpp:20
static AMCAX_API bool Write(const TopoShape &s, std::ostream &os, int format=3)
Write a shape to a stream.
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Mesh File Reading/Writing

OBJ

AMCAX::Meshing::Mesh::OBJReader provides the functionality to read OBJ files; AMCAX::Meshing::Mesh::OBJWriter provides the functionality to write OBJ files.

// Read
obj_reader.read("./data/cow.obj", io_options);
// Write
std::streamsize precision = 10;// Precision of floating point numbers
obj_writer.write("cow1.obj", io_options, precision);
Options about pre-described properties in mesh IO.
Definition IOOptions.hpp:19
Read triangle soup from an OBJ file.
Definition OBJReader.hpp:38
AMCAXMeshing_API bool read(const std::string &filename, IOOptions &opt)
Read triangle soup from the file. results will be stored in member variables of reader,...
Write triangle soup to an OBJ file.
Definition OBJWriter.hpp:38
AMCAXMeshing_API bool write(const std::string &filename, IOOptions &opt, std::streamsize precision)
Write triangle soup to file with given options and precison.

STL

AMCAX::Meshing::Mesh::STLReader provides the functionality to import STL files; AMCAX::Meshing::Mesh::STLWriter provides the functionality to export STL files.

// Read
stl_reader.read("./data/cow.stl", io_options);
// Write
std::streamsize precision = 10;// Precision of floating point numbers
stl_writer.write("cow2.stl", io_options, precision);
Read triangle soup from an STL file.
Definition STLReader.hpp:33
AMCAXMeshing_API bool read(const std::string &filename, IOOptions &opt)
Read triangle soup from the file.
Write mesh to an STL file.
Definition STLWriter.hpp:33
AMCAXMeshing_API bool write(const std::string &filename, IOOptions &opt, std::streamsize precision=6)
Write mesh to file with given options and precison.

IGES/IGS Files

Import

AMCAX::IGES::IgesIO::Read provides the functionality to import IGES/IGS files.

Import TopoShape

Supports importing wires, faces, and solids.

Import 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.

Import from data stream

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

Import Label

Import from iges/igs file

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

Import from data stream

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

Export

AMCAX::IGES::IgesIO::Write provides the functionality to export IGES/IGS files.
Before introducing the export functionality, let's explain the configuration parameters.

Configuration 1:

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

Configuration 2: Attribute inheritance strategy for WriteAF (export Label) 【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 【Prioritize using own attributes】
  • WRITE_ATTR_SELF_LOW_PRI: Parent topology high priority 【Prioritize using parent topology attributes】

Note:

  • WRITE_ATTR_SELF_HIGH_PRI and WRITE_ATTR_SELF_LOW_PRI configurations only take effect when attribute inheritance conflicts occur; when there is no conflict, parent topology attributes are automatically inherited.
  • Bitwise OR is only used for combining different configurations, such as: FACE_MODE | WRITE_ATTR_NOT_INHERIT

Export TopoShape

Supports exporting points, wires, faces, and solids as discrete geometric entities.

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.

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

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;
}

STEP Files

Import

Supports importing part bodies, names, text descriptions, positions, orientations, and simple assembly information.
To be down.

Export

Supports exporting part bodies, names, positions, orientations, colors, and other information.
To be down.