Difference between revisions of "User:Clouddrift/GSoC2014/Midterm"

From BRL-CAD
(Reorganize NMG Data Structure)
(Reorganize NMG Data Structure)
Line 1: Line 1:
 
== Reorganize NMG Data Structure ==
 
== Reorganize NMG Data Structure ==
  
The functionality of struct '''model''' and '''nmgregion''' are redundant to '''combination''' concept in BRL-CAD.
+
The functionality of struct '''model''' and '''nmgregion''' are top two level of old nmg structure. One '''model''' can include multiple '''nmgregion''', and one '''nmgregion''' can include multiple '''shell'''. We can have a brief view at following class defination.  
  
{{{{struct model
+
<pre>
 +
struct model
 
{
 
{
 
     uint32_t magic;
 
     uint32_t magic;
Line 9: Line 10:
 
     char *manifolds;            /**< @brief structure 1-3manifold table */
 
     char *manifolds;            /**< @brief structure 1-3manifold table */
 
     long index; /**< @brief struct # in this model */
 
     long index; /**< @brief struct # in this model */
     '''long maxindex; /**< @brief # of structs so far */'''
+
     long maxindex; /**< @brief # of structs so far */
 
};
 
};
}}}}
+
</pre>
  
 +
<pre>
 
struct nmgregion {
 
struct nmgregion {
 
     struct bu_list l; /**< @brief regions, in model's r_hd list */
 
     struct bu_list l; /**< @brief regions, in model's r_hd list */
Line 20: Line 22:
 
     long index; /**< @brief struct # in this model */
 
     long index; /**< @brief struct # in this model */
 
};
 
};
 +
</pre>
  
