gCAD3D 2.40
xa_mod.c File Reference

subModel-managment-functions without GUI More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include "../gui/gui_types.h"
#include "../ut/func_types.h"
#include "../ut/ut_geo.h"
#include "../ut/ut_memTab.h"
#include "../ut/ut_itmsh.h"
#include "../ut/ut_txt.h"
#include "../ut/ut_txfil.h"
#include "../ut/ut_txTab.h"
#include "../ut/ut_os.h"
#include "../ut/ut_cast.h"
#include "../db/ut_DB.h"
#include "../xa/xa_uid.h"
#include "../xa/xa_msg.h"
#include "../xa/xa_mem.h"
#include "../xa/xa_ed_mem.h"
#include "../xa/xa.h"

Functions

void Mod_chg_CB (char *modNam)
 
int Mod_ck_isMain ()
 
int Mod_mdbi_mdri (long ir)
 
int Mod_mNam_mdb (char *mNam, int *sSiz, int *typ, int imdb)
 
int Mod_mNam_mdr (char *mNam, int *sSiz, int *typ, long irMdl)
 
int Mod_m3_mdr (Mat_4x3 mat1, long irMdl)
 
int Mod_file2model (char *buf, FILE *fpi)
 
int Mod_init__ ()
 
int Mod_mkList (int mode)
 
int Mod_chg_x (char *modNam)
 
int Mod_chg_tit ()
 
int Mod_sav_ck (int mode)
 
int Mod_sav_cmp (char *fnM1, char *fnM2)
 
int Mod_sav__ (int iCompress, char *fnOut, int savActMdl)
 
int Mod_sav_i (int savActMdl)
 
int Mod_savSubBuf1 (char *modNam, int modSiz)
 
int Mod_sav2file_CB (char *fnam, char *dirNam)
 
int Mod_sav2file__ ()
 
int Mod_LoadSubmodel (char *fnam, char *dirNam)
 
int Mod_LoadFile__ ()
 
int Mod_sav_tmp ()
 
int Mod_init_path ()
 
int Mod_get_path (char *out_path, char *in_path)
 
int Mod_get_ftyp1 (char *fnam)
 
int Mod_get_typ1 (char *txbuf, char *cbuf)
 
int Mod_get_typ2 (char *txbuf)
 
int Mod_get_names ()
 
int Mod_sym_dump ()
 
int Mod_sym_dir__ (char *sym, char *dir, char *basDir)
 
int Mod_sym_get__ (char *symDir, char *absDir, char *fnam, char *inPath)
 
int Mod_fNam_sym (char *s2, char *s1)
 
int Mod_fNam_get (char *fn)
 
int Mod_fNam_set (char *fNam, int mode)
 
int Mod_sym_getAbs (char *absDir, char *symDir)
 
int Mod_sym_get1 (char *out_path, char *in_path, int imod)
 
int Mod_sym_get2 (char *out_sym, char *in_path, int imod)
 
int Mod_symOpen_set (char *sym, char *path)
 
int Mod_sym_del (char *sym)
 
int Mod_sym_add (char *sym, char *dir)
 
int Mod_kill__ ()
 
int Mod_load__ (int mode, char *filNam, int dbResiz)
 
int Mod_aload_prc (char *lBuf, int bufSiz, FILE *fpi)
 
int Mod_aload_sm (int mode, char *lBuf, int bufSiz, FILE *fpi)
 
int Mod_del1__ (char *smNam)
 
int Mod_load_allsm ()
 
int Mod_SM_add_file (char *smNam, char *fNam)
 
int Mod_load_sm (int mTyp, char *mnam)
 
int Mod_get_namAll ()
 
int Mod_get_namSub (int parNr, int iLev)
 
int Mod_get_namFil (char *fNam, int parNr, int iLev)
 
int Mod_get_namStore (char *cp, int parNr, int iLev)
 
int Mod_allmod_MS (double d1, double d2, double d3)
 
int Mod_safeName (char *outNam, char *inNam)
 
int Mod_fget_names_1 (TxtTab *mdlTab)
 
int Mod_fget_names_0 (char *mdlNam, TxtTab *mdlTab, TxtTab *surPtab, TxtTab *surMsh)
 
