MeshObjectData Class Reference

#include <MeshObjectData.h>

Collaboration diagram for MeshObjectData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MeshObjectData (const char *name=NULL)
virtual ~MeshObjectData (void)
void init (const char *name=NULL)
void free (void)
void free_value (void)
void clear (void)
void setName (const char *str)
char * getName (void)
void setAffineTrans (AffineTrans< double > a)
void delAffineTrans (void)
bool addData (FacetBaseData *facetdata, MaterialParam *param)
bool addData (Vector< double > *vct, Vector< double > *nrm, UVMap< double > *map, int vnum, MaterialParam *param, bool useBrep)
bool addData (TriPolyData *tridata, int tnum, int fnum, MaterialParam *param, bool useBrep)
 処理するFACETを選択できる
void joinData (MeshObjectData *&data)
 data は削除される.
void setMaterialParam (MaterialParam param, int num=-1)
bool importTriData (TriPolyData *tridata, int tnum, int fnum=-1)
bool importTriData (Vector< double > *vct, Vector< double > *nrm, UVMap< double > *map, int vnum)
bool addNode (FacetBaseData *facetdata, const char *name)
bool addNode (const char *name, bool useBrep)

Public Attributes

Buffer data_name
 データ名
int ttl_index
 インデックスの総数(実質的データ数)
int ttl_vertex
 頂点データの総数.
int ttl_texcrd
 テクスチャ画像の座標総数.通常は ttl_vertexと同じ値.
int num_node
 テクスチャー単位の面の数(Node の数)
int num_vcount
 1ポリゴン あたりの頂点数.現在は 3のみサポート
MeshObjectNodenodelist
 ノード(テクスチャー単位の面)のデータのリストへのポインタ
MeshObjectNodeendplist
 ノード(テクスチャー単位の面)のデータのリストの最後のデータへのポインタ
AffineTrans< double > * affine_trans
 アフィン変換.ここで使用するのは,shift, rotate, scale(size) のみ

Private Attributes

int num_import
 入力データの数
Vector< double > * impvtx_value
 入力された頂点データ.3個で 1ポリゴンを表現.法線方向は右手順.
Vector< double > * impnrm_value
 入力された頂点の法線ベクトル.impvtx_value と対応.
UVMap< double > * impmap_value
 入力されたテクスチャ座標データ.impvtx_value と対応.

Detailed Description

Definition at line 106 of file MeshObjectData.h.


Constructor & Destructor Documentation

MeshObjectData ( const char *  name = NULL  )  [inline]

Definition at line 130 of file MeshObjectData.h.

References MeshObjectData::init().

00130 { init(name);}

Here is the call graph for this function:

virtual ~MeshObjectData ( void   )  [inline, virtual]

Definition at line 131 of file MeshObjectData.h.

00131 {}


Member Function Documentation

bool addData ( TriPolyData tridata,
int  tnum,
int  fnum,
MaterialParam param,
bool  useBrep 
)

TriPolyData (三角ポリゴンデータ) を単位としてデータを追加し,MeshObjectのデータを作成する.
num を指定すると,指定されたFACET(面)のデータのみが追加される.これにより面ごとのデータ構造を形成することができる.

Parameters:
tridata 追加対象の三角ポリゴンデータへのポインタ
tnum 三角ポリゴンデータの数
fnum 追加するデータのFACETの番号(選択的に追加する場合に指定する).-1以下なら全てのFACETデータを追加する.
param マテリアル用パラメータへのポインタ
useBrep BREPを使用して頂点を配置する.速度は遅くなるが,頂点数(データ量)は減る.

Definition at line 545 of file MeshObjectData.cpp.

References MeshObjectData::addNode(), MeshObjectData::endplist, MaterialParam::getAdditionalName(), MeshObjectData::importTriData(), MeshObjectNode::setFacetNo(), and MeshObjectNode::setMaterialParam().

00546 {
00547     bool ret = importTriData(tridata, tnum, fnum);
00548     if (ret) {
00549         char* name = NULL;
00550         if (param!=NULL) name = param->getAdditionalName();
00551         ret = addNode(name, useBrep);
00552     }
00553     //
00554     if (ret) {
00555         if (fnum>=0)     endplist->setFacetNo(fnum);
00556         if (param!=NULL) endplist->setMaterialParam(*param);
00557     }
00558 
00559     return ret;
00560 }

Here is the call graph for this function:

