- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
SIMPLE_IND EXED_MESH_ MENEGER
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-11-2010 12:10 AM - last edited on 03-11-2010 04:28 AM
I don't know how to access mesh data when using SIMPLE_INDEXED_MESH_MANAGER
Re: SIMPLE_IND EXED_MESH_ MENEGER
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-11-2010 07:13 AM - last edited on 03-11-2010 07:14 AM
Hi
Please see http://doc.spatial.com/index.php/Faceter_Operation
By the way: using the faceter is a lot simpler if you don't try to write you own mesh manager. Unless you have specialized requirements which cannot be met using the INDEXED_MESH_MANAGER, we recommend using that.
hope this helps
Eric Zenk
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-15-2010 01:55 AM
I need to get points and vectors as simple x,y,z arrays that could be directly fed to OpenGL (also triangle indices). The only manager that provides data in this format is SIMPLE_MESH_MANAGER, am I wrong?
My problem is, I don't get how to get reference to the SIMPLE_MESH after facetting.
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-15-2010 06:54 AM
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-15-2010 07:06 AM
#include "af_api.hxx"
#include "fct_util.hxx"
#include "face.hxx"
void get_triangles_from_faceted_face( FACE* f , float*& points, int*& triangles
//, double*& normals // uncomment if you need normals too
)
{
SEQUENTIAL_MESH* mesh = GetSequentialMesh( f );
int num_nodes = mesh->get_num_node();
int num_polynodes = mesh->get_num_polynode();
int num_polygons = mesh->get_num_polygon();
points = ACIS_NEW float[ 3*num_nodes ]; // three position coordinates for each point in the mesh.
//normals = ACIS_NEW double[ 3*num_nodes]; //uncomment if you need normals.
triangles = ACIS_NEW int[ 3*num_polygons]; // three indices into points array for each triangle
MESH_NODE meshNode;
if (mesh->get_first_node(meshNode))
{
for (int ii = 0; ii < num_nodes; ii++)
{
const SPAposition& pos = mesh->get_position(meshNode);
points[ii*3+0] = (float)pos.x();
points[ii*3+1] = (float)pos.y();
points[ii*3+2] = (float)pos.z();
// uncomment the following double commented lines if you need normals too.
////const SPAunit_vector& norm = mesh->get_normal( meshNode );
////normals[ii*3+0] = norm.x();
////normals[ii*3+1] = norm.y();
////normals[ii*3+2] = norm.z();
logical ok = mesh->get_next_node(meshNode);
}
}
MESH_POLYGON meshPolygon;
logical ok = mesh->get_first_polygon(meshPolygon);
int polyIdx = 0;
int current_array_index = 0;
while (polyIdx < num_polygons)
{
polyIdx++;
// grab the polygon and find out how many vertices it has.
int numNodes = mesh->get_num_polynode(meshPolygon);
if( numNodes != 3 )
continue;
// The next "numNodes" entries are indices into the "points" array.
MESH_POLYNODE meshPolynode;
logical first_polynode_ok = mesh->get_first_polynode(meshPolygon, meshPolynode);
for (int jj = 0; jj < numNodes ; jj++ )
{
int index = mesh->get_node_index(meshPolynode);
triangles[current_array_index++] = index;
}
logical next_polynode_ok =mesh->get_next_polygon(meshPolygon);
}
}
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-17-2010 07:49 AM
My problem is, I'm working with huge meshes with millions of elements. Using INDEXED_MESH_MANAGER means that data is stored 2 times, once in a heap and once in my own arrays. It also takes about significant (in my context) time for the mentioned amount of data to be converted into arrays.
Wouldn't using SIMPLE_INDEXED_MESH and SIMPLE_INDEXED_MESH_MANAGER avoid mentioned overhead?
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-25-2010 10:30 AM
The SIMPLE_INDEXED_MESH_MANAGER is a very old piece of code, but still viable for reasons you stated. It is missing information that can be used for texture mapping and color strips/fans, but it is rather memory efficient. I would access this mesh by wrapping the mesh manager, then expose the data through a public method or attach the mesh to the FACE. Since you whould facet the whole body in one API call, accessing the mesh through attributes on th FACEs may be easier. Try the following...
class MY_MESH_MANAGER : public SIMPLE_INDEXED_MESH_MANAGER
{
public:
virtual void end_mesh_output( ENTITY *entity, ENTITY *app_ref, ENTITY *format)
{
SIMPLE_INDEXED_MESH_MANAGER::end_mesh_output( entity, app_ref, format );
if ( mesh )
{
af_update( entity, MY_MESH_APP_ID, MY_MESH_USER_ID, mesh );
}
}
};
Then access the data as follows...
MESH * face_mesh = NULL;
af_query( (ENTITY*)face, MY_MESH_APP_ID, MY_MESH_USER_ID, face_mesh );
if ( face_mesh != NULL )
{
SIMPLE_INDEXED_MESH * mesh = (SIMPLE_INDEXED_MESH*) face_mesh;
// For every facet (or polygon) ...
for ( int polygon_index = 0; polygon_index < mesh->get_npoly(); polygon_index++ )
{
for ( int polynode_index = 0; polynode_index < mesh->get_npolynode( polygon_index ); polynode_index++ )
{
const SPAposition & pos = mesh->get_position( mesh->get_polynode( polygon_index, polynode_index ) );
}
}
}
What you may need is your own mesh manager. You could store data as floats instead of doubles, store exactly what you need as you want it stored, or feed data directly to your renderer, or whatever. Please watch this posting, and I will try to reply with a sample mesh manager you can use and modify to your liking.
Re: SIMPLE_IND EXED_MESH_ MENEGER
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-25-2010 03:20 PM
Here is a link to an example of creating your own mesh manager.
http://doc.spatial.com/index.php/Mesh_Manager_Exam
You may modify this example code to your needs. For instance, you may not want the mesh attached as an attribute to faces, or you may need paramtric UV values for texture mapping.
FYI: There are three types of meshes that the ACIS Faceter produces:
1. Coordinate polygon. Very simple, it returns coordinates and other info for every facet. This means that it repeats coordnates
2. Indexed mesh. This is more efficient than coordinate polygon, and is what the example demonstrates.
3. Global mesh. This is one mesh for the whole body, not just individual faces. Nodes are shared between faces.

