亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stepncmodel.java

?? The view238 application is a simple tool for graphically displaying STEP-NC toolpaths. It is a Java
?? JAVA
字號:
/* $RCSfile: coolant.cxx,v $
 * $Revision: 1.3 $ $Date: 2006/08/21 14:15:51 $
 * 
 * Copyright (c) 1991-2006 by STEP Tools Inc. 
 * All Rights Reserved.
 * 
 * This file may be distributed and/or modified under the terms of 
 * the GNU General Public License version 2 as published by the Free
 * Software Foundation and appearing in the file LICENSE.GPL included
 * with this file.
 * 
 * THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTY OF ANY KIND,
 * INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE.
 * 
 * 		----------------------------------------
 */

package com.steptools.view238;


import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;

/**
 * AP238 Processing class.  An instance of this class provides read access to
 * the data in an AP238 (P28/XML) file.  This includes functionality to find
 * and access the toolpath objects in the design
 */

public class StepNcModel {

    /** URI for AP238 namespace */
    final static String INSTANCE_URI = "urn:oid:1.0.10303.238.1.0.1";
    
    /**
     * Get the root element for an XML file
     * @param file the file to read
     * @return the root element of the file
     */
    private static Element readXMLFile (File file)
	throws IOException, ParserConfigurationException, SAXException {
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	dbf.setNamespaceAware(true);
	DocumentBuilder parser = dbf.newDocumentBuilder();
	Document doc = parser.parse(file);
	
	return doc.getDocumentElement();
    }

    private Element root;
    private Map<String,Element> instances = new HashMap<String,Element>();

    /** Get the value of a STEP attribute that is written as a contained
     * 	element.  This encoding scheme is used for SELECTs and aggregates
     * (although the aggregates could have multiple values, so this is of
     * dubious value in that case.
     * @param el The DOM element to search for a child value in.
     * @return The value of the ref attribute.
     */
    public String getChildRef(Element el) {
	NodeList nl = el.getChildNodes();
	int sz = nl.getLength();
	for (int i=0; i<sz; i++) {
	    Node n = nl.item(i);
	    if (!(n instanceof Element))
		continue;

	    Element ch_el = (Element)n;
	    if (!(INSTANCE_URI.equals(el.getNamespaceURI())))
		continue;

	    String ref = ch_el.getAttribute ("ref");
	    return ref;	    
	}
	return null;
    }

    /**
     * Get the value of a STEP attribute in a specified object.
     * @param obj the ID for the object being queried.
     * @param prop the name of the property to obtain.
     * @return the value of the property as a string.  For STEP objects, this
     *   is an ID for the value.
     */
    public String getAttribute(String obj, String prop) {
	Element el = instances.get(obj);

	if (el.hasAttribute(prop))
	    return el.getAttribute(prop);

	NodeList nl = el.getChildNodes();
	int sz = nl.getLength();
	for (int i=0; i<sz; i++) {
	    Node n = nl.item(i);
	    if (!(n instanceof Element))
		continue;
	    Element ch_el = (Element)n;
	    if (!(INSTANCE_URI.equals(ch_el.getNamespaceURI())))
		continue;

	    if (!(ch_el.getLocalName().equals(prop)))
		continue;
	    return getChildRef(ch_el);
	}

	return null;
    }

    /**
     * Get the value of a STEP aggregate-typed attribute in a specified object.
     * @param obj the ID for the object being queried.
     * @param prop the name of the property to obtain.
     * @return an array of values for value of the property.  For STEP objects,
     *   this is an ID for the value.
     */    
    public String[] getAttributeCollection(String obj, String prop) {
	Element el = instances.get(obj);

	if (el.hasAttribute(prop)) {
	    return el.getAttribute(prop).split("\\s");	    
	}

// 	NodeList nl = el.getChildNodes();
// 	int sz = nl.getLength();
// 	for (int i=0; i<sz; i++) {
// 	    Node n = nl.item(i);
// 	    if (!(n instanceof Element))
// 		continue;
// 	    Element ch_el = (Element)n;
// 	    if (!(INSTANCE_URI.equals(ch_el.getNamespaceURI())))
// 		continue;

// 	    if (!(ch_el.getLocalName().equals(prop)))
// 		continue;
// 	    return getChildRef(ch_el);
// 	}

	return null;
    }