bool addData ( Vector< double > *  vct,
Vector< double > *  nrm,
UVMap< double > *  map,
int  vnum,
MaterialParam param,
bool  useBrep 
)

bool MeshObjectData::addData(Vector<double>* vct, Vector<double>* nrm, UVMap<double>* map, int vnum, MaterialParam* param, bool useBrep)

指定した頂点ベクトルのデータを追加し,MeshObjectのデータ(通常はFACET単位)を作成する.
vct, nrm, map は3個づつ組になって三角ポリゴンを表す.従って vnumは必ず3の倍数になるはず.
FACETを選択的に処理することはできない.予め FACETに分解しておくか,FACETが1つのみの場合に使用する.

その後 MeshObjectNode::computeVertexDirect() または MeshObjectNode::computeVertexByBREP() を使用して頂点データの計算を行う.

Parameters:
vct 追加対象の頂点座標データへのポインタ
nrm 追加対象の頂点の法線ベクトルのデータへのポインタ
map 追加対象のテクスチャ座標のデータへのポインタ
vnum データ数
param マテリアル用パラメータへのポインタ
useBrep BREPを使用して頂点を配置する.速度は遅くなるが,頂点数(データ量)は減る.

Definition at line 519 of file MeshObjectData.cpp.

References MeshObjectData::addNode(), MeshObjectData::endplist, MaterialParam::getAdditionalName(), MeshObjectData::importTriData(), and MeshObjectNode::setMaterialParam().

00520 {
00521     bool ret = importTriData(vct, nrm, map, vnum);
00522     if (ret) {
00523         char* name = NULL;
00524         if (param!=NULL) name = param->getAdditionalName();
00525         ret = addNode(name, useBrep);
00526     }
00527 
00528     if (ret && param!=NULL) endplist->setMaterialParam(*param);
00529 
00530     return ret;
00531 }

Here is the call graph for this function:

bool addData ( FacetBaseData facetdata,
MaterialParam param 
)

bool MeshObjectData::addData(FacetBaseData* facetdata, MaterialParam* param)

インデックス化された FacetBaseDataを importTriData()を介さずに,直接 Nodeデータに書き込む.
FACETを選択的に処理することはできない.予め FACETに分解しておくか,FACETが1つのみの場合に使用する.

この後 MeshObjectNode::computeVertexDirect() を使用して頂点データの計算を行う.

Definition at line 490 of file MeshObjectData.cpp.

References MeshObjectData::addNode(), MeshObjectData::endplist, MaterialParam::getAdditionalName(), and MeshObjectNode::setMaterialParam().

00491 {
00492     char* name = NULL;
00493     if (param!=NULL) name = param->getAdditionalName();
00494 
00495     bool ret = addNode(facetdata, name);
00496     if (ret && param!=NULL) endplist->setMaterialParam(*param);
00497 
00498     return ret;
00499 }

Here is the call graph for this function:

bool addNode ( const char *  name,
bool  useBrep 
)
Parameters:
name ノードの名前
useBrep BREPを使用して頂点を配置する.速度は遅くなるが,頂点数(データ量)は減る.

Definition at line 732 of file MeshObjectData.cpp.

References jbxl::AddMeshObjectNode(), MeshObjectNode::computeVertexByBREP(), MeshObjectNode::computeVertexDirect(), MeshObjectData::endplist, jbxl::freeNull(), MeshObjectData::impmap_value, MeshObjectData::impnrm_value, MeshObjectData::impvtx_value, MeshObjectData::nodelist, MeshObjectData::num_import, MeshObjectNode::num_index, MeshObjectData::num_node, MeshObjectNode::num_texcrd, MeshObjectData::num_vcount, MeshObjectNode::num_vertex, MeshObjectNode::setMaterialID(), MeshObjectData::ttl_index, MeshObjectData::ttl_texcrd, and MeshObjectData::ttl_vertex.

00733 {
00734     bool ret = false;
00735     if (impvtx_value==NULL) return ret;
00736 
00737     MeshObjectNode* node = new MeshObjectNode();
00738     if (node==NULL) return ret;
00739     node->setMaterialID(name);
00740 
00741     if (useBrep) {
00742         ret = node->computeVertexByBREP(impvtx_value, impnrm_value, impmap_value, num_import, num_vcount);
00743     }
00744     else {
00745         ret = node->computeVertexDirect(impvtx_value, impnrm_value, impmap_value, num_import, num_vcount);
00746     }
00747 
00748     if (ret) {
00749         if (nodelist==NULL) nodelist = endplist = node;
00750         else                endplist = AddMeshObjectNode(endplist, node);
00751         num_node++;
00752         ttl_index  += node->num_index;
00753         ttl_vertex += node->num_vertex;
00754         ttl_texcrd += node->num_texcrd;
00755     }
00756     //
00757     freeNull(impvtx_value);
00758     freeNull(impnrm_value);
00759     freeNull(impmap_value);
00760 
00761     return ret;
00762 }

