📄 sector3d.java
字号:
/**
* Copyright (C) 2006, Laboratorio di Valutazione delle Prestazioni - Politecnico di Milano
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package jmt.engine.jaba;
import jmt.engine.jaba.Hull.Vertex;
import java.util.Vector;
/**
* Created by IntelliJ IDEA.
* User: Andrea Zanzottera
* Date: 27-lug-2005
* Time: 13.54.43
*/
public class Sector3D {
private int type; // 3=triangolo
private Vector points = new Vector();
private Vector stations = new Vector();
private Vector xycoord = new Vector();
private Vector statname = new Vector();
private String sname;
private String[] classNames;
public Sector3D(){
}
public void setClassNames(String[] classNames) {
this.classNames = classNames;
}
// COSTRUTTORI DI TRIANGOLI (3 STAZIONI SATURANO CONTEMPORANEAMENTE)
public Sector3D(double b11,double b12,double b13,double b21,double b22,double b23,double b31,double b32,double b33,int thistype,Vertex vv1,Vertex vv2,Vertex vv3){
BetaVertex b1=new BetaVertex(b11,b12,b13);
BetaVertex b2=new BetaVertex(b21,b22,b23);
BetaVertex b3=new BetaVertex(b31,b32,b33);
points.addElement(b1);
points.addElement(b2);
points.addElement(b3);
type=thistype;
stations.addElement(vv1);
stations.addElement(vv2);
stations.addElement(vv3);
}
public Sector3D(double b11,double b12,double b13,double b21,double b22,double b23,double b31,double b32,double b33,int thistype,Vertex vv1,Vertex vv2,Vertex vv3,Vertex vv4){
BetaVertex b1=new BetaVertex(b11,b12,b13);
BetaVertex b2=new BetaVertex(b21,b22,b23);
BetaVertex b3=new BetaVertex(b31,b32,b33);
points.addElement(b1);
points.addElement(b2);
points.addElement(b3);
type=thistype;
stations.addElement(vv1);
stations.addElement(vv2);
stations.addElement(vv3);
stations.addElement(vv4);
}
// COSTRUTTORI DI SETTORI IN CUI SATURANO 2 STAZIONI CONTEMPORANEAMENTE
public Sector3D(BetaVertex v1,BetaVertex v2,BetaVertex v3,BetaVertex v4,int thistype,Vertex vv1,Vertex vv2){
points.addElement(v1);
points.addElement(v2);
points.addElement(v3);
points.addElement(v4);
type=thistype;
stations.addElement(vv1);
stations.addElement(vv2);
}
public Sector3D(Vector points,int thistype,Vertex vv1,Vertex vv2){
this.points=points;
type=thistype;
stations.addElement(vv1);
stations.addElement(vv2);
}
public Sector3D(Vector points,int thistype,Vertex vv1,Vertex vv2,Vertex vv3, Vertex vv4){
this.points=points;
type=thistype;
stations.addElement(vv1);
stations.addElement(vv2);
stations.addElement(vv3);
stations.addElement(vv4);
}
// COSTRUTTORE GENERICO CON VETTORI
public Sector3D(Vector points,int thistype,Vector stations){
this.points=points;
type=thistype;
this.stations=stations;
}
/** !!NON USATO!!
* Restituisce la coordinata "x","y" o "z" del vertice vertex nello spazio Beta
* @param vertex
* @param coord
* @return la coordinata "x","y" o "z" del vertice vertex nello spazio Beta
*/
public double getBeta(int vertex,String coord){
double beta=-1;
if (coord=="x" || coord=="X")
beta=((BetaVertex)points.get(vertex)).getX();
else if (coord=="y" || coord=="Y")
beta=((BetaVertex)points.get(vertex)).getY();
else if (coord=="z" || coord=="Z")
beta=((BetaVertex)points.get(vertex)).getZ();
return beta;
}
public double getBeta(int vertex,int coord){
double beta=-1;
if (coord==1)
{
beta=Math.rint((((BetaVertex)points.get(vertex)).getX())*1000);
beta=beta/1000;
}
else if (coord==2)
{
beta=Math.rint((((BetaVertex)points.get(vertex)).getY())*1000);
beta=beta/1000;
}
else if (coord==3)
{
beta=Math.rint((((BetaVertex)points.get(vertex)).getZ())*1000);
beta=beta/1000;
}
return beta;
}
/**
* Restituisce un array di double che contengono le coordinate nello spazio zeta
* del vertice vertex
* @param vertex
* @return un array di double che contengono le coordinate nello spazio zeta
*/
public double[] getBetas(int vertex){
double[] beta = new double[3];
beta[0]=((BetaVertex)points.get(vertex)).getX();
beta[1]=((BetaVertex)points.get(vertex)).getY();
beta[2]=((BetaVertex)points.get(vertex)).getZ();
return beta;
}
public BetaVertex getV0(){
return (BetaVertex)points.get(0);
}
public BetaVertex getV1(){
return (BetaVertex)points.get(1);
}
public BetaVertex getV2(){
return (BetaVertex)points.get(2);
}
public BetaVertex getV(int i){
return (BetaVertex)points.get(i);
}
public int CountPoint(){
return points.size();
}
// Metodi per ritornare le stazioni di un settore
public Vertex getS0() {
return (Vertex)stations.get(0);
}
public Vertex getS1(){
return (Vertex)stations.get(1);
}
public Vertex getS2(){
return (Vertex)stations.get(2);
}
public Vertex getS(int i){
return (Vertex)stations.get(i);
}
public Vector getS(){
return stations;
}
/**
* @return un int che corrisponde al numero di stazioni associati a un settore
*/
public int CountStations(){
return stations.size();
}
/**
* Aggiunge un punto nello spazio Beta e la relativa stazione
* @param betas
* @param station
* @return il settore aggiornato
*/
public Sector3D AddVertex(BetaVertex betas,Vertex station){
points.addElement(betas);
stations.addElement(station);
return this;
}
/**
* Il metodo serve per settare il tipo di settore.
* 1=Satura una singola stazione
* 2=Saturano 2 stazioni
* 3=Saturano 3 stazioni
* eccetera
* @param type
* @return il settore aggiornato
*/
public Sector3D setType(int type){
this.type=type;
return this;
}
/**
* @return il tipo di Settore
*/
public int getType(){
return type;
}
/**
* Verifica se un Sector3D
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -