@bitbybit-dev/occt
Version:
Bit By Bit Developers CAD algorithms using OpenCascade Technology kernel. Run in Node and in Browser.
78 lines (77 loc) • 2.46 kB
JavaScript
/**
* OCCT Assembly Query for querying assembly document data.
*
* This class provides methods for:
* - Querying document parts and assemblies
* - Getting shapes from labels
* - Retrieving label colors and transforms
* - Getting detailed label info
* - Retrieving full assembly hierarchy
*
* All methods use document handles directly (no global document storage).
*/
export class OCCTAssemblyQuery {
constructor(occ, och) {
this.occ = occ;
this.och = och;
}
/**
* Get all parts and assemblies in a document.
*
* @param inputs - Document handle
* @returns Array of part/assembly info objects
*/
getDocumentParts(inputs) {
const jsonString = this.occ.GetDocumentPartsFromDoc(inputs.document);
return JSON.parse(jsonString);
}
/**
* Get a shape from a label in a document.
*
* @param inputs - Document handle and label
* @returns The shape at the given label
*/
getShapeFromLabel(inputs) {
return this.occ.GetShapeFromDocLabel(inputs.document, inputs.label);
}
/**
* Get the color of a label in a document.
*
* @param inputs - Document handle and label
* @returns Color info including hasColor, r, g, b, a
*/
getLabelColor(inputs) {
const jsonString = this.occ.GetDocLabelColor(inputs.document, inputs.label);
return JSON.parse(jsonString);
}
/**
* Get the transformation of an instance label.
*
* @param inputs - Document handle and label
* @returns Transform info including matrix, translation, quaternion, scale
*/
getLabelTransform(inputs) {
const jsonString = this.occ.GetDocLabelTransform(inputs.document, inputs.label);
return JSON.parse(jsonString);
}
/**
* Get detailed info about a label.
*
* @param inputs - Document handle and label
* @returns Detailed label info including type, flags, children
*/
getLabelInfo(inputs) {
const jsonString = this.occ.GetDocLabelInfo(inputs.document, inputs.label);
return JSON.parse(jsonString);
}
/**
* Get full assembly hierarchy as structured data.
*
* @param inputs - Document handle
* @returns Assembly hierarchy with all nodes
*/
getAssemblyHierarchy(inputs) {
const jsonString = this.occ.GetDocAssemblyHierarchy(inputs.document);
return JSON.parse(jsonString);
}
}