Example #1
0
int MarkOuterElements( void )

{
	int ext;
	int loops;
	int external=0;
	float *xe, *ye;
	float xm,ym;
	Elem_type *pe;
	Line_type *pl;

        ResetHashTable(HLI);
        while( (pl = VisitHashTableL(HLI)) != NULL ) {
	    if( !IsLtype(pl,L_EXTERNAL_REF) && !IsLtype(pl,L_INTERNAL_REF) )
			continue;

	    MakeCoordsFromLine(pl,&xe,&ye);

	    ResetHashTable(HEL);
	    while( (pe=VisitHashTableE(HEL)) != NULL ) {
		if( IsEtype(pe, E_EXTERNAL ) ) continue;
		MakeCM(pe,&xm,&ym);
		loops = InClosedLine(pl->vertex,xe,ye,xm,ym);
		ext = 0;
		if( IsLtype(pl,L_EXTERNAL_REF) ) {
		    if( loops == 0 ) ext = 1;
		} else {
		    if( loops != 0 ) ext = 1;
		}
		if( ext ) {
		    SetEtype(pe, E_EXTERNAL );
                    external++;
		}
	    }

	    free(xe);
	    free(ye);
	}

	return external;
}
Example #2
0
void CheckCircumCircleProperty( void )

/*\
 *  New version of routine -> does a little bit too much.
\*/

{
	int i,node;
	Elem_type *pe, *pvis;

	ResetHashTable(HEL);
	while( (pe=VisitHashTableE(HEL)) != NULL ) {
	    if( IsEtype(pe, E_EXTERNAL ) ) continue;
	    if( !InElemCircumCircle(pe,pe,1.01) ) {
		Error2("CheckCircumCircleProperty: Violation (0)"
					,itos(pe->number));
	    }
	    for(i=0;i<3;i++) {
		pvis = RetrieveByElemNumber(HEL,pe->neibor[i]);
		node = pe->index[(i+2)%3];
		while( (pvis=GoAround(pvis,node,RIGHT)) != NULL ) {
		    if( pvis == NULL || pvis == pe ) break;
		    if( InElemCircumCircle(pvis,pe,0.99) ) {
			Error2("CheckCircumCircleProperty: Violation (1)"
					,itos(pe->number));
		    }
		}
		pvis = RetrieveByElemNumber(HEL,pe->neibor[i]);
		node = pe->index[(i+1)%3];
		while( (pvis=GoAround(pvis,node,LEFT)) != NULL ) {
		    if( pvis == NULL || pvis == pe ) break;
		    if( InElemCircumCircle(pvis,pe,0.99) ) {
			Error2("CheckCircumCircleProperty: Violation (2)"
					,itos(pe->number));
		    }
		}
	    }
	}
}
Example #3
0
void WriteFile( char *file , NodeList list , int all )

{
	int i,j;
	int count;
	int linetype;
	FILE *fp;
	Node_type *pn;
	Elem_type *pe;
	Line_type *pl;

	if( file == NULL ) {
	    fp=fopen("new.grd","w");
	} else {
	    fp=fopen(file,"w");
	}

	/* comments */

        fprintf(fp,"\n");
        fprintf(fp,"0 (mesh) automatic generated grid\n");
        fprintf(fp,"\n");

	/* nodes */

	ResetHashTable(HNN);
	while( (pn=VisitHashTableN(HNN)) != NULL ) {
		if( !all && IsNtype(pn, N_EXTERNAL ) ) continue;
                fprintf(fp,"1 %d %d %f %f"
                        ,pn->number
                        ,(int) pn->type
                        ,pn->coord.x
                        ,pn->coord.y
                        );
                if( pn->depth != NULLDEPTH )
                        fprintf(fp," %f\n",pn->depth);
                else
                        fprintf(fp,"\n");

	}

        fprintf(fp,"\n");

	/* elements */

        for(i=1;i<=NTotElems;i++) {
          if( (pe=RetrieveByElemNumber(HEL,i)) != NULL ) {
		if( !all && IsEtype(pe, E_EXTERNAL ) ) continue;
                fprintf(fp,"2 %d %d %d"
                        ,pe->number
                        ,(int) pe->type
                        ,pe->vertex
                        );

                for(j=0;j<pe->vertex;j++) {
                        if( j%10 == 0 && pe->vertex > 3 )
                                fprintf(fp,"\n");
                        fprintf(fp," %d",pe->index[j]);
                }
        	fprintf(fp,"\n");
	  }
	}

        fprintf(fp,"\n");

	/* lines */


        for(i=1;i<=NTotLines;i++) {
          if( (pl=RetrieveByLineNumber(HLI,i)) != NULL ) {
	    if( IsLtype(pl,L_EXTERNAL_REF) || IsLtype(pl,L_INTERNAL_REF) 
			|| IsLtype(pl,L_FAULT_REF)
			|| EqualsLtype(pl,L_NONE) ) {
		if( IsLtype(pl,L_EXTERNAL_REF) ) {
		  linetype = L_EXTERNAL;
		} else if( IsLtype(pl,L_INTERNAL_REF) ) {
		  linetype = L_INTERNAL;
		} else if( IsLtype(pl,L_FAULT_REF) ) {
		  linetype = L_FAULT;
		} else {
		  linetype = 0;
		}
                fprintf(fp,"3 %d %d %d"
                        ,pl->number
                        ,linetype
                        ,pl->vertex
                        );

                for(j=0;j<pl->vertex;j++) {
                        if( j%10 == 0 )
                                fprintf(fp,"\n");
                        fprintf(fp," %d",pl->index[j]);
                }
                fprintf(fp,"\n");
	    }
          }
        }

        fprintf(fp,"\n");

	/* list */

	if( list ) {
		count = list->count;
        	fprintf(fp,"3 1 1 %d",count+1);
        	for(j=0;j<=count;j++) {
                	if( j%10 == 0 ) fprintf(fp,"\n");
                	fprintf(fp," %d",list->index[j%count]);
        	}
        	fprintf(fp,"\n");
	}

	fclose(fp);
}