int Mod_fget_names__ (TxtTab *mdlTab, TxtTab *surPtab, TxtTab *surMsh)
 

Variables

Point WC_mod_ori
 der Model-Origin More...
 
int WC_modact_ind
 
int AP_src
 AP_SRC_MEM or AP_SRC_EDI. More...
 
ColRGB AP_defcol
 die DefaultColor des aktiven (sub)Model More...
 
int UI_InpMode
 
static ModelBasMod_father
 
static char sSecEnd [] ="SECTIONEND"
 

Detailed Description

subModel-managment-functions without GUI

=====================================================
List_functions_start:
Mod_load_all unused
Mod_load__ load native model
Mod_load_allsm load Models of mdb_dyn-Records;
Mod_load_sm load a subModel (ED_work_file / ED_Run)
Mod_SM_add_file add subModel from file
Mod_cre__ create new SubModel
Mod_cre_CB
Mod_ren__ rename Submodel
Mod_ren_CB
Mod_del__ delete Submodel
Mod_chg__ activate other Submodel
Mod_chg_CB load selected SubModel
Mod_chg_x activate internal subModel from modelname
Mod_m2s__ move Mainmodel > Submodel
Mod_m2s_CB
Mod_sav_ck save Model+Submodel -> File native; compare with last saved
Mod_sav_cmp compare <tmpDir>/Model mit <tmpDir>/Mod_in
Mod_sav__ save Model+Submodel -> File native
Mod_sav_i save Model+Submodels into tempDir as "Model" native. Intern
Mod_sav_tmp save the active Submodel AP_modact_nam -> TempFile
Mod_sav2file__ save the active Submodel AP_modact_nam -> permanent File
Mod_file2model save submodel > tmp/Model_<name>
Mod_savSubBuf1 save Submodel in Buffer1 + active Hidelist
Mod_LoadFile__ Model als Submodel laden
Mod_smNam_get get new subModelname from user
Mod_ck_isMain check if the active model is the mainmodel
Mod_sym_dir__ get symbolic-directory from any-directory
Mod_sym_get__ get symbolic-directory & absolute-path from filename
Mod_sym_get1 get path from symbol; resolv "symbol/fnam" or "fnam"
Mod_sym_get2 get symbol from path
Mod_sym_add register symbolic path
Mod_sym_del delete symbolic path
Mod_symOpen_set register symbolic path
Mod_get_path resolv "symbol/fnam" or "fnam"
Mod_sym_getAbs get abs.dir from symbolic-dir
Mod_fNam_sym get absolute-filename from symbolic-filename
Mod_fNam_get get AP_mod_dir,sym,fnam,ftyp from symbolic- or abs.filename
Mod_fNam_set get symbolic-filename or absolute-filename
Mod_sym_dump dump all symbolic directories
Mod_get_ftyp1 give Modeltyp from Filename
Mod_get_typ1 give modeltyp from definition Line and extract Modelname
Mod_get_typ2 give modeltyp from (complete) Modelname
Mod_get_names scan gesamten APT-Buffer nach Modelnames.
Mod_get_namStore save new BaseModel as mdb_dyn-Record
Mod_kill__ delete all tmp/Model_*
Mod_chg_tit display submodelname im Titlebar
Mod_mkList make list of all Submodels
DB_get_ModRef get referenceModel from refModelNr
Mod_mdbi_mdri get basicModelNr of refModelNr
Mod_m3_mdr get matrix of referenceModel
Mod_mNam_mdr get ModbasName from ModRefNr
Mod_mNam_mdb get ModbasName from basicModelNr
Mod_fget_names__ get lists of all subModels, PTAB-Surfs and MSH-Surfs
Mod_fget_names_0 get all subModels, PTAB-Surfs and MSH-Surfs from file
Mod_get_namAll scan rekursiv die SourceFiles aller basicModels;
Mod_get_namSub scan file of Model mb->mnam for Submodels; add Submodels
Mod_get_namFil scan File fNam and save all Submodelcalls as level iLev
Mod_allmod_MS in all subMods modify ModSiz
List_functions_end:
=====================================================
see also ../xa/xa_mod_gui.c Mod_*
SEE ALSO:
DB_get_ModRef get Ditto from Index
DB_get_ModBas returns ModelBas from its index
DB_get_ModNr get (basic-) ModelNr from Modelname
DB_list_ModBas Modelnames in korrekter Reihenfolge -> Datei
DB_mdlNam_iBas get the name of a basic-model from its basicModelNr
DB_mdlNam_iRef get Modelname from DB-index of the Modelreference

