node-occ
node-occ copied to clipboard
How do I move a face?
Tried using code like following, but does not seem to work. Any suggestions appreciated.
//Added moveFace method on Solid
NAN_METHOD(Solid::moveFace)
{
NanScope();
Solid* pThis = ObjectWrap::Unwrap<Solid>(args.This());
Face* pf = NULL;
if(!extractArg(args[0],pf)) {
NanThrowError("invalid arguments moveFace : expecting <FACE>");
NanReturnUndefined();
}
gp_Trsf transformation;
double x=0,y=0,z=0;
ReadPoint(args[1],&x,&y,&z);
transformation.SetTranslation(gp_Vec(x,y,z));
//This does not work
//Event BRepTools_ReShape does not work.
pf->face().Move(transformation);
NanReturnUndefined();
}
You can get a translated copy of an existing shape using the translate method.
var aPnt1 = [0, 0.0, 0];
var aPnt2 = [10, 1.0, 0];
var aPnt3 = [10, 9.0, 0];
var aPnt4 = [0, 10.0, 0];
var segment1 = new occ.Edge().createLine(aPnt1, aPnt2);
var segment2 = new occ.Edge().createLine(aPnt2, aPnt3);
var segment3 = new occ.Edge().createLine(aPnt3, aPnt4);
var segment4 = new occ.Edge().createLine(aPnt4, aPnt1);
var wire = new occ.Wire(segment1, segment2, segment3, segment4);
var face = new occ.Face(wire);
var translated_face = face.translate([10,20,30]);
But may be this is not what you want to achieve ?