Here is the call graph for this function:

bool addNode ( FacetBaseData facetdata,
const char *  name 
)

Definition at line 703 of file MeshObjectData.cpp.

References jbxl::AddMeshObjectNode(), MeshObjectNode::computeVertexDirect(), MeshObjectData::endplist, MeshObjectData::nodelist, MeshObjectNode::num_index, MeshObjectData::num_node, MeshObjectNode::num_texcrd, MeshObjectNode::num_vertex, MeshObjectNode::setMaterialID(), MeshObjectData::ttl_index, MeshObjectData::ttl_texcrd, and MeshObjectData::ttl_vertex.

Referenced by MeshObjectData::addData().

00704 {
00705     bool ret = false;
00706 
00707     MeshObjectNode* node = new MeshObjectNode();
00708     if (node==NULL) return ret;
00709     node->setMaterialID(name);
00710     
00711     ret = node->computeVertexDirect(facetdata);
00712 
00713     if (ret) {
00714         if (nodelist==NULL) nodelist = endplist = node;
00715         else                endplist = AddMeshObjectNode(endplist, node);
00716         num_node++;
00717         ttl_index  += node->num_index;
00718         ttl_vertex += node->num_vertex;
00719         ttl_texcrd += node->num_texcrd;
00720     }
00721 
00722     return ret;
00723 }

Here is the call graph for this function:

Here is the caller graph for this function:

void clear ( void   ) 

Definition at line 474 of file MeshObjectData.cpp.

References MeshObjectData::free(), and MeshObjectData::init().

00475 {
00476     this->free();
00477     init();
00478 }

Here is the call graph for this function:

void delAffineTrans ( void   )  [inline]

Definition at line 143 of file MeshObjectData.h.

References MeshObjectData::affine_trans, and jbxl::freeAffineTrans().

Referenced by MeshObjectData::free(), and MeshObjectData::setAffineTrans().

Here is the call graph for this function:

Here is the caller graph for this function:

void free ( void   ) 

Definition at line 452 of file MeshObjectData.cpp.

References MeshObjectData::data_name, MeshObjectData::delAffineTrans(), MeshObjectData::endplist, free_Buffer(), MeshObjectData::free_value(), jbxl::freeMeshObjectList(), and MeshObjectData::nodelist.

Referenced by MeshObjectData::clear(), and jbxl::freeMeshObjectData().

00453 {
00454     free_Buffer(&data_name);
00455     free_value();
00456 
00457     delAffineTrans();
00458 
00459     freeMeshObjectList(nodelist);
00460     nodelist = endplist = NULL;
00461 }

Here is the call graph for this function:

Here is the caller graph for this function:

void free_value ( void   ) 

Definition at line 465 of file MeshObjectData.cpp.

References jbxl::freeNull(), MeshObjectData::impmap_value, MeshObjectData::impnrm_value, and MeshObjectData::impvtx_value.

Referenced by MeshObjectData::free(), and MeshObjectData::importTriData().