Function Documentation

void Mod_chg_CB ( char *  modNam)
* - load new active SubModel
* - set AP_modact_nam = new active Modelname
* - RUN
*
int Mod_ck_isMain ( )

Mod_ck_isMain check if the active model is the mainmodel retCode 0 subModel is active 1 the main-model is active

int Mod_mdbi_mdri ( long  ir)
int Mod_mNam_mdb ( char *  mNam,
int *  sSiz,
int *  typ,
int  imdb 
)
int Mod_mNam_mdr ( char *  mNam,
int *  sSiz,
int *  typ,
long  irMdl 
)
int Mod_m3_mdr ( Mat_4x3  mat1,
long  irMdl 
)

Mod_m3_mdr get matrix of referenceModel

int Mod_file2model ( char *  buf,
FILE *  fpi 
)
* save submodel > tmp/Model_<name>
* Input: buf="SECTION MODEL modelNam"
* copy all lines from file fpi into tmp/Model_<name>
* irc < 0 = Error;
*
int Mod_init__ ( )

Bei jedem Init und File/new:

  • clear all tmp/Model_*
  • set AP_modact_nam="" (main)
int Mod_mkList ( int  mode)

make list of all Submodels -> <baseDir>/tmp/Mod.lst mode = 0: mit "-main-" mode = 1: ohne "-main-" Mainmodel wird mit "-main-" in die Liste eingetragen !

int Mod_chg_x ( char *  modNam)

Mod_chg_x activate internal subModel from modelname new Submodelname selected;

  • load new active SubModel
  • set AP_modact_nam = new active Modelname
  • RUN
int Mod_chg_tit ( )

display submodelname im Titlebar

int Mod_sav_ck ( int  mode)
* Mod_sav_ck save Model+Submodel -> File native; compare with last saved
* test if model is modified;
* mode 0=init (copy Model -> Mod_in)
* 1=compare Model - Mod_in
* retCode: 0=files_not_different, -1=different_files (only for mode=1)
*
* When loading new Model, after saving modified model: copy -> Mod_in.
* Check modified: compare active Model <tmpDir>/Model with <tmpDir>/Mod_in
*
int Mod_sav_cmp ( char *  fnM1,
char *  fnM2 
)
* Mod_sav_cmp compare <tmpDir>/Model mit <tmpDir>/Mod_in
* RetCode: 0=files_not_different, 1=different_files
*
int Mod_sav__ ( int  iCompress,
char *  fnOut,
int  savActMdl 
)

Mod_sav__ save Model+Submodel -> File native Input: filNam outfilename absolute iCompress 0=do not compress; else compress. savActMdl 0=save active model, 1=do not save active model

int Mod_sav_i ( int  savActMdl)
* Mod_sav_i save Model+Submodels into tempDir as "Model" native
* Input:
* filNam outfilename absolute
* savActMdl 0=save active model, 1=do not save active model
*
* - savActMdl=0: save the active Submodel AP_modact_nam -> File
* - join all files tmp/Model_* into file tmp/Model
* - mainModel = tmp/Model_; subModels = tmp/Model_*
*
int Mod_savSubBuf1 ( char *  modNam,
int  modSiz 
)

save Submodel in Buffer1 + active Hidelist –> File tmp/Model_<modNam> used by Step-Import (schreibt mit UTF_add1_line –> UTF_FilBuf1) see also Grp_exp ..

int Mod_sav2file_CB ( char *  fnam,
char *  dirNam 
)
int Mod_sav2file__ ( )

save the active Submodel AP_modact_nam -> permanent File

int Mod_LoadSubmodel ( char *  fnam,
char *  dirNam 
)

Models/load Submodel from File does: AP_mod_dir = dirNam

int Mod_LoadFile__ ( )

Model als Submodel laden

