Constraint Mesh with javascript

Discuss all 3DReshaper related issues here.
Post Reply
RemiBeauvais
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Fri Aug 10, 2018 7:22 am
Full Name: Rémi Beauvais
Company Details: Ville de Fribourg
Company Position Title: Collaborateur technique spécialiste 3D
Country: Switzerland
Linkedin Profile: Yes

Constraint Mesh with javascript

Post by RemiBeauvais » Fri Aug 10, 2018 8:53 am

Hello Fellow laserscan enthousiasts and 3DReshaper users!

I am currently working on a DTM optimization using breaklines and Lidar datas.
The idea is to generate separate meshes contain in 3D polygons perimeters (as seen below).
picture1.jpg
The best tool to do that is "Constraint Meshing" in 3DReshaper. Only problem with that is that it require to manually select corresponding point clouds and lines to get the best result.
If you select everything at a time, you will get a bit disappointing result :
picture5.jpg
Since I work with thousands of polygons and thousands of point clouds, I want to do this automatically with javascript.
Hopefully there are two functions which perform the same operation as Constraint Meshing : SPoly.ConstraintMesh2D and SPoly.ConstraintMesh3D.

Here is my script so far (I keep it simple so it's only working for one couple now) :
// Name of the polygon
var namepoly = '64';
// Name of the cloud
var namecloud = '64';

//select cloud
var result = SCloud.FromName( namecloud );
var cloud = result[0];

if (result.length != 1)
throw new Error('Cloud import failed');

//select lines
var lines = SMultiline.FromName( namepoly );


//perform Meshing operation
result = SPoly.ConstraintMesh2D(cloud,lines,SVector.New(0,0,1),0,1);

// Check meshing success
if ( result.ErrorCode != 0 )
throw new Error('Cloud meshing failed.');

// show result
result.PolyTbl[0].SetName(namecloud);
result.PolyTbl[0].AddToDoc();


The result is NOT what I wanted :

before :
picture2.jpg
after :
picture3.jpg
with the built-in function (the result I want to have):
picture4.jpg

It's seems that the lines are not taken into account...
I don't understand what I'm doing wrong. Any of you have any idea where is the problem?


I tried to use the other constraint mesh function, like this :

result = SPoly.ConstraintMesh3D(cloud,lines,0,1);

It's not working at all, the javascript show this error, which is very strange :
Line 18: TypeError: Result of expression 'SPoly.ConstraintMesh3D' [undefined] is not a function.


Any help would be great!
By the way, I'm currently using this version of 3DReshaper : 3DReshaper17,0,08,24617 - (64 bits) - Build on 2017 June, 16
You do not have the required permissions to view the files attached to this post.

User avatar
gilles_3Dreshaper
Forum Supporter
Forum Supporter
Posts: 134
Joined: Mon Dec 08, 2014 11:41 am
Full Name: Gilles Monnier
Company Details: Technodigit
Company Position Title: 3DReshaper Manager
Country: France
Linkedin Profile: Yes

Re: Constraint Mesh with javascript

Post by gilles_3Dreshaper » Fri Aug 10, 2018 10:53 am

Hi Remi,

to start with, I can explain why the ConstraintMesh3D returns an error.
The reason is it is not a static function. You should call it on an existing mesh!

Anyhow, you are right, for your purpose, the function you need to call is the ConstraintMesh2D.
And I would have called the ConstraintMesh2D function with 0 as a final argument, to keep only the triangles behind inside the contour.

I agree that the documentation is not very clear on that point.

Let me know how that goes,
Gilles
3DReshaper Manager
http://www.3dreshaper.com

RemiBeauvais
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Fri Aug 10, 2018 7:22 am
Full Name: Rémi Beauvais
Company Details: Ville de Fribourg
Company Position Title: Collaborateur technique spécialiste 3D
Country: Switzerland
Linkedin Profile: Yes

Re: Constraint Mesh with javascript

Post by RemiBeauvais » Fri Aug 10, 2018 1:15 pm

Hello Gilles,

It's amazing that someone from 3DReshaper is available and ready to answer even in a non official forum! Thanks for your dedication!

Actually, I found the main issue! It was that I had a SSetMultiline instead of a SMultiline as an input. :? :? :?
Hum hum hum... my bad!

The SPoly.ConstraintMesh2D is only working with Multiline and not an array of them. Since this function did not return any error, I took me a while to understand the problem... Just a little "Chain/Group Polylines" and it's a multiline again!

Before :
picture7.jpg
And now the result I wanted :
picture8.jpg
As you explained, by using directly a mesh, the "ConstraintMesh3D" is working :
//using the result of the ConstraintMesh2D which is a mesh
mesh = result.PolyTbl[0];
//transforming the mesh with the ConstraintMesh3D
mesh.ConstraintMesh3D(cloud,lines,0,0);
//Make the mesh appear
mesh.SetName(namecloud);
mesh.AddToDoc();

Now I'm back on tracks to build my 3D city!

Thanks again for your expertise, it helps me narrow down the problem!
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “3DReshaper”