00466 {
00467     freeNull(impvtx_value);
00468     freeNull(impnrm_value);
00469     freeNull(impmap_value);
00470 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* getName ( void   )  [inline]

Definition at line 140 of file MeshObjectData.h.

References _tochar, Buffer::buf, and MeshObjectData::data_name.

00140 { return _tochar(data_name.buf);}

bool importTriData ( Vector< double > *  vct,
Vector< double > *  nrm,
UVMap< double > *  map,
int  vnum 
)

指定した頂点ベクトルのデータを取り込む.
vct, nrm, map は3個づつ組になって三角ポリゴンを表す.従って vnumは必ず3の倍数になるはず.

Parameters:
vct 頂点座標データへのポインタ
nrm 頂点の法線ベクトルのデータへのポインタ
map テクスチャ座標のデータへのポインタ
vnum データ数

Definition at line 573 of file MeshObjectData.cpp.

References MeshObjectData::free_value(), jbxl::freeNull(), MeshObjectData::impmap_value, MeshObjectData::impnrm_value, MeshObjectData::impvtx_value, MeshObjectData::num_import, and MeshObjectData::num_vcount.

00574 {
00575     if (vct==NULL) return false;
00576     //
00577     free_value();
00578 
00579     int lsize = sizeof(Vector<double>)*vnum;
00580     impvtx_value = (Vector<double>*)malloc(lsize);
00581     if (impvtx_value!=NULL) memcpy(impvtx_value, vct, lsize);
00582     else return false;
00583 
00584     if (nrm!=NULL) {
00585         impnrm_value = (Vector<double>*)malloc(lsize);
00586         if (impnrm_value!=NULL) {
00587             memcpy(impnrm_value, nrm, lsize);
00588         }
00589         else {
00590             freeNull(impvtx_value);
00591             return false;
00592         }
00593     }
00594 
00595     if (map!=NULL) {
00596         int msize = sizeof(UVMap<double>)*vnum;
00597         impmap_value = (UVMap<double>*)malloc(msize);
00598         if (impmap_value!=NULL) {
00599             memcpy(impmap_value, map, msize);
00600         }
00601         else {
00602             freeNull(impvtx_value);
00603             freeNull(impnrm_value);
00604             return false;
00605         }
00606     }
00607 
00608     num_vcount = 3;
00609     num_import = vnum;
00610 
00611     return true;
00612 }

Here is the call graph for this function:

bool importTriData ( TriPolyData tridata,
int  tnum,
int  fnum = -1 
)

TriPolyData (三角ポリゴンデータ) を単位としてデータを取り込む.
num を指定すると,指定されたFACET(面)のデータのみが追加される.これにより面ごとのデータ構造を形成することができる.

Parameters:
tridata 三角ポリゴンデータへのポインタ
tnum 三角ポリゴンデータの数
fnum 追加するデータのFACETの番号(選択的に追加する番号).-1以下なら全てのFACETデータを追加する.

Definition at line 624 of file MeshObjectData.cpp.

References MeshObjectData::free_value(), jbxl::freeNull(), MeshObjectData::impmap_value, MeshObjectData::impnrm_value, MeshObjectData::impvtx_value, TriPolyData::normal, MeshObjectData::num_import, MeshObjectData::num_vcount, TriPolyData::texcrd, and TriPolyData::vertex.

Referenced by MeshObjectData::addData().

00625 {
00626     if (tridata==NULL) return false;
00627 
00628     free_value();
00629 
00630     int pnum = 0;
00631     if (fnum>=0) {
00632         for (int i=0; i<tnum; i++) {
00633             if (tridata[i].facetNum==fnum) pnum++;
00634         }
00635         if (pnum==0) return false;
00636     }
00637     else pnum = tnum;
00638 
00639     int vnum  = pnum*3;
00640     int lsize = sizeof(Vector<double>)*vnum;
00641 
00642     impvtx_value = (Vector<double>*)malloc(lsize);
00643     if (impvtx_value!=NULL) {
00644         for (int i=0, n=0; i<tnum; i++) {
00645             if (tridata[i].facetNum==fnum || fnum<0) {
00646                 impvtx_value[n*3]   = tridata[i].vertex[0];
00647                 impvtx_value[n*3+1] = tridata[i].vertex[1];
00648                 impvtx_value[n*3+2] = tridata[i].vertex[2];
00649                 n++;
00650             }
00651         }
00652     }
00653     else return false;
00654 
00655     impnrm_value = NULL;
00656     if (tridata[0].has_normal) {
00657         impnrm_value = (Vector<double>*)malloc(lsize);
00658         if (impnrm_value!=NULL) {
00659             for (int i=0, n=0; i<tnum; i++) {
00660                 if (tridata[i].facetNum==fnum || fnum<0) {
00661                     impnrm_value[n*3]   = tridata[i].normal[0];
00662                     impnrm_value[n*3+1] = tridata[i].normal[1];
00663                     impnrm_value[n*3+2] = tridata[i].normal[2];
00664                     n++;
00665                 }
00666             }
00667         }
00668         else {
00669             freeNull(impvtx_value);
00670             return false;
00671         }
00672     }
00673 
00674     impmap_value = NULL;
00675     if (tridata[0].has_texcrd) {
00676         int msize = sizeof(UVMap<double>)*vnum;
00677         impmap_value = (UVMap<double>*)malloc(msize);
00678         if (impmap_value!=NULL) {
00679             for (int i=0, n=0; i<tnum; i++) {
00680                 if (tridata[i].facetNum==fnum || fnum<0) {
00681                     impmap_value[n*3]   = tridata[i].texcrd[0];
00682                     impmap_value[n*3+1] = tridata[i].texcrd[1];
00683                     impmap_value[n*3+2] = tridata[i].texcrd[2];
00684                     n++;
00685                 }
00686             }
00687         }
00688         else {
00689             freeNull(impvtx_value);
00690             freeNull(impnrm_value);
00691             return false;
00692         }
00693     }
00694 
00695     num_vcount = 3;
00696     num_import = vnum;
00697 
00698     return true;
00699 }

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( const char *  name = NULL  ) 
void joinData ( MeshObjectData *&  data  ) 

現在の形状データに,dataを面の一部(Node)として結合させる.アフィン変換のパラメータの違うものは結合できない.

Parameters:
data 結合するMeshObjectデータ.結合後データは削除される.データのアフィン変換は無視する.

Definition at line 805 of file MeshObjectData.cpp.

References MeshObjectData::affine_trans, MeshObjectData::endplist, jbxl::freeMeshObjectData(), MeshObjectNode::next, MeshObjectData::nodelist, MeshObjectData::num_node, MeshObjectNode::prev, MeshObjectData::setAffineTrans(), MeshObjectData::ttl_index, MeshObjectData::ttl_texcrd, and MeshObjectData::ttl_vertex.

00806 {
00807     if (data==NULL) return;
00808 
00809     ttl_index  += data->ttl_index;
00810     ttl_vertex += data->ttl_vertex;
00811     ttl_texcrd += data->ttl_texcrd;
00812     num_node   += data->num_node;
00813 
00814     if (endplist==NULL) {   //  最初のデータ
00815         setAffineTrans(*data->affine_trans);
00816         nodelist = data->nodelist;
00817         endplist = data->endplist;
00818     }
00819     else if (data->nodelist!=NULL) {
00820         endplist->next = data->nodelist;
00821         data->nodelist->prev = endplist;
00822         endplist = data->endplist;
00823     }
00824 
00825     data->nodelist = NULL;
00826     freeMeshObjectData(data);
00827 
00828     return;
00829 }

Here is the call graph for this function:

void setAffineTrans ( AffineTrans< double >  a  )  [inline]

Definition at line 142 of file MeshObjectData.h.

References MeshObjectData::affine_trans, MeshObjectData::delAffineTrans(), and AffineTrans< T >::dup().

Referenced by MeshObjectData::joinData().

00142 { delAffineTrans(); affine_trans=new AffineTrans<double>(); affine_trans->dup(a);}

Here is the call graph for this function:

Here is the caller graph for this function:

void setMaterialParam ( MaterialParam  param,
int  num = -1 
)

void MeshObjectData::setMaterialParam(MaterialParam param, int num)

Parameters:
param マテリアルパラメータ
num 0以上の場合は指定したノードに,-1の場合は先頭から順にノードにパラメータを設定する

Definition at line 772 of file MeshObjectData.cpp.

References MaterialParam::enable, MeshObjectNode::facet_no, MeshObjectNode::material_param, MeshObjectNode::next, MeshObjectData::nodelist, and MeshObjectNode::setMaterialParam().

00773 {
00774     MeshObjectNode* node = nodelist;
00775 
00776     if (num>=0) {
00777         while (node!=NULL) {
00778             if (node->facet_no==num) {
00779                 node->setMaterialParam(param);
00780                 return;
00781             }
00782             node = node->next;
00783         }
00784     }
00785     else {
00786         while (node!=NULL) {
00787             if (!node->material_param.enable) {
00788                 node->setMaterialParam(param);
00789                 return;
00790             }
00791             node = node->next;
00792         }
00793     }
00794 
00795     return;
00796 }

Here is the call graph for this function:

void setName ( const char *  str  )  [inline]

Definition at line 139 of file MeshObjectData.h.

References MeshObjectData::data_name, free_Buffer(), and make_Buffer_str.

Here is the call graph for this function:


Member Data Documentation

UVMap<double>* impmap_value [private]
Vector<double>* impnrm_value [private]
Vector<double>* impvtx_value [private]
int num_import [private]
int num_node
int ttl_index

The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Lib++ (for Windows) by  doxygen 1.6.1