int Mod_sav_tmp ( )
* save the active sub- or mainmodel AP_modact_nam -> TempFile
* AP_modact_nam = "" - mainmodel; else submodel
*
int Mod_init_path ( )
int Mod_get_path ( char *  out_path,
char *  in_path 
)
* Input:
* in_path pathSymbol/filename" or "filename"
* without Symbol: "<bas_dir>dat/filename".
* Output:
* out_path filename complete (Path + Filename + Filetyp).
* RetCod 0 = OK;
* -1 = Symbol_not_found
*
int Mod_get_ftyp1 ( char *  fnam)

Mod_get_ftyp1 give Modeltyp from Filename RetCod=fTyp (see AP_iftyp_ftyp)

int Mod_get_typ1 ( char *  txbuf,
char *  cbuf 
)

give typ from definition Line and extract (complete) Modelname –> txbuf Input: cbuf definitionLine; zB M20=CTLG "Profile/4x4_60" .. OutPut: RetCod: -1 = internal model MBTYP_INTERN -2 = catalog-model MBTYP_CATALOG -3 = Error

int Mod_get_typ2 ( char *  txbuf)

Mod_get_typ2 give typ from (complete) Modelname (internal or external!) (using filetype of modelname) -3 = Error -2 = catalog-model MBTYP_CATALOG -1 internal model MBTYP_INTERN // M1 = "Submodel1" 0 external/native MBTYP_EXTERN 1-9 external 10-19 Mockup Mtyp_WRL-Mtyp_WRL2 20-29 Image Mtyp_BMP-Mtyp_JPG

int Mod_get_names ( )
* scan gesamten APT-Buffer nach Modelnames.
* siehe ED_work_END - DYNAMIC_AREA abarbeiten,
*
int Mod_sym_dump ( )

Mod_sym_dump dump all symbolic directories

int Mod_sym_dir__ ( char *  sym,
char *  dir,
char *  basDir 
)
int Mod_sym_get__ ( char *  symDir,
char *  absDir,
char *  fnam,
char *  inPath 
)

Mod_sym_get__ get symbolic-directory & absolute-path from filename

int Mod_fNam_sym ( char *  s2,
char *  s1 
)
* Mod_fNam_sym get absolute-filename from symbolic-filename
* copy absolute filenames, else resolve symbolic-directory
* Input s1 symbolic-filename or absolute-filename
* Output s2 absolute-filename
* Retcod: 0 OK
* -1 filename not symbolic and not absolute.
*
int Mod_fNam_get ( char *  fn)
* Mod_fNam_get get sym,dir,fnam,ftyp from symbolic- or abs.filename
* Output:
* RetCod: 0=OK, -1=no-symDir, dir=path
*
int Mod_fNam_set ( char *  fNam,
int  mode 
)
int Mod_sym_getAbs ( char *  absDir,
char *  symDir 
)
* Mod_sym_getAbs get absoute-direcory from symbolic-directory
* symdir must be terminated with '/'
* Input:
* symDir: eg: "Data"
* Output:
* absDir: full path (from file xa/dir.lst) Size 128.
* RetCod
* >= 0 OK; path in out_path; Linenumber of symbol in path.
* -1 Symbol from in_path not found in file
*
int Mod_sym_get1 ( char *  out_path,
char *  in_path,
int  imod 
)
* get path from symbol
* see also Mod_sym_getAbs
* symdir must be terminated with '/'
* Input:
* in_path: "<symbol>/<filename>" eg: "Data/Niet1.dat"
* imod: 0=get 1=check(no Msg)
* Output:
* out_path: full path (from file xa/dir.lst) Size 256.
* filename not added; use Mod_get_path for path/filename
* RetCod
* >= 0 OK; path in out_path; Linenumber of symbol in path.
* -1 Symbol from in_path not found in file
*
int Mod_sym_get2 ( char *  out_sym,
char *  in_path,
int  imod 
)
* get symbol from path
* Input:
* in_path: der Pfad (mit "/" am Ende)
* imod: 0=get 1=check(no Msg)
* Output:
* out_sym: das zugehoerige Symbol (aus datei xa/dir.lst)
* filename not added; use Mod_get_path for path/filename
* RetCod 0 OK; symTxt in out_sym;
* -1 in_path not found in file
*
int Mod_symOpen_set ( char *  sym,
char *  path 
)

Mod_symOpen_set set symbolic path

int Mod_sym_del ( char *  sym)

Mod_sym_del delete symbolic path