Then, change struct '''shell''' to fit new nmg philosophy.
+
In general, it's a classical representation for NMG structure. But they are  redundant in BRL-CAD. There have been similar concepts here called '''combination''' which can hold several primitives as a whole. So some reorganization is necessary that these two structs ('''model''' and '''nmgregion''') are replaced by the BRL-CAD inner combination to fit new NMG philosophy.
  
 
old:
 
old:
  
 +
<pre>
 
struct shell {
 
struct shell {
     '''struct bu_list l; /**< @brief shells, in region's s_hd list */'''
+
     struct bu_list l; /**< @brief shells, in region's s_hd list */
     '''struct nmgregion *r_p; /**< @brief owning region */'''
+
     struct nmgregion *r_p; /**< @brief owning region */
 
     struct shell_a *sa_p; /**< @brief attribs */
 
     struct shell_a *sa_p; /**< @brief attribs */
 
     struct bu_list fu_hd; /**< @brief list of face uses in shell */
 
     struct bu_list fu_hd; /**< @brief list of face uses in shell */
Line 35: Line 39:
 
     long index; /**< @brief struct # in this model */
 
     long index; /**< @brief struct # in this model */
 
};
 
};
 +
</pre>
  
 
new:
 
new:
 +
 +
<pre>
 
struct shell {
 
struct shell {
     '''uint32_t magic;'''
+
     uint32_t magic;
 
     struct shell_a *sa_p; /**< @brief attribs */
 
     struct shell_a *sa_p; /**< @brief attribs */
 
     struct bu_list fu_hd; /**< @brief list of face uses in shell */
 
     struct bu_list fu_hd; /**< @brief list of face uses in shell */
Line 44: Line 51:
 
     struct bu_list eu_hd; /**< @brief wire list (shell has wires) */
 
     struct bu_list eu_hd; /**< @brief wire list (shell has wires) */
 
     struct vertexuse *vu_p; /**< @brief internal ptr to single vertexuse */
 
     struct vertexuse *vu_p; /**< @brief internal ptr to single vertexuse */
     '''char *manifolds; /**< @brief structure 1-3manifold table */'''
+
     char *manifolds; /**< @brief structure 1-3manifold table */
 
     long index; /**< @brief struct # in this model */
 
     long index; /**< @brief struct # in this model */
     '''long maxindex; /**< @brief # of structs so far */'''
+
     long maxindex; /**< @brief # of structs so far */
 
};
 
};
 +
</pre>
  
 
== Fix Debugs ==
 
== Fix Debugs ==

Revision as of 02:44, 26 June 2014

Reorganize NMG Data Structure

The functionality of struct model and nmgregion are top two level of old nmg structure. One model can include multiple nmgregion, and one nmgregion can include multiple shell. We can have a brief view at following class defination.

struct model
{
    uint32_t magic;
    struct bu_list r_hd;	/**< @brief list of regions */
    char *manifolds;            /**< @brief structure 1-3manifold table */
    long index;			/**< @brief struct # in this model */
    long maxindex;		/**< @brief # of structs so far */
};
struct nmgregion {
    struct bu_list l;		/**< @brief regions, in model's r_hd list */
    struct model *m_p;		/**< @brief owning model */
    struct nmgregion_a *ra_p;	/**< @brief attributes */
    struct bu_list s_hd;	/**< @brief list of shells in region */
    long index;			/**< @brief struct # in this model */
};

In general, it's a classical representation for NMG structure. But they are redundant in BRL-CAD. There have been similar concepts here called combination which can hold several primitives as a whole. So some reorganization is necessary that these two structs (model and nmgregion) are replaced by the BRL-CAD inner combination to fit new NMG philosophy.

old:

struct shell {
    struct bu_list l;		/**< @brief shells, in region's s_hd list */
    struct nmgregion *r_p;	/**< @brief owning region */
    struct shell_a *sa_p;	/**< @brief attribs */
    struct bu_list fu_hd;	/**< @brief list of face uses in shell */
    struct bu_list lu_hd;	/**< @brief wire loopuses (edge groups) */
    struct bu_list eu_hd;	/**< @brief wire list (shell has wires) */
    struct vertexuse *vu_p;	/**< @brief internal ptr to single vertexuse */
    long index;			/**< @brief struct # in this model */
};

new:

struct shell {
    uint32_t magic;
    struct shell_a *sa_p;	/**< @brief attribs */
    struct bu_list fu_hd;	/**< @brief list of face uses in shell */
    struct bu_list lu_hd;	/**< @brief wire loopuses (edge groups) */
    struct bu_list eu_hd;	/**< @brief wire list (shell has wires) */
    struct vertexuse *vu_p;	/**< @brief internal ptr to single vertexuse */
    char *manifolds;		/**< @brief structure 1-3manifold table */
    long index;			/**< @brief struct # in this model */
    long maxindex;		/**< @brief # of structs so far */
};

Fix Debugs

Due to the change of core NMG data structure, thousands of compiling errors are coming. I spend most time in these weeks to fix and test them properly.

28 functions in raytrace.h are removed because they are no longer necessary. The detailed list is as following:

  • struct model *nmg_mmr(void);
  • struct nmgregion *nmg_mrsv(struct model *m);
  • int nmg_kr(struct nmgregion *r);
  • void nmg_km(struct model *m);
  • void nmg_region_a(struct nmgregion *r, const struct bn_tol *tol);
  • struct model *nmg_find_model(const uint32_t *magic_p);
  • struct vertex *nmg_find_pt_in_model(const struct model *m, point_t pt, struct bn_tol *tol);
  • void nmg_pr_m(const struct model *m);
  • void nmg_pr_r(const struct nmgregion *r, *h);
  • int nmg_find_outer_and_void_shells(struct nmgregion *r, bu_ptbl ***shells, struct bn_tol *tol);
  • fastf_t nmg_region_area(const struct nmgregion *r);
  • fastf_t nmg_model_area(const struct model *m);
  • struct model *nmg_mk_model_from_region(struct nmgregion *r, reindex);
  • int nmg_mv_shell_to_region(struct shell *s, nmgregion *r);
  • char *nmg_manifolds(struct model *m);
  • void nmg_r_to_vlist(struct bu_list *vhead, struct nmgregion *r, int poly_markers);
  • void nmg_m_to_vlist(struct bu_list *vhead, struct model *m, int poly_markers);
  • void nmg_pl_r(FILE *fp, const struct nmgregion *r);
  • void nmg_pl_m(FILE *fp, const struct model *m);
  • void nmg_vlblock_r(struct bn_vlblock *vbp, const struct nmgregion *r, int fancy);
  • void nmg_vlblock_m(struct bn_vlblock *vbp, const struct model *m, int fancy);
  • void nmg_vshell(const struct bu_list *hp, const struct nmgregion *r);
  • void nmg_vregion(const struct bu_list *hp, const struct model *m);
  • void nmg_vmodel(const struct model *m);
  • int nmg_ck_closed_region(const struct nmgregion *r, const struct bn_tol *tol);
  • void nmg_r_radial_check(const struct nmgregion *r, const struct bn_tol *tol);
  • void nmg_visit_region(struct nmgregion *r, const struct nmg_visit_handlers *htab, genptr_t state);
  • void nmg_visit_model(struct model *model, const struct nmg_visit_handlers *htab, genptr_t state);

Conclusion