    /** Abstract base type for a ToolPath */
    public abstract class Curve {}

    /** A single line segment in a ToolPath */
    public class LineSegment extends Curve {
	double x1;
	double y1;
	double z1;
	double x2;
	double y2;
	double z2;
    }

    /** A single arc in a ToolPath */
    public class Arc extends Curve {
	double radius;
	boolean sense;

	/** Center */
	double ox;
	double oy;
	double oz;

	/** Axis direction */
	double ax;
	double ay;
	double az;
	
	/** First trim point */
	double tx1;
	double ty1;
	double tz1;

	/** Second trim point */
	double tx2;
	double ty2;
	double tz2;
    }
    

    /** A single tool path. */
    public class ToolPath {
	final String toolpath_id;
	final String curve_id;
	final List<Curve> curves = new ArrayList<Curve>();
	
	ToolPath (String tp, String c) {
	    toolpath_id = tp;
	    curve_id = c;
	}

	public String getName() {
	    return getAttribute(toolpath_id, "Name");
	}
    }

    
    List<ToolPath> toolpaths = new ArrayList<ToolPath> ();

    /** Get the STEP entity type on an object */
    public String getType (String id) {
	Element el = instances.get(id);
	return el.getLocalName();
    }

    
    private void appendPolyline (ToolPath tp, String pl) {
	String[] points = getAttributeCollection(pl, "Points");
	double oldx=0.0, oldy=0.0, oldz=0.0;
	boolean first = true;
	
	for (String pid : points) {	    
	    String[] coords = getAttributeCollection(pid, "Coordinates");
	    double x = parseDouble(coords[0]);
	    double y = parseDouble(coords[1]);
	    double z = parseDouble(coords[2]);

	    if (first)
		first = false;
	    else {
		LineSegment seg = new LineSegment();
		seg.x1 = oldx;
		seg.y1 = oldy;
		seg.z1 = oldz;
		seg.x2 = x;
		seg.y2 = y;
		seg.z2 = z;

		tp.curves.add(seg);
	    }

	    oldx = x;
	    oldy = y;
	    oldz = z;
	}
    }

    static double parseDouble(String txt) {
	if (txt.contains("..")) {
	    System.out.println ("WARNING: corrupt real number: "+txt);
	    txt = txt.replaceAll("\\.+", ".");
	    System.out.println ("Fixed to "+txt);
	}
	return Double.parseDouble(txt);
    }

