Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I move a face? #20

Open
skbizport opened this issue Jun 6, 2015 · 1 comment
Open

How do I move a face? #20

skbizport opened this issue Jun 6, 2015 · 1 comment

Comments

@skbizport
Copy link

skbizport commented Jun 6, 2015

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();
}
@erossignon
Copy link
Collaborator

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 ?

erossignon added a commit that referenced this issue Jan 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants