bool ShadingSurfaceGroup_Impl::setShadedSubSurface(const SubSurface& subSurface) { boost::optional<Space> space = this->space(); if (!space){ return false; } boost::optional<Space> otherSpace = subSurface.space(); if (!otherSpace){ return false; } if (space->handle() != otherSpace->handle()){ return false; } bool test = setPointer(OS_ShadingSurfaceGroupFields::ShadedObjectName, subSurface.handle()); OS_ASSERT(test); return test; }
void GeomScreen::GuiDeviceCallBack( GuiDevice* device ) { assert( m_ScreenMgr ); Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr ) { Hide(); return; } if ( device == &m_ColorPicker ) { vec3d c = m_ColorPicker.GetColor(); geom_ptr->SetColor( ( int )c.x(), ( int )c.y(), ( int )c.z() ); } else if ( device == &m_MaterialChoice ) { int index = m_MaterialChoice.GetVal() - 1; Material mat; if( MaterialMgr.FindMaterial( index, mat ) ) { geom_ptr->SetMaterial( mat.m_Name, mat.m_Ambi, mat.m_Diff, mat.m_Spec, mat.m_Emis, mat.m_Shininess ); } else { geom_ptr->SetMaterialToDefault(); } } else if ( device == &m_SymAncestorChoice ) { geom_ptr->m_SymAncestor.SetFromDevice( m_SymAncestorChoice.GetVal() ); } else if ( device == &m_CustomMaterialButton ) { ( ( MaterialEditScreen* ) ( m_ScreenMgr->GetScreen( ScreenMgr::VSP_MATERIAL_EDIT_SCREEN ) ) )->m_OrigColor = geom_ptr->GetMaterial()->m_Name; geom_ptr->GetMaterial()->m_Name = "Custom"; m_ScreenMgr->ShowScreen( ScreenMgr::VSP_MATERIAL_EDIT_SCREEN ); } else if ( device == &m_ScaleAcceptButton ) { geom_ptr->AcceptScale(); } else if ( device == &m_ScaleResetButton ) { geom_ptr->ResetScale(); } else if ( device == &m_NameInput ) { geom_ptr->SetName( m_NameInput.GetString() ); } else if ( device == &m_AddSubSurfButton ) { SubSurface* ssurf = NULL; if ( m_SubSurfChoice.GetVal() == vsp::SS_LINE ) { ssurf = geom_ptr->AddSubSurf( vsp::SS_LINE ); } else if ( m_SubSurfChoice.GetVal() == vsp::SS_RECTANGLE ) { ssurf = geom_ptr->AddSubSurf( vsp::SS_RECTANGLE ); } else if ( m_SubSurfChoice.GetVal() == vsp::SS_ELLIPSE ) { ssurf = geom_ptr->AddSubSurf( vsp::SS_ELLIPSE ); } if ( ssurf ) { ssurf->Update(); } SubSurfaceMgr.SetCurrSubSurfInd( geom_ptr->NumSubSurfs() - 1 ); } else if ( device == &m_DelSubSurfButton ) { geom_ptr->DelSubSurf( SubSurfaceMgr.GetCurrSurfInd() ); SubSurfaceMgr.SetCurrSubSurfInd( geom_ptr->NumSubSurfs() - 1 ); } else if ( device == &m_SubNameInput ) { SubSurface* sub_surf = geom_ptr->GetSubSurf( SubSurfaceMgr.GetCurrSurfInd() ); if ( sub_surf ) { sub_surf->SetName( m_SubNameInput.GetString() ); } } m_ScreenMgr->SetUpdateFlag( true ); }
bool GeomScreen::Update() { assert( m_ScreenMgr ); Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr ) { Hide(); return false; } char str[256]; TabScreen::Update(); //==== Name ===// m_NameInput.Update( geom_ptr->GetName() ); //==== Color ====// m_ColorPicker.Update( geom_ptr->GetColor() ); //==== Material ====// Material * mat = geom_ptr->GetMaterial(); UpdateMaterialNames(); m_MaterialChoice.UpdateItems(); m_MaterialChoice.SetVal( 0 ); std::vector< std::string > choices = m_MaterialChoice.GetItems(); for ( int i = 0; i < (int)choices.size(); i++ ) { if( mat->m_Name == choices[i] ) { m_MaterialChoice.SetVal(i); break; } } //==== XForms ====// m_ScaleSlider.Update( geom_ptr->m_Scale.GetID() ); //===== Rel of Abs ====// m_XFormAbsRelToggle.Update( geom_ptr->m_AbsRelFlag.GetID() ); geom_ptr->DeactivateXForms(); if ( geom_ptr->m_AbsRelFlag() == GeomXForm::RELATIVE_XFORM ) { m_XLocSlider.Update( 1, geom_ptr->m_XRelLoc.GetID(), geom_ptr->m_XLoc.GetID() ); m_YLocSlider.Update( 1, geom_ptr->m_YRelLoc.GetID(), geom_ptr->m_YLoc.GetID() ); m_ZLocSlider.Update( 1, geom_ptr->m_ZRelLoc.GetID(), geom_ptr->m_ZLoc.GetID() ); m_XRotSlider.Update( 1, geom_ptr->m_XRelRot.GetID(), geom_ptr->m_XRot.GetID() ); m_YRotSlider.Update( 1, geom_ptr->m_YRelRot.GetID(), geom_ptr->m_YRot.GetID() ); m_ZRotSlider.Update( 1, geom_ptr->m_ZRelRot.GetID(), geom_ptr->m_ZRot.GetID() ); } else { m_XLocSlider.Update( 2, geom_ptr->m_XRelLoc.GetID(), geom_ptr->m_XLoc.GetID() ); m_YLocSlider.Update( 2, geom_ptr->m_YRelLoc.GetID(), geom_ptr->m_YLoc.GetID() ); m_ZLocSlider.Update( 2, geom_ptr->m_ZRelLoc.GetID(), geom_ptr->m_ZLoc.GetID() ); m_XRotSlider.Update( 2, geom_ptr->m_XRelRot.GetID(), geom_ptr->m_XRot.GetID() ); m_YRotSlider.Update( 2, geom_ptr->m_YRelRot.GetID(), geom_ptr->m_YRot.GetID() ); m_ZRotSlider.Update( 2, geom_ptr->m_ZRelRot.GetID(), geom_ptr->m_ZRot.GetID() ); } m_RotOriginSlider.Update( geom_ptr->m_Origin.GetID() ); //==== Symmetry ====// std::vector<std::string> ancestorNames; ancestorNames.push_back( "GLOBAL ORIGIN" ); geom_ptr->BuildAncestorList( ancestorNames ); m_SymAncestorChoice.ClearItems(); for( int i = 0; i < (int) ancestorNames.size(); i++ ) { sprintf( str, "%3d %s", i, ancestorNames[i].c_str() ); m_SymAncestorChoice.AddItem( str ); } m_SymAncestorChoice.UpdateItems(); m_SymAncestorChoice.SetVal( geom_ptr->m_SymAncestor() ); m_SymAncestorOriginObjectToggle.Update( geom_ptr->m_SymAncestOriginFlag.GetID() ); m_XYSymToggle.Update( geom_ptr->m_SymPlanFlag.GetID() ); m_XZSymToggle.Update( geom_ptr->m_SymPlanFlag.GetID() ); m_YZSymToggle.Update( geom_ptr->m_SymPlanFlag.GetID() ); m_AxialToggleGroup.Update( geom_ptr->m_SymAxFlag.GetID() ); m_AxialNSlider.Update( geom_ptr->m_SymRotN.GetID() ); //==== Mass Props ====// m_DensityInput.Update( geom_ptr->m_Density.GetID() ); m_ShellMassAreaInput.Update( geom_ptr->m_MassArea.GetID() ); m_ThinShellButton.Update( geom_ptr->m_ShellFlag.GetID() ); m_PriorCounter.Update( geom_ptr->m_MassPrior.GetID() ); //==== Attachments ====// m_TransToggleGroup.Update( geom_ptr->m_TransAttachFlag.GetID() ); m_RotToggleGroup.Update( geom_ptr->m_RotAttachFlag.GetID() ); m_AttachUSlider.Update( geom_ptr->m_ULoc.GetID() ); m_AttachVSlider.Update( geom_ptr->m_WLoc.GetID() ); if ( geom_ptr->m_ShellFlag.Get() ) { m_ShellMassAreaInput.Activate(); } else { m_ShellMassAreaInput.Deactivate(); } m_NumUSlider.Update( geom_ptr->m_TessU.GetID() ); m_NumWSlider.Update( geom_ptr->m_TessW.GetID() ); //==== Set Browser ====// vector< string > set_name_vec = m_ScreenMgr->GetVehiclePtr()->GetSetNameVec(); vector< bool > set_flag_vec = geom_ptr->GetSetFlags(); assert( set_name_vec.size() == set_flag_vec.size() ); //==== Load Set Names and Values ====// m_SetBrowser->clear(); for ( int i = SET_SHOWN ; i < ( int )set_name_vec.size() ; i++ ) { m_SetBrowser->add( set_name_vec[i].c_str(), static_cast<int>( set_flag_vec[i] ) ); } //================= SubSurfaces Tab ===================// SubSurface* subsurf = geom_ptr->GetSubSurf( SubSurfaceMgr.GetCurrSurfInd() ); if ( subsurf ) { m_SubNameInput.Update( subsurf->GetName() ); if ( subsurf->GetType() == vsp::SS_LINE ) { SSLine* ssline = dynamic_cast< SSLine* >( subsurf ); assert( ssline ); m_SSLineConstToggleGroup.Update( ssline->m_ConstType.GetID() ); m_SSLineTestToggleGroup.Update( ssline->m_TestType.GetID() ); m_SSLineConstSlider.Update( ssline->m_ConstVal.GetID() ); SubSurfDispGroup( &m_SSLineGroup ); } else if ( subsurf->GetType() == vsp::SS_RECTANGLE ) { SSRectangle* ssrec = dynamic_cast< SSRectangle* >( subsurf ); assert( subsurf ); m_SSRecTestToggleGroup.Update( ssrec->m_TestType.GetID() ); m_SSRecCentUSlider.Update( ssrec->m_CenterU.GetID() ); m_SSRecCentWSlider.Update( ssrec->m_CenterW.GetID() ); m_SSRecULenSlider.Update( ssrec->m_ULength.GetID() ); m_SSRecWLenSlider.Update( ssrec->m_WLength.GetID() ); m_SSRecThetaSlider.Update( ssrec->m_Theta.GetID() ); SubSurfDispGroup( &m_SSRecGroup ); } else if ( subsurf->GetType() == vsp::SS_ELLIPSE ) { SSEllipse* ssell = dynamic_cast< SSEllipse* >( subsurf ); assert( ssell ); m_SSEllTestToggleGroup.Update( ssell->m_TestType.GetID() ); m_SSEllTessSlider.Update( ssell->m_Tess.GetID() ); m_SSEllCentUSlider.Update( ssell->m_CenterU.GetID() ); m_SSEllCentWSlider.Update( ssell->m_CenterW.GetID() ); m_SSEllULenSlider.Update( ssell->m_ULength.GetID() ); m_SSEllWLenSlider.Update( ssell->m_WLength.GetID() ); m_SSEllThetaSlider.Update( ssell->m_Theta.GetID() ); SubSurfDispGroup( & m_SSEllGroup ); } } else { SubSurfDispGroup( NULL ); } //==== SubSurfBrowser ====// m_SubSurfBrowser->clear(); static int widths[] = { 75, 75 }; m_SubSurfBrowser->column_widths( widths ); m_SubSurfBrowser->column_char( ':' ); sprintf( str, "@[email protected]:@[email protected]" ); m_SubSurfBrowser->add( str ); string ss_name, ss_type; vector<SubSurface*> subsurf_vec = geom_ptr->GetSubSurfVec(); for ( int i = 0; i < ( int )subsurf_vec.size() ; i++ ) { ss_name = subsurf_vec[i]->GetName(); ss_type = SubSurface::GetTypeName( subsurf_vec[i]->GetType() ); sprintf( str, "%s:%s", ss_name.c_str(), ss_type.c_str() ); m_SubSurfBrowser->add( str ); } if ( geom_ptr->ValidSubSurfInd( SubSurfaceMgr.GetCurrSurfInd() ) ) { m_SubSurfBrowser->select( SubSurfaceMgr.GetCurrSurfInd() + 2 ); } return true; }
OptionalModelObject ReverseTranslator::translateFenestrationSurfaceDetailed( const WorkspaceObject & workspaceObject ) { if( workspaceObject.iddObject().type() != IddObjectType::FenestrationSurface_Detailed ){ LOG(Error, "WorkspaceObject is not IddObjectType: Site:FenestrationSurface_Detailed"); return boost::none; } openstudio::Point3dVector vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, workspaceObject); boost::optional<SubSurface> subSurface; try{ subSurface = SubSurface(vertices, m_model); }catch(const std::exception&){ LOG(Error, "Cannot create SubSurface for object: " << workspaceObject); return boost::none; } OptionalString s = workspaceObject.name(); if(s) { subSurface->setName(*s); } OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::ConstructionName); if (target){ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); if (modelObject){ if (modelObject->optionalCast<ConstructionBase>()){ subSurface->setConstruction(modelObject->cast<ConstructionBase>()); } } } target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::BuildingSurfaceName); if (target){ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); if (modelObject){ if (modelObject->optionalCast<Surface>()){ subSurface->setSurface(modelObject->cast<Surface>()); } } } // needs to be after .setSurface. s = workspaceObject.getString(FenestrationSurface_DetailedFields::SurfaceType); if (s) { if (istringEqual("Window", *s)){ s = "FixedWindow"; boost::optional<Surface> surface = subSurface->surface(); if (surface){ if ((surface->surfaceType() == "RoofCeiling") && (surface->outsideBoundaryCondition() == "Outdoors")){ s = "Skylight"; } } } subSurface->setSubSurfaceType(*s); } target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject); if (target){ if (target->iddObject().type() == IddObjectType::Zone){ // Zone boundary condition OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); if(modelObject->optionalCast<Space>()){ Space adjacentSpace = modelObject->cast<Space>(); OptionalSurface surface = subSurface->surface(); if (surface && surface->space()){ Space space = surface->space().get(); if (surface->adjacentSurface()){ Surface adjacentSurface = surface->adjacentSurface().get(); if (adjacentSurface.space() && adjacentSpace.handle() == adjacentSurface.space()->handle()){ Transformation transformation = adjacentSpace.transformation().inverse()*surface->space()->transformation(); // duplicate subsurface in other space SubSurface adjacentSubSurface = subSurface->clone(m_model).cast<SubSurface>(); adjacentSubSurface.setName(subSurface->name().get() + " Reversed"); std::reverse(vertices.begin(), vertices.end()); adjacentSubSurface.setVertices(transformation*vertices); adjacentSubSurface.setSurface(adjacentSurface); subSurface->setAdjacentSubSurface(adjacentSubSurface); return subSurface.get(); } } } } }else if (target->iddObject().type() == IddObjectType::FenestrationSurface_Detailed){ // SubSurface boundary condition // see if we have already mapped other sub surface, don't do it here because that is circular auto it = m_workspaceToModelMap.find(target->handle()); if( it != m_workspaceToModelMap.end()){ if (it->second.optionalCast<SubSurface>()){ // this will set other side boundary object on both surfaces SubSurface adjacentSubSurface = it->second.cast<SubSurface>(); subSurface->setAdjacentSubSurface(adjacentSubSurface); return subSurface.get(); } } }else{ LOG(Error, "OutsideBoundaryConditionObject not yet mapped for object of type " << target->iddObject().name()); } } // DLM: should these be before control paths that return above? OptionalDouble d = workspaceObject.getDouble(FenestrationSurface_DetailedFields::ViewFactortoGround); if (d) { subSurface->setViewFactortoGround(*d); } target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::ShadingControlName); if (target){ LOG(Warn, "Shading Control Name not yet mapped for FenestrationSurface:Detailed"); } target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::FrameandDividerName); if (target){ LOG(Warn, "Frame and Divider Name not yet mapped for FenestrationSurface:Detailed"); } OptionalInt i = workspaceObject.getInt(FenestrationSurface_DetailedFields::Multiplier); if (i) { subSurface->setMultiplier(*i); } return subSurface.get(); }
boost::optional<IdfObject> ForwardTranslator::translateDaylightingDeviceShelf( model::DaylightingDeviceShelf & modelObject ) { SubSurface window = modelObject.subSurface(); boost::optional<Space> space = window.space(); boost::optional<InteriorPartitionSurface> insideShelf = modelObject.insideShelf(); boost::optional<ShadingSurface> outsideShelf = modelObject.outsideShelf(); if (!space){ return boost::none; } if (!(insideShelf || outsideShelf)){ return boost::none; } IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::DaylightingDevice_Shelf, modelObject); idfObject.setString(DaylightingDevice_ShelfFields::WindowName, window.name().get()); // inside shelf is converted to a surface if (insideShelf){ openstudio::Transformation transformation; boost::optional<InteriorPartitionSurfaceGroup> group = insideShelf->interiorPartitionSurfaceGroup(); if (group){ transformation = group->transformation(); } Point3dVector vertices = transformation*insideShelf->vertices(); Surface newSurface(vertices, modelObject.model()); newSurface.setName(modelObject.name().get()); newSurface.setSpace(*space); newSurface.setAdjacentSurface(newSurface); boost::optional<ConstructionBase> construction = insideShelf->construction(); if (!construction){ Model t_model = modelObject.model(); construction = interiorPartitionSurfaceConstruction(t_model); } OS_ASSERT(construction); newSurface.setConstruction(*construction); boost::optional<IdfObject> newSurfaceObject = translateAndMapModelObject(newSurface); if (newSurfaceObject){ idfObject.setString(DaylightingDevice_ShelfFields::InsideShelfName, newSurfaceObject->name().get()); } } if (outsideShelf){ idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfName, outsideShelf->name().get()); boost::optional<ConstructionBase> construction = outsideShelf->construction(); if (!construction){ Model t_model = modelObject.model(); construction = exteriorSurfaceConstruction(t_model); } OS_ASSERT(construction); idfObject.setString(DaylightingDevice_ShelfFields::OutsideShelfConstructionName, construction->name().get()); OptionalDouble d = modelObject.viewFactortoOutsideShelf(); if (d){ idfObject.setDouble(DaylightingDevice_ShelfFields::ViewFactortoOutsideShelf, *d); } } return idfObject; }