    private void appendTrimmed_curve(ToolPath tp, String tc) {
	String trim1 = getAttribute(tc, "Trim_1");
	if ( !("Cartesian_point".equals(getType(trim1)))) {
	    System.out.println ("Unexpected type for trim1 "+ getType(trim1));
	    return;
	}
	
	String trim2 = getAttribute(tc, "Trim_2");
	if ( !("Cartesian_point".equals(getType(trim2)))) {
	    System.out.println ("Unexpected type for trim2 "+ getType(trim2));
	    return;
	}
	
	String basis = getAttribute(tc, "Basis_curve");
	if ( !("Circle".equals(getType(basis)))) {
	    System.out.println ("Unexpected type for basis_curve "
				+ getType(basis));
	    return;
	}

	String pos = getAttribute(basis, "Position");
	if ( !("Axis2_placement_3d".equals(getType(pos)))) {
	    System.out.println ("Unexpected type for position "+ getType(pos));
	    return;
	}

	String center = getAttribute(pos, "Location");
	String[] center_coords = getAttributeCollection(center, "Coordinates");
	
	String axis = getAttribute(pos, "Axis");
	String[] axis_comps = getAttributeCollection(axis, "Direction_ratios");
	    
//	String dir = getAttributeCollection(pos, "Ref_direction");
//	String[] dir_comps = getAttributeCollection(dir, "Direction_ratios");

	Arc arc = new Arc();
	tp.curves.add(arc);

	arc.radius = parseDouble(getAttribute(basis, "Radius"));
	arc.sense = "true".equals(getAttribute(tc, "Sense_agreement"));

	arc.ox = parseDouble(center_coords[0]);
	arc.oy = parseDouble(center_coords[1]);
	arc.oz = parseDouble(center_coords[2]);

	arc.ax = parseDouble(axis_comps[0]);
	arc.ay = parseDouble(axis_comps[1]);
	arc.az = parseDouble(axis_comps[2]);

	String[] trim1_coords = getAttributeCollection(trim1, "Coordinates");
	arc.tx1 = parseDouble(trim1_coords[0]);
	arc.ty1 = parseDouble(trim1_coords[1]);
	arc.tz1 = parseDouble(trim1_coords[2]);

	String[] trim2_coords = getAttributeCollection(trim2, "Coordinates");
	arc.tx2 = parseDouble(trim2_coords[0]);
	arc.ty2 = parseDouble(trim2_coords[1]);
	arc.tz2 = parseDouble(trim2_coords[2]);
    }
    
    
    private void appendCompositeCurve(ToolPath tp, String pl) {
	String[] segments = getAttributeCollection(pl, "Segments");
	for (String seg : segments) {
	    String parent = getAttribute(seg, "Parent_curve");
	    String type = getType(parent);

	    if (type.equals("Trimmed_curve")) {
		appendTrimmed_curve(tp, parent);		
	    }

	    else if (type.equals("Polyline")) {
		appendPolyline(tp, parent);
	    }

	    else {
		System.out.println ("  Unexpected type \"" +type+
				    "\" in composite"  +parent);
	    }
	}
    }

    
    
    private ToolPath createToolPath(String tp, String curve_id) {
	ToolPath ret = new ToolPath(tp, curve_id);

	String type = getType(curve_id);
	if (type.equals("Polyline")) {
	    appendPolyline(ret, curve_id);
	}

	else if (type.equals("Composite_curve")) {
	    appendCompositeCurve(ret, curve_id);
	}
	
	return ret;
    }

	
    
    private void findBasicCurve(String apr) {
	String ap = getAttribute(apr, "Property");
	if (ap == null)
	    return;

	if (!(getAttribute(ap, "Name").equals("basic curve")))
	    return;
		
	String tp = getAttribute(ap, "Definition");
	if (!("Machining_toolpath".equals(getType(tp))))
	    return;
	
	String rep = getAttribute(apr, "Representation");
	if (rep == null)
	    return;

	for (String item : getAttributeCollection(rep, "Items")) {
	    String type = getType(item);
	    if (type.equals("Polyline")
		|| type.equals("Composite_curve")) {
		String tp_name = getAttribute(tp, "Name");
		
		toolpaths.add(createToolPath(tp, item));
		break;
	    }
	}
    }

    /**
     * Display a toolpath for debugging
     */
    public void dump(PrintStream out, ToolPath tp) {
 	out.println ("Toolpath: "+tp.getName());

	for (Curve c : tp.curves) {

	    if (c instanceof LineSegment) {
		LineSegment s = (LineSegment) c;
		System.out.println
		    ("  Segment: ("
		     +s.x1+ ", " +s.y1+ ", " +s.z1+ ") -> ("
		     +s.x2+ ", " +s.y2+ ", " +s.z2+ ")");
		
	    }

	    else if (c instanceof Arc) {
		Arc a = (Arc) c;
		System.out.println
		    ("  Arc: O=("+a.ox+ ", " +a.oy+ ", " +a.oz+ "), "
		     +" r="+a.radius+ " Sense=" +a.sense);
		System.out.println
		    ("    Axis dir = ( " +a.ax+ ", " +a.ay+ ", " +a.az+") ");
		System.out.println
		    ("    Range: ("
		     +a.tx1+ ", " +a.ty1+ ", " +a.tz1+ ") -> ("
		     +a.tx2+ ", " +a.ty2+ ", " +a.tz2+ ")");
	    }

	    else
		throw new RuntimeException ("Unexpected case");
	}
	
    }