int Mod_sym_add ( char *  sym,
char *  dir 
)
* Mod_sym_add register symbolic path in File cfg/dir.lst
* path comes from AP_mod_dir
*
int Mod_kill__ ( )
  • alle tmp/Model_* loeschen
  • alle tmp/*.tess loeschen

see also OS_file_delete OS_file_delGrp

int Mod_load__ ( int  mode,
char *  filNam,
int  dbResiz 
)
* Mod_load__ load native model
* Ein ganz neues Model als MainModel oeffnen;
* - alle tmp/Model_* loeschen
* - file einlesen - aufteilen -> tmp/Model_*
* - Submodel tmp/Model_ (-main-) laden
* mode 0 = load new
* mode 1 = insert; do not write Title & do not rescale
* mode 2 = tmp/Model_ is ready to load (reload)
* - dbResiz = 0: increase DB-Size for new objects; 1 = not.
*
int Mod_aload_prc ( char *  lBuf,
int  bufSiz,
FILE *  fpi 
)
* read from fpi and write until SECTIONEND into file tmp/Model_<mdlNam>
* lBuf is line "SECTION PROCESS process_<prcNam>"
* 01234567890123456
* add proc to file <tmp>processes.lst
*
int Mod_aload_sm ( int  mode,
char *  lBuf,
int  bufSiz,
FILE *  fpi 
)
* read from fpi and write until SECTIONEND into file tmp/Model_<mdlNam>
* lBuf is line "SECTION MODEL <mdlNam>"
* mode=0 old version; "MODEL modelname" bis "MODEL END"
* mode=1 new version; "SECTION modelname" bis "SECTIONEND"
*
int Mod_del1__ ( char *  smNam)
int Mod_load_allsm ( )

Load Models of mdb_dyn-Records; Load Models; Reihenfolge=seqNr.

int Mod_SM_add_file ( char *  smNam,
char *  fNam 
)
int Mod_load_sm ( int  mTyp,
char *  mnam 
)

ein einzelnes subModel laden mnam zB "Submodel1"; das subModel darf keine noch nicht existierenden subModels enthalten !!

int Mod_get_namAll ( )

scan rekursiv die SourceFiles aller dzt existierenden basicModels; load Submodels as (zusaetzliche) basicModels. basicModels = mdb_dyn-Rec's (DB_StoreModBas) Recurse tru alls Submodels.

int Mod_get_namSub ( int  parNr,
int  iLev 
)

scan file of Model Mod_father->mnam for Submodels; add Submodels as seqNr=iLev

int Mod_get_namFil ( char *  fNam,
int  parNr,
int  iLev 
)

scan File fNam and save all Submodelcalls as level iLev irc = 0 = OK; -1 = Err.

int Mod_get_namStore ( char *  cp,
int  parNr,
int  iLev 
)

save new BaseModel as mdb_dyn-Record Input: cp = line mit "M20=..." basicModelNr of parent (father) == parNr; SourcefileName ist Mod_father->mnam

int Mod_allmod_MS ( double  d1,
double  d2,
double  d3 
)

Mod_allmod_MS in all subMods modify ModSiz

int Mod_safeName ( char *  outNam,
char *  inNam 
)

give back Filename im <base>tmp/<safeName>

int Mod_fget_names_1 ( TxtTab mdlTab)
int Mod_fget_names_0 ( char *  mdlNam,
TxtTab mdlTab,
TxtTab surPtab,
TxtTab surMsh 
)
* Find all subModels in modelfile of model <mdlNam>; add to List 'mdlTab'.
* Find all PTAB-Surfs; add to List 'surPtab'.
* Find all MSH-Surfs; add to List 'surMsh'.
*
int Mod_fget_names__ ( TxtTab mdlTab,
TxtTab surPtab,
TxtTab surMsh 
)
* get lists of all subModels, PTAB-Surfs and MSH-Surfs out of
* mainmodel and all subModelfiles
*

Variable Documentation

Point WC_mod_ori

der Model-Origin

int WC_modact_ind
int AP_src

AP_SRC_MEM or AP_SRC_EDI.

ColRGB AP_defcol

die DefaultColor des aktiven (sub)Model

int UI_InpMode
ModelBas* Mod_father
static
char sSecEnd[] ="SECTIONEND"
static