31 #include "SimDiscrete.h"
40 : _size_type(0), _size_val(0.), _fangle(0), _shrtRatio(5) {
42 if ( logfile) Sim_logOn( logfile);
46 Sim_registerKey(
"cen002 surface 20060331 0 mTcaTqnWjLIUId26P29r3w==");
47 Sim_registerKey(
"cen002 discrete 20060331 0 8VnUzbSAnldsPdfPbpWFVw==");
63 Sim_unregisterAllKeys();
70 std::vector<const COM::Pane*> panes;
75 int numVerts = panes[0]->size_of_nodes();
76 int numElems = panes[0]->size_of_elements();
79 std::vector<const COM::Connectivity*> elems;
80 panes[0]->elements( elems);
82 elems[0]->element_type()==COM::Connectivity::TRI3,
83 "Window must be a serial one");
85 pMesh mesh = M_new(0,0);
87 std::vector<int> elemTypes(numElems, 5 );
89 int *tris =
const_cast<int*
>(elems[0]->pointer());
90 std::vector<int> tris_vec( numElems*3,0);
91 for (
int i=0;
i<numElems*3; ++
i)
92 tris_vec[
i] = tris[
i]-1;
94 double *coors =
const_cast<double*
>(panes[0]->coordinates());
95 M_importFromData( mesh, numVerts, coors, numElems, &elemTypes[0],
96 &tris_vec[0], NULL, NULL);
103 pMesh mesh = (pMesh)m;
106 std::vector<COM::Pane*> panes;
107 outwin->panes(panes);
109 int pid = panes[0]->id();
112 COM::Attribute *coor = panes[0]->attribute(
COM::COM_NC);
113 outwin->set_size( coor->name(), pid, M_numVertices(mesh));
116 outwin->resize_array( coor, (
void**)&coors);
118 VIter vIter = M_vertexIter(mesh);
121 for (
int i=0; (vertex=VIter_next(vIter)); ++
i) {
122 EN_setID((pEntity)vertex,
i+1);
123 V_coord(vertex, &coors[3*
i]);
128 std::vector<COM::Connectivity*> elems;
129 panes[0]->elements( elems);
131 outwin->set_size( elems[0]->name(), pid, M_numFaces(mesh));
134 outwin->resize_array( elems[0], (
void**)&tris);
136 FIter fIter = M_faceIter(mesh);
138 for (
int i=0; (face = FIter_next(fIter)); ++
i){
139 pPList fVerts = F_vertices(face,1);
141 for(j=0; j < 3; j++){
142 vertex = (pVertex)PList_item( fVerts, j);
143 tris[3*
i+
j] = EN_id((pEntity)vertex);
151 double lave,
double fangle) {
153 std::cout <<
"Setting average edge length to " << lave << std::endl;
154 std::cout <<
"Setting feature angle to " << fangle << std::endl;
162 COM::Window *outwin = mesh_out->window();
165 wm->serialize_window( outwin);
168 pDiscreteModel model = DM_createFromMesh( mesh,
true);
172 double angleRadian =
_fangle/180*3.14159265358979;
174 DM_findEdgesByFaceNormals( model, angleRadian);
175 DM_eliminateDanglingEdges( model);
177 DM_completeTopology( model);
180 pMesh newMesh = DM_getMeshCopy( model);
181 pACase newCase = MS_newMeshCase(model);
186 pModelMember mdomain = GM_domain(model);
191 DM_modifySurfaceMesh( newMesh, newCase ,0,0,0,0,
198 GM_release((SGModel *) model);
#define PROP_END_NAMESPACE
#define PROP_BEGIN_NAMESPACE
#define COM_assertion_msg(EX, msg)
void set_fangle(double fangle)
static int instances
This file provides a wrapper to invoke GeomSim from Simmetrix to remesh a surface mesh...
Remesher_Simmetrix(const char *logfile=NULL)
Initialize the remesher.
virtual void remesh_serial(Manifold *wm, COM::Attribute *mesh_out, double lave, double fangle)
SURF::Window_manifold_2 Manifold
void set_global_mesh_size(int type, double val)
static T_VertexSet * face
virtual ~Remesher_Simmetrix()
Finalize the remesher.
void set_short_ratio(double r)
void simmesh_to_window(void *mesh, COM::Window *outwin)
void * window_to_simmesh(const COM::Window *outwin)