    /**
     * Create a model given a AP238 XML file
     * @param ap238 the file to read.
     * @throws IOException when there is an IO exception processing the file.
     * @throws StepNcException general problem processing the data.
     */
    public StepNcModel(File ap238) throws IOException, StepNcException {
	try {
	    root = readXMLFile(ap238);
	} catch (ParserConfigurationException ex) {
	    throw new StepNcException (ex);
	} catch (SAXException ex) {
	    throw new StepNcException (ex);
	}

	NodeList nl = root.getChildNodes();
	int sz = nl.getLength();

	Set<String> aprs = new LinkedHashSet<String>();
	
	for (int i=0; i<sz; i++) {
	    Node n = nl.item(i);
	    if (!(n instanceof Element))
		continue;

	    Element el = (Element)n;
	    if (!(INSTANCE_URI.equals(el.getNamespaceURI())))
		continue;

	    String id = el.getAttribute ("id");
	    
	    instances.put(id, el);
	    if (el.getLocalName().equals("Action_property_representation")) {
		aprs.add(id);
	    }
	}

	/* Get the basiccurves */
	for (String apr : aprs) {
	    findBasicCurve(apr);
	}
    }

    /**
     * Sample driver program to display the AP238 data in a file
     */
    public static void main(String[] argv) throws IOException, StepNcException{
	File file = new File(argv[0]);
	StepNcModel mod = new StepNcModel(file);

 	for (ToolPath tp : mod.toolpaths) {
 	    mod.dump(System.out, tp);
	    System.out.println();
 	}
    }
};

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影一区二区| 日韩欧美色电影| 欧美挠脚心视频网站| 久久久久久久久99精品| 一区二区在线观看视频| 日韩欧美三级在线| 一级特黄大欧美久久久| 久久不见久久见免费视频7| 美国三级日本三级久久99| 欧美巨大另类极品videosbest| 日韩欧美一级在线播放| 综合网在线视频| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲精品一二三| 国产一区日韩二区欧美三区| 欧美色欧美亚洲另类二区| 卡一卡二国产精品| 中文字幕欧美激情一区| 蜜臀久久久久久久| 精品污污网站免费看| 亚洲精品国产一区二区三区四区在线| 国产精品中文有码| 2020国产精品久久精品美国| 欧美mv日韩mv| 国产精品久久久久毛片软件| 久久国产精品72免费观看| 欧美猛男男办公室激情| 91亚洲精华国产精华精华液| 国产视频911| 国内成+人亚洲+欧美+综合在线 | 成人国产精品免费观看动漫| 精品理论电影在线观看| 奇米亚洲午夜久久精品| 欧美一区二区三区在线电影| 日本欧洲一区二区| 26uuu欧美| 亚洲蜜臀av乱码久久精品蜜桃| 99国产精品一区| 亚洲综合视频在线观看| 欧美影院一区二区三区| 欧洲精品一区二区| 美国精品在线观看| 日韩免费一区二区| 国产一区二区在线看| 久久久99精品免费观看不卡| 国产成人精品www牛牛影视| 中文字幕欧美日韩一区| 91蜜桃视频在线| 亚洲午夜激情网站| 欧美一级久久久| 国产成人免费在线视频| 综合av第一页| 精品国产伦一区二区三区观看体验| 一本久久综合亚洲鲁鲁五月天 | 亚洲欧洲精品一区二区三区 | 欧美日本一区二区在线观看| 日本欧美大码aⅴ在线播放| 日韩欧美激情在线| 成人免费毛片嘿嘿连载视频| 亚洲欧美日韩电影| 日韩欧美中文一区二区| 国产成人无遮挡在线视频| 中文字幕av不卡| 欧美午夜精品一区二区蜜桃| 奇米一区二区三区av| 国产精品污污网站在线观看| 精品视频在线免费看| 国产一区999| 一区二区三区欧美亚洲| 精品国产百合女同互慰| 在线观看精品一区| 国产精品91xxx| 日韩精品高清不卡| 国产精品久久久久久久久久久免费看 | 波多野结衣亚洲一区| 污片在线观看一区二区| 激情久久五月天| 亚洲欧美视频在线观看视频| 欧美不卡123| 26uuu色噜噜精品一区二区| 亚洲一区二区高清| 久久精品一区八戒影视| 欧美日韩视频专区在线播放| 国产乱码精品一区二区三区五月婷| 亚洲欧美中日韩| ww亚洲ww在线观看国产| 欧美日韩国产经典色站一区二区三区| 精品无码三级在线观看视频| 亚洲天堂福利av| 久久婷婷一区二区三区| 欧美日韩和欧美的一区二区| 成人美女视频在线观看18| 日韩高清不卡在线| 亚洲已满18点击进入久久| 中文无字幕一区二区三区| 91精品国产色综合久久ai换脸| 91免费看`日韩一区二区| 国产精品77777| 麻豆精品在线播放| 午夜伦欧美伦电影理论片| 国产精品的网站| 久久久久久久久久久久电影| 日韩欧美卡一卡二| 91精品国产手机| 日韩一区二区免费在线电影| 欧美色图在线观看| 欧美在线短视频| 一本色道久久综合亚洲aⅴ蜜桃| 成人福利在线看| 国产成人一级电影| 国产乱人伦偷精品视频不卡 | 国产精品久久久久久久第一福利| www日韩大片| 久久嫩草精品久久久精品| 精品国产亚洲一区二区三区在线观看| 欧美一区二区三区人| 欧美精品久久99久久在免费线 | 97久久人人超碰| 99精品久久只有精品| 亚洲最大色网站| 欧美大片顶级少妇| 国产大陆精品国产| 国产精品一区在线| 国产成人精品网址| 91在线国产福利| 在线一区二区三区四区五区| 欧美在线999| 欧美精三区欧美精三区| 精品精品欲导航| 中文乱码免费一区二区| 亚洲欧美区自拍先锋| 视频一区视频二区中文| 久草在线在线精品观看| 国产老妇另类xxxxx| 成人午夜激情影院| 欧美综合欧美视频| 精品国产一区二区三区久久影院 | 欧美亚洲日本国产| 在线观看91av| 国产亚洲女人久久久久毛片| 中文字幕成人av| 亚洲大尺度视频在线观看| 麻豆精品在线播放| 不卡的av电影| 7777精品伊人久久久大香线蕉的| 欧美精品一区二区三区四区| 国产精品卡一卡二| 午夜日韩在线观看| 久久久久久久久97黄色工厂| 亚洲码国产岛国毛片在线| 日韩中文字幕区一区有砖一区 | 国产精品三级av| 亚洲精品水蜜桃| 久久国产三级精品| 国产色一区二区| 欧美视频一区在线观看| 欧美va亚洲va国产综合| 亚洲免费在线电影| 国产一区二区三区在线观看免费视频 | 日韩精品视频网| av亚洲精华国产精华| 91精品国产免费久久综合| 中文字幕一区二区日韩精品绯色| 免费在线看一区| 1024成人网色www| 欧美一区二区三区视频| 国产精品美女久久久久高潮| 奇米888四色在线精品| 91免费观看视频在线| 久久久久久9999| 日本欧美大码aⅴ在线播放| 色综合一区二区| 国产日韩欧美不卡| 精品一区二区三区av| 欧美日韩一区二区三区高清| 国产精品久久久久婷婷| 国产资源在线一区| 91精品国产综合久久久久久| 亚洲欧洲精品天堂一级| 国产一区二区三区高清播放| 91精品国产综合久久精品麻豆| 在线亚洲一区观看| 欧美国产欧美综合| 国产一区二区伦理| 精品三级在线看| 日韩电影在线免费观看| 欧美区一区二区三区| 亚洲成人激情综合网| 欧美在线免费播放| 亚洲成人资源在线| 欧美揉bbbbb揉bbbbb| 一区av在线播放| 91国产成人在线| 亚洲国产欧美日韩另类综合| 一本大道久久精品懂色aⅴ| 国产99久久久精品| 成人18精品视频| 亚洲三级在线看| 色偷偷久久一区二区三区| 亚洲免费在线看|