Re: [gts-general] Cutting a model up...
Brought to you by:
popinet
|
From: Paul <pau...@st...> - 2001-08-20 13:26:58
|
I can't store the pointers properly and I get errors... here is my code
8<------------------------------------------------------------
static void cut_model( GtsTriangle *t, vector<GtsTriangle*> tv )
{
GtsPoint * p1, * p2, * p3;
gts_triangle_vertices (t,
(GtsVertex **) &p1,
(GtsVertex **) &p2,
(GtsVertex **) &p3);
if (p1->y < 0 || p2->y < 0 || p3->y < 0) {
tv.push_back(t);
cout << tv.size() << " " << p1->y << " " << p2->y <<
" " << p3->y << endl;
}
}
void SimpleWindow::cut()
{
vector<GtsTriangle*> tri_vec;
tri_vec.push_back(NULL);
gts_surface_foreach_face(s, (GtsFunc) cut_model, &tri_vec);
for (int i = 1; i < (int)tri_vec.size(); i++) {
gts_object_destroy(GTS_OBJECT(tri_vec[i]));
}
tri_vec.clear();
}
------------------------------------------------------------>8
Is there any problem in sending a STL vector? It causes a memory
leak. Also in case you are wondering why I put in the NULL at the start,
I did it because the data seems to get corrupted on the first element.
Does anyone know what is happening? Or have any suggestion as to what I
should store the values in?
Thanks for all the help so far and in advance for this problem,
Paul
PS A message to Stephane:
The CVS does not contain gts_surface_foreach_face_remove() in surface.c
Also, do you know when the next will be (roughly)?
On Mon, 20 Aug 2001, Stephane Popinet wrote:
> Hi Paul,
>
> > I didn't know whether I should be receiving a GtsTriangle or a GtsFace, so
> > I tried both but the program fails on the assert - keep_faces ==
> > FALSE. This is set in the GTS function gts_surface_foreach_face.
>
> Ok, what you do is allright in principle but the function
> gts_surface_foreach_face() does not allow you to destroy faces of the
> surface you are currently traversing (it confuses the hash table used
> to store the faces of a given surface, hence the test on keep_faces in
> gts_surface_foreach_face).
>
> In the next release (due soon), there will be a
> gts_surface_foreach_face_remove() function which will allow you to do that.
>
> Go and have a look in the CVS repository in the surface.c file you
> will find this new function.
>
> > I have
> > also tried passing an array to store all the triangles in that I want to
> > delete and then deleteing them afterwards but this doesn't seem to work
> > either.
>
> Hmm, this is more surprising, this approach should work, you probably
> want to check that there isn't another problem in your code.
>
> > So any pointers as to what I should be doing would be very helpful, but
> > here are a few questions...
> >
> > (1) can I just delete a GtsTriangle, and
> > (2) does it update the information associated with the surrounding
> > triangles?
>
> Yes, it does.
>
> > (3) can I just delete a GtsFace, and
> > (4) does it update the information associated with the surrounding
> > triangles?
>
> Yes, in the same way.
>
> > (5) which should I use - and what is the difference?
>
> There is no difference. A GtsFace is also (via inheritance) a
> GtsTriangle, if you call the gts_object_destroy() function on these
> objects, there destroy() methods will be called (recursively if
> necessary), if this is a GtsFace, its destroy() method will be called
> and update the parent GtsSurface, then the destroy() method for
> GtsTriangle will be called (because a GtsFace is also a GtsTriangle)
> which will update the GtsEdge used by this GtsTriangle, and so on
> until the destroy() method for a GtsObject is called which will free
> the memory associated with this object.
>
> > (6) is there something better to use than gts_surface_foreach_face to get
> > the information I need.
>
> See my point above.
>
> Hope this helps,
>
> Stephane
>
>
> _______________________________________________
> Gts-general mailing list
> Gts...@li...
> http://lists.sourceforge.net/lists/listinfo/gts-general
>
|