Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
smyrna_utils.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10#include "smyrna_utils.h"
11#include <common/types.h>
12#include <common/utils.h>
13#include <limits.h>
14#include <stdio.h>
15
16int l_int(void *obj, Agsym_t * attr, int def)
17{
18 return late_int(obj, attr, def, INT_MIN);
19}
20
21float l_float(void *obj, Agsym_t * attr, float def)
22{
23 char *p;
24 if (!attr || !obj)
25 return def;
26 p = agxget(obj, attr);
27 if (!p || p[0] == '\0')
28 return def;
29 return atof(p);
30}
31int getAttrBool(Agraph_t* g,void* obj,char* attr_name,int def)
32{
33 Agsym_t* attr;
34 attr = agattr(g, AGTYPE(obj), attr_name,0);
35 return late_bool(obj, attr,def);
36}
37int getAttrInt(Agraph_t* g,void* obj,char* attr_name,int def)
38{
39 Agsym_t* attr;
40 attr = agattr(g, AGTYPE(obj), attr_name,0);
41 return l_int(obj,attr,def);
42}
43float getAttrFloat(Agraph_t* g,void* obj,char* attr_name,float def)
44{
45 Agsym_t* attr;
46 attr = agattr(g, AGTYPE(obj), attr_name,0);
47 return l_float(obj,attr,def);
48}
49char* getAttrStr(Agraph_t* g,void* obj,char* attr_name,char* def)
50{
51 Agsym_t* attr;
52 attr = agattr(g, AGTYPE(obj), attr_name,0);
53 return late_string(obj, attr,def);
54}
55
57 glCompPoint p = {0};
58 (void)sscanf(str, "%f,%f,%f", &p.x, &p.y, &p.z);
59 return p;
60}
61
63{
64 int npol=selPoly->cnt;
65
66 int i, j, c = 0;
67 for (i = 0, j = npol-1; i < npol; j = i++)
68 {
69 if ((((selPoly->pts[i].y <= p.y) && (p.y < selPoly->pts[j].y)) ||
70 ((selPoly->pts[j].y <= p.y) && (p.y < selPoly->pts[i].y))) &&
71 (p.x < (selPoly->pts[j].x - selPoly->pts[i].x) * (p.y - selPoly->pts[i].y) / (selPoly->pts[j].y - selPoly->pts[i].y) + selPoly->pts[i].x))
72 c = !c;
73 }
74 return c;
75 }
char * late_string(void *obj, attrsym_t *attr, char *defaultValue)
Definition utils.c:78
int late_int(void *obj, attrsym_t *attr, int defaultValue, int minimum)
Definition utils.c:33
bool late_bool(void *obj, attrsym_t *attr, bool defaultValue)
Definition utils.c:91
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
Definition attr.c:341
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:458
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Definition cgraph.h:216
agxbuf * str
Definition htmlparse.c:97
float getAttrFloat(Agraph_t *g, void *obj, char *attr_name, float def)
int point_in_polygon(glCompPoly *selPoly, glCompPoint p)
int getAttrInt(Agraph_t *g, void *obj, char *attr_name, int def)
int getAttrBool(Agraph_t *g, void *obj, char *attr_name, int def)
glCompPoint getPointFromStr(const char *str)
char * getAttrStr(Agraph_t *g, void *obj, char *attr_name, char *def)
int l_int(void *obj, Agsym_t *attr, int def)
float l_float(void *obj, Agsym_t *attr, float def)
graph or subgraph
Definition cgraph.h:425
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:639
glCompPoint * pts
Definition glcompdefs.h:145
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t